Esempio n. 1
0
        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;
        }
Esempio n. 2
0
 public static FaacImp LastFaacImp = null;//该变量只在IE OCX上面使用,其他地方不要使用
 public FaacImp(int channel, int sample, int bitrate)
 {
     _channel        = channel;
     _sample         = sample;
     _bitrate        = bitrate;
     _handle         = faacEncOpen(_sample, _channel, inputSample, maxOutputBytes);
     _inputSamples   = BitConverter.ToInt32(inputSample, 0);
     _maxOutputBytes = BitConverter.ToInt32(maxOutputBytes, 0);
     _maxInputBytes  = _inputSamples * 16 / 8;
     InitConfiguration();
     _outputBytes = new byte[_maxOutputBytes];
     LastFaacImp  = this;
 }