示例#1
0
        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);
            }
        }
示例#2
0
        public void Dispose()
        {
            if (_isDisposed)
            {
                return;
            }

            _isDisposed = true;
            SetPlayerClockSource(null);
            DisableClock();
            _this = null;
        }
示例#3
0
        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;
        }
示例#4
0
        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}");
        }
示例#5
0
        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();
        }
示例#6
0
        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");
            }
        }
示例#7
0
 public Synchronizer(PlayerClockProvider playerClockSource)
 {
     _playerClockSource = playerClockSource;
 }