Files
shaka-player/lib/dash/dash_json_parser.js
T
Álvaro Velad Galván 4f62ce8b24 build: Reduce bundle size by deduplicating license headers (#10182)
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.
2026-06-05 12:43:28 +02:00

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());