Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 | 1x 1x 1x 1x 1x 1x 1x 1x 1x | import Metrics from '../vo/Metrics.js';
import Range from '../vo/Range.js';
import Reporting from '../vo/Reporting.js';
import FactoryMaker from '../../../core/FactoryMaker.js';
function ManifestParsing (config) {
config = config || {};
let instance;
let adapter = config.adapter;
const constants = config.constants;
function getMetricsRangeStartTime(manifest, dynamic, range) {
let voPeriods,
reportingStartTime;
let presentationStartTime = 0;
if (dynamic) {
// For services with MPD@type='dynamic', the start time is
// indicated in wall clock time by adding the value of this
// attribute to the value of the MPD@availabilityStartTime
// attribute.
presentationStartTime = adapter.getAvailabilityStartTime(manifest) / 1000;
} else {
// For services with MPD@type='static', the start time is indicated
// in Media Presentation time and is relative to the PeriodStart
// time of the first Period in this MPD.
voPeriods = adapter.getRegularPeriods(manifest);
if (voPeriods.length) {
presentationStartTime = voPeriods[0].start;
}
}
// When not present, DASH Metrics collection is
// requested from the beginning of content
// consumption.
reportingStartTime = presentationStartTime;
if (range && range.hasOwnProperty(constants.START_TIME)) {
reportingStartTime += range.starttime;
}
return reportingStartTime;
}
function getMetrics(manifest) {
let metrics = [];
Iif (manifest && manifest.Metrics) {
manifest.Metrics.forEach(metric => {
var metricEntry = new Metrics();
var isDynamic = adapter.getIsDynamic(manifest);
if (metric.hasOwnProperty('metrics')) {
metricEntry.metrics = metric.metrics;
} else {
return;
}
if (metric.Range) {
metric.Range.forEach(range => {
var rangeEntry = new Range();
rangeEntry.starttime =
getMetricsRangeStartTime(manifest, isDynamic, range);
if (range.hasOwnProperty('duration')) {
rangeEntry.duration = range.duration;
} else {
// if not present, the value is identical to the
// Media Presentation duration.
rangeEntry.duration = adapter.getDuration(manifest);
}
rangeEntry._useWallClockTime = isDynamic;
metricEntry.Range.push(rangeEntry);
});
}
if (metric.Reporting) {
metric.Reporting.forEach(reporting => {
var reportingEntry = new Reporting();
if (reporting.hasOwnProperty(constants.SCHEME_ID_URI)) {
reportingEntry.schemeIdUri = reporting.schemeIdUri;
} else {
// Invalid Reporting. schemeIdUri must be set. Ignore.
return;
}
if (reporting.hasOwnProperty('value')) {
reportingEntry.value = reporting.value;
}
if (reporting.hasOwnProperty(constants.DVB_REPORTING_URL)) {
reportingEntry.dvbReportingUrl = reporting[constants.DVB_REPORTING_URL];
}
if (reporting.hasOwnProperty(constants.DVB_PROBABILITY)) {
reportingEntry.dvbProbability = reporting[constants.DVB_PROBABILITY];
}
metricEntry.Reporting.push(reportingEntry);
});
} else {
// Invalid Metrics. At least one reporting must be present. Ignore
return;
}
metrics.push(metricEntry);
});
}
return metrics;
}
instance = {
getMetrics: getMetrics
};
return instance;
}
ManifestParsing.__dashjs_factory_name = 'ManifestParsing';
export default FactoryMaker.getSingletonFactory(ManifestParsing);
|