mirror of
https://github.com/shaka-project/shaka-player.git
synced 2026-06-26 17:46:26 +03:00
1c58dee0c2
Add new ContentProtection interpretation API that allows applications to return multiple DRM configurations for each ContentProtection element and to parse raw ContentProtection XML elements. This patch deprecates DrmSchemeInfo in favor of DrmInfo. Furthermore, DrmSchemeInfo will be removed post v1.5.0. * Replace DrmSchemeInfo with DrmInfo. * Move Restrictions class definition into its own file. * Populate initData values from explicit PSSHs without application intervention. * Allow explicit PSSHs to differ between Representations Issue #71 Issue #137 Closes b/23428584 Change-Id: Ib8d6ba630b930ee64f923a3f4a3e518abacccf88
203 lines
4.7 KiB
JavaScript
203 lines
4.7 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 an HTTP video source.
|
|
*/
|
|
|
|
goog.provide('shaka.player.HttpVideoSource');
|
|
|
|
goog.require('shaka.features');
|
|
goog.require('shaka.media.StreamConfig');
|
|
goog.require('shaka.player.DrmInfo');
|
|
goog.require('shaka.player.IVideoSource');
|
|
goog.require('shaka.util.FakeEventTarget');
|
|
|
|
|
|
|
|
/**
|
|
* Creates an HttpVideoSource.
|
|
* @param {string} mediaUrl The media URL.
|
|
* @param {string} textUrl The text URL, or empty string if no subtitles.
|
|
* @param {shaka.player.DrmInfo.Config} drmInfoConfig A DrmInfo Config object,
|
|
* an empty object indicates unencrypted content.
|
|
* @struct
|
|
* @constructor
|
|
* @implements {shaka.player.IVideoSource}
|
|
* @extends {shaka.util.FakeEventTarget}
|
|
* @exportDoc
|
|
*/
|
|
shaka.player.HttpVideoSource = function(mediaUrl, textUrl, drmInfoConfig) {
|
|
shaka.util.FakeEventTarget.call(this, null);
|
|
|
|
/** @private {string} */
|
|
this.mediaUrl_ = mediaUrl;
|
|
|
|
/** @private {string} */
|
|
this.textUrl_ = textUrl;
|
|
|
|
/** @private {shaka.player.DrmInfo} */
|
|
this.drmInfo_ = shaka.player.DrmInfo.createFromConfig(drmInfoConfig);
|
|
|
|
/** @private {HTMLTrackElement} */
|
|
this.textTrack_ = null;
|
|
};
|
|
goog.inherits(shaka.player.HttpVideoSource, shaka.util.FakeEventTarget);
|
|
if (shaka.features.Http) {
|
|
goog.exportSymbol('shaka.player.HttpVideoSource',
|
|
shaka.player.HttpVideoSource);
|
|
}
|
|
|
|
|
|
/** @override */
|
|
shaka.player.HttpVideoSource.prototype.configure = function(config) {
|
|
// nop
|
|
};
|
|
|
|
|
|
/** @override */
|
|
shaka.player.HttpVideoSource.prototype.destroy = function() {
|
|
if (this.textTrack_) {
|
|
this.textTrack_.parentElement.removeChild(this.textTrack_);
|
|
this.textTrack_ = null;
|
|
}
|
|
|
|
this.drmInfo_ = null;
|
|
this.parent = null;
|
|
};
|
|
|
|
|
|
/** @override */
|
|
shaka.player.HttpVideoSource.prototype.attach = function(player, video) {
|
|
this.parent = player;
|
|
|
|
// This fixes bug #18614098. See comments in DashVideoSource.attach for more
|
|
// details.
|
|
var backupMediaKeys = video.mediaKeys;
|
|
video.src = this.mediaUrl_;
|
|
var restorePromise = video.setMediaKeys(backupMediaKeys);
|
|
|
|
if (this.textUrl_) {
|
|
this.textTrack_ = /** @type {HTMLTrackElement} */
|
|
(document.createElement('track'));
|
|
this.textTrack_.src = this.textUrl_;
|
|
video.appendChild(this.textTrack_);
|
|
// NOTE: mode must be set after appending to the DOM.
|
|
this.textTrack_.track.mode = 'showing';
|
|
}
|
|
|
|
return restorePromise;
|
|
};
|
|
|
|
|
|
/** @override */
|
|
shaka.player.HttpVideoSource.prototype.load = function() {
|
|
return Promise.resolve();
|
|
};
|
|
|
|
|
|
/** @override */
|
|
shaka.player.HttpVideoSource.prototype.getVideoTracks = function() {
|
|
return [];
|
|
};
|
|
|
|
|
|
/** @override */
|
|
shaka.player.HttpVideoSource.prototype.getAudioTracks = function() {
|
|
return [];
|
|
};
|
|
|
|
|
|
/** @override */
|
|
shaka.player.HttpVideoSource.prototype.getTextTracks = function() {
|
|
return [];
|
|
};
|
|
|
|
|
|
/** @override */
|
|
shaka.player.HttpVideoSource.prototype.getResumeThreshold = function() {
|
|
return 5.0;
|
|
};
|
|
|
|
|
|
/** @override */
|
|
shaka.player.HttpVideoSource.prototype.getConfigurations = function() {
|
|
var cfg = new shaka.media.StreamConfig();
|
|
cfg.drmInfo = this.drmInfo_;
|
|
return [cfg];
|
|
};
|
|
|
|
|
|
/** @override */
|
|
shaka.player.HttpVideoSource.prototype.selectConfigurations =
|
|
function(configs) {
|
|
// nop
|
|
};
|
|
|
|
|
|
/** @override */
|
|
shaka.player.HttpVideoSource.prototype.selectVideoTrack =
|
|
function(id, clearBuffer, opt_clearBufferOffset) {
|
|
return false;
|
|
};
|
|
|
|
|
|
/** @override */
|
|
shaka.player.HttpVideoSource.prototype.selectAudioTrack =
|
|
function(id, clearBuffer) {
|
|
return false;
|
|
};
|
|
|
|
|
|
/** @override */
|
|
shaka.player.HttpVideoSource.prototype.selectTextTrack =
|
|
function(id, clearBuffer) {
|
|
return false;
|
|
};
|
|
|
|
|
|
/** @override */
|
|
shaka.player.HttpVideoSource.prototype.enableTextTrack = function(enabled) {
|
|
if (!this.textTrack_) {
|
|
return;
|
|
}
|
|
|
|
this.textTrack_.track.mode = enabled ? 'showing' : 'disabled';
|
|
};
|
|
|
|
|
|
/** @override */
|
|
shaka.player.HttpVideoSource.prototype.setPlaybackStartTime =
|
|
function(startTime) {
|
|
// nop
|
|
};
|
|
|
|
|
|
/** @override */
|
|
shaka.player.HttpVideoSource.prototype.getSessionIds = function() {
|
|
return [];
|
|
};
|
|
|
|
|
|
/** @override */
|
|
shaka.player.HttpVideoSource.prototype.isOffline = function() {
|
|
return false;
|
|
};
|
|
|
|
|
|
/** @override */
|
|
shaka.player.HttpVideoSource.prototype.isLive = function() {
|
|
return false;
|
|
};
|