Beispiel #1
0
        /// <summary>
        /// Processes packet push result. Returned is an indication if retry
        /// should take place or not
        /// </summary>
        /// <param name="status">ESPlayer.SubmitStatus</param>
        /// <param name="token">CancellationToken</param>
        /// <returns>
        /// True - retry packet push
        /// False - do not retry packet push
        /// </returns>
        /// <exception cref="PacketSubmitException">
        /// Exception thrown on submit error
        /// </exception>
        private bool ShouldRetry(ESPlayer.SubmitStatus status, CancellationToken token)
        {
            TimeSpan delay;

            switch (status)
            {
            case ESPlayer.SubmitStatus.Success:
                return(false);

            case ESPlayer.SubmitStatus.NotPrepared:
                logger.Info(streamType + ": " + status);
                delay = TimeSpan.FromSeconds(1);
                break;

            case ESPlayer.SubmitStatus.Full:
                delay = TimeSpan.FromMilliseconds(500);
                break;

            default:
                throw new PacketSubmitException("Packet Submit Error", status);
            }

            // We are left with Status.Full
            // For now sleep, however, once buffer events will be
            // emitted from ESPlayer, they could be used here
            using (var napTime = new ManualResetEventSlim(false))
                napTime.Wait(delay, token);

            return(true);
        }
Beispiel #2
0
        private TimeSpan CalculateDelay(ESPlayer.SubmitStatus status)
        {
            // calculate delay
            switch (status)
            {
            case ESPlayer.SubmitStatus.NotPrepared:
                return(TimeSpan.FromSeconds(1));

            case ESPlayer.SubmitStatus.Full:
                return(TimeSpan.FromMilliseconds(500));

            default:
                return(TimeSpan.Zero);
            }
        }
Beispiel #3
0
        private TimeSpan CalculateDelay(ESPlayer.SubmitStatus status)
        {
            // calculate delay
            switch (status)
            {
            case ESPlayer.SubmitStatus.NotPrepared:
                logger.Info($"{streamType}: Packet NOT Prepared");
                return(TimeSpan.FromSeconds(1));

            case ESPlayer.SubmitStatus.Full:
                return(TimeSpan.FromMilliseconds(500));

            default:
                return(TimeSpan.Zero);
            }
        }
Beispiel #4
0
 private bool ShouldRetry(ESPlayer.SubmitStatus status)
 {
     return(status == ESPlayer.SubmitStatus.NotPrepared || status == ESPlayer.SubmitStatus.Full);
 }
Beispiel #5
0
 public PacketSubmitException(string message, ESPlayer.SubmitStatus status) : base(message)
 {
     SubmitStatus = status;
 }