public EsStreamController(EsPlayerPacketStorage storage, Window window) { if (SynchronizationContext.Current == null) { throw new ArgumentNullException(nameof(SynchronizationContext.Current)); } _syncCtx = SynchronizationContext.Current; // Create placeholder to data streams & chunk states esStreams = new EsStream[(int)StreamType.Count]; playbackErrorSubs = new IDisposable[(int)StreamType.Count]; _playerClock = new PlayerClockProvider(_clockScheduler); dataSynchronizer = new Synchronizer(_playerClock); _dataClock = new DataClockProvider(_clockScheduler, _playerClock); _dataClock.SynchronizerClock = dataSynchronizer.Pts(); packetStorage = storage; displayWindow = window; try { player = new ESPlayer.ESPlayer(); OpenPlayer(); } catch (Exception e) { logger.Error(e); } }
public void Dispose() { if (_isDisposed) { return; } _isDisposed = true; SetPlayerClockSource(null); DisableClock(); _this = null; }
public PlayerClockProvider(IScheduler scheduler) { _scheduler = scheduler; _playerClockConnectable = Observable.Interval(ClockInterval, _scheduler) .TakeWhile(_ => !_isDisposed) .Select(_ => _playerClock()) .Where(clkValue => clkValue >= LastClock) .Do(clkValue => LastClock = clkValue) .Publish(); _this = this; }
public DataClockProvider(IScheduler scheduler, PlayerClockProvider playerClock) { _scheduler = scheduler; _playerClock = playerClock; _dataClockSource = Observable.Interval(DataClockProviderConfig.ClockInterval, _scheduler) .TakeWhile(_ => !_isDisposed) .Select(GetDataClock) .Multicast(_dataClockSubject); // Defer connection of IConnectObservable till very first subscription _dataClockObservable = Observable.Defer(StartOnSubscription); Logger.Info($"Initial Data Clock: {_sourceClock + _dataLimit}"); }
public EsStreamController(EsPlayerPacketStorage storage, Window window) { _playerClock = new PlayerClockProvider(_clockScheduler); _dataClock = new DataClockProvider(_clockScheduler); _suspendResumeLogic = new SuspendResumeLogic(SuspendPlayback, ResumePlayback, SetPlayerState, GetVideoPlayerState, SetDataTransferState, activeTaskCts.Token); displayWindow = window; CreatePlayer(); packetStorage = storage; // Create placeholder to data streams & chunk states esStreams = new EsStream[(int)StreamType.Count]; streamReconfigureSubs = new IDisposable[(int)StreamType.Count]; playbackErrorSubs = new IDisposable[(int)StreamType.Count]; dataSynchronizer = new Synchronizer(_playerClock); AttachEventHandlers(); }
public EsStream(StreamType type, EsPlayerPacketStorage storage, Synchronizer synchronizer, PlayerClockProvider playerClock) { streamType = type; packetStorage = storage; _dataSynchronizer = synchronizer; _dataSynchronizer.Initialize(streamType); _playerClock = playerClock; switch (streamType) { case StreamType.Audio: PushStreamConfig = PushAudioConfig; break; case StreamType.Video: PushStreamConfig = PushVideoConfig; break; default: throw new ArgumentException($"Stream Type {streamType} is unsupported"); } }
public Synchronizer(PlayerClockProvider playerClockSource) { _playerClockSource = playerClockSource; }