]> git.sesse.net Git - vlc/blobdiff - modules/demux/ts.c
Fix [79b485f92c454b7444ff5a2f2fd6e649aa7b8270] properly. Thanks for finding the dupli...
[vlc] / modules / demux / ts.c
index 2e8d34650269c9a2c0fa374e8551d822748e01bd..68a61c5925add1d497d47ce6c1ba17c4403da161 100644 (file)
@@ -31,6 +31,7 @@
 #endif
 
 #include <vlc/vlc.h>
+#include <vlc_plugin.h>
 
 #include <ctype.h>
 
@@ -39,7 +40,7 @@
 #include <vlc_meta.h>
 #include <vlc_epg.h>
 
-#include "iso_lang.h"
+#include <vlc_iso_lang.h>
 #include <vlc_network.h>
 #include <vlc_charset.h>
 
@@ -137,7 +138,7 @@ static void Close ( vlc_object_t * );
     "Specify the size of the buffer here and not the number of packets." )
 
 vlc_module_begin();
-    set_description( _("MPEG Transport Stream demuxer") );
+    set_description( N_("MPEG Transport Stream demuxer") );
     set_shortname ( "MPEG-TS" );
     set_category( CAT_INPUT );
     set_subcategory( SUBCAT_INPUT_DEMUX );
@@ -157,7 +158,7 @@ vlc_module_begin();
     add_integer( "ts-dump-size", 16384, NULL, DUMPSIZE_TEXT,
                  DUMPSIZE_LONGTEXT, true );
 
-    set_capability( "demux2", 10 );
+    set_capability( "demux", 10 );
     set_callbacks( Open, Close );
     add_shortcut( "ts" );
 vlc_module_end();
@@ -170,7 +171,7 @@ typedef struct
 {
     uint8_t                 i_objectTypeIndication;
     uint8_t                 i_streamType;
-    bool              b_upStream;
+    bool                    b_upStream;
     uint32_t                i_bufferSizeDB;
     uint32_t                i_maxBitrate;
     uint32_t                i_avgBitrate;
@@ -182,14 +183,14 @@ typedef struct
 
 typedef struct
 {
-    bool              b_useAccessUnitStartFlag;
-    bool              b_useAccessUnitEndFlag;
-    bool              b_useRandomAccessPointFlag;
-    bool              b_useRandomAccessUnitsOnlyFlag;
-    bool              b_usePaddingFlag;
-    bool              b_useTimeStampsFlags;
-    bool              b_useIdleFlag;
-    bool              b_durationFlag;
+    bool                    b_useAccessUnitStartFlag;
+    bool                    b_useAccessUnitEndFlag;
+    bool                    b_useRandomAccessPointFlag;
+    bool                    b_useRandomAccessUnitsOnlyFlag;
+    bool                    b_usePaddingFlag;
+    bool                    b_useTimeStampsFlags;
+    bool                    b_useIdleFlag;
+    bool                    b_durationFlag;
     uint32_t                i_timeStampResolution;
     uint32_t                i_OCRResolution;
     uint8_t                 i_timeStampLength;
@@ -211,11 +212,11 @@ typedef struct
 
 typedef struct
 {
-    bool              b_ok;
+    bool                    b_ok;
     uint16_t                i_es_id;
 
-    bool              b_streamDependenceFlag;
-    bool              b_OCRStreamFlag;
+    bool                    b_streamDependenceFlag;
+    bool                    b_OCRStreamFlag;
     uint8_t                 i_streamPriority;
 
     char                    *psz_url;
@@ -230,7 +231,7 @@ typedef struct
 
 typedef struct
 {
-    uint8_t                i_iod_label, i_iod_label_scope;
+    uint8_t                 i_iod_label, i_iod_label_scope;
 
     /* IOD */
     uint16_t                i_od_id;
@@ -290,8 +291,8 @@ typedef struct
 {
     int         i_pid;
 
-    bool  b_seen;
-    bool  b_valid;
+    bool        b_seen;
+    bool        b_valid;
     int         i_cc;   /* countinuity counter */
 
     /* PSI owner (ie PMT -> PAT, ES -> PMT */
@@ -324,16 +325,16 @@ struct demux_sys_t
     ts_pid_t    **pmt;
 
     /* */
-    bool  b_es_id_pid;
+    bool        b_es_id_pid;
     csa_t       *csa;
     int         i_csa_pkt_size;
-    bool  b_silent;
+    bool        b_silent;
 
-    bool  b_udp_out;
+    bool        b_udp_out;
     int         fd; /* udp socket */
     uint8_t     *buffer;
 
-    bool  b_dvb_control;
+    bool        b_dvb_control;
     int         i_dvb_program;
     int64_t     i_dvb_start;
     int64_t     i_dvb_length;
@@ -343,10 +344,10 @@ struct demux_sys_t
     char        *psz_file;  /* file to dump data in */
     FILE        *p_file;    /* filehandle */
     uint64_t    i_write;    /* bytes written */
-    bool  b_file_out; /* dump mode enabled */
+    bool        b_file_out; /* dump mode enabled */
 
     /* */
-    bool  b_meta;
+    bool        b_meta;
 };
 
 static int Demux    ( demux_t *p_demux );
@@ -396,8 +397,8 @@ static int Open( vlc_object_t *p_this )
 
     ts_pid_t    *pat;
     const char  *psz_mode;
-    bool   b_append;
-    bool   b_topfield = false;
+    bool         b_append;
+    bool         b_topfield = false;
 
     vlc_value_t  val;
 
@@ -911,7 +912,7 @@ static void Close( vlc_object_t *p_this )
     /* If in dump mode, then close the file */
     if( p_sys->b_file_out )
     {
-        msg_Info( p_demux ,"closing %s ("I64Fd" Kbytes dumped)",
+        msg_Info( p_demux ,"closing %s (%"PRId64" Kbytes dumped)",
                   p_sys->psz_file, p_sys->i_write / 1024 );
 
         if( p_sys->p_file != stdout )
@@ -951,10 +952,10 @@ static int DemuxFile( demux_t *p_demux )
     /* Test continuity counter */
     while( i_pos < i_data )
     {
-        ts_pid_t    *p_pid;   /* point to a PID structure */
-        bool b_payload; /* indicates a packet with payload */
-        bool b_adaptation; /* adaptation field */
-        int i_cc  = 0;        /* continuity counter */
+        ts_pid_t *p_pid;   /* point to a PID structure */
+        bool      b_payload; /* indicates a packet with payload */
+        bool      b_adaptation; /* adaptation field */
+        int       i_cc  = 0;    /* continuity counter */
 
         if( p_sys->buffer[i_pos] != 0x47 )
         {
@@ -1049,7 +1050,7 @@ static int Demux( demux_t *p_demux )
     /* We read at most 100 TS packet or until a frame is completed */
     for( i_pkt = 0; i_pkt < p_sys->i_ts_read; i_pkt++ )
     {
-        bool  b_frame = false;
+        bool         b_frame = false;
         block_t     *p_pkt;
         ts_pid_t    *p_pid;
 
@@ -1190,9 +1191,9 @@ static int DVBEventInformation( demux_t *p_demux, int64_t *pi_time, int64_t *pi_
         if( p_sys->i_dvb_start <= t && t < p_sys->i_dvb_start + p_sys->i_dvb_length )
         {
             if( pi_length )
-                *pi_length = p_sys->i_dvb_length * I64C(1000000);
+                *pi_length = p_sys->i_dvb_length * INT64_C(1000000);
             if( pi_time )
-                *pi_time   = (t - p_sys->i_dvb_start) * I64C(1000000);
+                *pi_time   = (t - p_sys->i_dvb_start) * INT64_C(1000000);
             return VLC_SUCCESS;
         }
     }
@@ -1209,7 +1210,7 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
     int i_int;
 
     if( p_sys->b_file_out )
-        return demux2_vaControlHelper( p_demux->s, 0, -1, 0, 1, i_query, args );
+        return demux_vaControlHelper( p_demux->s, 0, -1, 0, 1, i_query, args );
 
     switch( i_query )
     {
@@ -1255,7 +1256,7 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
             pi64 = (int64_t*)va_arg( args, int64_t * );
             if( p_sys->i_mux_rate > 0 )
             {
-                *pi64 = I64C(1000000) * ( stream_Size( p_demux->s ) / 50 ) /
+                *pi64 = INT64_C(1000000) * ( stream_Size( p_demux->s ) / 50 ) /
                         p_sys->i_mux_rate;
                 return VLC_SUCCESS;
             }
@@ -1778,11 +1779,11 @@ static void PCRHandle( demux_t *p_demux, ts_pid_t *pid, block_t *p_bk )
 
 static bool GatherPES( demux_t *p_demux, ts_pid_t *pid, block_t *p_bk )
 {
-    const uint8_t    *p = p_bk->p_buffer;
+    const uint8_t *p = p_bk->p_buffer;
     const bool b_unit_start = p[1]&0x40;
     const bool b_adaptation = p[3]&0x20;
     const bool b_payload    = p[3]&0x10;
-    const int        i_cc         = p[3]&0x0f;   /* continuity counter */
+    const int  i_cc         = p[3]&0x0f;   /* continuity counter */
     bool       b_discontinuity = false;/* discontinuity */
 
     /* transport_scrambling_control is ignored */
@@ -2083,9 +2084,9 @@ static iod_descriptor_t *IODNew( int i_data, uint8_t *p_data )
     iod_descriptor_t *p_iod;
     int i;
     int i_es_index;
-    uint8_t     i_flags, i_iod_tag, byte1, byte2, byte3;
+    uint8_t i_flags, i_iod_tag, byte1, byte2, byte3;
     bool  b_url;
-    int         i_iod_length;
+    int   i_iod_length;
 
     p_iod = malloc( sizeof( iod_descriptor_t ) );
     if( !p_iod ) return NULL;
@@ -3236,7 +3237,8 @@ static void PMTCallBack( demux_t *p_demux, dvbpsi_pmt_t *p_pmt )
                     pid->es->fmt.i_cat = SPU_ES;
                     pid->es->fmt.i_codec = VLC_FOURCC( 't', 'e', 'l', 'x' );
                     pid->es->fmt.i_extra = p_dr->i_length;
-                    pid->es->fmt.p_extra = malloc( p_dr->i_length );
+                    pid->es->fmt.p_extra = p_dr->i_length ?
+                        malloc( p_dr->i_length ) : NULL;
                     if( pid->es->fmt.p_extra )
                         memcpy( pid->es->fmt.p_extra, p_dr->p_data,
                                 p_dr->i_length );