mirror of
https://github.com/samsonjs/media.git
synced 2026-04-10 12:05:47 +00:00
Hardcode libopus output frequency to 48000Hz
Issue: #3080 ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=162746202
This commit is contained in:
parent
cdfe57833d
commit
4436e94ba8
2 changed files with 26 additions and 1 deletions
|
|
@ -16,6 +16,7 @@
|
|||
package com.google.android.exoplayer2.ext.opus;
|
||||
|
||||
import android.os.Handler;
|
||||
import com.google.android.exoplayer2.C;
|
||||
import com.google.android.exoplayer2.Format;
|
||||
import com.google.android.exoplayer2.audio.AudioProcessor;
|
||||
import com.google.android.exoplayer2.audio.AudioRendererEventListener;
|
||||
|
|
@ -32,6 +33,8 @@ public final class LibopusAudioRenderer extends SimpleDecoderAudioRenderer {
|
|||
private static final int NUM_BUFFERS = 16;
|
||||
private static final int INITIAL_INPUT_BUFFER_SIZE = 960 * 6;
|
||||
|
||||
private OpusDecoder decoder;
|
||||
|
||||
public LibopusAudioRenderer() {
|
||||
this(null, null);
|
||||
}
|
||||
|
|
@ -69,8 +72,16 @@ public final class LibopusAudioRenderer extends SimpleDecoderAudioRenderer {
|
|||
@Override
|
||||
protected OpusDecoder createDecoder(Format format, ExoMediaCrypto mediaCrypto)
|
||||
throws OpusDecoderException {
|
||||
return new OpusDecoder(NUM_BUFFERS, NUM_BUFFERS, INITIAL_INPUT_BUFFER_SIZE,
|
||||
decoder = new OpusDecoder(NUM_BUFFERS, NUM_BUFFERS, INITIAL_INPUT_BUFFER_SIZE,
|
||||
format.initializationData, mediaCrypto);
|
||||
return decoder;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Format getOutputFormat() {
|
||||
return Format.createAudioSampleFormat(null, MimeTypes.AUDIO_RAW, null, Format.NO_VALUE,
|
||||
Format.NO_VALUE, decoder.getChannelCount(), decoder.getSampleRate(), C.ENCODING_PCM_16BIT,
|
||||
null, null, 0, null);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -197,6 +197,20 @@ import java.util.List;
|
|||
opusClose(nativeDecoderContext);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the channel count of output audio.
|
||||
*/
|
||||
public int getChannelCount() {
|
||||
return channelCount;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the sample rate of output audio.
|
||||
*/
|
||||
public int getSampleRate() {
|
||||
return SAMPLE_RATE;
|
||||
}
|
||||
|
||||
private static int nsToSamples(long ns) {
|
||||
return (int) (ns * SAMPLE_RATE / 1000000000);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue