media codec sample implementation in android 4.1

7.3k Views Asked by At

I am trying to display video buffers on an android. I am using the media codec API released in Android 4.1 Jelly Bean.

The sample goes like this:

 MediaCodec codec = MediaCodec.createDecoderByType(type);
 codec.configure(format, ...);

configure method accepts 3 other arguments, apart from MediaFormat. I have been able to figure out MediaFormat somehow but I am not sure about the other 3 parameters. (below).

 MediaSurface, MediaCrypto and Flags. 

Any leads?

Also, what should I do with the MediaCrypto argument, if I am not encrypting my video buffers.

Requirements:

1) Decode the buffers on the android device, 
2) Display them on the screen. 
2

There are 2 best solutions below

1
On
1
On

Just for completeness:

To decode -

MediaSurface is the surface to render the frame to ( or null if not rendering )

MediaCrypto should be null if the is no encryption

flags == 0 if decoding or MediaCodec.CONFIGURE_FLAG_ENCODE if encoding