Пример #1
0
    private void initHwEncoder(string codec)
    {
        MediaFormat format = new MediaFormat();

        string mime_type = null;

        switch (codec)
        {
        case "amrnb":
            mime_type = MediaFormat.MimetypeAudioAmrNb;
            format.SetInteger(MediaFormat.KeySampleRate, 8000);
            format.SetInteger(MediaFormat.KeyBitRate, 7950);
            break;

        case "amrwb":
            mime_type = MediaFormat.MimetypeAudioAmrWb;
            format.SetInteger(MediaFormat.KeySampleRate, 16000);
            format.SetInteger(MediaFormat.KeyBitRate, 18250);
            break;
        }

        if (mime_type != null)
        {
            format.SetString(MediaFormat.KeyMime, mime_type);
            format.SetInteger(MediaFormat.KeyChannelCount, 1);
            format.SetInteger(MediaFormat.KeyMaxInputSize, bufferSize);
            format.SetInteger(MediaFormat.KeyLatency, 1);
            format.SetInteger(MediaFormat.KeyPriority, 0);
            audioEncoder = new HwEncoder(mime_type, format, this);
            audioEncoder.start();
        }
    }
Пример #2
0
 private void initOpusEncoder()
 {
     audioEncoder = new OpusEncoder(sampleRate, 24000, channels, Concentus.Enums.OpusApplication.OPUS_APPLICATION_RESTRICTED_LOWDELAY, this);
     audioEncoder.start();
 }