24 #include "com_tagtraum_ffsampledsp_FFURLInputStream.h" 62 const char *input_url = (*env)->GetStringUTFChars(env, url, NULL);
64 res = AVERROR(ENOMEM);
71 res = AVERROR(ENOMEM);
87 fprintf(stderr,
"stream->codecpar->bits_per_coded_sample: %i\n", aio->
stream->codecpar->bits_per_coded_sample);
88 fprintf(stderr,
"stream->codecpar->bits_per_raw_sample : %i\n", aio->
stream->codecpar->bits_per_raw_sample);
89 fprintf(stderr,
"stream->codecpar->bit_rate: %lli\n", aio->
stream->codecpar->bit_rate);
90 fprintf(stderr,
"frames : %" PRId64
"\n", aio->
stream->nb_frames);
91 fprintf(stderr,
"sample_rate: %i\n", aio->
stream->codecpar->sample_rate);
92 fprintf(stderr,
"channels : %i\n", aio->
stream->codecpar->channels);
93 fprintf(stderr,
"frame_size : %i\n", aio->
stream->codecpar->frame_size);
94 fprintf(stderr,
"codec_id : %i\n", aio->
stream->codecpar->codec_id);
100 (*env)->ReleaseStringUTFChars(env, url, input_url);
102 return (jlong)(intptr_t)aio;
115 jboolean seekable = JNI_FALSE;
131 int64_t seek_target = microseconds;
132 int64_t current_timestamp = 0;
135 seek_target = av_rescale_q(seek_target, AV_TIME_BASE_Q, aio->
stream->time_base);
137 fprintf(stderr,
"Current Timestamp = %" PRId64
", seek_target = %" PRId64
"\n", current_timestamp, seek_target);
139 res = av_seek_frame(aio->
format_context, aio->
stream_index, seek_target, current_timestamp > seek_target ? AVSEEK_FLAG_BACKWARD : 0);
int stream_index
Index of the audio stream we are using.
void throwIOExceptionIfError(JNIEnv *env, int err, const char *message)
Throws an IOException.
AVFormatContext * format_context
Current AVFormatContext.
AVStream * stream
Audio stream we are interested in.
int ff_open_file(JNIEnv *env, AVFormatContext **format_context, AVStream **openedStream, AVCodecContext **context, int *stream_index, const char *url)
Opens the input file/url, allocates a AVFormatContext for it and opens the audio stream with an appro...
int ff_fill_buffer(FFAudioIO *aio)
Reads a frame via av_read_frame(AVFormatContext, AVPacket), decodes it to a AVPacket, and writes the result to the Java-side nativeBuffer.
int ff_init_audioio(JNIEnv *env, FFAudioIO *aio)
Initialize our main context FFAudioIO, so that SwrContext, decode buffers and the encoder are set to ...
AVPacket decode_packet
AVPacket for decoding.
JNIEnv * env
JNI environment.
AVCodecContext * decode_context
Codec context for decoding.
Central context representing the native peer to the Java FFNativePeerInputStream object.
void ff_audioio_free(FFAudioIO *aio)
Free all resources held by aio and then itself.
uint64_t timestamp
Current timestamp (in samples, not seconds)
jobject java_instance
Calling Java instance.