Skip to content

Commit

Permalink
Fix events payload (#3457)
Browse files Browse the repository at this point in the history
* EventBus: automatically add streamId and mediaType in event payload if set as filters

* Restore event propagation management (sor smooth streaming use case)
  • Loading branch information
bbert authored Nov 17, 2020
1 parent 236639d commit 5be3377
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 3 deletions.
7 changes: 7 additions & 0 deletions src/core/EventBus.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,13 @@ function EventBus() {

payload.type = type;

if (filters.streamId) {
payload.streamId = filters.streamId;
}
if (filters.mediaType) {
payload.mediaType = filters.mediaType;
}

handlers[type] = handlers[type].filter((item) => item);
handlers[type].forEach(handler => {
if (!handler) return;
Expand Down
3 changes: 3 additions & 0 deletions src/streaming/StreamProcessor.js
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,9 @@ function StreamProcessor(config) {
}

function onInitFragmentNeeded(e) {
// Event propagation may have been stopped (see MssHandler)
if (!e.sender) return;

if (adapter.getIsTextTrack(mimeType) && !textController.isTextEnabled()) return;

if (bufferController && e.representationId) {
Expand Down
4 changes: 2 additions & 2 deletions src/streaming/controllers/ScheduleController.js
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ function ScheduleController(config) {
logger.debug('Quality has changed, get init request for representationid = ' + currentRepresentationInfo.id);
}
eventBus.trigger(Events.INIT_FRAGMENT_NEEDED,
{ representationId: currentRepresentationInfo.id },
{ representationId: currentRepresentationInfo.id, sender: instance },
{ streamId: streamInfo.id, mediaType: type }
);
lastInitQuality = currentRepresentationInfo.quality;
Expand All @@ -201,7 +201,7 @@ function ScheduleController(config) {
if (replacement && replacement.isInitializationRequest()) {
// To be sure the specific init segment had not already been loaded
eventBus.trigger(Events.INIT_FRAGMENT_NEEDED,
{ representationId: replacement.representationId },
{ representationId: replacement.representationId, sender: instance },
{ streamId: streamInfo.id, mediaType: type }
);
checkPlaybackQuality = false;
Expand Down
2 changes: 1 addition & 1 deletion src/streaming/text/NotFragmentedTextBufferController.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ function NotFragmentedTextBufferController(config) {

// // Text data file is contained in initialization segment
eventBus.trigger(Events.INIT_FRAGMENT_NEEDED,
{ representationId: e.currentRepresentation.id },
{ representationId: e.currentRepresentation.id, sender: instance },
{ streamId: streamInfo.id, mediaType: type }
);
}
Expand Down

0 comments on commit 5be3377

Please sign in to comment.