29static jfieldID nativeBuffer_FID = NULL;
30static jmethodID rewind_MID = NULL;
31static jmethodID limit_MID = NULL;
32static jmethodID capacity_MID = NULL;
33static jmethodID setNativeBufferCapacity_MID = NULL;
34static jmethodID logFine_MID = NULL;
35static jmethodID logWarning_MID = NULL;
36static const int MIN_PROBE_SCORE =
41static const int FF_FILL_TARGET = 64 * 1024;
55 JNIEnv *env, jclass streamClass) {
56 jclass bufferClass = (*env)->FindClass(env,
"java/nio/Buffer");
60 nativeBuffer_FID = (*env)->GetFieldID(env, streamClass,
"nativeBuffer",
61 "Ljava/nio/ByteBuffer;");
62 if (!nativeBuffer_FID)
65 (*env)->GetMethodID(env, bufferClass,
"rewind",
"()Ljava/nio/Buffer;");
69 (*env)->GetMethodID(env, bufferClass,
"limit",
"(I)Ljava/nio/Buffer;");
72 capacity_MID = (*env)->GetMethodID(env, bufferClass,
"capacity",
"()I");
75 setNativeBufferCapacity_MID =
76 (*env)->GetMethodID(env, streamClass,
"setNativeBufferCapacity",
"(I)I");
77 if (!setNativeBufferCapacity_MID)
80 (*env)->GetMethodID(env, streamClass,
"logFine",
"(Ljava/lang/String;)V");
83 logWarning_MID = (*env)->GetMethodID(env, streamClass,
"logWarning",
84 "(Ljava/lang/String;)V");
95 fprintf(stderr,
"Opening stream...\n");
99 AVCodec *decoder = NULL;
101 decoder = avcodec_find_decoder(stream->codecpar->codec_id);
103 fprintf(stderr,
"Failed to find %s codec\n",
104 av_get_media_type_string(AVMEDIA_TYPE_AUDIO));
105 res = AVERROR(EINVAL);
107 "Failed to find codec.");
110 *context = avcodec_alloc_context3(decoder);
112 fprintf(stderr,
"Failed to allocate context\n");
113 res = AVERROR(ENOMEM);
115 env, res,
"Failed to allocate codec context.");
120 if ((res = avcodec_parameters_to_context(*context, stream->codecpar)) < 0) {
121 fprintf(stderr,
"Failed to copy %s codec parameters to decoder context\n",
122 av_get_media_type_string(AVMEDIA_TYPE_AUDIO));
124 env, res,
"Failed to copy codec parameters.");
128 if ((res = avcodec_open2(*context, decoder, NULL)) < 0) {
129 fprintf(stderr,
"Failed to open %s codec\n",
130 av_get_media_type_string(AVMEDIA_TYPE_AUDIO));
132 "Failed to open codec.");
137 fprintf(stderr,
"Stream was opened.\n");
152static int open_codec_context(
int *stream_index,
153 AVFormatContext *format_context,
154 enum AVMediaType type) {
155 int res = av_find_best_stream(format_context, type, -1, -1, NULL, 0);
168static void throw_new(JNIEnv *env,
const char *class_name,
169 const char *message) {
170 if ((*env)->ExceptionCheck(env))
172 jclass excCls = (*env)->FindClass(env, class_name);
175 (*env)->ThrowNew(env, excCls, message);
176 (*env)->DeleteLocalRef(env, excCls);
183 const char *message) {
185 char formattedMessage[strlen(message) + 4 + AV_ERROR_MAX_STRING_SIZE];
186 snprintf(formattedMessage, strlen(message) + 4 + AV_ERROR_MAX_STRING_SIZE,
187 "%s (%.64s)", message, av_err2str(err));
189 fprintf(stderr,
"UnsupportedAudioFileException: %s\n", formattedMessage);
191 throw_new(env,
"javax/sound/sampled/UnsupportedAudioFileException",
201 char formattedMessage[15];
202 snprintf(formattedMessage, 15,
"%d", index);
204 fprintf(stderr,
"IndexOutOfBoundsException: %d\n", index);
206 throw_new(env,
"java/lang/IndexOutOfBoundsException", formattedMessage);
215 char formattedMessage[strlen(message) + 4 + AV_ERROR_MAX_STRING_SIZE];
216 snprintf(formattedMessage, strlen(message) + 4 + AV_ERROR_MAX_STRING_SIZE,
217 "%s (%.64s)", message, av_err2str(err));
219 fprintf(stderr,
"IOException: %s\n", formattedMessage);
221 throw_new(env,
"java/io/IOException", formattedMessage);
229 const char *message) {
232 fprintf(stderr,
"FileNotFoundException: '%s' %d (%4.4s)\n", message,
233 (
int)err, (
char *)&err);
235 throw_new(env,
"java/io/FileNotFoundException", message);
246static void log_message(
FFAudioIO *aio, jmethodID log_MID,
int err,
247 const char *message) {
248 JNIEnv *env = aio->
env;
251 if ((*env)->ExceptionCheck(env)) {
253 fprintf(stderr,
"Not logging, exception pending: %s\n", message);
258 char formattedMessage[strlen(message) + 20 + AV_ERROR_MAX_STRING_SIZE];
259 snprintf(formattedMessage, strlen(message) + 20 + AV_ERROR_MAX_STRING_SIZE,
260 "%s %i (%.64s)", message, err, av_err2str(err));
261 s = (*env)->NewStringUTF(env, formattedMessage);
263 s = (*env)->NewStringUTF(env, message);
267 (*env)->DeleteLocalRef(env, s);
269 if ((*env)->ExceptionCheck(env)) {
270 (*env)->ExceptionClear(env);
278 log_message(aio, logWarning_MID, err, message);
285 log_message(aio, logFine_MID, err, message);
298 const char *url,
int io_buffer_size) {
302 res = avformat_open_input(format_context, url, NULL, NULL);
304 if (res == AVERROR(ENOENT) || res == AVERROR_HTTP_NOT_FOUND) {
306 }
else if (res == AVERROR_PROTOCOL_NOT_FOUND ||
307 res == AVERROR_HTTP_BAD_REQUEST ||
308 res == AVERROR_HTTP_UNAUTHORIZED ||
309 res == AVERROR_HTTP_FORBIDDEN || res == AVERROR_HTTP_OTHER_4XX ||
310 res == AVERROR_HTTP_SERVER_ERROR || res == AVERROR(EIO)) {
314 "Failed to open audio file");
319 probe_score = (*format_context)->probe_score;
322 fprintf(stderr,
"ff_open_format_context(): probe score=%i\n", probe_score);
325 if (probe_score < MIN_PROBE_SCORE) {
328 "Probe score too low");
332 res = avformat_find_stream_info(*format_context, NULL);
335 "Failed to find stream info");
339 if (io_buffer_size > 0 && (*format_context)->pb) {
340 AVIOContext *pb = (*format_context)->pb;
341 if (pb->buffer_size < io_buffer_size) {
342 unsigned char *new_buf = (
unsigned char *)av_malloc(io_buffer_size);
344 int valid = (int)(pb->buf_end - pb->buf_ptr);
346 memcpy(new_buf, pb->buf_ptr, valid);
348 pb->buffer = new_buf;
349 pb->buf_ptr = new_buf;
350 pb->buf_end = new_buf + valid;
351 pb->buffer_size = io_buffer_size;
352 pb->buf_ptr_max = new_buf + valid;
353 pb->checksum_ptr = NULL;
355 pb->update_checksum = NULL;
379 AVStream **openedStream, AVCodecContext **context,
380 int *stream_index,
const char *url,
int io_buffer_size) {
389 fprintf(stderr,
"Desired audio stream index: %i.\n", *stream_index);
392 if (*stream_index < 0) {
394 res = open_codec_context(stream_index, *format_context, AVMEDIA_TYPE_AUDIO);
397 env, res,
"Failed to find best audio stream.");
400 *openedStream = (*format_context)->streams[*stream_index];
409 int audio_stream_number = 0;
410 AVStream *stream = NULL;
412 AVFormatContext *deref_format_context = *format_context;
413 for (i = 0; i < deref_format_context->nb_streams; i++) {
414 stream = deref_format_context->streams[i];
415 if (stream->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
416 if (audio_stream_number == *stream_index) {
419 fprintf(stderr,
"Found desired audio stream at index: %i.\n", i);
423 audio_stream_number++;
427 if (stream == NULL) {
430 if (*stream_index == 0) {
432 "No stream found (index=0).");
442 *openedStream = stream;
446 fprintf(stderr,
"File is DRM-crippled.\n");
449 "File is DRM-crippled.");
454 fprintf(stderr,
"Opened stream index: %i.\n", *stream_index);
455 fprintf(stderr,
"Opened stream: %ld.\n", (
long)*openedStream);
471static int init_swr(JNIEnv *env,
FFAudioIO *aio) {
473 AVChannelLayout ch_layout = {0};
477 if (aio->
stream->codecpar->ch_layout.order == AV_CHANNEL_ORDER_UNSPEC) {
478 av_channel_layout_default(&ch_layout,
479 aio->
stream->codecpar->ch_layout.nb_channels);
481 av_channel_layout_copy(&ch_layout, &aio->
stream->codecpar->ch_layout);
486 res = AVERROR(ENOMEM);
491 av_opt_set_sample_fmt(aio->
swr_context,
"in_sample_fmt",
492 aio->
stream->codecpar->format, 0);
494 av_opt_set_sample_fmt(aio->
swr_context,
"out_sample_fmt",
495 av_get_packed_sample_fmt(aio->
stream->codecpar->format),
498 av_opt_set_chlayout(aio->
swr_context,
"in_chlayout", &ch_layout, 0);
499 av_opt_set_chlayout(aio->
swr_context,
"out_chlayout", &ch_layout, 0);
501 aio->
stream->codecpar->sample_rate, 0);
502 av_opt_set_int(aio->
swr_context,
"out_sample_rate",
503 aio->
stream->codecpar->sample_rate, 0);
507 res = AVERROR(ENOMEM);
513 av_channel_layout_uninit(&ch_layout);
529 int big_endian,
int signedSamples) {
530 enum AVCodecID codec_id;
533 fprintf(stderr,
"ff_find_encoder(fmt=%d,bits=%d,big_endian=%d,signed=%d)\n",
534 sampleFormat, bits, big_endian, signedSamples);
537 switch (sampleFormat) {
538 case AV_SAMPLE_FMT_U8:
539 case AV_SAMPLE_FMT_U8P:
541 codec_id = AV_CODEC_ID_PCM_S8;
543 codec_id = AV_CODEC_ID_PCM_U8;
545 case AV_SAMPLE_FMT_S16:
546 case AV_SAMPLE_FMT_S16P:
548 codec_id = big_endian ? AV_CODEC_ID_PCM_S16BE : AV_CODEC_ID_PCM_S16LE;
550 codec_id = big_endian ? AV_CODEC_ID_PCM_U16BE : AV_CODEC_ID_PCM_U16LE;
552 case AV_SAMPLE_FMT_S32:
553 case AV_SAMPLE_FMT_S32P:
556 codec_id = big_endian ? AV_CODEC_ID_PCM_S24BE : AV_CODEC_ID_PCM_S24LE;
558 codec_id = big_endian ? AV_CODEC_ID_PCM_U24BE : AV_CODEC_ID_PCM_U24LE;
561 codec_id = big_endian ? AV_CODEC_ID_PCM_S32BE : AV_CODEC_ID_PCM_S32LE;
563 codec_id = big_endian ? AV_CODEC_ID_PCM_U32BE : AV_CODEC_ID_PCM_U32LE;
566 case AV_SAMPLE_FMT_FLT:
567 case AV_SAMPLE_FMT_FLTP:
568 codec_id = big_endian ? AV_CODEC_ID_PCM_F32BE : AV_CODEC_ID_PCM_F32LE;
570 case AV_SAMPLE_FMT_DBL:
571 case AV_SAMPLE_FMT_DBLP:
572 codec_id = big_endian ? AV_CODEC_ID_PCM_F64BE : AV_CODEC_ID_PCM_F64LE;
578 return avcodec_find_encoder(codec_id);
593 int64_t out_sample_rate;
594 AVChannelLayout out_ch_layout = {0};
595 enum AVSampleFormat out_sample_fmt;
608 res = AVERROR(ENOMEM);
614 av_opt_get_chlayout(aio->
swr_context,
"out_chlayout", 0, &out_ch_layout);
615 av_opt_get_int(aio->
swr_context,
"out_sample_rate", 0, &out_sample_rate);
616 av_opt_get_sample_fmt(aio->
swr_context,
"out_sample_fmt", 0, &out_sample_fmt);
620 av_channel_layout_copy(&aio->
encode_context->ch_layout, &out_ch_layout);
624 res = AVERROR(ENOMEM);
632 res = AVERROR(ENOMEM);
640 res = AVERROR(ENOMEM);
651 av_channel_layout_uninit(&out_ch_layout);
666 AVCodec *codec = NULL;
671 nb_planes = av_sample_fmt_is_planar(aio->
stream->codecpar->format)
672 ? aio->
stream->codecpar->ch_layout.nb_channels
676 res = init_swr(env, aio);
687 int src_bits = aio->
stream->codecpar->bits_per_coded_sample;
689 if (src_bits == 24 || (src_big_endian && src_bits > 8)) {
693 res = AVERROR(EINVAL);
695 "Could not find suitable encoder codec.");
707 aio->
audio_data = av_mallocz(
sizeof(uint8_t *) * nb_planes);
709 res = AVERROR(ENOMEM);
716 res = AVERROR(ENOMEM);
724 res = AVERROR(ENOMEM);
743static int encode_buffer(
FFAudioIO *aio,
const uint8_t *in_buf,
int in_size,
744 const uint8_t *out_buf) {
748 res = av_samples_get_buffer_size(NULL, nb_channels,
754 "encode_buffer: channels=%d frame->nb_samples=%d in_size=%d\n",
756 fprintf(stderr,
"encode_buffer: needed buffer=%d available=%d\n", res,
761 res = av_samples_fill_arrays(aio->
encode_frame->data, NULL, in_buf,
774 "Failed to send audio frame for encoding.");
778 if (res < 0 && res != AVERROR(EAGAIN) && res != AVERROR_EOF) {
804static int resample(
FFAudioIO *aio, uint8_t **out_buf,
int out_samples,
805 const uint8_t **in_buf,
const int in_samples) {
807 AVChannelLayout out_ch_layout = {0};
808 int out_channel_count;
809 enum AVSampleFormat out_sample_format;
811 if (out_samples == 0)
814 av_opt_get_chlayout(aio->
swr_context,
"out_chlayout", 0, &out_ch_layout);
815 out_channel_count = out_ch_layout.nb_channels;
816 av_channel_layout_uninit(&out_ch_layout);
817 av_opt_get_sample_fmt(aio->
swr_context,
"out_sample_fmt", 0,
823 "resample: out_samples=%d in_samples=%d, channels=%d sample_format=%d\n",
824 out_samples, in_samples, out_channel_count, out_sample_format);
828 res = av_samples_alloc(out_buf, NULL, out_channel_count, out_samples,
829 out_sample_format, 1);
831 res = AVERROR(ENOMEM);
833 "Could not allocate resample buffer.");
838 res = swr_convert(aio->
swr_context, out_buf, out_samples, in_buf, in_samples);
849static int copy_to_java_buffer(
FFAudioIO *aio, uint32_t offset,
int samples,
850 uint8_t **resample_buf) {
852 uint32_t buffer_size = 0;
853 jobject byte_buffer = NULL;
854 uint8_t *java_buffer = NULL;
855 AVChannelLayout out_ch_layout = {0};
857 enum AVSampleFormat format;
859 av_opt_get_sample_fmt(aio->
swr_context,
"out_sample_fmt", 0, &format);
860 av_opt_get_chlayout(aio->
swr_context,
"out_chlayout", 0, &out_ch_layout);
861 channel_count = out_ch_layout.nb_channels;
862 av_channel_layout_uninit(&out_ch_layout);
864 res = av_samples_get_buffer_size(NULL, channel_count, samples, format, 1);
872 jint new_capacity = (*aio->
env)->CallIntMethod(
874 (jint)(buffer_size + offset));
875 if ((*aio->
env)->ExceptionCheck(aio->
env)) {
894 (uint8_t *)(*aio->
env)->GetDirectBufferAddress(aio->
env, byte_buffer);
898 "Failed to get address for native buffer.");
901 java_buffer += offset;
904 res = encode_buffer(aio, resample_buf[0], buffer_size, java_buffer);
911 memcpy(java_buffer, resample_buf[0], buffer_size);
918 (*aio->
env)->CallObjectMethod(aio->
env, byte_buffer, rewind_MID);
919 if ((*aio->
env)->ExceptionCheck(aio->
env)) {
923 (*aio->
env)->DeleteLocalRef(aio->
env, self);
926 jobject self = (*aio->
env)->CallObjectMethod(
927 aio->
env, byte_buffer, limit_MID, offset + buffer_size);
928 if ((*aio->
env)->ExceptionCheck(aio->
env)) {
932 (*aio->
env)->DeleteLocalRef(aio->
env, self);
940 (*aio->
env)->DeleteLocalRef(aio->
env, byte_buffer);
952static int receive_and_process_frames(
FFAudioIO *aio,
int is_flush,
953 uint32_t initial_offset) {
956 uint8_t **resample_buf = NULL;
957 uint32_t java_buffer_offset = initial_offset;
958 uint32_t out_buf_size = 0;
959 int out_buf_samples = 0;
960 int64_t out_sample_rate;
962 av_opt_get_int(aio->
swr_context,
"out_sample_rate", 0, &out_sample_rate);
964 resample_buf = av_mallocz(
sizeof(uint8_t *));
967 "Could not allocate resample buffer pointer.");
968 return AVERROR(ENOMEM);
973 if (res == AVERROR(EAGAIN) || res == AVERROR_EOF) {
978 logWarning(aio, res,
"Error receiving frame from decoder:");
983 if (aio->
stream->codecpar->ch_layout.nb_channels !=
985 logWarning(aio, 0,
"Skipping frame: channel count mismatch");
994 stderr,
"samples%s n:%" PRIu64
" nb_samples:%d pts:%s\n",
1000 out_buf_samples = av_rescale_rnd(
1003 out_sample_rate, aio->
stream->codecpar->sample_rate, AV_ROUND_UP);
1005 res = av_samples_alloc(
1010 "Could not allocate audio buffer.");
1018 res = resample(aio, resample_buf, out_buf_samples,
1023 out_buf_samples = res;
1025 if (out_buf_samples > 0 && resample_buf[0]) {
1026 java_buffer_offset += out_buf_size;
1027 res = copy_to_java_buffer(aio, java_buffer_offset, out_buf_samples,
1034 if (resample_buf[0])
1035 av_freep(&resample_buf[0]);
1047 fprintf(stderr,
"Flushing SWR delay: %" PRId64
" samples\n", delay);
1049 res = resample(aio, resample_buf, (
int)delay, NULL, 0);
1052 out_buf_samples = res;
1053 if (out_buf_samples > 0 && resample_buf[0]) {
1054 java_buffer_offset += out_buf_size;
1055 res = copy_to_java_buffer(aio, java_buffer_offset, out_buf_samples,
1062 if (resample_buf[0])
1063 av_freep(&resample_buf[0]);
1069 if (resample_buf[0])
1070 av_freep(&resample_buf[0]);
1071 av_free(resample_buf);
1075 return res < 0 ? res : total_bytes;
1085static int decode_packet(
FFAudioIO *aio, uint32_t offset) {
1087 if (res == AVERROR(EINVAL)) {
1089 "Invalid argument for decoder.");
1093 if (res < 0 && res != AVERROR_EOF) {
1094 logWarning(aio, res,
"Skipping packet. avcodec_send_packet failed:");
1097 return receive_and_process_frames(aio, 0, offset);
1109 int total_bytes = 0;
1114 while (total_bytes < FF_FILL_TARGET) {
1116 if ((*aio->
env)->ExceptionCheck(aio->
env)) {
1120 res = read_res < 0 ? read_res : -1;
1123 if (read_res >= 0) {
1127 fprintf(stderr,
"duration : %lli\n", aio->
decode_packet->duration);
1128 fprintf(stderr,
"timestamp : %" PRId64
"\n", aio->
timestamp);
1129 fprintf(stderr,
"pts : %" PRId64
"\n", aio->
decode_packet->pts);
1130 fprintf(stderr,
"dts : %" PRId64
"\n", aio->
decode_packet->dts);
1132 int bytes = decode_packet(aio, (uint32_t)total_bytes);
1138 total_bytes += bytes;
1143 fprintf(stderr,
"Flushing decoder at EOF\n");
1147 if (read_res == AVERROR_EOF) {
1149 int bytes = receive_and_process_frames(aio, 1, (uint32_t)total_bytes);
1151 total_bytes += bytes;
1171 fprintf(stderr,
"ff_audioio_free\n");
1190 if ((s->iformat && s->iformat->flags & AVFMT_NOFILE) ||
1191 (s->flags & AVFMT_FLAG_CUSTOM_IO)) {
1194 avio_context_free(&s->pb);
1224 case AV_CODEC_ID_PCM_S16BE:
1225 case AV_CODEC_ID_PCM_U16BE:
1226 case AV_CODEC_ID_PCM_S32BE:
1227 case AV_CODEC_ID_PCM_U32BE:
1228 case AV_CODEC_ID_PCM_S24BE:
1229 case AV_CODEC_ID_PCM_U24BE:
1230 case AV_CODEC_ID_PCM_F32BE:
1231 case AV_CODEC_ID_PCM_F64BE:
1244 avformat_network_init();
1245 return JNI_VERSION_1_6;
void ff_audioio_free(FFAudioIO *aio)
Free all resources held by aio and then itself.
int ff_big_endian(enum AVCodecID codec_id)
Indicates whether the given id belongs to a big endian codec.
void logWarning(FFAudioIO *aio, int err, const char *message)
Log a warning.
void throwFileNotFoundExceptionIfError(JNIEnv *env, int err, const char *message)
Throws a FileNotFoundException.
int ff_open_file(JNIEnv *env, AVFormatContext **format_context, AVStream **openedStream, AVCodecContext **context, int *stream_index, const char *url, int io_buffer_size)
Opens the input file/url, allocates a AVFormatContext for it and opens the audio stream with an appro...
int ff_open_format_context(JNIEnv *env, AVFormatContext **format_context, const char *url, int io_buffer_size)
Opens the input file/url and allocates a AVFormatContext for it, but does not open the audio stream w...
AVCodec * ff_find_encoder(enum AVSampleFormat sampleFormat, int bits, int big_endian, int signedSamples)
Finds an AVCodec encoder for the given sample format, bits per sample, byte order and signed/unsigned...
int ff_fill_buffer(FFAudioIO *aio)
Reads frames via av_read_frame, decodes them, and writes the result to the Java-side nativeBuffer.
void throwUnsupportedAudioFileExceptionIfError(JNIEnv *env, int err, const char *message)
Throws an UnsupportedAudioFileException.
int ff_init_audioio(JNIEnv *env, FFAudioIO *aio)
Initialize our main context FFAudioIO, so that SwrContext, decode buffers and the encoder are set to ...
int ff_init_encoder(JNIEnv *env, FFAudioIO *aio, AVCodec *encoder)
Allocates and initializes the encoder context and frame in FFAudioIO.
void throwIOExceptionIfError(JNIEnv *env, int err, const char *message)
Throws an IOException.
JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *reserved)
Make sure FFmpeg is initialized all the way.
const uint32_t CODEC_TAG_DRMS
JNIEXPORT void JNICALL Java_com_tagtraum_ffsampledsp_FFNativePeerInputStream_initIDs(JNIEnv *env, jclass streamClass)
Init static method and field ids for Java methods/fields.
int ff_open_stream(JNIEnv *env, AVStream *stream, AVCodecContext **context)
Opens the given stream, i.e.
void throwIndexOutOfBoundsExceptionIfError(JNIEnv *env, int err, int index)
Throws an IndexOutOfBoundsException.
void logFine(FFAudioIO *aio, int err, const char *message)
Log a debug message.
Central context representing the native peer to the Java FFNativePeerInputStream object.
uint64_t timestamp
Current timestamp (in samples, not seconds).
AVFormatContext * format_context
Current AVFormatContext.
int stream_index
Index of the audio stream we are using.
AVStream * stream
Audio stream we are interested in.
JNIEnv * env
JNI environment.
AVPacket * encode_packet
AVPacket for encoding.
uint64_t decoded_samples
Running count of decoded samples.
AVFrame * decode_frame
AVFrame for decoding.
AVFrame * encode_frame
AVFrame for encoding.
AVPacket * decode_packet
AVPacket for decoding.
jint java_buffer_capacity
Current capacity of the Java nativeBuffer.
AVCodecContext * decode_context
Codec context for decoding.
uint8_t ** audio_data
Audio data (accommodates multiple planes).
SwrContext * swr_context
Resampling context.
jobject java_instance
Calling Java instance.
uint64_t resampled_samples
Count of resampled samples.
AVCodecContext * encode_context
Codec context for encoding.