Esempio n. 1
0
        private async ValueTask <bool> ProcessNextPacket(CancellationToken token)
        {
            if (currentPacket == null)
            {
                var displayBuffering = packetStorage.Count(streamType) == 0 &&
                                       (_playerClock.LastClock - currentPts).Duration() <= EsStreamConfig.BufferingEventThreshold;

                _bufferingSubject.OnNext(displayBuffering);

                currentPacket = packetStorage.GetPacket(streamType, token);

                currentPts = currentPacket.Pts;
            }

            var shouldContinue = await ProcessPacket(currentPacket, token);

            _dataSynchronizer.DataOut(currentPacket);
            var packetType = currentPacket.GetType();

            currentPacket.Dispose();
            currentPacket = null;

            _packetProcessed.OnNext(packetType);
            return(shouldContinue);
        }
Esempio n. 2
0
        private async ValueTask <bool> ProcessNextPacket(CancellationToken token)
        {
            if (currentPacket == null)
            {
                if (packetStorage.Count(streamType) == 0 &&
                    (PlayerClockProvider.LastClock - currentPts).Duration() <= EsStreamConfig.BufferingEventThreshold)
                {
                    await _suspendResumeLogic.RequestBuffering(true);

                    currentPacket = packetStorage.GetPacket(streamType, token);
#pragma warning disable 4014 // No need to wait for dissapear. Will happen.. eventually.
                    _suspendResumeLogic.RequestBuffering(false);
#pragma warning restore 4014
                }
                else
                {
                    currentPacket = packetStorage.GetPacket(streamType, token);
                }

                currentPts = currentPacket.Pts;
            }

            var shouldContinue = await ProcessPacket(currentPacket, token);

            _dataSynchronizer.DataOut(currentPacket);

            if (_firstDataPacketTcs?.Task.IsCompleted == false)
            {
                ConfirmFirstDataPacket();
            }

            currentPacket.Dispose();
            currentPacket = null;

            return(shouldContinue);
        }