Skip to content

Commit

Permalink
Don't ignore InbandEventStreams at the Representation level
Browse files Browse the repository at this point in the history
Closes #686
  • Loading branch information
sanbornhilland committed Feb 7, 2017
1 parent dc55676 commit d184ac5
Show file tree
Hide file tree
Showing 2 changed files with 85 additions and 31 deletions.
28 changes: 26 additions & 2 deletions lib/dash/dash_parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -904,8 +904,7 @@ shaka.dash.DashParser.prototype.parseAdaptationSet_ = function(context, elem) {

// InbandEventStream indicates that a segment contains inband
// information.
var eventStream = XmlUtils.findChild(elem, 'InbandEventStream');
var containsInband = eventStream != null;
var containsInband = this.eventStreamIsPresent_(elem);

var essentialProperties = XmlUtils.findChildren(elem, 'EssentialProperty');
// ID of real AdaptationSet if this is a trick mode set:
Expand Down Expand Up @@ -991,6 +990,31 @@ shaka.dash.DashParser.prototype.parseAdaptationSet_ = function(context, elem) {
};


/**
* Indicates whether and InbandEventStream element is present at the Adaption
* Set or Representation level.
*
* @param {!Element} elem The AdaptationSet element.
* @return {boolean} Whether the InbandEventStream element if present.
* @private
*/
shaka.dash.DashParser.prototype.eventStreamIsPresent_ = function(elem) {
var XmlUtils = shaka.util.XmlUtils;

var adaptationEventStream = XmlUtils.findChild(elem, 'InbandEventStream');
var representation = XmlUtils.findChild(elem, 'Representation');

if (representation) {
var representationEventStream =
XmlUtils.findChild(representation, 'InbandEventStream');
}

var eventStream = adaptationEventStream || representationEventStream;

return eventStream != null;
};


/**
* Parses a Representation XML element.
*
Expand Down
88 changes: 59 additions & 29 deletions test/dash/dash_parser_manifest_unit.js
Original file line number Diff line number Diff line change
Expand Up @@ -751,35 +751,43 @@ describe('DashParser Manifest', function() {
.then(done);
});

it('updates manifest when emsg box is present', function(done) {
var manifestText = [
'<MPD minBufferTime="PT75S">',
' <Period id="1" duration="PT30S">',
' <AdaptationSet mimeType="video/mp4">',
' <InbandEventStream scheme_id_uri="urn:mpeg:dash:event:2012" />',
' <Representation bandwidth="1">',
' <SegmentTemplate media="1.mp4" duration="1" />',
' </Representation>',
' </AdaptationSet>',
' </Period>',
'</MPD>'
].join('\n');

fakeNetEngine.setResponseMapAsText({'dummy://foo': manifestText});
parser.start('dummy://foo', playerInterface)
.then(function() {
expect(fakeNetEngine.registerResponseFilter).toHaveBeenCalled();
var filter =
fakeNetEngine.registerResponseFilter.calls.mostRecent().args[0];
var type = shaka.net.NetworkingEngine.RequestType.SEGMENT;
var response = {data: emsgUpdate.buffer};
fakeNetEngine.request.calls.reset();
filter(type, response);
expect(fakeNetEngine.request).toHaveBeenCalled();
})
.catch(fail)
.then(done);
});
it('updates manifest when emsg box is present on AdaptationSet',
function(done) {
var manifestText = [
'<MPD minBufferTime="PT75S">',
' <Period id="1" duration="PT30S">',
' <AdaptationSet mimeType="video/mp4">',
' <InbandEventStream',
' scheme_id_uri="urn:mpeg:dash:event:2012" />',
' <Representation bandwidth="1">',
' <SegmentTemplate media="1.mp4" duration="1" />',
' </Representation>',
' </AdaptationSet>',
' </Period>',
'</MPD>'
].join('\n');

emsgBoxPresenceHelper(manifestText, emsgUpdate, done);
});

it('updates manifest when emsg box is present on Representation',
function(done) {
var manifestText = [
'<MPD minBufferTime="PT75S">',
' <Period id="1" duration="PT30S">',
' <AdaptationSet mimeType="video/mp4">',
' <Representation bandwidth="1">',
' <InbandEventStream',
' scheme_id_uri="urn:mpeg:dash:event:2012" />',
' <SegmentTemplate media="1.mp4" duration="1" />',
' </Representation>',
' </AdaptationSet>',
' </Period>',
'</MPD>'
].join('\n');

emsgBoxPresenceHelper(manifestText, emsgUpdate, done);
});

it('dispatches an event on non-typical emsg content', function(done) {
var manifestText = [
Expand Down Expand Up @@ -969,4 +977,26 @@ describe('DashParser Manifest', function() {
.catch(fail)
.then(done);
});

/**
* @param {string} manifestText
* @param {Uint8Array} emsgUpdate
* @param {Function} done
*/
function emsgBoxPresenceHelper(manifestText, emsgUpdate, done) {
fakeNetEngine.setResponseMapAsText({'dummy://foo': manifestText});
parser.start('dummy://foo', playerInterface)
.then(function() {
expect(fakeNetEngine.registerResponseFilter).toHaveBeenCalled();
var filter =
fakeNetEngine.registerResponseFilter.calls.mostRecent().args[0];
var type = shaka.net.NetworkingEngine.RequestType.SEGMENT;
var response = {data: emsgUpdate.buffer};
fakeNetEngine.request.calls.reset();
filter(type, response);
expect(fakeNetEngine.request).toHaveBeenCalled();
})
.catch(fail)
.then(done);
}
});

0 comments on commit d184ac5

Please sign in to comment.