Skip to content

Commit 0b89d5f

Browse files
authored
Feature/pathway cloning base (Dash-Industry-Forum#4706)
* Update available BaseURLs after each content steering manifest update * Overwrite existing BaseURLs if they have the same serviceLocation as the synthesized ones
1 parent 3194700 commit 0b89d5f

File tree

3 files changed

+27
-3
lines changed

3 files changed

+27
-3
lines changed

src/streaming/controllers/StreamController.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,8 @@ function StreamController() {
133133
eventBus.on(MediaPlayerEvents.MANIFEST_VALIDITY_CHANGED, _onManifestValidityChanged, instance);
134134
eventBus.on(MediaPlayerEvents.BUFFER_LEVEL_UPDATED, _onBufferLevelUpdated, instance);
135135
eventBus.on(MediaPlayerEvents.QUALITY_CHANGE_REQUESTED, _onQualityChanged, instance);
136+
eventBus.on(MediaPlayerEvents.CONTENT_STEERING_REQUEST_COMPLETED, _onSteeringManifestUpdated, instance);
137+
136138

137139
if (Events.KEY_SESSION_UPDATED) {
138140
eventBus.on(Events.KEY_SESSION_UPDATED, _onKeySessionUpdated, instance);
@@ -159,6 +161,7 @@ function StreamController() {
159161
eventBus.off(MediaPlayerEvents.MANIFEST_VALIDITY_CHANGED, _onManifestValidityChanged, instance);
160162
eventBus.off(MediaPlayerEvents.BUFFER_LEVEL_UPDATED, _onBufferLevelUpdated, instance);
161163
eventBus.off(MediaPlayerEvents.QUALITY_CHANGE_REQUESTED, _onQualityChanged, instance);
164+
eventBus.off(MediaPlayerEvents.CONTENT_STEERING_REQUEST_COMPLETED, _onSteeringManifestUpdated, instance);
162165

163166
if (Events.KEY_SESSION_UPDATED) {
164167
eventBus.off(Events.KEY_SESSION_UPDATED, _onKeySessionUpdated, instance);
@@ -1264,6 +1267,16 @@ function StreamController() {
12641267
}
12651268
}
12661269

1270+
/**
1271+
* Callback handler after the steering manifest was updated
1272+
* @param {object} e
1273+
* @private
1274+
*/
1275+
function _onSteeringManifestUpdated() {
1276+
const manifest = manifestModel.getValue();
1277+
baseURLController.initialize(manifest);
1278+
}
1279+
12671280
/**
12681281
* Callback handler after the manifest has been updated. Trigger an update in the adapter and filter unsupported stuff.
12691282
* Finally, attempt UTC sync

src/streaming/models/BaseURLTreeModel.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,18 @@ function BaseURLTreeModel() {
125125
const synthesizedBaseUrls = contentSteeringController.getSynthesizedBaseUrlElements(targetBaseUrls);
126126

127127
if (synthesizedBaseUrls && synthesizedBaseUrls.length > 0) {
128-
targetBaseUrls = targetBaseUrls.concat(synthesizedBaseUrls)
128+
synthesizedBaseUrls.forEach((synthesizedBaseUrl) => {
129+
// If we already have a BaseURL with the same serviceLocation, we overwrite it with the synthesized one
130+
const foundIndex = targetBaseUrls.findIndex((elem) => {
131+
return elem.serviceLocation === synthesizedBaseUrl.serviceLocation
132+
})
133+
134+
if (foundIndex !== -1) {
135+
targetBaseUrls[foundIndex] = synthesizedBaseUrl;
136+
} else {
137+
targetBaseUrls.push(synthesizedBaseUrl)
138+
}
139+
})
129140
}
130141

131142
return targetBaseUrls;

src/streaming/models/ManifestModel.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ function ManifestModel() {
5252
}
5353

5454
instance = {
55-
getValue: getValue,
56-
setValue: setValue
55+
getValue,
56+
setValue
5757
};
5858

5959
return instance;

0 commit comments

Comments
 (0)