Esempio n. 1
0
            private MediaFrame CreateAudioMediaFrame(byte[] data, long tick)
            {
                if (_firstAudioFrame)
                {
                    var adts       = new AAC_ADTS(data);
                    var frequencys = new int[] { 96000, 88200, 64000, 48000, 44100, 32000, 24000, 22050, 16000, 2000, 11025 };
                    Frequency   = frequencys[adts.MPEG_4_Sampling_Frequency_Index];
                    Channel     = adts.MPEG_4_Channel_Configuration;
                    AudioFormat = 16;
                    Samples     = 0;
                }
                VideoFrameCount++;
                var mf = new MediaFrame()
                {
                    nIsAudio          = 1,
                    nIsKeyFrame       = 1,
                    Data              = data,
                    nSize             = data.Length,
                    nChannel          = Channel,
                    nFrequency        = Frequency,
                    nAudioFormat      = AudioFormat,
                    nTimetick         = tick,
                    nOffset           = 0,
                    nEncoder          = MediaFrame.AAC_Encoder,
                    nEx               = (byte)(_firstAudioFrame ? 0 : 1),
                    MediaFrameVersion = 1,
                };

                _firstAudioFrame = false;

                return(mf);
            }
Esempio n. 2
0
        private byte[] DecMultiAAC(byte[] buffer)
        {
            var aacs = AAC_ADTS.GetMultiAAC(buffer);

            if (aacs != null)
            {
                if (aacs.Length == 1)
                {
                    return(DecAAC(buffer));
                }
                else
                {
                    return(DecMultiAAC(aacs));
                }
            }
            else
            {
                return(new byte[0]);
            }
        }