36 JNIEnv *env, jobject stream, jlong aio_pointer) {
58 JNIEnv *env, jobject stream, jstring url, jbyteArray urlBytes,
59 jint streamIndex, jint fileBufferSize) {
63 char *input_url = NULL;
66 jsize urlLen = (*env)->GetArrayLength(env, urlBytes);
67 jbyte *urlBuf = (*env)->GetByteArrayElements(env, urlBytes, NULL);
68 input_url = (
char *)malloc(urlLen + 1);
70 (*env)->ReleaseByteArrayElements(env, urlBytes, urlBuf, JNI_ABORT);
71 res = AVERROR(ENOMEM);
75 memcpy(input_url, urlBuf, urlLen);
76 input_url[urlLen] =
'\0';
77 (*env)->ReleaseByteArrayElements(env, urlBytes, urlBuf, JNI_ABORT);
82 res = AVERROR(ENOMEM);
100 fprintf(stderr,
"stream->codecpar->bits_per_coded_sample: %i\n",
101 aio->
stream->codecpar->bits_per_coded_sample);
102 fprintf(stderr,
"stream->codecpar->bits_per_raw_sample : %i\n",
103 aio->
stream->codecpar->bits_per_raw_sample);
104 fprintf(stderr,
"stream->codecpar->bit_rate: %lli\n",
105 aio->
stream->codecpar->bit_rate);
106 fprintf(stderr,
"frames : %" PRId64
"\n", aio->
stream->nb_frames);
107 fprintf(stderr,
"sample_rate: %i\n", aio->
stream->codecpar->sample_rate);
108 fprintf(stderr,
"channels : %i\n",
109 aio->
stream->codecpar->ch_layout.nb_channels);
110 fprintf(stderr,
"frame_size : %i\n", aio->
stream->codecpar->frame_size);
111 fprintf(stderr,
"codec_id : %i\n", aio->
stream->codecpar->codec_id);
120 return (jlong)(intptr_t)aio;
131JNIEXPORT jboolean JNICALL
136 jboolean seekable = JNI_FALSE;
150 JNIEnv *env, jobject stream, jlong aio_pointer, jlong microseconds) {
153 int64_t seek_target = microseconds;
154 int64_t current_timestamp = 0;
158 av_rescale_q(seek_target, AV_TIME_BASE_Q, aio->
stream->time_base);
161 "Current Timestamp = %" PRId64
", seek_target = %" PRId64
"\n",
162 current_timestamp, seek_target);
166 current_timestamp > seek_target ? AVSEEK_FLAG_BACKWARD : 0);
193 JNIEnv *env, jobject stream, jlong aio_pointer) {
void ff_audioio_free(FFAudioIO *aio)
Free all resources held by aio and then itself.
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_fill_buffer(FFAudioIO *aio)
Reads frames via av_read_frame, decodes them, 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 ...
void throwIOExceptionIfError(JNIEnv *env, int err, const char *message)
Throws an IOException.
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 * decode_packet
AVPacket for decoding.
AVCodecContext * decode_context
Codec context for decoding.
jobject java_instance
Calling Java instance.