[vlc-commits] codec/mediacodec: add api->set_output_surface

Thomas Guillem git at videolan.org
Tue Dec 13 17:11:05 CET 2016


vlc | branch: master | Thomas Guillem <thomas at gllm.fr> | Mon Dec 12 17:51:46 2016 +0100| [89a7c6477d2a4eb9d73b1e5fe4f4d39df200161c] | committer: Thomas Guillem

codec/mediacodec: add api->set_output_surface

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=89a7c6477d2a4eb9d73b1e5fe4f4d39df200161c
---

 modules/codec/omxil/mediacodec.h     |  4 ++++
 modules/codec/omxil/mediacodec_jni.c | 11 +++++++++++
 modules/codec/omxil/mediacodec_ndk.c | 19 +++++++++++++++++++
 3 files changed, 34 insertions(+)

diff --git a/modules/codec/omxil/mediacodec.h b/modules/codec/omxil/mediacodec.h
index 73c9073..b07faf1 100644
--- a/modules/codec/omxil/mediacodec.h
+++ b/modules/codec/omxil/mediacodec.h
@@ -146,6 +146,10 @@ struct mc_api
 
     /* i_index is the index returned by dequeue_out and should be >= 0 */
     int (*release_out)(mc_api *, int i_index, bool b_render);
+
+    /* Dynamically sets the output surface
+     * Returns 0 on success, or MC_API_ERROR */
+    int (*set_output_surface)(mc_api*, void *p_surface, void *p_jsurface);
 };
 
 #endif
diff --git a/modules/codec/omxil/mediacodec_jni.c b/modules/codec/omxil/mediacodec_jni.c
index c5e5063..2264a5c 100644
--- a/modules/codec/omxil/mediacodec_jni.c
+++ b/modules/codec/omxil/mediacodec_jni.c
@@ -930,6 +930,16 @@ static int ReleaseOutput(mc_api *api, int i_index, bool b_render)
 }
 
 /*****************************************************************************
+ * SetOutputSurface
+ *****************************************************************************/
+static int SetOutputSurface(mc_api *api, void *p_surface, void *p_jsurface)
+{
+    (void) api; (void) p_surface; (void) p_jsurface;
+
+    return MC_API_ERROR;
+}
+
+/*****************************************************************************
  * Clean
  *****************************************************************************/
 static void Clean(mc_api *api)
@@ -979,6 +989,7 @@ int MediaCodecJni_Init(mc_api *api)
     api->dequeue_out = DequeueOutput;
     api->get_out = GetOutput;
     api->release_out = ReleaseOutput;
+    api->set_output_surface = SetOutputSurface;
 
     /* Allow interlaced picture only after API 21 */
     api->b_support_interlaced = jfields.get_input_buffer
diff --git a/modules/codec/omxil/mediacodec_ndk.c b/modules/codec/omxil/mediacodec_ndk.c
index 8cfb65a..da8343f 100644
--- a/modules/codec/omxil/mediacodec_ndk.c
+++ b/modules/codec/omxil/mediacodec_ndk.c
@@ -143,6 +143,9 @@ typedef uint8_t* (*pf_AMediaCodec_getOutputBuffer)(AMediaCodec*,
 typedef media_status_t (*pf_AMediaCodec_releaseOutputBuffer)(AMediaCodec*,
         size_t idx, bool render);
 
+typedef media_status_t (*pf_AMediaCodec_setOutputSurface)(AMediaCodec*,
+        ANativeWindow *surface);
+
 typedef AMediaFormat *(*pf_AMediaFormat_new)();
 typedef media_status_t (*pf_AMediaFormat_delete)(AMediaFormat*);
 
@@ -171,6 +174,7 @@ struct syms
         pf_AMediaCodec_dequeueOutputBuffer dequeueOutputBuffer;
         pf_AMediaCodec_getOutputBuffer getOutputBuffer;
         pf_AMediaCodec_releaseOutputBuffer releaseOutputBuffer;
+        pf_AMediaCodec_setOutputSurface setOutputSurface;
     } AMediaCodec;
     struct {
         pf_AMediaFormat_new new;
@@ -204,6 +208,7 @@ static struct members members[] =
     { "AMediaCodec_dequeueOutputBuffer", OFF(dequeueOutputBuffer), true },
     { "AMediaCodec_getOutputBuffer", OFF(getOutputBuffer), true },
     { "AMediaCodec_releaseOutputBuffer", OFF(releaseOutputBuffer), true },
+    { "AMediaCodec_setOutputSurface", OFF(setOutputSurface), false },
 #undef OFF
 #define OFF(x) offsetof(struct syms, AMediaFormat.x)
     { "AMediaFormat_new", OFF(new), true },
@@ -550,6 +555,19 @@ static int ReleaseOutput(mc_api *api, int i_index, bool b_render)
         return MC_API_ERROR;
 }
 
+/*****************************************************************************
+ * SetOutputSurface
+ *****************************************************************************/
+static int SetOutputSurface(mc_api *api, void *p_surface, void *p_jsurface)
+{
+    (void) p_jsurface;
+    assert(p_surface != NULL);
+    mc_api_sys *p_sys = api->p_sys;
+
+    return syms.AMediaCodec.setOutputSurface != NULL
+        && syms.AMediaCodec.setOutputSurface(p_sys->p_codec, p_surface)
+        == AMEDIA_OK ? 0 : MC_API_ERROR;
+}
 
 /*****************************************************************************
  * Clean
@@ -597,6 +615,7 @@ int MediaCodecNdk_Init(mc_api *api)
     api->dequeue_out = DequeueOutput;
     api->get_out = GetOutput;
     api->release_out = ReleaseOutput;
+    api->set_output_surface = SetOutputSurface;
 
     api->b_support_interlaced = true;
     return 0;



More information about the vlc-commits mailing list