UNPKG

@svta/common-media-library

Version:
75 lines 3.73 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.mapTracks = mapTracks; const getChannels_js_1 = require("./utils/getChannels.js"); const getCodec_js_1 = require("./utils/getCodec.js"); const getContentType_js_1 = require("./utils/getContentType.js"); const getFrameRate_js_1 = require("./utils/getFrameRate.js"); const getLanguage_js_1 = require("./utils/getLanguage.js"); const getSampleRate_js_1 = require("./utils/getSampleRate.js"); const getSar_js_1 = require("./utils/getSar.js"); const getTrackDuration_js_1 = require("./utils/getTrackDuration.js"); /** * @internal * * Map dash components to ham tracks. * * @param adaptationSet - AdaptationSet of the dash manifest * @param representation - Representation of the dash manifest * @param segments - Segments from the representation of the dash manifest * @param initializationUrl - Initialization url from the track * @returns AudioTrack, VideoTrack or TextTrack depending on the type */ function mapTracks(adaptationSet, representation, segments, initializationUrl) { var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k; if (!adaptationSet) { throw new Error('Error: AdaptationSet is undefined'); } const type = (0, getContentType_js_1.getContentType)(adaptationSet, representation); if (type === 'video') { return { bandwidth: +((_a = representation.$.bandwidth) !== null && _a !== void 0 ? _a : 0), codec: (0, getCodec_js_1.getCodec)(adaptationSet, representation), duration: (0, getTrackDuration_js_1.getTrackDuration)(segments), frameRate: (0, getFrameRate_js_1.getFrameRate)(adaptationSet, representation), height: +((_b = representation.$.height) !== null && _b !== void 0 ? _b : 0), id: (_c = representation.$.id) !== null && _c !== void 0 ? _c : '', language: (0, getLanguage_js_1.getLanguage)(adaptationSet), par: (_d = adaptationSet.$.par) !== null && _d !== void 0 ? _d : '', sar: (0, getSar_js_1.getSar)(adaptationSet, representation), scanType: (_e = representation.$.scanType) !== null && _e !== void 0 ? _e : '', segments, type, width: +((_f = representation.$.width) !== null && _f !== void 0 ? _f : 0), urlInitialization: initializationUrl, }; } else if (type === 'audio') { return { bandwidth: +((_g = representation.$.bandwidth) !== null && _g !== void 0 ? _g : 0), channels: (0, getChannels_js_1.getChannels)(adaptationSet, representation), codec: (0, getCodec_js_1.getCodec)(adaptationSet, representation), duration: (0, getTrackDuration_js_1.getTrackDuration)(segments), id: (_h = representation.$.id) !== null && _h !== void 0 ? _h : '', language: (0, getLanguage_js_1.getLanguage)(adaptationSet), sampleRate: (0, getSampleRate_js_1.getSampleRate)(adaptationSet, representation), segments, type, urlInitialization: initializationUrl, }; } else { // if (type === 'text') return { bandwidth: +((_j = representation.$.bandwidth) !== null && _j !== void 0 ? _j : 0), codec: (0, getCodec_js_1.getCodec)(adaptationSet, representation), duration: (0, getTrackDuration_js_1.getTrackDuration)(segments), id: (_k = representation.$.id) !== null && _k !== void 0 ? _k : '', language: (0, getLanguage_js_1.getLanguage)(adaptationSet), segments, type, urlInitialization: initializationUrl, }; } } //# sourceMappingURL=mapTracks.js.map