Rename FfmpegDecoder to FfmpegAudioDecoder
It looks like the video path will use a separate FfmpegVideoDecoder Issue: #2159 PiperOrigin-RevId: 303068617
This commit is contained in:
parent
dd54259d47
commit
b314da5f02
@ -28,11 +28,9 @@ import com.google.android.exoplayer2.util.Util;
|
|||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/** FFmpeg audio decoder. */
|
||||||
* FFmpeg audio decoder.
|
/* package */ final class FfmpegAudioDecoder
|
||||||
*/
|
extends SimpleDecoder<DecoderInputBuffer, SimpleOutputBuffer, FfmpegDecoderException> {
|
||||||
/* package */ final class FfmpegDecoder extends
|
|
||||||
SimpleDecoder<DecoderInputBuffer, SimpleOutputBuffer, FfmpegDecoderException> {
|
|
||||||
|
|
||||||
// Output buffer sizes when decoding PCM mu-law streams, which is the maximum FFmpeg outputs.
|
// Output buffer sizes when decoding PCM mu-law streams, which is the maximum FFmpeg outputs.
|
||||||
private static final int OUTPUT_BUFFER_SIZE_16BIT = 65536;
|
private static final int OUTPUT_BUFFER_SIZE_16BIT = 65536;
|
||||||
@ -52,7 +50,7 @@ import java.util.List;
|
|||||||
private volatile int channelCount;
|
private volatile int channelCount;
|
||||||
private volatile int sampleRate;
|
private volatile int sampleRate;
|
||||||
|
|
||||||
public FfmpegDecoder(
|
public FfmpegAudioDecoder(
|
||||||
int numInputBuffers,
|
int numInputBuffers,
|
||||||
int numOutputBuffers,
|
int numOutputBuffers,
|
||||||
int initialInputBufferSize,
|
int initialInputBufferSize,
|
@ -41,7 +41,7 @@ public final class FfmpegAudioRenderer extends DecoderAudioRenderer {
|
|||||||
|
|
||||||
private final boolean enableFloatOutput;
|
private final boolean enableFloatOutput;
|
||||||
|
|
||||||
private @MonotonicNonNull FfmpegDecoder decoder;
|
private @MonotonicNonNull FfmpegAudioDecoder decoder;
|
||||||
|
|
||||||
public FfmpegAudioRenderer() {
|
public FfmpegAudioRenderer() {
|
||||||
this(/* eventHandler= */ null, /* eventListener= */ null);
|
this(/* eventHandler= */ null, /* eventListener= */ null);
|
||||||
@ -117,12 +117,12 @@ public final class FfmpegAudioRenderer extends DecoderAudioRenderer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected FfmpegDecoder createDecoder(Format format, @Nullable ExoMediaCrypto mediaCrypto)
|
protected FfmpegAudioDecoder createDecoder(Format format, @Nullable ExoMediaCrypto mediaCrypto)
|
||||||
throws FfmpegDecoderException {
|
throws FfmpegDecoderException {
|
||||||
int initialInputBufferSize =
|
int initialInputBufferSize =
|
||||||
format.maxInputSize != Format.NO_VALUE ? format.maxInputSize : DEFAULT_INPUT_BUFFER_SIZE;
|
format.maxInputSize != Format.NO_VALUE ? format.maxInputSize : DEFAULT_INPUT_BUFFER_SIZE;
|
||||||
decoder =
|
decoder =
|
||||||
new FfmpegDecoder(
|
new FfmpegAudioDecoder(
|
||||||
NUM_BUFFERS, NUM_BUFFERS, initialInputBufferSize, format, shouldUseFloatOutput(format));
|
NUM_BUFFERS, NUM_BUFFERS, initialInputBufferSize, format, shouldUseFloatOutput(format));
|
||||||
return decoder;
|
return decoder;
|
||||||
}
|
}
|
||||||
|
@ -36,25 +36,25 @@ extern "C" {
|
|||||||
#define LOGE(...) ((void)__android_log_print(ANDROID_LOG_ERROR, LOG_TAG, \
|
#define LOGE(...) ((void)__android_log_print(ANDROID_LOG_ERROR, LOG_TAG, \
|
||||||
__VA_ARGS__))
|
__VA_ARGS__))
|
||||||
|
|
||||||
#define DECODER_FUNC(RETURN_TYPE, NAME, ...) \
|
#define AUDIO_DECODER_FUNC(RETURN_TYPE, NAME, ...) \
|
||||||
extern "C" { \
|
extern "C" { \
|
||||||
JNIEXPORT RETURN_TYPE \
|
JNIEXPORT RETURN_TYPE \
|
||||||
Java_com_google_android_exoplayer2_ext_ffmpeg_FfmpegDecoder_ ## NAME \
|
Java_com_google_android_exoplayer2_ext_ffmpeg_FfmpegAudioDecoder_##NAME( \
|
||||||
(JNIEnv* env, jobject thiz, ##__VA_ARGS__);\
|
JNIEnv *env, jobject thiz, ##__VA_ARGS__); \
|
||||||
} \
|
} \
|
||||||
JNIEXPORT RETURN_TYPE \
|
JNIEXPORT RETURN_TYPE \
|
||||||
Java_com_google_android_exoplayer2_ext_ffmpeg_FfmpegDecoder_ ## NAME \
|
Java_com_google_android_exoplayer2_ext_ffmpeg_FfmpegAudioDecoder_##NAME( \
|
||||||
(JNIEnv* env, jobject thiz, ##__VA_ARGS__)\
|
JNIEnv *env, jobject thiz, ##__VA_ARGS__)
|
||||||
|
|
||||||
#define LIBRARY_FUNC(RETURN_TYPE, NAME, ...) \
|
#define LIBRARY_FUNC(RETURN_TYPE, NAME, ...) \
|
||||||
extern "C" { \
|
extern "C" { \
|
||||||
JNIEXPORT RETURN_TYPE \
|
JNIEXPORT RETURN_TYPE \
|
||||||
Java_com_google_android_exoplayer2_ext_ffmpeg_FfmpegLibrary_ ## NAME \
|
Java_com_google_android_exoplayer2_ext_ffmpeg_FfmpegLibrary_##NAME( \
|
||||||
(JNIEnv* env, jobject thiz, ##__VA_ARGS__);\
|
JNIEnv *env, jobject thiz, ##__VA_ARGS__); \
|
||||||
} \
|
} \
|
||||||
JNIEXPORT RETURN_TYPE \
|
JNIEXPORT RETURN_TYPE \
|
||||||
Java_com_google_android_exoplayer2_ext_ffmpeg_FfmpegLibrary_ ## NAME \
|
Java_com_google_android_exoplayer2_ext_ffmpeg_FfmpegLibrary_##NAME( \
|
||||||
(JNIEnv* env, jobject thiz, ##__VA_ARGS__)\
|
JNIEnv *env, jobject thiz, ##__VA_ARGS__)
|
||||||
|
|
||||||
#define ERROR_STRING_BUFFER_LENGTH 256
|
#define ERROR_STRING_BUFFER_LENGTH 256
|
||||||
|
|
||||||
@ -63,7 +63,7 @@ static const AVSampleFormat OUTPUT_FORMAT_PCM_16BIT = AV_SAMPLE_FMT_S16;
|
|||||||
// Output format corresponding to AudioFormat.ENCODING_PCM_FLOAT.
|
// Output format corresponding to AudioFormat.ENCODING_PCM_FLOAT.
|
||||||
static const AVSampleFormat OUTPUT_FORMAT_PCM_FLOAT = AV_SAMPLE_FMT_FLT;
|
static const AVSampleFormat OUTPUT_FORMAT_PCM_FLOAT = AV_SAMPLE_FMT_FLT;
|
||||||
|
|
||||||
// Error codes matching FfmpegDecoder.java.
|
// Error codes matching FfmpegAudioDecoder.java.
|
||||||
static const int DECODER_ERROR_INVALID_DATA = -1;
|
static const int DECODER_ERROR_INVALID_DATA = -1;
|
||||||
static const int DECODER_ERROR_OTHER = -2;
|
static const int DECODER_ERROR_OTHER = -2;
|
||||||
|
|
||||||
@ -115,8 +115,9 @@ LIBRARY_FUNC(jboolean, ffmpegHasDecoder, jstring codecName) {
|
|||||||
return getCodecByName(env, codecName) != NULL;
|
return getCodecByName(env, codecName) != NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
DECODER_FUNC(jlong, ffmpegInitialize, jstring codecName, jbyteArray extraData,
|
AUDIO_DECODER_FUNC(jlong, ffmpegInitialize, jstring codecName,
|
||||||
jboolean outputFloat, jint rawSampleRate, jint rawChannelCount) {
|
jbyteArray extraData, jboolean outputFloat,
|
||||||
|
jint rawSampleRate, jint rawChannelCount) {
|
||||||
AVCodec *codec = getCodecByName(env, codecName);
|
AVCodec *codec = getCodecByName(env, codecName);
|
||||||
if (!codec) {
|
if (!codec) {
|
||||||
LOGE("Codec not found.");
|
LOGE("Codec not found.");
|
||||||
@ -154,7 +155,7 @@ DECODER_FUNC(jint, ffmpegDecode, jlong context, jobject inputData,
|
|||||||
outputSize);
|
outputSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
DECODER_FUNC(jint, ffmpegGetChannelCount, jlong context) {
|
AUDIO_DECODER_FUNC(jint, ffmpegGetChannelCount, jlong context) {
|
||||||
if (!context) {
|
if (!context) {
|
||||||
LOGE("Context must be non-NULL.");
|
LOGE("Context must be non-NULL.");
|
||||||
return -1;
|
return -1;
|
||||||
@ -162,7 +163,7 @@ DECODER_FUNC(jint, ffmpegGetChannelCount, jlong context) {
|
|||||||
return ((AVCodecContext *) context)->channels;
|
return ((AVCodecContext *) context)->channels;
|
||||||
}
|
}
|
||||||
|
|
||||||
DECODER_FUNC(jint, ffmpegGetSampleRate, jlong context) {
|
AUDIO_DECODER_FUNC(jint, ffmpegGetSampleRate, jlong context) {
|
||||||
if (!context) {
|
if (!context) {
|
||||||
LOGE("Context must be non-NULL.");
|
LOGE("Context must be non-NULL.");
|
||||||
return -1;
|
return -1;
|
||||||
@ -170,7 +171,7 @@ DECODER_FUNC(jint, ffmpegGetSampleRate, jlong context) {
|
|||||||
return ((AVCodecContext *) context)->sample_rate;
|
return ((AVCodecContext *) context)->sample_rate;
|
||||||
}
|
}
|
||||||
|
|
||||||
DECODER_FUNC(jlong, ffmpegReset, jlong jContext, jbyteArray extraData) {
|
AUDIO_DECODER_FUNC(jlong, ffmpegReset, jlong jContext, jbyteArray extraData) {
|
||||||
AVCodecContext *context = (AVCodecContext *) jContext;
|
AVCodecContext *context = (AVCodecContext *) jContext;
|
||||||
if (!context) {
|
if (!context) {
|
||||||
LOGE("Tried to reset without a context.");
|
LOGE("Tried to reset without a context.");
|
||||||
@ -198,7 +199,7 @@ DECODER_FUNC(jlong, ffmpegReset, jlong jContext, jbyteArray extraData) {
|
|||||||
return (jlong) context;
|
return (jlong) context;
|
||||||
}
|
}
|
||||||
|
|
||||||
DECODER_FUNC(void, ffmpegRelease, jlong context) {
|
AUDIO_DECODER_FUNC(void, ffmpegRelease, jlong context) {
|
||||||
if (context) {
|
if (context) {
|
||||||
releaseContext((AVCodecContext *) context);
|
releaseContext((AVCodecContext *) context);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user