Beispiel #1
0
        protected override void PushNextPacket()
        {
            if (AudioCodec == null)
            {
                return;
            }

            RTPPacket packet = IncomingRTPPacketBuffer.GetPacket();

            if (packet == null)
            {
                return;
            }

            byte[] bNewAudioData = AudioCodec.DecodeToBytes(packet);

            if (bNewAudioData != null)
            {
                ReceiveAudioQueue.AppendData(bNewAudioData);
                if (ReceiveAudioQueue.Size > m_nPacketBytes * MaxAudioPacketsQueue)                // someone isn't taking our packets (either directly our through IAudioSource), so let's not get too big
                {
                    ReceiveAudioQueue.GetNSamples(ReceiveAudioQueue.Size - m_nPacketBytes * MaxAudioPacketsQueue);
                }

                if (RenderSink != null)
                {
                    MediaSample samp = new MediaSample(bNewAudioData, AudioCodec.AudioFormat);
                    RenderSink.PushSample(samp, this);
                }
            }
        }
Beispiel #2
0
        public override byte[] GetNextPacketSample(bool bReturnArrayOnNA)
        {
            if (AudioCodec == null)
            {
                return(null);
            }

            int nSamples   = AudioCodec.AudioFormat.CalculateNumberOfSamplesForDuration(TimeSpan.FromMilliseconds(AudioCodec.ReceivePTime));
            int nSizeBytes = nSamples * AudioCodec.AudioFormat.BytesPerSample;

            RTPPacket packet = IncomingRTPPacketBuffer.GetPacket();

            if ((packet == null) && (bReturnArrayOnNA == true))
            {
                return(new byte[nSizeBytes]);
            }

            return(AudioCodec.DecodeToBytes(packet));
        }
Beispiel #3
0
        public byte[] WaitNextPacketSample(bool bReturnArrayOnNA, int nTimeOut, out int nMsTook)
        {
            nMsTook = 0;
            if (AudioCodec == null)
            {
                return(null);
            }

            int nSamples   = AudioCodec.AudioFormat.CalculateNumberOfSamplesForDuration(TimeSpan.FromMilliseconds(AudioCodec.ReceivePTime));
            int nSizeBytes = nSamples * AudioCodec.AudioFormat.BytesPerSample;

            RTPPacket packet = IncomingRTPPacketBuffer.WaitPacket(nTimeOut, out nMsTook);

            if ((packet == null) && (bReturnArrayOnNA == true))
            {
                return(new byte[nSizeBytes]);
            }

            return(AudioCodec.DecodeToBytes(packet));
        }