diff options
author | Lajos Molnar <lajos@google.com> | 2015-05-02 02:23:06 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2015-05-02 02:23:11 +0000 |
commit | 4971de2a2efe448171b87471ad65e986c3608c21 (patch) | |
tree | 8070b4260c8902c56bd0dd9bca4c16e44cfb3ece /media/jni | |
parent | 039cd7ffaa28376fe00396b92dc77716bfa6e42e (diff) | |
parent | 5e02ba977ede1e38c9f206057ec3f0f1e89ba943 (diff) | |
download | frameworks_base-4971de2a2efe448171b87471ad65e986c3608c21.zip frameworks_base-4971de2a2efe448171b87471ad65e986c3608c21.tar.gz frameworks_base-4971de2a2efe448171b87471ad65e986c3608c21.tar.bz2 |
Merge "media: hook up MediaCodec.setSurface" into mnc-dev
Diffstat (limited to 'media/jni')
-rw-r--r-- | media/jni/android_media_MediaCodec.cpp | 50 | ||||
-rw-r--r-- | media/jni/android_media_MediaCodec.h | 3 |
2 files changed, 53 insertions, 0 deletions
diff --git a/media/jni/android_media_MediaCodec.cpp b/media/jni/android_media_MediaCodec.cpp index a09c5c0..f808c0d 100644 --- a/media/jni/android_media_MediaCodec.cpp +++ b/media/jni/android_media_MediaCodec.cpp @@ -254,6 +254,19 @@ status_t JMediaCodec::configure( return mCodec->configure(format, mSurfaceTextureClient, crypto, flags); } +status_t JMediaCodec::setSurface( + const sp<IGraphicBufferProducer> &bufferProducer) { + sp<Surface> client; + if (bufferProducer != NULL) { + client = new Surface(bufferProducer, true /* controlledByApp */); + } + status_t err = mCodec->setSurface(client); + if (err == OK) { + mSurfaceTextureClient = client; + } + return err; +} + status_t JMediaCodec::createInputSurface( sp<IGraphicBufferProducer>* bufferProducer) { return mCodec->createInputSurface(bufferProducer); @@ -811,6 +824,10 @@ static jint throwExceptionAsNecessary( jniThrowException(env, "java/lang/IllegalStateException", msg); return 0; + case BAD_VALUE: + jniThrowException(env, "java/lang/IllegalArgumentException", msg); + return 0; + default: if (isCryptoError(err)) { throwCryptoException(env, err, msg); @@ -883,6 +900,35 @@ static void android_media_MediaCodec_native_configure( throwExceptionAsNecessary(env, err); } +static void android_media_MediaCodec_native_setSurface( + JNIEnv *env, + jobject thiz, + jobject jsurface) { + sp<JMediaCodec> codec = getMediaCodec(env, thiz); + + if (codec == NULL) { + throwExceptionAsNecessary(env, INVALID_OPERATION); + return; + } + + sp<IGraphicBufferProducer> bufferProducer; + if (jsurface != NULL) { + sp<Surface> surface(android_view_Surface_getSurface(env, jsurface)); + if (surface != NULL) { + bufferProducer = surface->getIGraphicBufferProducer(); + } else { + jniThrowException( + env, + "java/lang/IllegalArgumentException", + "The surface has been released"); + return; + } + } + + status_t err = codec->setSurface(bufferProducer); + throwExceptionAsNecessary(env, err); +} + sp<PersistentSurface> android_media_MediaCodec_getPersistentInputSurface( JNIEnv* env, jobject object) { sp<PersistentSurface> persistentSurface; @@ -1692,6 +1738,10 @@ static JNINativeMethod gMethods[] = { "Landroid/media/MediaCrypto;I)V", (void *)android_media_MediaCodec_native_configure }, + { "native_setSurface", + "(Landroid/view/Surface;)V", + (void *)android_media_MediaCodec_native_setSurface }, + { "createInputSurface", "()Landroid/view/Surface;", (void *)android_media_MediaCodec_createInputSurface }, diff --git a/media/jni/android_media_MediaCodec.h b/media/jni/android_media_MediaCodec.h index 4721d2d..bf61f42 100644 --- a/media/jni/android_media_MediaCodec.h +++ b/media/jni/android_media_MediaCodec.h @@ -54,6 +54,9 @@ struct JMediaCodec : public AHandler { const sp<ICrypto> &crypto, int flags); + status_t setSurface( + const sp<IGraphicBufferProducer> &surface); + status_t createInputSurface(sp<IGraphicBufferProducer>* bufferProducer); status_t usePersistentInputSurface(const sp<PersistentSurface> &surface); |