Skip to content

Commit

Permalink
feat(sup-39815):[LG WebOS] add support for webOS initial bitrate option
Browse files Browse the repository at this point in the history
  • Loading branch information
inbalvasserman committed Nov 8, 2023
1 parent 9ce2b0e commit 9301aea
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion src/engines/html5/media-source/adapters/native-adapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,9 @@ export default class NativeAdapter extends BaseMediaSourceAdapter {
}
if (Utils.Object.hasPropertyPath(config, 'abr')) {
const abr = config.abr;
if (abr.defaultBandwidthEstimate) {
adapterConfig.abrEwmaDefaultEstimate = abr.defaultBandwidthEstimate;
}
if (abr.restrictions) {
Utils.Object.createPropertyPath(adapterConfig, 'abr.restrictions', abr.restrictions);
}
Expand Down Expand Up @@ -456,7 +459,30 @@ export default class NativeAdapter extends BaseMediaSourceAdapter {
requestFilterPromise = requestFilterPromise || Promise.resolve(pkRequest);
requestFilterPromise
.then(updatedRequest => {
this._videoElement.src = updatedRequest.url;
if (this._config.useSourceTag) {
const source = document.createElement('source');
const mimetype = this._sourceObj.mimetype.toLowerCase();
source.setAttribute('src', updatedRequest.url);
source.setAttribute('type', mimetype);

if (this._config.useMediaOptionAttribute) {
NativeAdapter._logger.debug('this._config.abrEwmaDefaultEstimate', this._config.abrEwmaDefaultEstimate);
const options = {};
options.option = {};
if (this._config.abrEwmaDefaultEstimate) {
options.option.adaptiveStreaming = {};
options.option.adaptiveStreaming.bps = {
start: this._config.abrEwmaDefaultEstimate
};
}
NativeAdapter._logger.debug('options', options);
const mediaOption = encodeURI(JSON.stringify(options));
source.setAttribute('type', mimetype + ';mediaOption=' + mediaOption);
}
this._videoElement.appendChild(source);
} else {
this._videoElement.src = updatedRequest.url;
}
})
.catch(error => {
this._trigger(Html5EventType.ERROR, new Error(Error.Severity.CRITICAL, Error.Category.NETWORK, Error.Code.REQUEST_FILTER_ERROR, error));
Expand Down

0 comments on commit 9301aea

Please sign in to comment.