[vlc-commits] mux: ts: add base support for standards compliance

Francois Cartegnie git at videolan.org
Tue Dec 13 14:52:55 CET 2016


vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Tue Dec 13 10:53:47 2016 +0100| [2568a24fb06b138c393e7c2508d9958dcb7222c8] | committer: Francois Cartegnie

mux: ts: add base support for standards compliance

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

 modules/demux/mpeg/ts_hotfixes.c |  1 +
 modules/mux/mpeg/tables.c        |  4 ++++
 modules/mux/mpeg/tables.h        |  7 ++++++
 modules/mux/mpeg/ts.c            | 49 ++++++++++++++++++++++++++++++++++++----
 4 files changed, 57 insertions(+), 4 deletions(-)

diff --git a/modules/demux/mpeg/ts_hotfixes.c b/modules/demux/mpeg/ts_hotfixes.c
index 036dd9f..85c6728 100644
--- a/modules/demux/mpeg/ts_hotfixes.c
+++ b/modules/demux/mpeg/ts_hotfixes.c
@@ -342,6 +342,7 @@ void MissingPATPMTFixup( demux_t *p_demux )
         }
 
         BuildPMT( GetPID(p_sys, 0)->u.p_pat->handle, VLC_OBJECT(p_demux),
+                 p_sys->standard == TS_STANDARD_ATSC ? TS_MUX_STANDARD_ATSC : TS_MUX_STANDARD_DVB,
                 p_program_pid, BuildPMTCallback,
                 0, 1,
                 i_pcr_pid,
diff --git a/modules/mux/mpeg/tables.c b/modules/mux/mpeg/tables.c
index 8514ca5..f2a574b 100644
--- a/modules/mux/mpeg/tables.c
+++ b/modules/mux/mpeg/tables.c
@@ -352,6 +352,7 @@ static inline size_t Write_AnnexA_String( uint8_t *p_dest, const char *p_src )
 }
 
 void BuildPMT( dvbpsi_t *p_dvbpsi, vlc_object_t *p_object,
+               ts_mux_standard standard,
                void *p_opaque, PEStoTSCallback pf_callback,
                int i_tsid, int i_pmt_version_number,
                int i_pcr_pid,
@@ -363,6 +364,7 @@ void BuildPMT( dvbpsi_t *p_dvbpsi, vlc_object_t *p_object,
     if( !dvbpmt )
             return;
 
+    VLC_UNUSED(standard);
     dvbpsi_sdt_t sdtpsi;
     uint8_t *pi_service_types = NULL;
     uint8_t *pi_service_cats = NULL;
@@ -461,6 +463,8 @@ void BuildPMT( dvbpsi_t *p_dvbpsi, vlc_object_t *p_object,
         }
         else if( p_stream->pes->i_codec == VLC_CODEC_EAC3 )
         {
+            /* FIXME: ATSC AC-3 audio_stream_descriptor */
+            /* FIXME: DVB AC-3 descriptor */
             uint8_t data[1] = { 0x00 };
             dvbpsi_pmt_es_descriptor_add( p_es, 0x7a, 1, data );
         }
diff --git a/modules/mux/mpeg/tables.h b/modules/mux/mpeg/tables.h
index 061ca5d..bb8166d 100644
--- a/modules/mux/mpeg/tables.h
+++ b/modules/mux/mpeg/tables.h
@@ -49,7 +49,14 @@ typedef struct
     int i_mapped_prog;
 } pes_mapped_stream_t;
 
+typedef enum ts_mux_standard
+{
+    TS_MUX_STANDARD_DVB = 0,
+    TS_MUX_STANDARD_ATSC,
+} ts_mux_standard;
+
 void BuildPMT( dvbpsi_t *p_dvbpsi, vlc_object_t *p_object,
+               ts_mux_standard,
                void *p_opaque, PEStoTSCallback pf_callback,
                int i_tsid, int i_pmt_version_number,
                int i_pcr_pid,
diff --git a/modules/mux/mpeg/ts.c b/modules/mux/mpeg/ts.c
index 59c13ce..dae86d0 100644
--- a/modules/mux/mpeg/ts.c
+++ b/modules/mux/mpeg/ts.c
@@ -90,6 +90,13 @@ static int ActiveKeyCallback    ( vlc_object_t *, char const *, vlc_value_t, vlc
 static int     Open   ( vlc_object_t * );
 static void    Close  ( vlc_object_t * );
 
+static const char *const ts_standards_list[] =
+    { "dvb", "atsc", };
+static const char *const ts_standards_list_text[] =
+    { "DVB", "ATSC", };
+
+#define STANDARD_TEXT N_("Digital TV Standard")
+
 #define VPID_TEXT N_("Video PID")
 #define VPID_LONGTEXT N_("Assign a fixed PID to the video stream. The PCR " \
   "PID will automatically be the video.")
@@ -193,6 +200,8 @@ vlc_module_begin ()
     set_capability( "sout mux", 120 )
     add_shortcut( "ts" )
 
+    add_string( SOUT_CFG_PREFIX "standard", "dvb", STANDARD_TEXT, NULL, true )
+        change_string_list( ts_standards_list, ts_standards_list_text )
     add_integer(SOUT_CFG_PREFIX "pid-video", 100, VPID_TEXT, VPID_LONGTEXT, true)
         change_integer_range( 32, 8190 )
     add_integer(SOUT_CFG_PREFIX "pid-audio", 200, APID_TEXT, APID_LONGTEXT, true)
@@ -231,6 +240,7 @@ vlc_module_end ()
  * Local data structures
  *****************************************************************************/
 static const char *const ppsz_sout_options[] = {
+    "standard",
     "pid-video", "pid-audio", "pid-spu", "pid-pmt", "tsid",
     "netid", "sdtdesc",
     "es-id-pid", "shaping", "pcr", "bmin", "bmax", "use-key-frames",
@@ -351,6 +361,7 @@ struct sout_mux_sys_t
     bool            b_data_alignment;
 
     sdt_psi_t       sdt;
+    ts_mux_standard standard;
 
     /* for TS building */
     int64_t         i_bitrate_min;
@@ -543,6 +554,11 @@ static int Open( vlc_object_t *p_this )
     }
     p_sys->p_dvbpsi->p_sys = (void *) p_mux;
 
+    char *psz_standard = var_GetString( p_mux, SOUT_CFG_PREFIX "standard" );
+    if( psz_standard && !strcmp("atsc", psz_standard) )
+        p_sys->standard = TS_MUX_STANDARD_ATSC;
+    free( psz_standard );
+
     p_sys->b_es_id_pid = var_GetBool( p_mux, SOUT_CFG_PREFIX "es-id-pid" );
 
     /*
@@ -975,8 +991,15 @@ static int AddStream( sout_mux_t *p_mux, sout_input_t *p_input )
         p_stream->pes.i_stream_id = 0xc0;
         break;
     case VLC_CODEC_A52:
-        p_stream->ts.i_stream_type = 0x81;
         p_stream->pes.i_stream_id = 0xbd;
+        if( p_sys->standard == TS_MUX_STANDARD_ATSC )
+        {
+            p_stream->ts.i_stream_type = 0x81;
+        }
+        else
+        {
+            p_stream->ts.i_stream_type = 0x06;
+        }
         break;
     case VLC_CODEC_DVD_LPCM:
         p_stream->ts.i_stream_type = 0x83;
@@ -989,9 +1012,27 @@ static int AddStream( sout_mux_t *p_mux, sout_input_t *p_input )
             break;
         }
     case VLC_CODEC_EAC3:
-    case VLC_CODEC_DTS:
-        p_stream->ts.i_stream_type = 0x06;
         p_stream->pes.i_stream_id = 0xbd;
+        if( p_sys->standard == TS_MUX_STANDARD_ATSC )
+        {
+            /* FIXME: Mandatory EAC3 audio_descriptor */
+            p_stream->ts.i_stream_type = 0x87;
+        }
+        else
+        {
+            p_stream->ts.i_stream_type = 0x06;
+        }
+        break;
+    case VLC_CODEC_DTS:
+        if( p_sys->standard == TS_MUX_STANDARD_ATSC )
+        {
+            return VLC_EGENERIC;
+        }
+        else
+        {
+            p_stream->ts.i_stream_type = 0x06;
+            p_stream->pes.i_stream_id = 0xbd;
+        }
         break;
     case VLC_CODEC_MP4A:
         /* XXX: make that configurable in some way when LOAS
@@ -1996,7 +2037,7 @@ static void GetPMT( sout_mux_t *p_mux, sout_buffer_chain_t *c )
         mappeds[i_stream].ts = &p_stream->ts;
     }
 
-    BuildPMT( p_sys->p_dvbpsi, VLC_OBJECT(p_mux),
+    BuildPMT( p_sys->p_dvbpsi, VLC_OBJECT(p_mux), p_sys->standard,
               c, (PEStoTSCallback)BufferChainAppend,
               p_sys->i_tsid, p_sys->i_pmt_version_number,
               ((sout_input_sys_t *)p_sys->p_pcr_input->p_sys)->ts.i_pid,



More information about the vlc-commits mailing list