dashboard-ui/modules/flvjs/core/media-info.js
2023-09-01 16:30:57 +02:00

111 lines
3.6 KiB
JavaScript

define(["exports"], function (_exports) {
Object.defineProperty(_exports, "__esModule", { value: !0 }),
(_exports.default = void 0),
(_exports.default = (function () {
function MediaInfo() {
babelHelpers.classCallCheck(this, MediaInfo),
(this.mimeType = null),
(this.duration = null),
(this.hasAudio = null),
(this.hasVideo = null),
(this.audioCodec = null),
(this.videoCodec = null),
(this.audioDataRate = null),
(this.videoDataRate = null),
(this.audioSampleRate = null),
(this.audioChannelCount = null),
(this.width = null),
(this.height = null),
(this.fps = null),
(this.profile = null),
(this.refFrames = null),
(this.chromaFormat = null),
(this.sarNum = null),
(this.sarDen = null),
(this.metadata = null),
(this.segments = null),
(this.segmentCount = null),
(this.hasKeyframesIndex = null),
(this.keyframesIndex = null);
}
return (
babelHelpers.createClass(MediaInfo, [
{
key: "isComplete",
value: function () {
var audioInfoComplete =
!1 === this.hasAudio ||
(!0 === this.hasAudio &&
null != this.audioCodec &&
null != this.audioSampleRate &&
null != this.audioChannelCount),
videoInfoComplete =
!1 === this.hasVideo ||
(!0 === this.hasVideo &&
null != this.videoCodec &&
null != this.width &&
null != this.height);
return (
null != this.mimeType &&
null != this.duration &&
null != this.metadata &&
null != this.hasKeyframesIndex &&
audioInfoComplete &&
videoInfoComplete
);
},
},
{
key: "isSeekable",
value: function () {
return !0 === this.hasKeyframesIndex;
},
},
{
key: "getNearestKeyframe",
value: function (milliseconds) {
var table;
return null == this.keyframesIndex
? null
: ((table = this.keyframesIndex),
{
index: (milliseconds = this._search(
table.times,
milliseconds,
)),
milliseconds: table.times[milliseconds],
fileposition: table.filepositions[milliseconds],
});
},
},
{
key: "_search",
value: function (list, value) {
var mid,
idx = 0,
last = list.length - 1,
lbound = 0,
ubound = last;
for (
value < list[0] && ((idx = 0), (lbound = ubound + 1));
lbound <= ubound;
) {
if (
(mid = lbound + Math.floor((ubound - lbound) / 2)) === last ||
(value >= list[mid] && value < list[mid + 1])
) {
idx = mid;
break;
}
list[mid] < value ? (lbound = mid + 1) : (ubound = mid - 1);
}
return idx;
},
},
]),
MediaInfo
);
})());
});