mirror of
https://github.com/shaka-project/shaka-player.git
synced 2026-06-26 17:46:26 +03:00
4f62ce8b24
Ensure generated bundles contain a single license header instead of repeating the same notice across bundled modules. Normalize all copyright years to 2016 and remove duplicate license headers from generated bundles. This reduces the final bundle size while preserving license information in the distributed artifacts.
52 lines
1.4 KiB
JavaScript
52 lines
1.4 KiB
JavaScript
/*! @license
|
|
* Shaka Player
|
|
* Copyright 2016 Google LLC
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
*/
|
|
|
|
goog.provide('shaka.dash.DashJsonParser');
|
|
|
|
goog.require('shaka.dash.DashParser');
|
|
goog.require('shaka.dash.JsonUtils');
|
|
goog.require('shaka.media.ManifestParser');
|
|
goog.require('shaka.util.Error');
|
|
goog.require('shaka.util.StringUtils');
|
|
goog.require('shaka.util.TXml');
|
|
|
|
|
|
/**
|
|
* @extends {shaka.dash.DashParser}
|
|
* @export
|
|
*/
|
|
shaka.dash.DashJsonParser = class extends shaka.dash.DashParser {
|
|
/**
|
|
* @override
|
|
* @param {BufferSource} data
|
|
* @param {string} finalManifestUri
|
|
* @param {string} rootElement
|
|
* @return {!Promise}
|
|
*/
|
|
parseManifest(data, finalManifestUri, rootElement) {
|
|
const jsonString = shaka.util.StringUtils.fromBytesAutoDetect(data);
|
|
|
|
let mpd;
|
|
try {
|
|
/** @type {!Object} */
|
|
const json = /** @type {!Object} */ (JSON.parse(jsonString));
|
|
const xmlString = shaka.dash.JsonUtils.jsonToMpd(json);
|
|
mpd = shaka.util.TXml.parseXmlString(xmlString, rootElement);
|
|
} catch (e) {
|
|
throw new shaka.util.Error(
|
|
shaka.util.Error.Severity.CRITICAL,
|
|
shaka.util.Error.Category.MANIFEST,
|
|
shaka.util.Error.Code.DASH_INVALID_JSON,
|
|
finalManifestUri);
|
|
}
|
|
|
|
return this.processParsedMpd(mpd, finalManifestUri, rootElement);
|
|
}
|
|
};
|
|
|
|
shaka.media.ManifestParser.registerParserByMime(
|
|
'application/dash+json', () => new shaka.dash.DashJsonParser());
|