mirror of
https://github.com/shaka-project/shaka-player.git
synced 2026-06-25 17:45:03 +03:00
56650d6820
Change-Id: I1cb18e779721695333dd510ecb62119b9420d7ae
94 lines
3.0 KiB
JavaScript
94 lines
3.0 KiB
JavaScript
/**
|
|
* Copyright 2014 Google Inc.
|
|
*
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
* you may not use this file except in compliance with the License.
|
|
* You may obtain a copy of the License at
|
|
*
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
* See the License for the specific language governing permissions and
|
|
* limitations under the License.
|
|
*
|
|
* @fileoverview Implements a DASH video source.
|
|
*/
|
|
|
|
goog.provide('shaka.player.DashVideoSource');
|
|
|
|
goog.require('shaka.dash.MpdProcessor');
|
|
goog.require('shaka.dash.MpdRequest');
|
|
goog.require('shaka.dash.mpd');
|
|
goog.require('shaka.player.DrmSchemeInfo');
|
|
goog.require('shaka.player.StreamVideoSource');
|
|
goog.require('shaka.util.TypedBind');
|
|
|
|
|
|
|
|
/**
|
|
* Creates a DashVideoSource.
|
|
* @param {string} mpdUrl The MPD URL.
|
|
* @param {?shaka.player.DashVideoSource.ContentProtectionCallback}
|
|
* interpretContentProtection A callback to interpret the ContentProtection
|
|
* elements in the MPD.
|
|
*
|
|
* @struct
|
|
* @constructor
|
|
* @extends {shaka.player.StreamVideoSource}
|
|
* @export
|
|
*/
|
|
shaka.player.DashVideoSource = function(mpdUrl, interpretContentProtection) {
|
|
shaka.player.StreamVideoSource.call(this, null);
|
|
|
|
/** @private {string} */
|
|
this.mpdUrl_ = mpdUrl;
|
|
|
|
/** @private {?shaka.player.DashVideoSource.ContentProtectionCallback} */
|
|
this.interpretContentProtection_ = interpretContentProtection;
|
|
};
|
|
goog.inherits(shaka.player.DashVideoSource, shaka.player.StreamVideoSource);
|
|
|
|
|
|
/**
|
|
* A callback to the application to interpret DASH ContentProtection elements.
|
|
* These elements can contain almost anything and can be highly application-
|
|
* specific, so they cannot (in general) be interpreted by the library.
|
|
*
|
|
* The first parameter is the ContentProtection element.
|
|
* The callback should return a DrmSchemeInfo object if the ContentProtection
|
|
* element is understood by the application, or null otherwise.
|
|
*
|
|
* @typedef {function(!shaka.dash.mpd.ContentProtection):
|
|
* shaka.player.DrmSchemeInfo}
|
|
* @expose
|
|
*/
|
|
shaka.player.DashVideoSource.ContentProtectionCallback;
|
|
|
|
|
|
/** @override */
|
|
shaka.player.DashVideoSource.prototype.destroy = function() {
|
|
this.interpretContentProtection_ = null;
|
|
shaka.player.StreamVideoSource.prototype.destroy.call(this);
|
|
};
|
|
|
|
|
|
/** @override */
|
|
shaka.player.DashVideoSource.prototype.load = function(preferredLanguage) {
|
|
var mpdRequest = new shaka.dash.MpdRequest(this.mpdUrl_);
|
|
|
|
return mpdRequest.send().then(shaka.util.TypedBind(this,
|
|
/** @param {!shaka.dash.mpd.Mpd} mpd */
|
|
function(mpd) {
|
|
var mpdProcessor =
|
|
new shaka.dash.MpdProcessor(this.interpretContentProtection_);
|
|
mpdProcessor.process(mpd);
|
|
|
|
this.manifestInfo = mpdProcessor.manifestInfo;
|
|
var baseClassLoad = shaka.player.StreamVideoSource.prototype.load;
|
|
return baseClassLoad.call(this, preferredLanguage);
|
|
})
|
|
);
|
|
};
|