Skip to content

Commit

Permalink
Made ParsedBox into an extern
Browse files Browse the repository at this point in the history
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
  • Loading branch information
theodab committed Aug 6, 2018
1 parent 5313c2b commit 0726543
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 44 deletions.
57 changes: 57 additions & 0 deletions externs/shaka/mp4_parser.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/**
* @license
* Copyright 2016 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/


/**
* @externs
*/

/**
* @typedef {{
* parser: !shaka.util.Mp4Parser,
* partialOkay: boolean,
* start: number,
* size: number,
* version: ?number,
* flags: ?number,
* reader: !shaka.util.DataViewReader
* }}
*
* @property {!shaka.util.Mp4Parser} parser
* The parser that parsed this box. The parser can be used to parse child
* boxes where the configuration of the current parser is needed to parsed
* other boxes.
* @property {boolean} partialOkay
* If true, allows reading partial payloads from some boxes. If the goal is a
* child box, we can sometimes find it without enough data to find all child
* boxes. This property allows the partialOkay flag from parse() to be
* propagated through methods like children().
* @property {number} start
* The start of this box (before the header) in the original buffer. This
* start position is the absolute position.
* @property {number} size
* The size of this box (including the header).
* @property {?number} version
* The version for a full box, null for basic boxes.
* @property {?number} flags
* The flags for a full box, null for basic boxes.
* @property {!shaka.util.DataViewReader} reader
* The reader for this box is only for this box. Reading or not reading to
* the end will have no affect on the parser reading other sibling boxes.
* @exportDoc
*/
shaka.extern.ParsedBox;
2 changes: 1 addition & 1 deletion lib/media/mp4_segment_index_parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ shaka.media.Mp4SegmentIndexParser = function(
* @param {number} scaledPresentationTimeOffset
* @param {!Array.<string>} uris The possible locations of the MP4 file that
* contains the segments.
* @param {!shaka.util.Mp4Parser.ParsedBox} box
* @param {!shaka.extern.ParsedBox} box
* @return {!Array.<!shaka.media.SegmentReference>}
* @private
*/
Expand Down
2 changes: 1 addition & 1 deletion lib/media/streaming_engine.js
Original file line number Diff line number Diff line change
Expand Up @@ -1746,7 +1746,7 @@ shaka.media.StreamingEngine.prototype.append_ = function(
*
* @param {!shaka.extern.Period} period
* @param {!shaka.media.SegmentReference} reference
* @param {!shaka.util.Mp4Parser.ParsedBox} box
* @param {!shaka.extern.ParsedBox} box
* @private
*/
shaka.media.StreamingEngine.prototype.parseEMSG_ = function(
Expand Down
45 changes: 4 additions & 41 deletions lib/util/mp4_parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,44 +41,7 @@ shaka.util.Mp4Parser = function() {


/**
* @typedef {{
* parser: !shaka.util.Mp4Parser,
* partialOkay: boolean,
* start: number,
* size: number,
* version: ?number,
* flags: ?number,
* reader: !shaka.util.DataViewReader
* }}
*
* @property {!shaka.util.Mp4Parser} parser
* The parser that parsed this box. The parser can be used to parse child
* boxes where the configuration of the current parser is needed to parsed
* other boxes.
* @property {boolean} partialOkay
* If true, allows reading partial payloads from some boxes. If the goal is a
* child box, we can sometimes find it without enough data to find all child
* boxes. This property allows the partialOkay flag from parse() to be
* propagated through methods like children().
* @property {number} start
* The start of this box (before the header) in the original buffer. This
* start position is the absolute position.
* @property {number} size
* The size of this box (including the header).
* @property {?number} version
* The version for a full box, null for basic boxes.
* @property {?number} flags
* The flags for a full box, null for basic boxes.
* @property {!shaka.util.DataViewReader} reader
* The reader for this box is only for this box. Reading or not reading to
* the end will have no affect on the parser reading other sibling boxes.
* @exportInterface
*/
shaka.util.Mp4Parser.ParsedBox;


/**
* @typedef {function(!shaka.util.Mp4Parser.ParsedBox)}
* @typedef {function(!shaka.extern.ParsedBox)}
* @exportInterface
*/
shaka.util.Mp4Parser.CallbackType;
Expand Down Expand Up @@ -218,7 +181,7 @@ shaka.util.Mp4Parser.prototype.parseNext =
new DataView(payload.buffer, payload.byteOffset, payload.byteLength),
shaka.util.DataViewReader.Endianness.BIG_ENDIAN);

/** @type {shaka.util.Mp4Parser.ParsedBox } */
/** @type {shaka.extern.ParsedBox} */
let box = {
parser: this,
partialOkay: partialOkay || false,
Expand All @@ -241,7 +204,7 @@ shaka.util.Mp4Parser.prototype.parseNext =
* A callback that tells the Mp4 parser to treat the body of a box as a series
* of boxes. The number of boxes is limited by the size of the parent box.
*
* @param {!shaka.util.Mp4Parser.ParsedBox} box
* @param {!shaka.extern.ParsedBox} box
* @export
*/
shaka.util.Mp4Parser.children = function(box) {
Expand All @@ -257,7 +220,7 @@ shaka.util.Mp4Parser.children = function(box) {
* number of children is represented by a 4 byte unsigned integer. Each child
* is a box.
*
* @param {!shaka.util.Mp4Parser.ParsedBox} box
* @param {!shaka.extern.ParsedBox} box
* @export
*/
shaka.util.Mp4Parser.sampleDescription = function(box) {
Expand Down
2 changes: 1 addition & 1 deletion lib/util/pssh.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ shaka.util.Pssh = function(psshBox) {


/**
* @param {!shaka.util.Mp4Parser.ParsedBox} box
* @param {!shaka.extern.ParsedBox} box
* @private
*/
shaka.util.Pssh.prototype.parseBox_ = function(box) {
Expand Down

0 comments on commit 0726543

Please sign in to comment.