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); } } }
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)); }