Skip to content

Commit

Permalink
Merge branch 'development' into fix-httplist-d-metric-reporting
Browse files Browse the repository at this point in the history
  • Loading branch information
piersoh authored Jul 12, 2022
2 parents 8fec8cd + 7fdbf4e commit 1fa1841
Show file tree
Hide file tree
Showing 10 changed files with 289 additions and 159 deletions.
2 changes: 1 addition & 1 deletion samples/advanced/listening-to-SCTE-EMSG-events.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

function init() {
player = dashjs.MediaPlayer().create();
player.updateSettings({ 'debug': { 'logLevel': dashjs.Debug.LOG_LEVEL_NONE }});
player.updateSettings({ 'debug': { 'logLevel': dashjs.Debug.LOG_LEVEL_DEBUG }});
player.on(SCHEMEIDURI, showStartEvent, null); /* Default mode is onStart, no need to specify a mode */
player.on(SCHEMEIDURI, showReceiveEvent, null, { mode: EVENT_MODE_ON_RECEIVE });
player.initialize(document.querySelector("video"), URL, true);
Expand Down
2 changes: 1 addition & 1 deletion src/core/Settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -767,7 +767,7 @@ function Settings() {
cacheInitSegments: false,
applyServiceDescription: true,
applyProducerReferenceTime: true,
eventControllerRefreshDelay: 150,
eventControllerRefreshDelay: 100,
capabilities: {
filterUnsupportedEssentialProperties: true,
useMediaCapabilitiesApi: false
Expand Down
11 changes: 7 additions & 4 deletions src/dash/DashAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -510,18 +510,21 @@ function DashAdapter() {
* @instance
* @ignore
*/
function getEventsFor(info, voRepresentation) {
function getEventsFor(info, voRepresentation, streamInfo) {
let events = [];

if (voPeriods.length > 0) {
const manifest = voPeriods[0].mpd.manifest;

if (info instanceof StreamInfo) {
events = dashManifestModel.getEventsForPeriod(getPeriodForStreamInfo(info, voPeriods));
const period = getPeriodForStreamInfo(info, voPeriods)
events = dashManifestModel.getEventsForPeriod(period);
} else if (info instanceof MediaInfo) {
events = dashManifestModel.getEventStreamForAdaptationSet(manifest, getAdaptationForMediaInfo(info));
const period = getPeriodForStreamInfo(streamInfo, voPeriods)
events = dashManifestModel.getEventStreamForAdaptationSet(manifest, getAdaptationForMediaInfo(info), period);
} else if (info instanceof RepresentationInfo) {
events = dashManifestModel.getEventStreamForRepresentation(manifest, voRepresentation);
const period = getPeriodForStreamInfo(streamInfo, voPeriods)
events = dashManifestModel.getEventStreamForRepresentation(manifest, voRepresentation, period);
}
}

Expand Down
15 changes: 8 additions & 7 deletions src/dash/models/DashManifestModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ function DashManifestModel() {

function getProducerReferenceTimesForAdaptation(adaptation) {
const prtArray = adaptation && adaptation.hasOwnProperty(DashConstants.PRODUCERREFERENCETIME_ASARRAY) ? adaptation[DashConstants.PRODUCERREFERENCETIME_ASARRAY] : [];

// ProducerReferenceTime elements can also be contained in Representations
const representationsArray = adaptation && adaptation.hasOwnProperty(DashConstants.REPRESENTATION_ASARRAY) ? adaptation[DashConstants.REPRESENTATION_ASARRAY] : [];

Expand Down Expand Up @@ -206,7 +206,7 @@ function DashManifestModel() {
// UTC element contained must be same as that in the MPD
prtsForAdaptation.push(entry);
})

return prtsForAdaptation;
}

Expand Down Expand Up @@ -932,7 +932,7 @@ function DashManifestModel() {
return events;
}

function getEventStreams(inbandStreams, representation) {
function getEventStreams(inbandStreams, representation, period) {
const eventStreams = [];
let i;

Expand All @@ -955,12 +955,13 @@ function DashManifestModel() {
eventStream.value = inbandStreams[i].value;
}
eventStreams.push(eventStream);
eventStream.period = period;
}

return eventStreams;
}

function getEventStreamForAdaptationSet(manifest, adaptation) {
function getEventStreamForAdaptationSet(manifest, adaptation, period) {
let inbandStreams,
periodArray,
adaptationArray;
Expand All @@ -975,10 +976,10 @@ function DashManifestModel() {
}
}

return getEventStreams(inbandStreams, null);
return getEventStreams(inbandStreams, null, period);
}

function getEventStreamForRepresentation(manifest, representation) {
function getEventStreamForRepresentation(manifest, representation, period) {
let inbandStreams,
periodArray,
adaptationArray,
Expand All @@ -997,7 +998,7 @@ function DashManifestModel() {
}
}

return getEventStreams(inbandStreams, representation);
return getEventStreams(inbandStreams, representation, period);
}

function getUTCTimingSources(manifest) {
Expand Down
12 changes: 7 additions & 5 deletions src/streaming/Stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ function Stream(config) {
checkConfig();

isUpdating = true;
addInlineEvents();
_addInlineEvents();


let element = videoModel.getElement();
Expand Down Expand Up @@ -694,10 +694,12 @@ function Stream(config) {
}
}

function addInlineEvents() {
function _addInlineEvents() {
if (eventController) {
const events = adapter.getEventsFor(streamInfo);
eventController.addInlineEvents(events);
if (events && events.length > 0) {
eventController.addInlineEvents(events, streamInfo.id);
}
}
}

Expand Down Expand Up @@ -787,7 +789,7 @@ function Stream(config) {

function onInbandEvents(e) {
if (eventController) {
eventController.addInbandEvents(e.events);
eventController.addInbandEvents(e.events, streamInfo.id);
}
}

Expand Down Expand Up @@ -842,7 +844,7 @@ function Stream(config) {
streamInfo = updatedStreamInfo;

if (eventController) {
addInlineEvents();
_addInlineEvents();
}

let promises = [];
Expand Down
4 changes: 2 additions & 2 deletions src/streaming/StreamProcessor.js
Original file line number Diff line number Diff line change
Expand Up @@ -955,8 +955,8 @@ function StreamProcessor(config) {
// If we switch tracks this event might be fired after the representations in the RepresentationController have been updated according to the new MediaInfo.
// In this case there will be no currentRepresentation and voRepresentation matching the "old" quality
if (currentRepresentation && voRepresentation) {
const eventStreamMedia = adapter.getEventsFor(currentRepresentation.mediaInfo);
const eventStreamTrack = adapter.getEventsFor(currentRepresentation, voRepresentation);
const eventStreamMedia = adapter.getEventsFor(currentRepresentation.mediaInfo, null, streamInfo);
const eventStreamTrack = adapter.getEventsFor(currentRepresentation, voRepresentation, streamInfo);

if (eventStreamMedia && eventStreamMedia.length > 0 || eventStreamTrack && eventStreamTrack.length > 0) {
const request = fragmentModel.getRequests({
Expand Down
4 changes: 2 additions & 2 deletions src/streaming/controllers/BufferController.js
Original file line number Diff line number Diff line change
Expand Up @@ -665,8 +665,8 @@ function BufferController(config) {

function _checkIfBufferingCompleted() {
const isLastIdxAppended = maxAppendedIndex >= maximumIndex - 1; // Handles 0 and non 0 based request index
const periodBuffered = playbackController.getTimeToStreamEnd(streamInfo) - bufferLevel <= 0;

// To avoid rounding error when comparing, the stream time and buffer level only must be within 5 decimal places
const periodBuffered = playbackController.getTimeToStreamEnd(streamInfo) - bufferLevel < 0.00001;
if ((isLastIdxAppended || periodBuffered) && !isBufferingCompleted) {
setIsBufferingCompleted(true);
logger.debug(`checkIfBufferingCompleted trigger BUFFERING_COMPLETED for stream id ${streamInfo.id} and type ${type}`);
Expand Down
Loading

0 comments on commit 1fa1841

Please sign in to comment.