[vlc-commits] demux: add some controls to demux_vaControlHelper()

Rémi Denis-Courmont git at videolan.org
Tue Oct 20 19:52:35 CEST 2015


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Tue Oct 20 19:50:44 2015 +0300| [567822715f7dab6925fd17e7be7abd954cc18154] | committer: Rémi Denis-Courmont

demux: add some controls to demux_vaControlHelper()

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

 src/input/demux.c |   41 +++++++++++++++++++++++++++++++++++------
 1 file changed, 35 insertions(+), 6 deletions(-)

diff --git a/src/input/demux.c b/src/input/demux.c
index 189bdca..a8a07de 100644
--- a/src/input/demux.c
+++ b/src/input/demux.c
@@ -25,6 +25,8 @@
 # include "config.h"
 #endif
 
+#include <assert.h>
+
 #include "demux.h"
 #include <libvlc.h>
 #include <vlc_codec.h>
@@ -257,6 +259,9 @@ void demux_Delete( demux_t *p_demux )
         stream_Delete( s );
 }
 
+#define static_control_match(foo) \
+    static_assert((unsigned) DEMUX_##foo == STREAM_##foo, "Mismatch")
+
 /*****************************************************************************
  * demux_vaControlHelper:
  *****************************************************************************/
@@ -274,8 +279,33 @@ int demux_vaControlHelper( stream_t *s,
     if( i_align <= 0 ) i_align = 1;
     i_tell = stream_Tell( s );
 
+    static_control_match(CAN_PAUSE);
+    static_control_match(CAN_CONTROL_PACE);
+    static_control_match(GET_PTS_DELAY);
+    static_control_match(GET_META);
+    static_control_match(GET_SIGNAL);
+    static_control_match(SET_PAUSE_STATE);
+
     switch( i_query )
     {
+        case DEMUX_CAN_SEEK:
+        {
+            bool *b = va_arg( args, bool * );
+
+            if( (i_bitrate <= 0 && i_start >= i_end)
+             || stream_Control( s, STREAM_CAN_SEEK, b ) )
+                *b = false;
+            break;
+        }
+
+        case DEMUX_CAN_PAUSE:
+        case DEMUX_CAN_CONTROL_PACE:
+        case DEMUX_GET_PTS_DELAY:
+        case DEMUX_GET_META:
+        case DEMUX_GET_SIGNAL:
+        case DEMUX_SET_PAUSE_STATE:
+            return stream_vaControl( s, i_query, args );
+
         case DEMUX_GET_LENGTH:
             pi64 = (int64_t*)va_arg( args, int64_t * );
             if( i_bitrate > 0 && i_end > i_start )
@@ -332,14 +362,10 @@ int demux_vaControlHelper( stream_t *s,
             }
             return VLC_EGENERIC;
 
-        case DEMUX_GET_META:
-            return stream_vaControl( s, STREAM_GET_META, args );
-
         case DEMUX_IS_PLAYLIST:
             *va_arg( args, bool * ) = false;
             return VLC_SUCCESS;
 
-        case DEMUX_GET_PTS_DELAY:
         case DEMUX_GET_FPS:
         case DEMUX_HAS_UNSUPPORTED_META:
         case DEMUX_SET_NEXT_DEMUX_TIME:
@@ -348,14 +374,17 @@ int demux_vaControlHelper( stream_t *s,
         case DEMUX_SET_ES:
         case DEMUX_GET_ATTACHMENTS:
         case DEMUX_CAN_RECORD:
-        case DEMUX_SET_RECORD_STATE:
-        case DEMUX_GET_SIGNAL:
             return VLC_EGENERIC;
 
+        case DEMUX_SET_TITLE:
+        case DEMUX_SET_SEEKPOINT:
+        case DEMUX_SET_RECORD_STATE:
+            assert(0);
         default:
             msg_Err( s, "unknown query in demux_vaControlDefault" );
             return VLC_EGENERIC;
     }
+    return VLC_SUCCESS;
 }
 
 /****************************************************************************



More information about the vlc-commits mailing list