Skip to content

Commit

Permalink
Delete event message data after the event has been dispatched to app
Browse files Browse the repository at this point in the history
  • Loading branch information
dsilhavy committed Jan 13, 2025
1 parent c1d338c commit 48a2bf5
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 8 deletions.
5 changes: 4 additions & 1 deletion index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1055,14 +1055,17 @@ declare namespace dashjs {
applyServiceDescription?: boolean,
applyProducerReferenceTime?: boolean,
applyContentSteering?: boolean,
eventControllerRefreshDelay?: number,
enableManifestDurationMismatchFix?: boolean,
parseInbandPrft?: boolean,
enableManifestTimescaleMismatchFix?: boolean,
capabilities?: {
filterUnsupportedEssentialProperties?: boolean,
useMediaCapabilitiesApi?: boolean
},
events?: {
eventControllerRefreshDelay?: number,
deleteEventMessageDataAfterEventStarted?: boolean
}
timeShiftBuffer?: {
calcFromSegmentTimeline?: boolean
fallbackToSegmentTimeline?: boolean
Expand Down
23 changes: 19 additions & 4 deletions src/core/Settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ import Events from './events/Events.js';
* applyServiceDescription: true,
* applyProducerReferenceTime: true,
* applyContentSteering: true,
* eventControllerRefreshDelay: 100,
* enableManifestDurationMismatchFix: true,
* parseInbandPrft: false,
* enableManifestTimescaleMismatchFix: false,
Expand All @@ -86,6 +85,10 @@ import Events from './events/Events.js';
* filterVideoColorimetryEssentialProperties: false,
* filterHDRMetadataFormatEssentialProperties: false
* },
* events: {
* eventControllerRefreshDelay: 100,
* deleteEventMessageDataAfterEventStarted: true
* }
* timeShiftBuffer: {
* calcFromSegmentTimeline: false,
* fallbackToSegmentTimeline: true
Expand Down Expand Up @@ -342,6 +345,16 @@ import Events from './events/Events.js';
* In case the MPD uses \<SegmentTimeline\ and no segment is found within the DVR window the DVR window is calculated based on the entries in \<SegmentTimeline\>.
*/

/**
* @typedef {Object} EventSettings
* @property {number} [eventControllerRefreshDelay=100]
* Interval timer used by the EventController to check if events need to be triggered or removed.
* @property {boolean} [deleteEventMessageDataAfterEventStarted=true]
* If this flag is enabled the EventController will delete the message data of events after they have been started. This is to save memory in case events have a long duration and need to be persisted in the EventController.
* Note: Applications will receive a copy of the original event data when they subscribe to an event. This copy contains the original message data and is not affected by this setting.
* Only if an event is dispatched for the second time (e.g. when the user seeks back) the message data will not be included in the dispatched event.
*/

/**
* @typedef {Object} LiveDelay
* @property {number} [liveDelayFragmentCount=NaN]
Expand Down Expand Up @@ -937,8 +950,6 @@ import Events from './events/Events.js';
* Set to true if dash.js should use the parameters defined in ProducerReferenceTime elements in combination with ServiceDescription elements.
* @property {boolean} [applyContentSteering=true]
* Set to true if dash.js should apply content steering during playback.
* @property {number} [eventControllerRefreshDelay=100]
* For multi-period streams, overwrite the manifest mediaPresentationDuration attribute with the sum of period durations if the manifest mediaPresentationDuration is greater than the sum of period durations
* @property {boolean} [enableManifestDurationMismatchFix=true]
* Overwrite the manifest segments base information timescale attributes with the timescale set in initialization segments
* @property {boolean} [enableManifestTimescaleMismatchFix=false]
Expand All @@ -947,6 +958,7 @@ import Events from './events/Events.js';
* Set to true if dash.js should parse inband prft boxes (ProducerReferenceTime) and trigger events.
* @property {module:Settings~Metrics} metrics Metric settings
* @property {module:Settings~LiveDelay} delay Live Delay settings
* @property {module:Settings~EventSettings} events Event settings
* @property {module:Settings~TimeShiftBuffer} timeShiftBuffer TimeShiftBuffer settings
* @property {module:Settings~Protection} protection DRM related settings
* @property {module:Settings~Capabilities} capabilities Capability related settings
Expand Down Expand Up @@ -1078,7 +1090,6 @@ function Settings() {
applyServiceDescription: true,
applyProducerReferenceTime: true,
applyContentSteering: true,
eventControllerRefreshDelay: 100,
enableManifestDurationMismatchFix: true,
parseInbandPrft: false,
enableManifestTimescaleMismatchFix: false,
Expand All @@ -1099,6 +1110,10 @@ function Settings() {
filterVideoColorimetryEssentialProperties: false,
filterHDRMetadataFormatEssentialProperties: false
},
events: {
eventControllerRefreshDelay: 100,
deleteEventMessageDataAfterEventStarted: true
},
timeShiftBuffer: {
calcFromSegmentTimeline: false,
fallbackToSegmentTimeline: true
Expand Down
10 changes: 7 additions & 3 deletions src/streaming/controllers/EventController.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ function EventController() {
try {
checkConfig();
logger.debug('Start Event Controller');
const refreshDelay = settings.get().streaming.eventControllerRefreshDelay;
const refreshDelay = settings.get().streaming.events.eventControllerRefreshDelay;
if (!isStarted && !isNaN(refreshDelay)) {
isStarted = true;
eventInterval = setInterval(_onEventTimer, refreshDelay);
Expand Down Expand Up @@ -474,7 +474,7 @@ function EventController() {
if (mode === MediaPlayerEvents.EVENT_MODE_ON_RECEIVE && !event.triggeredReceivedEvent) {
logger.debug(`Received event ${eventId}`);
event.triggeredReceivedEvent = true;
eventBus.trigger(event.eventStream.schemeIdUri, { event: event }, { mode });
eventBus.trigger(event.eventStream.schemeIdUri, { event: JSON.parse(JSON.stringify(event)) }, { mode });
return;
}

Expand All @@ -490,7 +490,11 @@ function EventController() {
_sendCallbackRequest(event.messageData);
} else {
logger.debug(`Starting event ${eventId} from period ${event.eventStream.period.id} at ${currentVideoTime}`);
eventBus.trigger(event.eventStream.schemeIdUri, { event: event }, { mode });
eventBus.trigger(event.eventStream.schemeIdUri, { event: JSON.parse(JSON.stringify(event)) }, { mode });
if (settings.get().streaming.events.deleteEventMessageDataAfterEventStarted) {
delete event.messageData;
delete event.parsedMessageData;
}
}
event.triggeredStartEvent = true;
}
Expand Down

0 comments on commit 48a2bf5

Please sign in to comment.