The MP4 box header depends on both whether the box is a "full" box
(with version and flags) and whether the box has an extra 64-bit size
field. The MP4 parser was only considering the version and flags, but
not whether the extra size field was present. We already correctly
parsed the 64-bit size field, but computed offsets for other fields
without considering this.
Groundwork for a fix for #2759
Change-Id: I48f16ef073a036954b6f7d25641ccf29828b02c8
This enables the eslint rule requiring jsdocs on all class
declarations, function declarations, and methods.
Unfortunately, there are two problems with this:
1. We don't use class _declarations_, we use class _expressions_,
which are not covered by this rule. So it does not enforce jsdoc at
the class level.
2. We tend to document a class at the class-level, rather than at the
constructor. But a constructor counts as a method for eslint, so it
requires docs on the constructor. There is no way to configure it to
make an exception for trivial constructors.
So for all trivial (no-argument) constructors, we add empty jsdocs:
/** */
constructor() {
This was quicker and easier than setting up some alternative plugin in
eslint to make an exception for us.
The good news is that this rule caught several undocumented parameters
and places where the jsdoc comment was malformed. So fixing those
also improves the compiler's ability to enforce types.
Change-Id: Icbc46ed690c94e53d354648a883119524f8fca45
To enable low latency streaming, we need to append chunked data of
ReadableStream by complete MP4 boxes.
Everytime we get chunked data of the ReadableStream, we find the
last complete Mdat box. Append the completed boxes of data, and save
the data of the incomplete box until next time we get the chunked
data.
Issue #1525
Change-Id: I722ff992f397ee2f62bca45db33a0834ef57a270
This fixes all the license headers in the main library, which corrects
the appearance of the main license in the compiled output.
It seems that the `!` in the header forces the compiler to keep it in
the output. I believe older compiler releases did this purely based
on `@license`.
Issue #2638
Change-Id: I7f0e918caad10c9af689c9d07672b7fe9be7b2f3
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
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
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 changes the network API to use BufferSource instead of ArrayBuffer,
which allows plugins to return a "view" on a buffer instead of the
whole buffer. This also adds some utilities for changing between
views and buffers.
Lastly this forbids the use of the "buffer" property of TypedArrays
since it doesn't work with partial "views". This audits and fixes the
usages of the "buffer" property to ensure correct usage.
It should be noted that both MSE and EME accept a BufferSource as input,
so we don't need to convert a "view" into an ArrayBuffer before passing
to it.
Change-Id: Iaa417773f8ce5304424e43c7372ce10ebf540d2a
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
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
In some situations, the mp4 parser might be required to read a box
that has a "size" value that is longer than its actual size.
For example, if there was a partial range request that ends in the
middle of a box.
Obviously, trying to READ a box like that would be a bad idea, but
if the box is going to be skipped anyway, skipping it without an
error is probably not harmful.
Closes#1535
Change-Id: I31d4c00426e6127ef6e1492e9edc7e10ac50ec8b
The ParsedBox structure used by the Mp4Parser, previously, had
its property names changed in compiled mode.
This makes ParsedBox into an extern, so that it will be preserved
unchanged in compiled mode.
Closes#1522
Change-Id: I0964f8a4b9ccea57c61e2c587a776ed76cfbc8da
Previously, we would read each individual VTTC and VTTE box in the
MDAT and associate them with durations in the TRUN. This worked for a
lot of content, but if sampleSize is defined in the TRUN, a duration
might refer to multiple VTTC boxes.
This changes the VTT in mp4 reader to parse the MDAT based on the TRUN,
to account for such situations.
For the moment, this only accounts for a single MDAT, and assumes that
the MDAT contains nothing but vttc or vtte boxes, listed in order.
Issue #1266
Change-Id: I56e310d085abdda16e968761ed3b4fd0cc5e24d0
This makes a large number of small typo fixes. It also rewords a
number of comments and JSDoc descriptions, and does some
formatting standardization.
This doesn't fix every single issue, but it fixes a lot. Notably,
there were some formatting issues I declined to standardize due to
ambivalence on what the proper standardization would be; for example,
when and where empty lines should show up in JSDoc.
Change-Id: I225f5c7e54adf4cca8512cddae082ba50ed82e4e
This is part of a change to convert all usages of 'var' with either
'let' or 'const'. This takes a conservative approach for 'const' where
it will only be used for aliases and storing the "original" values in
tests.
Change-Id: I10f5c38a8b06b5797c6eec7492829084114514c9
When we started fetching partial HLS segments to find the start time,
we were no longer able to start playback for content with a moof box
larger than the partial segment. This is because we parsed the boxes
hierarchically, which required the entire payload.
Now, we can selectively instruct the parser to tolerate a partial box
if the part we have includes the child box we are looking for.
This fixes playback of several pieces of HLS content in our demo app.
Change-Id: I956c8b8905dc9f1707f2b24b8248b984b1c036c6
This speeds up HLS stream startup significantly for servers that
permit this kind of request, and falls back to full segments for
servers that do not.
Closes#1106
Change-Id: I96bc7f0df0fb84b75f3a3fe43476ba0ba5fc2264
This converts from using ArrayBuffer in the text parsers to using
Uint8Array. This avoids doing extra buffer copies when using
ArrayBuffer.slice().
Closes#1022
Change-Id: I34a789ec4eb76c95169ba81f27a8433ef25f27f0
When defining a box, the box would be defined as a four
byte integer. Now there is a "fromString" function that
can be used to convert a four character assci string to
a four byte integer.
Change-Id: I78c704e012620c94ae681efb450977305bdb84aa
Before the segment start time and end time were used to determine
the start and end time for all subtitles that appeared in the MDAT
box. The time values for each subtitle is specified in the TRUN box.
Now the time values are extracted from the TRUN box and mapped to
the correct subtitle in the MDAT box.
Closes: #699
Change-Id: I7179874aee7b617e994b136d17a082060ab1a0d2
Before parsing Mp4Boxes was done using the "findBox" method. This
was limted to only looking at one level of the structure and
required a large amount of code to dig deeper into the structure.
This change creates a generalized Mp4 Box parser that should
simplify parsing Mp4Boxes. This will help work on #699.
Change-Id: Ie67ff30a6db890cae16fe02ae9c92bca711815a9
Rather than having it in the DashParser as a network response filter,
we should have it in StreamingEngine. This will give it access to the
segment times so we can calculate the presentation times for the event.
Otherwise, there is no way to know when the event should actually occur
since the app can't know which segment is being downloaded or which it
came from.
This also adds startTime and endTime fields to the event so the app
doesn't have to calculate them. For reverse compatibility, the old
fields will still exist.
Closes#698
Change-Id: Icbaf3619aedfca7ea06bc8b1fe49e9cce65b0cc2