public MicEncoder(AudioEncodeCfg audioCfg, Action <MediaFrame> callback)
        {
            _audioCfg  = audioCfg;
            _channels  = audioCfg.channel;
            _frequency = audioCfg.frequency;
            _capturer  = new MicCapturer(audioCfg.micId, _channels, _frequency, audioCfg.samples, MicCapturer_CallBack);
            if (audioCfg.encodeName.EqIgnoreCase("SPEX"))
            {
                _speex = new Speex(4);
            }
            else if (audioCfg.encodeName.EqIgnoreCase("AAC_"))
            {
                if (audioCfg.Params.ContainsKey("UseLastFaacImp") && FaacImp.LastFaacImp != null)
                {
                    _faacImp = FaacImp.LastFaacImp;
                    _faacImp.Encode(new byte[2048]);
                    _faacImp.Encode(new byte[2048]);
                    _faacImp.Encode(new byte[2048]);
                    _faacImp.Encode(new byte[2048]);
                    _faacImp.Encode(new byte[2048]);
                }
                else
                {
                    _faacImp = new FaacImp(_channels, _frequency, audioCfg.bitrate);
                }
            }

            _callBack = callback;
        }
Beispiel #2
0
        public int bitrate      = 32000; // 比特率



        public static AudioEncodeCfg GetDefault()
        {
            AudioEncodeCfg r = new AudioEncodeCfg();

            r.SetEncoder("AAC_");
            r.frequency = 32000;
            r.format    = 16;
            r.channel   = 1;
            r.samples   = 1024 * 2;
            r.micId     = 0;
            return(r);
        }