[vlc-devel] [PATCH 04/13] encoder: add a function to get the decoder device to use with the encoder

Steve Lhomme robux4 at ycbcr.xyz
Mon Dec 23 16:49:28 CET 2019


Similar to decoder_GetDecoderDevice() but for the encoder.
---
 include/vlc_codec.h         | 22 ++++++++++++++++++++++
 src/input/decoder_helpers.c | 11 +++++++++++
 src/libvlccore.sym          |  1 +
 3 files changed, 34 insertions(+)

diff --git a/include/vlc_codec.h b/include/vlc_codec.h
index 2ea6c1f8ed1..d8503a25318 100644
--- a/include/vlc_codec.h
+++ b/include/vlc_codec.h
@@ -214,6 +214,25 @@ struct decoder_cc_desc_t
  * @}
  */
 
+struct encoder_owner_callbacks
+{
+    struct
+    {
+        vlc_decoder_device *(*get_device)( encoder_t * );
+    } video;
+};
+
+/**
+ * Creates/Updates the output decoder device.
+ *
+ * \note
+ * This function is not reentrant.
+ *
+ * @return the held decoder device, NULL if none should be used
+ */
+VLC_API vlc_decoder_device *encoder_GetDecoderDevice( encoder_t * );
+
+
 /**
  * \defgroup encoder Encoder
  * \ingroup sout
@@ -247,6 +266,9 @@ struct encoder_t
 
     /* Encoder config */
     config_chain_t *p_cfg;
+
+    /* Private structure for the owner of the encoder */
+    const struct encoder_owner_callbacks *cbs;
 };
 
 /**
diff --git a/src/input/decoder_helpers.c b/src/input/decoder_helpers.c
index 3f03394eadd..c6b45c27c7a 100644
--- a/src/input/decoder_helpers.c
+++ b/src/input/decoder_helpers.c
@@ -294,3 +294,14 @@ vlc_decoder_device* vlc_video_context_HoldDevice(vlc_video_context *vctx)
         return NULL;
     return vlc_decoder_device_Hold( vctx->device );
 }
+
+
+/** encoder **/
+vlc_decoder_device *encoder_GetDecoderDevice( encoder_t *enc )
+{
+    vlc_assert( enc->fmt_in.i_cat == VIDEO_ES && enc->cbs != NULL );
+    if ( unlikely(enc->fmt_in.i_cat != VIDEO_ES || enc->cbs == NULL ) )
+        return NULL;
+
+    return enc->cbs->video.get_device( enc );
+}
\ No newline at end of file
diff --git a/src/libvlccore.sym b/src/libvlccore.sym
index 2c120349902..98b1a9f7979 100644
--- a/src/libvlccore.sym
+++ b/src/libvlccore.sym
@@ -83,6 +83,7 @@ decoder_AbortPictures
 decoder_NewAudioBuffer
 decoder_UpdateVideoFormat
 decoder_UpdateVideoOutput
+encoder_GetDecoderDevice
 vlc_decoder_device_Create
 vlc_decoder_device_Hold
 vlc_decoder_device_Release
-- 
2.17.1



More information about the vlc-devel mailing list