update components
This commit is contained in:
@@ -60,11 +60,12 @@ class LevelController extends EventHandler {
|
||||
|
||||
// only keep level with supported audio/video codecs
|
||||
levels = levels.filter(function(level) {
|
||||
var checkSupported = function(codec) { return MediaSource.isTypeSupported(`video/mp4;codecs=${codec}`);};
|
||||
var checkSupportedAudio = function(codec) { return MediaSource.isTypeSupported(`audio/mp4;codecs=${codec}`);};
|
||||
var checkSupportedVideo = function(codec) { return MediaSource.isTypeSupported(`video/mp4;codecs=${codec}`);};
|
||||
var audioCodec = level.audioCodec, videoCodec = level.videoCodec;
|
||||
|
||||
return (!audioCodec || checkSupported(audioCodec)) &&
|
||||
(!videoCodec || checkSupported(videoCodec));
|
||||
return (!audioCodec || checkSupportedAudio(audioCodec)) &&
|
||||
(!videoCodec || checkSupportedVideo(videoCodec));
|
||||
});
|
||||
|
||||
if(levels.length) {
|
||||
|
||||
+1
-1
@@ -1076,7 +1076,7 @@ class MSEMediaController extends EventHandler {
|
||||
logger.log(`selected A/V codecs for sourceBuffers:${audioCodec},${videoCodec}`);
|
||||
// create source Buffer and link them to MediaSource
|
||||
if (audioCodec) {
|
||||
sb = this.sourceBuffer.audio = this.mediaSource.addSourceBuffer(`video/mp4;codecs=${audioCodec}`);
|
||||
sb = this.sourceBuffer.audio = this.mediaSource.addSourceBuffer(`audio/mp4;codecs=${audioCodec}`);
|
||||
sb.addEventListener('updateend', this.onsbue);
|
||||
sb.addEventListener('error', this.onsbe);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
/*
|
||||
* Timeline Controller
|
||||
*/
|
||||
|
||||
import Event from '../events';
|
||||
import EventHandler from '../event-handler';
|
||||
import CEA708Interpreter from '../utils/cea-708-interpreter';
|
||||
|
||||
class TimelineController extends EventHandler {
|
||||
|
||||
constructor(hls) {
|
||||
super(hls, Event.MEDIA_ATTACHING,
|
||||
Event.MEDIA_DETACHING,
|
||||
Event.FRAG_PARSING_USERDATA,
|
||||
Event.MANIFEST_LOADING,
|
||||
Event.FRAG_LOADED);
|
||||
|
||||
this.hls = hls;
|
||||
this.config = hls.config;
|
||||
|
||||
if (this.config.enableCEA708Captions)
|
||||
{
|
||||
this.cea708Interpreter = new CEA708Interpreter();
|
||||
}
|
||||
}
|
||||
|
||||
destroy() {
|
||||
EventHandler.prototype.destroy.call(this);
|
||||
}
|
||||
|
||||
onMediaAttaching(data) {
|
||||
var media = this.media = data.media;
|
||||
this.cea708Interpreter.attach(media);
|
||||
}
|
||||
|
||||
onMediaDetaching() {
|
||||
this.cea708Interpreter.detach();
|
||||
}
|
||||
|
||||
onManifestLoading()
|
||||
{
|
||||
this.lastPts = Number.POSITIVE_INFINITY;
|
||||
}
|
||||
|
||||
onFragLoaded(data)
|
||||
{
|
||||
var pts = data.frag.start; //Number.POSITIVE_INFINITY;
|
||||
|
||||
// if this is a frag for a previously loaded timerange, remove all captions
|
||||
// TODO: consider just removing captions for the timerange
|
||||
if (pts <= this.lastPts)
|
||||
{
|
||||
this.cea708Interpreter.clear();
|
||||
}
|
||||
|
||||
this.lastPts = pts;
|
||||
}
|
||||
|
||||
onFragParsingUserdata(data) {
|
||||
// push all of the CEA-708 messages into the interpreter
|
||||
// immediately. It will create the proper timestamps based on our PTS value
|
||||
for (var i=0; i<data.samples.length; i++)
|
||||
{
|
||||
this.cea708Interpreter.push(data.samples[i].pts, data.samples[i].bytes);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export default TimelineController;
|
||||
Reference in New Issue
Block a user