Exemplo n.º 1
0
        /// <summary>
        /// Pushes unencrypted data packet to ESPlayer
        /// </summary>
        /// <param name="dataPacket">Packet</param>
        /// <param name="token">CancellationToken</param>
        /// <exception cref="PacketSubmitException">
        /// Exception thrown on submit error
        /// </exception>
        /// <exception cref="OperationCanceledException">
        /// Exception thrown on submit cancellation
        /// </exception>
        private async ValueTask PushUnencryptedPacket(Packet dataPacket, CancellationToken token)
        {
            for (; ;)
            {
                var submitStatus = player.Submit(dataPacket);

                logger.Debug(
                    $"{dataPacket.StreamType}: ({submitStatus} )PTS: {dataPacket.Pts} Duration: {dataPacket.Duration}");

                if (submitStatus == ESPlayer.SubmitStatus.Success)
                {
                    return;
                }

                if (!ShouldRetry(submitStatus))
                {
                    throw new PacketSubmitException("Packet Submit Error", submitStatus);
                }

                await Task.Delay(CalculateDelay(submitStatus), token);
            }
        }