Exemple #1
0
        private void GetAudioPrivateCodecData()
        {
            WaveFormatEx waveFormat;

            waveFormat = new WaveFormatEx();
            waveFormat.BitsPerSample  = (short)this.SampleSize;
            waveFormat.AvgBytesPerSec = (this.SampleSize / 8) * this.SampleRate * this.ChannelCount;
            waveFormat.Channels       = (short)this.ChannelCount;
            waveFormat.FormatTag      = WaveFormatEx.FormatMpegHEAAC; // 0xFF; // WaveFormatEx.FormatPCM; // Raw_AAC
            waveFormat.SamplesPerSec  = (int)this.SampleRate;
            waveFormat.BlockAlign     = 1;                            // (short)(waveFormat.Channels * (waveFormat.BitsPerSample / 8));
            byte[] config = QBox.GetAudioSpecificConfig(this.audioMetaSample);
            waveFormat.ext = new byte[12 + config.Length];
            for (int i = 0; i < 12; i++)
            {
                waveFormat.ext[i] = 0;
            }
            //waveFormat.ext[0] = 3; // payload type
            waveFormat.Size = (short)waveFormat.ext.Length;
            for (int i = 12, j = 0; i < waveFormat.Size; i++, j++)
            {
                waveFormat.ext[i] = config[j];
            }
            waveFormat.ValidateWaveFormat();
            Codec.PrivateCodecData = waveFormat.ToHexString();
        }
Exemple #2
0
        private void GetAudioPrivateCodecDataFromWaveFormatEx()
        {
            WaveFormatEx waveFormat;

            waveFormat = new WaveFormatEx();
            waveFormat.BitsPerSample  = (short)this.SampleSize;
            waveFormat.AvgBytesPerSec = (this.SampleSize / 8) * this.SampleRate * this.ChannelCount;
            waveFormat.Channels       = (short)this.ChannelCount;
            waveFormat.FormatTag      = 0xFF; // WaveFormatEx.FormatPCM; // Raw_AAC
            waveFormat.SamplesPerSec  = (int)this.SampleRate;
            waveFormat.BlockAlign     = (short)(waveFormat.Channels * (waveFormat.BitsPerSample / 8));
            waveFormat.ext            = null; // new byte[12]; // QBox.GetAudioSpecificConfig(this.audioMetaSample);
            waveFormat.Size           = 0;    // 12; // (short)waveFormat.ext.Length;
            //waveFormat.ext[0] = 1;
            //waveFormat.ext[4] = 0xFE;
            waveFormat.ValidateWaveFormat();
            Codec.PrivateCodecData = waveFormat.ToHexString();
        }