public AACFrame AssembleAudioFrame(AudioData data, AACProfile profile,
                                           int samplingFreq, byte channels)
        {
            AACFrame aacFrame  = null;
            ulong    timestamp = data.Timestamp;


            if (timestamp > _lastProcessedTimestamp)
            {
                // Only process new audio frames
                aacFrame = new AACFrame(data.Data, data.Timestamp, data.FrameId, data.Flags,
                                        profile, samplingFreq, channels);
                _lastProcessedTimestamp = timestamp;
            }

            return(aacFrame);
        }
Ejemplo n.º 2
0
        void IAudioConsumer.ConsumeAudioData(object sender, AudioDataEventArgs args)
        {
            AACFrame frame = AudioAssembler.AssembleAudioFrame(
                args.AudioData, AACProfile.LC, 48000, 2);

            if (frame == null)
            {
                return;
            }

            if (_dumpSingleFrames)
            {
                string frameFilename = $"{_fileName}.audio.{audioFrameCount}.{frame.TimeStamp}.raw";
                using (FileStream fs = new FileStream(frameFilename, FileMode.CreateNew))
                {
                    fs.Write(frame.RawData, 0, frame.RawData.Length);
                }
                audioFrameCount++;
            }
            else
            {
                _audioFile.Write(frame.RawData, 0, frame.RawData.Length);
            }
        }