Ejemplo n.º 1
0
        internal void ProcessPacketQueueChanges(PacketQueueOp operation, MediaPacket packet, MediaType mediaType)
        {
            if (OnPacketQueueChanged == null)
            {
                return;
            }

            var state = default(PacketBufferState);

            state.HasEnoughPackets = true;

            foreach (var c in All)
            {
                state.Length         += c.BufferLength;
                state.Count          += c.BufferCount;
                state.CountThreshold += c.BufferCountThreshold;
                if (state.HasEnoughPackets && c.HasEnoughPackets == false)
                {
                    state.HasEnoughPackets = false;
                }
            }

            // Update the buffer state
            lock (BufferSyncLock)
                BufferState = state;

            // Send the callback
            OnPacketQueueChanged?.Invoke(operation, packet, mediaType, state);
        }
Ejemplo n.º 2
0
        internal void ProcessPacketQueueChanges(PacketQueueOp operation, MediaPacket packet, MediaType mediaType)
        {
            if (OnPacketQueueChanged == null)
            {
                return;
            }

            var state = default(PacketBufferState);

            state.HasEnoughPackets = true;
            state.Duration         = TimeSpan.MaxValue;

            foreach (var c in All)
            {
                state.Length         += c.BufferLength;
                state.Count          += c.BufferCount;
                state.CountThreshold += c.BufferCountThreshold;
                if (c.HasEnoughPackets == false)
                {
                    state.HasEnoughPackets = false;
                }

                if ((c.MediaType == MediaType.Audio || c.MediaType == MediaType.Video) &&
                    c.BufferDuration != TimeSpan.MinValue &&
                    c.BufferDuration.Ticks < state.Duration.Ticks)
                {
                    state.Duration = c.BufferDuration;
                }
            }

            if (state.Duration == TimeSpan.MaxValue)
            {
                state.Duration = TimeSpan.MinValue;
            }

            // Update the buffer state
            lock (BufferSyncLock)
                BufferState = state;

            // Send the callback
            OnPacketQueueChanged?.Invoke(operation, packet, mediaType, state);
        }