jni: fixed Buffer/ByteBuffer and added ByteBuffer.duplicate
jni: Add a templated helper for retrieving jobjectArrays.

This takes care of ensuring global references, and skips a copy by using
emplace_back rather than push_back.
jni: MediaCodec, remove non-standard functions