[vlc-devel] [PATCH 12/24] [demux/dirac] Trying to make dirac demuxing work with --input-slave

davidf+nntp at woaf.net davidf+nntp at woaf.net
Thu Oct 30 12:29:41 CET 2008


From: David Flynn <davidf at rd.bbc.co.uk>


Signed-off-by: David Flynn <davidf at rd.bbc.co.uk>
---
 modules/demux/dirac.c |   34 ++++++++++++++++++++++++++++++----
 1 files changed, 30 insertions(+), 4 deletions(-)

diff --git a/modules/demux/dirac.c b/modules/demux/dirac.c
index 43634f9..9e7214f 100644
--- a/modules/demux/dirac.c
+++ b/modules/demux/dirac.c
@@ -56,6 +56,7 @@ vlc_module_end();
 struct demux_sys_t
 {
     mtime_t     i_dts;
+    mtime_t     i_offset;
     es_out_id_t *p_es;
 
     decoder_t *p_packetizer;
@@ -92,6 +93,8 @@ static int Open( vlc_object_t * p_this )
     p_demux->pf_control= Control;
     p_demux->p_sys     = p_sys = malloc( sizeof( demux_sys_t ) );
     p_sys->p_es        = NULL;
+    p_sys->i_offset    = 0;
+    p_sys->i_dts       = 0;
 
     /* Load the packetizer */
     es_format_Init( &fmt, VIDEO_ES, VLC_FOURCC( 'd','r','a','c' ) );
@@ -146,6 +149,9 @@ static int Demux( demux_t *p_demux)
                 p_sys->p_es = es_out_Add( p_demux->out, &p_sys->p_packetizer->fmt_out);
             }
 
+            p_block_out->i_dts += p_sys->i_offset;
+            p_block_out->i_pts += p_sys->i_offset;
+            p_sys->i_dts = p_block_out->i_dts;
             es_out_Control( p_demux->out, ES_OUT_SET_PCR, p_block_out->i_dts );
             es_out_Send( p_demux->out, p_sys->p_es, p_block_out );
 
@@ -160,13 +166,33 @@ static int Demux( demux_t *p_demux)
  *****************************************************************************/
 static int Control( demux_t *p_demux, int i_query, va_list args )
 {
-    /* demux_sys_t *p_sys  = p_demux->p_sys; */
-    /* FIXME calculate the bitrate */
-    if( i_query == DEMUX_SET_TIME )
-        return VLC_EGENERIC;
+    demux_sys_t *p_sys  = p_demux->p_sys;
+    if( DEMUX_SET_TIME == i_query )
+    {
+        int64_t i64 = (int64_t)va_arg( args, int64_t );
+        p_sys->i_offset = i64;
+        return VLC_SUCCESS;
+    }
+    else if( DEMUX_GET_TIME == i_query )
+    {
+        int64_t *pi64 = (int64_t*)va_arg( args, int64_t * );
+        *pi64 = p_sys->i_dts;
+        return VLC_SUCCESS;
+    }
+    else if( DEMUX_GET_FPS == i_query )
+    {
+        if( !p_sys->p_packetizer->fmt_out.video.i_frame_rate )
+            return VLC_EGENERIC;
+        double *pd = (double*)va_arg( args, double * );
+        *pd = (float) p_sys->p_packetizer->fmt_out.video.i_frame_rate
+            / p_sys->p_packetizer->fmt_out.video.i_frame_rate_base;
+        return VLC_SUCCESS;
+    }
     else
+    {
         return demux_vaControlHelper( p_demux->s,
                                        0, -1,
                                        0, 1, i_query, args );
+    }
 }
 
-- 
1.5.6.5




More information about the vlc-devel mailing list