This is an MP4 Parser which extracts CEA-708 packets from Fragmented MP4 streams.
The Closed Caption Parser (shaka.media.ClosedCaptionParser) will own this MP4 Parser, and will initialize it and call it as shown. As data comes in, the parser will parse this data, and the caption packets data then be returned in a callback (on708Data), as shown. Here, a theoretical decoder (future pull request, mentioned as a Todo comment) will decode and extract the parsed captions from these packets.
Issue #2648
The period-flattening algorithm is run even on single-period content
if the manifest is dynamic, because we don't know if another period
will be added later.
As a failsafe, we should create one output per input for single-period
content, and we can ensure that no streams are unused by marking an
input stream as the "best match" for an output if they share the same
ID. That way, even if all other characteristics for two inputs are
the same, the input-to-output mapping for single-period content will
always be sane.
That ID-based logic was missing for text streams. This change
corrects that.
Closes#2646
Change-Id: I28c6c63d92bcf710ae0072783911f9e66ed78228
This corrects/normalizes license headers in misc. files, such as
config files, docs, build tools, tests, and externs. This does not
affect the compiled output, and is only done for consistency.
Issue #2638
Change-Id: I9d8da2de55243b08d7df2b743aac73c6f15e858a
We used to alias static utility methods by assigning the method itself
to a local variable. This is not allowed by the new Closure Compiler
release that we are adopting, and for good reason.
The old compiler did not understand the use of "this" in static
methods, but the new one does. And it turns out that when we start
using "this" in static methods (see #2532), aliasing the method itself
can break everything.
When you refer to "this" in a static method, it refers to the class.
This is really useful in utility classes that have private static
methods they use to perform common tasks. However, just as it ruins
the value of "this" to alias an instance method, the same is true of
an ES6 class's static method.
The fix is to always alias the class instead of the method. The new
compiler will simply not let us get away with the old way any more, so
regressions after this are unlikely.
Issue #2528 (compiler upgrade)
Issue #2532 (static "this")
Change-Id: Id800d466e639c7cbcf4aa6fbb05114c772a2229f
This creates a new utility used by DashParser and old offline DB
formats to combine Streams across Periods. This allows multi-Period
DASH content to be played without period-specific structures in the
manifest format, StreamingEngine, or Player. This also makes the
Tracks stable across Periods.
Closes#1339 (flatten periods)
Closes#1698 (rapid period transitions issue)
Closes#856 (audio change causes bitrate change)
Change-Id: Icb04c8e47e36eacf7ac024a5063130d85a115e54
This removes periods from the internal manifest structure and cleans
up code and tests accordingly. This leaves us unable to play
multi-period DASH & offline streams until the main period-flattening
algorithm is completed in shaka.util.Periods.
Three test cases have been disabled for the moment.
Multi-period playback will be restored in a smaller, more focused
follow-up commit, with disabled tests re-enabled.
Issue #1339 (flatten periods)
Issue #1698 (rapid period transitions issue)
Issue #856 (audio change causes bitrate change)
Closes#892 (refactor StreamingEngine)
Change-Id: I0cbf3b56bfdb51add15229df323b902f0b2e643a
This changes the eslint rule to enforce a strict pattern for the
argument comments. The comment must appear before the argument and
must be /* foo= */. This still ignores line comments.
Change-Id: I3afb01c65e1088eda13facb3aeeaa7595a2f5aee
This reflects changes in Google's policy on JavaScript license
headers, which should be smaller to avoid increasing the size of the
binary unnecessarily.
This also updates the company name from "Google, Inc" to "Google LLC".
Change-Id: I3f8b9ed3700b6351f43173d50c94d35c333e82b4
Now shaka.util.Pssh will only create a view on the buffer instead of
re-creating the PSSH boxes for each element. This also removes the
boundaries field since the data fields are the useful ones.
This also fixes a possible bug in BufferUtils, updates comments, and
adds some more tests for negative offsets.
Change-Id: Ibe1b7d61d5f5c7e52dfd7aa954db98f0592da4a5
The "reader" reads the payload of the box, so we need to add the header
size to the start index to get a correct value for the "start" field.
The "start" field isn't used anywhere, so this wasn't caught.
Change-Id: Ia870d01620524ac6e87dea2b7f1bc8571425a976
This allows us to avoid suppressing the indentation rules and ensures
we have correct indentation. It also makes it harder to make mistakes
since the variables are only accessible within the callback and you
can't accidentally contaminate another object with an incorrect call.
Closes#1692
Change-Id: Ic38b5cd57a2587dfc8c115ba782656c15565b655
Using "new Uint8Array" with a TypedArray creates a copy of the buffer;
this is unnecessarily expensive for large buffers. This adds a rule
to disallow using it in favor of a new utility that correctly creates
a new "view" on the same buffer.
Note it is fine to pass an ArrayBuffer to "new Uint8Array" and it won't
copy; but there there are many cases where the type is BufferSource,
so it could be a TypedArray. Unfortunately, there are many other cases
where we explicitly pass an ArrayBuffer; but the compiler rules don't
allow us to whitelist this case (since ArrayBuffer is part of
BufferSource).
Change-Id: I58696a85a9cbcc188c0b16919c9eeb63e56edca1
Now the EbmlParser and DataViewReader types can accept BufferSource
objects to avoid the caller having to convert it at each callsite.
Change-Id: I527fbc638485214bfe976d7da89b79b6098033a8
This is a helper to aid in iterating over items. This returns a list
of objects that contain:
- "item": The current value.
- "prev": The previous value in the list.
- "next": The next value in the list.
- "i": The zero-based index in the list.
Issue #1518
Change-Id: Id18ab977e3ae45dfbfd2b4137a1bffb6e53c6bce
This ensures that we get the expected types and that type coercion
doesn't convert between types. This also ensures we are consistent
in how we check for equality of primitives in tests.
Change-Id: I9f3aacdf25ab1afe5e8d6e4b895b5299ee687d54
- Reduce times for "short delays".
- Remove backoff delay from networking tests.
- Avoid hard-coding delays in the library.
- Move Storage tests to integration tests since they use indexedDB (and
take over 200ms each to run).
This reduces the time it takes to run unit tests (with --quick) from
50 seconds to about 6 seconds. Now all but one unit test finish <100ms.
Change-Id: I88461472a87c4cf750a36d07d07422818e069a4d
Creating them in beforeAll will usually cause test contamination, so
they should be created in beforeEach instead so they are reset for
each test.
Change-Id: I51f11de85555cbf5b8c18969eabeecbe8617b8f3
This is a fully automated change. The linter will fail because the
extra indentation caused line-length errors. These won't be fixed
automatically. They are fixed in a follow-up to make this one fully
automated.
Change-Id: I4d8cf9c998985add2bcd24a81c8d65495668c4f3
With the new style rule, we cannot have two statements on the same line.
So we can no longer have an "if" on a single line and we cannot have
an arrow function with a body on the same line as when it is used.
This is mostly a manual change.
Change-Id: I2285202dd5ecbad764308bc725e6d317ff2ee7f0
We use custom indentation for the ManifestGenerator to make the repeated
calls easier to read. This disables the coming linter rule for these
blocks of code. This also goes through and unifies the formatting. The
indentation should be 4 spaces from the left side.
Change-Id: I687e69cea39bded1e9e06bffdcc888970b383fa2
This is an automated change to convert use of "function" functions
to arrow functions. This doesn't change all uses of bind() that
could be converted. This also doesn't remove all "function" functions.
Change-Id: I40ac7d086bcef947a1be083359c8fd1d4499a9c3
A coming update to the Google eslint config will require using "const"
over "let". This makes that one change to isolate the big changes.
Change-Id: I7d0974c3ae15c53cc45a6b07bf9f6586e2d34aca
This prepares some changes for the conversion from "let" to "const".
This ensures the follow-up is just an automated change with minimal
intervention.
Change-Id: I19b24dc67f20038dffd36b8903547f6ee4f00c25
It is type-safe to alias a class, but not one of its static methods.
Aliasing the method without the class makes it a "free call" to invoke
the aliased method.
A "free call" is when you call a method without the context of its
instance of class. There were several cases of this with static
methods.
This will be enforced by a future release of the compiler, which I
believe will lead into compiler support for "this" in static ES6
methods. In ES6, you can use "this" in static methods to refer to the
class and call other static methods. Closure compiler doesn't support
static "this" yet, but we will start using it as soon as it is
supported.
Change-Id: I4249db8b6dda9231ebba60ee0d4ad734a692c2fe
This adds a polyfill for Apple's prefixed EME implementation. This
will be used on all macOS versions prior to 10.14 (Mojave) and on
Safari versions prior to 12.1.
This also adds support for FairPlay license protocol eccentricities
in DrmEngine, so that the proper formatting is used for requests and
responses.
Issue #382
Change-Id: If1274d2f018a475f56c09df97645694f13acbde9
When listening to the same event on the same object from two places,
it's important that both listeners get called back.
This fixes EventManager's listenOnce() so that the unlisten() call
within listenOnce() doesn't remove both listeners at once. Now each
listener will be called before it is removed.
This bug is over two years old!
Change-Id: Id99f3a8e5ab80819921b30e28aa66d8a08b29e86
We track how much time we spend in different states in the state
history, this means that we can derive the total time rather than
needing to track it separately.
Change-Id: I8ba0f8a7a842b54839cef14c5c42bf3c379549b0
This change makes state history track any state by moving the idea of
buffering, playing, etc to the player.
This allowed the stats and state history to drop they connection to the
media element.
Change-Id: Ieed198a09b3ade33e4ee850445b809f251cf2558
We often use the IDestroyable interface to provide us with a standardized
way to break internal references and tear-down objects, however many
objects don't need this to be async. Once using IDestroyable, everyone
must assume that you must be async.
This change introduces IReleasable, a sibling to IDestryable, which
provides the |release| method. IReleasable is the synchronous version of
IDestroyable.
This change converts EventManager from IDestroyable to IReleasable as
the first of many conversions.
Change-Id: Ic3e90e594abc1c7326eccbe2521eb71676b74a09
Now that we have a formal terminology for how we talk about
language and locales, this change updates our code to utilize
our new vocabulary.
For more information on our terminology, see our "Talking About
Languages" document.
While the expression of the behaviour has changed, the final
observable behaviour should not have changed. The goal of the
"rephrasing" was to build our logic based on the concepts discussed
in our "Talking About Languages" document.
Change-Id: I16c405e3d5a4d1e2275c99d5ec0bbdbaaf8373b9
Added a filter method for iterables so that we can filter any type
of collection without first needing to convert it over to an
array.
Change-Id: I28919e271672649d13d3b6c2e6902d0ff549a2ee
Added some tests for language normalization to ensure
that it is returning data in the way that we expect.
Updated the normalization code to make the base language
lowercase and the region uppercase.
Change-Id: I8f454b61e94b26a55aeb5b3437050155c8976568
Created utilities to get the language of variants and text streams.
This should be used whenever we need to get the language of a variant
or text stream.
Change-Id: Id34fe5aefa10dd368f7995314cff9d927654a326
Change player to use the new adaptation sets and adaptation set
criteria to handle picking variants.
Issue #1071
Change-Id: Ia31002c4202e01182f7c39f25391114393230652
To avoid always having to create arrays to do array-like methods
I have created a util that recreates some of those simple yet useful
methods that will act on any iterable or iterator.
This should make it easier to work with Set and Map.
Change-Id: Iec868fda4c9d018f813e824ea197ef914436fee3
In this change I try to isolate the code that takes the current
period and selects the variant and text stream that should be
played.
Through this, some logic has been pulled up from lower levels to
higher levels in an attempt to better illustrate what is being
done.
Change-Id: Ie5dd4be044de5f5b8d46e28b281cca468b640af6
This replaces almost every instance of indexOf on both String and
Array. There are very few places where we really wanted an index.
Mostly, indexOf was used to check for inclusion.
Change-Id: I08e299768b6ffdb4bfc30b39b5d82a058c6d1b56
This method checks that two arrays contain the same elements (with the
same number of occurrences) in them. This will be used in follow-up
CLs.
Change-Id: I9b98c2f0b93de5a5aa0d8e00476a88d22482704c
Now it will correctly remove duplicate NaN entries. This also updates
it to use ES6 and uses indexOf instead of an explicit inner loop.
Change-Id: I18e747bd882515c46c9a1c410696321ca4d3cc0e
cloneObject used to be part of config_utils.js.
This meant that a number of classes that didn't actually use
config objects required ConfigUtils.
This moves cloneObject into the new ObjectUtils, to clarify that.
Change-Id: I92d630eba8798b3e2671dcce95b61f44282b05e7