[vlc-commits] TS mux: simplify unsupported codec path

Rafaël Carré git at videolan.org
Fri Feb 10 08:26:38 CET 2012


vlc | branch: master | Rafaël Carré <funman at videolan.org> | Thu Feb  9 22:08:24 2012 -0500| [9229335a2a7de53d56b434f953be8ce2adfe4912] | committer: Rafaël Carré

TS mux: simplify unsupported codec path

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

 modules/mux/mpeg/ts.c |  199 +++++++++++++++++++++++--------------------------
 1 files changed, 92 insertions(+), 107 deletions(-)

diff --git a/modules/mux/mpeg/ts.c b/modules/mux/mpeg/ts.c
index 0170fcd..a42c892 100644
--- a/modules/mux/mpeg/ts.c
+++ b/modules/mux/mpeg/ts.c
@@ -925,120 +925,105 @@ static int AddStream( sout_mux_t *p_mux, sout_input_t *p_input )
     msg_Dbg( p_mux, "adding input codec=%4.4s pid=%d",
              (char*)&p_stream->i_codec, p_stream->i_pid );
 
-    switch( p_input->p_fmt->i_cat )
+    p_stream->i_stream_type = -1;
+    switch( p_input->p_fmt->i_codec )
     {
-    case VIDEO_ES:
-        switch( p_input->p_fmt->i_codec )
-        {
-        case VLC_CODEC_MPGV:
-            /* TODO: do we need to check MPEG-I/II ? */
-            p_stream->i_stream_type = 0x02;
-            p_stream->i_stream_id = 0xe0;
-            break;
-        case VLC_CODEC_MP4V:
-            p_stream->i_stream_type = 0x10;
-            p_stream->i_stream_id = 0xe0;
-            p_stream->i_es_id = p_stream->i_pid;
-            break;
-        case VLC_CODEC_H264:
-            p_stream->i_stream_type = 0x1b;
-            p_stream->i_stream_id = 0xe0;
-            break;
-        /* XXX dirty dirty but somebody want crapy MS-codec XXX */
-        case VLC_CODEC_H263I:
-        case VLC_CODEC_H263:
-        case VLC_CODEC_WMV3:
-        case VLC_CODEC_WMV2:
-        case VLC_CODEC_WMV1:
-        case VLC_CODEC_DIV3:
-        case VLC_CODEC_DIV2:
-        case VLC_CODEC_DIV1:
-        case VLC_CODEC_MJPG:
-            p_stream->i_stream_type = 0xa0; /* private */
-            p_stream->i_stream_id = 0xa0;   /* beurk */
-            p_stream->i_bih_codec  = p_input->p_fmt->i_codec;
-            p_stream->i_bih_width  = p_input->p_fmt->video.i_width;
-            p_stream->i_bih_height = p_input->p_fmt->video.i_height;
-            break;
-        case VLC_CODEC_DIRAC:
-            /* stream_id makes use of stream_id_extension */
-            p_stream->i_stream_id = (PES_EXTENDED_STREAM_ID << 8) | 0x60;
-            p_stream->i_stream_type = 0xd1;
-            break;
-        default:
-            free( p_stream );
-            return VLC_EGENERIC;
-        }
+    /* VIDEO */
+
+    case VLC_CODEC_MPGV:
+        /* TODO: do we need to check MPEG-I/II ? */
+        p_stream->i_stream_type = 0x02;
+        p_stream->i_stream_id = 0xe0;
+        break;
+    case VLC_CODEC_MP4V:
+        p_stream->i_stream_type = 0x10;
+        p_stream->i_stream_id = 0xe0;
+        p_stream->i_es_id = p_stream->i_pid;
+        break;
+    case VLC_CODEC_H264:
+        p_stream->i_stream_type = 0x1b;
+        p_stream->i_stream_id = 0xe0;
+        break;
+    /* XXX dirty dirty but somebody want crapy MS-codec XXX */
+    case VLC_CODEC_H263I:
+    case VLC_CODEC_H263:
+    case VLC_CODEC_WMV3:
+    case VLC_CODEC_WMV2:
+    case VLC_CODEC_WMV1:
+    case VLC_CODEC_DIV3:
+    case VLC_CODEC_DIV2:
+    case VLC_CODEC_DIV1:
+    case VLC_CODEC_MJPG:
+        p_stream->i_stream_type = 0xa0; /* private */
+        p_stream->i_stream_id = 0xa0;   /* beurk */
+        p_stream->i_bih_codec  = p_input->p_fmt->i_codec;
+        p_stream->i_bih_width  = p_input->p_fmt->video.i_width;
+        p_stream->i_bih_height = p_input->p_fmt->video.i_height;
+        break;
+    case VLC_CODEC_DIRAC:
+        /* stream_id makes use of stream_id_extension */
+        p_stream->i_stream_id = (PES_EXTENDED_STREAM_ID << 8) | 0x60;
+        p_stream->i_stream_type = 0xd1;
         break;
 
-    case AUDIO_ES:
-        switch( p_input->p_fmt->i_codec )
-        {
-        case VLC_CODEC_MPGA:
-            p_stream->i_stream_type =
-                p_input->p_fmt->audio.i_rate >= 32000 ? 0x03 : 0x04;
-            p_stream->i_stream_id = 0xc0;
-            break;
-        case VLC_CODEC_A52:
-            p_stream->i_stream_type = 0x81;
-            p_stream->i_stream_id = 0xbd;
-            break;
-        case VLC_CODEC_EAC3:
-            p_stream->i_stream_type = 0x06;
-            p_stream->i_stream_id = 0xbd;
-            break;
-        case VLC_CODEC_DVD_LPCM:
-            p_stream->i_stream_type = 0x83;
-            p_stream->i_stream_id = 0xbd;
-            break;
-        case VLC_CODEC_DTS:
-            p_stream->i_stream_type = 0x06;
-            p_stream->i_stream_id = 0xbd;
-            break;
-        case VLC_CODEC_MP4A:
-            /* XXX: make that configurable in some way when LOAS
-             * is implemented for AAC in TS */
-            //p_stream->i_stream_type = 0x11; /* LOAS/LATM */
-            p_stream->i_stream_type = 0x0f; /* ADTS */
-            p_stream->i_stream_id = 0xc0;
-            p_sys->i_mpeg4_streams++;
-            p_stream->i_es_id = p_stream->i_pid;
-            break;
-        default:
-            free( p_stream );
-            return VLC_EGENERIC;
-        }
+    /* AUDIO */
+
+    case VLC_CODEC_MPGA:
+        p_stream->i_stream_type =
+            p_input->p_fmt->audio.i_rate >= 32000 ? 0x03 : 0x04;
+        p_stream->i_stream_id = 0xc0;
+        break;
+    case VLC_CODEC_A52:
+        p_stream->i_stream_type = 0x81;
+        p_stream->i_stream_id = 0xbd;
+        break;
+    case VLC_CODEC_EAC3:
+        p_stream->i_stream_type = 0x06;
+        p_stream->i_stream_id = 0xbd;
+        break;
+    case VLC_CODEC_DVD_LPCM:
+        p_stream->i_stream_type = 0x83;
+        p_stream->i_stream_id = 0xbd;
+        break;
+    case VLC_CODEC_DTS:
+        p_stream->i_stream_type = 0x06;
+        p_stream->i_stream_id = 0xbd;
+        break;
+    case VLC_CODEC_MP4A:
+        /* XXX: make that configurable in some way when LOAS
+         * is implemented for AAC in TS */
+        //p_stream->i_stream_type = 0x11; /* LOAS/LATM */
+        p_stream->i_stream_type = 0x0f; /* ADTS */
+        p_stream->i_stream_id = 0xc0;
+        p_sys->i_mpeg4_streams++;
+        p_stream->i_es_id = p_stream->i_pid;
         break;
 
-    case SPU_ES:
-        switch( p_input->p_fmt->i_codec )
-        {
-        case VLC_CODEC_SPU:
-            p_stream->i_stream_type = 0x82;
-            p_stream->i_stream_id = 0xbd;
-            break;
-        case VLC_CODEC_SUBT:
-            p_stream->i_stream_type = 0x12;
-            p_stream->i_stream_id = 0xfa;
-            p_sys->i_mpeg4_streams++;
-            p_stream->i_es_id = p_stream->i_pid;
-            break;
-        case VLC_CODEC_DVBS:
-            p_stream->i_stream_type = 0x06;
-            p_stream->i_es_id = p_input->p_fmt->subs.dvb.i_id;
-            p_stream->i_stream_id = 0xbd;
-            break;
-        case VLC_CODEC_TELETEXT:
-            p_stream->i_stream_type = 0x06;
-            p_stream->i_stream_id = 0xbd; /* FIXME */
-            break;
-        default:
-            free( p_stream );
-            return VLC_EGENERIC;
-        }
+    /* TEXT */
+
+    case VLC_CODEC_SPU:
+        p_stream->i_stream_type = 0x82;
+        p_stream->i_stream_id = 0xbd;
         break;
+    case VLC_CODEC_SUBT:
+        p_stream->i_stream_type = 0x12;
+        p_stream->i_stream_id = 0xfa;
+        p_sys->i_mpeg4_streams++;
+        p_stream->i_es_id = p_stream->i_pid;
+        break;
+    case VLC_CODEC_DVBS:
+        p_stream->i_stream_type = 0x06;
+        p_stream->i_es_id = p_input->p_fmt->subs.dvb.i_id;
+        p_stream->i_stream_id = 0xbd;
+        break;
+    case VLC_CODEC_TELETEXT:
+        p_stream->i_stream_type = 0x06;
+        p_stream->i_stream_id = 0xbd; /* FIXME */
+        break;
+    }
 
-    default:
+    if (p_stream->i_stream_type == -1)
+    {
         free( p_stream );
         return VLC_EGENERIC;
     }



More information about the vlc-commits mailing list