]> git.sesse.net Git - vlc/blobdiff - src/input/demux.c
Add a few harmless const
[vlc] / src / input / demux.c
index b014b5a6b7aa0d8ffc7ff29ad94f2340b1d01c5e..a91327cf8bf7c2ffafa78b65fdf78f6c6fc3c8e2 100644 (file)
@@ -1,7 +1,7 @@
 /*****************************************************************************
  * demux.c
  *****************************************************************************
- * Copyright (C) 1999-2004 VideoLAN
+ * Copyright (C) 1999-2004 the VideoLAN team
  * $Id$
  *
  * Author: Laurent Aimar <fenrir@via.ecp.fr>
@@ -18,7 +18,7 @@
  *
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
  *****************************************************************************/
 
 #include <stdlib.h>
 
 #include "input_internal.h"
 
+static void SkipID3Tag( demux_t * );
+
 /*****************************************************************************
  * demux2_New:
  *  if s is NULL then load a access_demux
  *****************************************************************************/
 demux_t *__demux2_New( vlc_object_t *p_obj,
-                       char *psz_access, char *psz_demux, char *psz_path,
+                       const char *psz_access, const char *psz_demux,
+                       const char *psz_path,
                        stream_t *s, es_out_t *out, vlc_bool_t b_quick )
 {
     demux_t *p_demux = vlc_object_create( p_obj, VLC_OBJECT_DEMUX );
-    char *psz_module;
+    const char *psz_module;
 
-    if( p_demux == NULL )
-    {
-        return NULL;
-    }
+    if( p_demux == NULL ) return NULL;
 
     /* Parse URL */
     p_demux->psz_access = strdup( psz_access );
@@ -57,7 +57,7 @@ demux_t *__demux2_New( vlc_object_t *p_obj,
 
     if( !b_quick )
     {
-        msg_Dbg( p_obj, "demux2_New: access='%s' demux='%s' path='%s'",
+        msg_Dbg( p_obj, "creating demux: access='%s' demux='%s' path='%s'",
                  p_demux->psz_access, p_demux->psz_demux, p_demux->psz_path );
     }
 
@@ -71,18 +71,17 @@ demux_t *__demux2_New( vlc_object_t *p_obj,
     p_demux->info.i_title  = 0;
     p_demux->info.i_seekpoint = 0;
 
-    if( s )
-        psz_module = p_demux->psz_demux;
-    else
-        psz_module = p_demux->psz_access;
+    if( s ) psz_module = p_demux->psz_demux;
+    else psz_module = p_demux->psz_access;
 
     if( s && *psz_module == '\0' && strrchr( p_demux->psz_path, '.' ) )
     {
-        /* XXX: add only file without any problem here and with strong detection.
-         *  - no .mp3, .a52, ... (aac is added as it works only by file ext anyway
-         *  - wav can't be added 'cause of a52 and dts in them as raw audio
+       /* XXX: add only file without any problem here and with strong detection.
+        *  - no .mp3, .a52, ... (aac is added as it works only by file ext
+        *     anyway
+        *  - wav can't be added 'cause of a52 and dts in them as raw audio
          */
-         static struct { char *ext; char *demux; } exttodemux[] =
+         static struct { const char *ext; const char *demux; } exttodemux[] =
          {
             { "aac",  "aac" },
             { "aiff", "aiff" },
@@ -91,7 +90,7 @@ demux_t *__demux2_New( vlc_object_t *p_obj,
             { "au",   "au" },
             { "flac", "flac" },
             { "dv",   "dv" },
-            { "m3u",  "m3u" },
+            { "m3u",  "playlist" },
             { "mkv",  "mkv" }, { "mka",  "mkv" }, { "mks",  "mkv" },
             { "mp4",  "mp4" }, { "m4a",  "mp4" }, { "mov",  "mp4" }, { "moov", "mp4" },
             { "mod",  "mod" }, { "xm",   "mod" },
@@ -99,10 +98,12 @@ demux_t *__demux2_New( vlc_object_t *p_obj,
             { "ogg",  "ogg" }, { "ogm",  "ogg" },
             { "pva",  "pva" },
             { "rm",   "rm" },
+            { "m4v",  "m4v" },
+            { "h264",  "h264" },
             { NULL,  NULL },
         };
         /* Here, we don't mind if it does not work, it must be quick */
-        static struct { char *ext; char *demux; } exttodemux_quick[] = 
+        static struct { const char *ext; const char *demux; } exttodemux_quick[] =
         {
             { "mp3", "mpga" },
             { "ogg", "ogg" },
@@ -110,7 +111,7 @@ demux_t *__demux2_New( vlc_object_t *p_obj,
             { NULL, NULL }
         };
 
-        char *psz_ext = strrchr( p_demux->psz_path, '.' ) + 1;
+        const char *psz_ext = strrchr( p_demux->psz_path, '.' ) + 1;
         int  i;
 
         if( !b_quick )
@@ -143,6 +144,11 @@ demux_t *__demux2_New( vlc_object_t *p_obj,
 
     if( s )
     {
+        /* ID3 tags will mess-up demuxer probing so we skip it here.
+         * ID3 parsers will called later on in the demuxer to access the
+         * skipped info. */
+        SkipID3Tag( p_demux );
+
         p_demux->p_module =
             module_Need( p_demux, "demux2", psz_module,
                          !strcmp( psz_module, p_demux->psz_demux ) ?
@@ -296,7 +302,7 @@ static int DStreamControl( stream_t *, int i_query, va_list );
 static int DStreamThread ( stream_t * );
 
 
-stream_t *__stream_DemuxNew( vlc_object_t *p_obj, char *psz_demux,
+stream_t *__stream_DemuxNew( vlc_object_t *p_obj, const char *psz_demux,
                              es_out_t *out )
 {
     /* We create a stream reader, and launch a thread */
@@ -311,6 +317,9 @@ stream_t *__stream_DemuxNew( vlc_object_t *p_obj, char *psz_demux,
     s->pf_peek   = DStreamPeek;
     s->pf_control= DStreamControl;
 
+    s->i_char_width = 1;
+    s->b_little_endian = VLC_FALSE;
+
     s->p_sys = malloc( sizeof( d_stream_sys_t) );
     p_sys = (d_stream_sys_t*)s->p_sys;
 
@@ -529,3 +538,37 @@ static int DStreamThread( stream_t *s )
     p_demux->b_die = VLC_TRUE;
     return VLC_SUCCESS;
 }
+
+/****************************************************************************
+ * Utility functions
+ ****************************************************************************/
+static void SkipID3Tag( demux_t *p_demux )
+{
+    uint8_t *p_peek;
+    uint8_t version, revision;
+    int i_size;
+    int b_footer;
+
+    if( !p_demux->s ) return;
+
+    /* Get 10 byte id3 header */
+    if( stream_Peek( p_demux->s, &p_peek, 10 ) < 10 ) return;
+
+    if( p_peek[0] != 'I' || p_peek[1] != 'D' || p_peek[2] != '3' ) return;
+
+    version = p_peek[3];
+    revision = p_peek[4];
+    b_footer = p_peek[5] & 0x10;
+    i_size = (p_peek[6]<<21) + (p_peek[7]<<14) + (p_peek[8]<<7) + p_peek[9];
+
+    if( b_footer ) i_size += 10;
+    i_size += 10;
+
+    /* Skip the entire tag */
+    stream_Read( p_demux->s, NULL, i_size );
+
+    msg_Dbg( p_demux, "ID3v2.%d revision %d tag found, skipping %d bytes",
+             version, revision, i_size );
+
+    return;
+}