Exemplo n.º 1
0
 private byte[] DecMultiAAC(byte[] buffer)
 {
     AAC_ADTS[] aacs = null;
     try
     {
         aacs = AAC_ADTS.GetMultiAAC(buffer);
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex);
         aacs = null;
     }
     if (aacs != null)
     {
         if (aacs.Length == 1)
         {
             return(DecAAC(buffer));
         }
         else
         {
             return(DecMultiAAC(aacs));
         }
     }
     else
     {
         return(null);
     }
 }
Exemplo n.º 2
0
        public static AAC_ADTS[] GetMultiAAC(byte[] bs)
        {
            var             ms   = new MemoryStream(bs);
            List <AAC_ADTS> aacs = new List <AAC_ADTS>();

            while (ms.Position + 7 < ms.Length)
            {
                var aac = new AAC_ADTS(ms);
                aacs.Add(aac);
            }
            return(aacs.ToArray());
        }
Exemplo n.º 3
0
        private void Init(byte[] buffer)
        {
            if (!_inited)
            {
                AAC_ADTS[] adtss = AAC_ADTS.GetMultiAAC(buffer);

                if (adtss != null)
                {
                    int channels  = adtss[0].MPEG_4_Channel_Configuration;
                    int frequency = adtss[0].Frequency;
                    //_aac = new FaadImp();
                    _aac    = new FFImp(AVCodecCfg.CreateAudio(channels, frequency, (int)AVCode.CODEC_ID_AAC), true, false);
                    _inited = true;
                }
            }
        }
Exemplo n.º 4
0
        public static Boolean Check(int frequency, int channel, byte[] bs)
        {
            try {
                var aac = new AAC_ADTS(bs);
                if (aac.AACDataLen != aac.AACData.Length)
                {
                    return(false);
                }
                var frequencys = new int[] { 96000, 88200, 64000, 48000, 44100, 32000, 24000, 22050, 16000, 2000, 11025 };

                if (frequencys[aac.MPEG_4_Sampling_Frequency_Index] != frequency)
                {
                    return(false);
                }

                if (aac.MPEG_4_Channel_Configuration != channel)
                {
                    return(false);
                }
                return(true);
            } catch {
                return(false);
            }
        }