Skip to content

Commit

Permalink
mediacodec: allow to open with a custom extra buffer
Browse files Browse the repository at this point in the history
  • Loading branch information
tguillem committed Apr 24, 2015
1 parent 2a09b42 commit 0621dfe
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions modules/codec/omxil/android_mediacodec.c
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ struct decoder_sys_t
char *name;

void *p_extra_buffer;
size_t i_extra_buffer;

bool allocated;
bool started;
Expand Down Expand Up @@ -529,10 +530,9 @@ static int OpenMediaCodec(decoder_t *p_dec, JNIEnv *env)
jfields.create_video_format, (*env)->NewStringUTF(env, mime),
p_dec->fmt_in.video.i_width, p_dec->fmt_in.video.i_height);

if (p_dec->fmt_in.i_extra) {
if (p_dec->fmt_in.i_extra && !p_sys->p_extra_buffer) {
uint32_t size = p_dec->fmt_in.i_extra;
int buf_size = p_dec->fmt_in.i_extra + 20;
jobject jextra_buffer;

/* Don't free p_extra_buffer until Format use it, so until MediaCodec
* is closed */
Expand All @@ -554,9 +554,15 @@ static int OpenMediaCodec(decoder_t *p_dec, JNIEnv *env)
} else {
memcpy(p_sys->p_extra_buffer, p_dec->fmt_in.p_extra, size);
}
p_sys->i_extra_buffer = size;
}
if (p_sys->p_extra_buffer)
{
jobject jextra_buffer;

jextra_buffer = (*env)->NewDirectByteBuffer( env,
p_sys->p_extra_buffer,
size);
p_sys->i_extra_buffer);
if (CHECK_EXCEPTION() || !jextra_buffer)
{
msg_Warn(p_dec, "java extra buffer allocation failed");
Expand Down

0 comments on commit 0621dfe

Please sign in to comment.