[vlc-devel] [PATCH 13/38] decoder: split the decoder format update in 2 parts

Steve Lhomme robux4 at ycbcr.xyz
Tue Oct 1 13:12:36 CEST 2019


The first part is to create the decoder device.
The second part is to create the display module (or other depending on the
decoder owner).

Turn decoder_UpdateVideoFormat() is calling the two new functions.
---
 include/vlc_codec.h         | 37 +++++++++++++++++++++++++++++++++++++
 src/input/decoder_helpers.c | 19 +++++++++++++++++++
 src/libvlccore.sym          |  2 ++
 3 files changed, 58 insertions(+)

diff --git a/include/vlc_codec.h b/include/vlc_codec.h
index 28a65846d9e..e5a9232b730 100644
--- a/include/vlc_codec.h
+++ b/include/vlc_codec.h
@@ -49,6 +49,7 @@ struct decoder_owner_callbacks
     {
         struct
         {
+            vlc_decoder_device * (*get_device)( decoder_t * );
             int         (*format_update)( decoder_t * );
 
             /* cf. decoder_NewPicture, can be called from any decoder thread */
@@ -253,6 +254,42 @@ struct encoder_t
  * @{
  */
 
+/**
+ * Creates/Updates the output decoder device.
+ *
+ * This function notifies the video output pipeline of a new video output
+ * format (fmt_out.video). If there was no decoder device so far or a new
+ * decoder device is required, a new decoder device will be set up.
+ * decoder_UpdateVideoOutput() can then be used.
+ *
+ * If the format is unchanged, this function has no effects and returns zero.
+ *
+ * \param dec the decoder object
+ *
+ * \note
+ * This function is not reentrant.
+ *
+ * @return the received of the held decoder device, NULL not to get one
+ */
+VLC_API vlc_decoder_device * decoder_GetDecoderDevice( decoder_t *dec );
+
+/**
+ * Creates/Updates the rest of the video output pipeline.
+ *
+ * After a call to decoder_GetDecoderDevice() this function notifies the
+ * video output pipeline of a new video output format (fmt_out.video). If there
+ * was no video output from the decoder so far, a new decoder video output will
+ * be set up. decoder_NewPicture() can then be used to allocate picture buffers.
+ *
+ * If the format is unchanged, this function has no effects and returns zero.
+ *
+ * \note
+ * This function is not reentrant.
+ *
+ * @return 0 if the video output was set up successfully, -1 otherwise.
+ */
+VLC_API int decoder_UpdateVideoOutput( decoder_t *dec );
+
 /**
  * Updates the video output format.
  *
diff --git a/src/input/decoder_helpers.c b/src/input/decoder_helpers.c
index 6d5b0050ed7..b33506a6ff3 100644
--- a/src/input/decoder_helpers.c
+++ b/src/input/decoder_helpers.c
@@ -76,6 +76,25 @@ void decoder_Destroy( decoder_t *p_dec )
 }
 
 int decoder_UpdateVideoFormat( decoder_t *dec )
+{
+    vlc_decoder_device *dec_dev = decoder_GetDecoderDevice( dec );
+    if (dec_dev) vlc_decoder_device_Release( dec_dev );
+    return decoder_UpdateVideoOutput( dec );
+}
+
+vlc_decoder_device * decoder_GetDecoderDevice( decoder_t *dec )
+{
+    vlc_assert( dec->fmt_in.i_cat == VIDEO_ES && dec->cbs != NULL );
+    if ( unlikely(dec->fmt_in.i_cat != VIDEO_ES || dec->cbs == NULL ) )
+        return NULL;
+
+    if ( dec->cbs->video.get_device == NULL )
+        return NULL; /* TODO make it mandatory for all decoder owners */
+
+    return dec->cbs->video.get_device( dec );
+}
+
+int decoder_UpdateVideoOutput( decoder_t *dec )
 {
     vlc_assert( dec->fmt_in.i_cat == VIDEO_ES && dec->cbs != NULL );
     if ( unlikely(dec->fmt_in.i_cat != VIDEO_ES || dec->cbs == NULL ||
diff --git a/src/libvlccore.sym b/src/libvlccore.sym
index 960541512b3..3782d1711d8 100644
--- a/src/libvlccore.sym
+++ b/src/libvlccore.sym
@@ -82,6 +82,8 @@ decoder_Destroy
 decoder_AbortPictures
 decoder_NewAudioBuffer
 decoder_UpdateVideoFormat
+decoder_GetDecoderDevice
+decoder_UpdateVideoOutput
 vlc_decoder_device_Hold
 vlc_decoder_device_Release
 demux_PacketizerDestroy
-- 
2.17.1



More information about the vlc-devel mailing list