]> git.sesse.net Git - vlc/blobdiff - modules/demux/playlist/ram.c
skins2: simplify equalizer initialization
[vlc] / modules / demux / playlist / ram.c
index 8542f0631ef2b2a3f005c4f8079f1920aa6ddb67..8c8de7184586077338f5a8b8fcae77426944b432 100644 (file)
@@ -1,24 +1,24 @@
 /*****************************************************************************
  * ram.c : RAM playlist format import
  *****************************************************************************
- * Copyright (C) 2009 the VideoLAN team
+ * Copyright (C) 2009 VLC authors and VideoLAN
  * $Id$
  *
  * Authors: Srikanth Raju <srikiraju@gmail.com>
  *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2.1 of the License, or
  * (at your option) any later version.
  *
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
  *
- * 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., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
  *****************************************************************************/
 
 /*
@@ -47,9 +47,12 @@ http://service.real.com/help/library/guides/realone/IntroGuide/HTML/htmfiles/ram
 # include "config.h"
 #endif
 
+#include <ctype.h>
+
 #include <vlc_common.h>
 #include <vlc_demux.h>
 #include <vlc_url.h>
+#include <vlc_charset.h>
 
 #include "playlist.h"
 
@@ -62,7 +65,6 @@ struct demux_sys_t
  * Local prototypes
  *****************************************************************************/
 static int Demux( demux_t *p_demux);
-static int Control( demux_t *p_demux, int i_query, va_list args );
 static void ParseClipInfo( const char * psz_clipinfo, char **ppsz_artist, char **ppsz_title,
                            char **ppsz_album, char **ppsz_genre, char **ppsz_year,
                            char **ppsz_cdnum, char **ppsz_comments );
@@ -75,11 +77,20 @@ static void ParseClipInfo( const char * psz_clipinfo, char **ppsz_artist, char *
 int Import_RAM( vlc_object_t *p_this )
 {
     demux_t *p_demux = (demux_t *)p_this;
+    const uint8_t *p_peek;
 
     if(! demux_IsPathExtension( p_demux, ".ram" ) ||
          demux_IsPathExtension( p_demux, ".rm" ) )
         return VLC_EGENERIC;
 
+    /* Many Real Media Files are misdetected */
+    if( stream_Peek( p_demux->s, &p_peek, 4 ) < 4 )
+        return VLC_EGENERIC;
+    if( !memcmp( p_peek, ".ra", 3 ) || !memcmp( p_peek, ".RMF", 4 ) )
+    {
+        return VLC_EGENERIC;
+    }
+
     STANDARD_DEMUX_INIT_MSG( "found valid RAM playlist" );
     p_demux->p_sys->psz_prefix = FindPrefix( p_demux );
 
@@ -137,7 +148,7 @@ static int ParseTime( const char *s, size_t i_strlen)
     s = SkipBlanks(s, i_strlen);
 
     val = 0;
-    while( (s < end) && isdigit(*s) )
+    while( (s < end) && isdigit((unsigned char)*s) )
     {
         int newval = val*10 + (*s - '0');
         if( newval < val )
@@ -157,7 +168,7 @@ static int ParseTime( const char *s, size_t i_strlen)
         s = SkipBlanks(s, end-s);
         result = result * 60;
         val = 0;
-        while( (s < end) && isdigit(*s) )
+        while( (s < end) && isdigit((unsigned char)*s) )
         {
             int newval = val*10 + (*s - '0');
             if( newval < val )
@@ -177,7 +188,7 @@ static int ParseTime( const char *s, size_t i_strlen)
             s = SkipBlanks(s, end-s);
             result = result * 60;
             val = 0;
-            while( (s < end) && isdigit(*s) )
+            while( (s < end) && isdigit((unsigned char)*s) )
             {
                 int newval = val*10 + (*s - '0');
                 if( newval < val )
@@ -205,7 +216,6 @@ static int Demux( demux_t *p_demux )
     char       *psz_line;
     char       *psz_artist = NULL, *psz_album = NULL, *psz_genre = NULL, *psz_year = NULL;
     char       *psz_author = NULL, *psz_title = NULL, *psz_copyright = NULL, *psz_cdnum = NULL, *psz_comments = NULL;
-    int        i_parsed_duration = 0;
     mtime_t    i_duration = -1;
     const char **ppsz_options = NULL;
     int        i_options = 0, i_start = 0, i_stop = 0;
@@ -214,6 +224,8 @@ static int Demux( demux_t *p_demux )
 
     input_item_t *p_current_input = GetCurrentItem(p_demux);
 
+    input_item_node_t *p_subitems = input_item_node_Create( p_current_input );
+
     psz_line = stream_ReadLine( p_demux->s );
     while( psz_line )
     {
@@ -280,8 +292,12 @@ static int Demux( demux_t *p_demux )
                            &psz_cdnum, &psz_comments ); /* clipinfo has various sub parameters, which is parsed by this function */
                     }
                     else if( !strcmp( psz_param, "author" ) )
+                    {
                         psz_author = decode_URI_duplicate(psz_value);
-                    else if( !strcmp( psz_param, "start" ) )
+                        EnsureUTF8( psz_author );
+                    }
+                    else if( !strcmp( psz_param, "start" )
+                            && strncmp( psz_mrl, "rtsp", 4 ) /* Our rtsp-real or our real demuxer is wrong */  )
                     {
                         i_start = ParseTime( psz_value, strlen( psz_value ) );
                         char *temp;
@@ -302,9 +318,15 @@ static int Demux( demux_t *p_demux )
                         }
                     }
                     else if( !strcmp( psz_param, "title" ) )
+                    {
                         psz_title = decode_URI_duplicate(psz_value);
+                        EnsureUTF8( psz_title );
+                    }
                     else if( !strcmp( psz_param, "copyright" ) )
+                    {
                         psz_copyright = decode_URI_duplicate(psz_value);
+                        EnsureUTF8( psz_copyright );
+                    }
                     else
                     {   /* TODO: insert option anyway? Currently ignores*/
                         /* INSERT_ELEM( ppsz_options, i_options, i_options, psz_option ); */
@@ -313,7 +335,7 @@ static int Demux( demux_t *p_demux )
             }
 
             /* Create the input item and pump in all the options into playlist item */
-            p_input = input_item_NewExt( p_demux, psz_mrl, psz_title, i_options, ppsz_options, 0, i_duration );
+            p_input = input_item_NewExt( psz_mrl, psz_title, i_options, ppsz_options, 0, i_duration );
 
             if( !EMPTY_STR( psz_artist ) ) input_item_SetArtist( p_input, psz_artist );
             if( !EMPTY_STR( psz_author ) ) input_item_SetPublisher( p_input, psz_author );
@@ -321,11 +343,11 @@ static int Demux( demux_t *p_demux )
             if( !EMPTY_STR( psz_copyright ) ) input_item_SetCopyright( p_input, psz_copyright );
             if( !EMPTY_STR( psz_album ) ) input_item_SetAlbum( p_input, psz_album );
             if( !EMPTY_STR( psz_genre ) ) input_item_SetGenre( p_input, psz_genre );
-            if( !EMPTY_STR( psz_year ) ) input_item_SetDate( p_input, psz_copyright );
+            if( !EMPTY_STR( psz_year ) ) input_item_SetDate( p_input, psz_year );
             if( !EMPTY_STR( psz_cdnum ) ) input_item_SetTrackNum( p_input, psz_cdnum );
             if( !EMPTY_STR( psz_comments ) ) input_item_SetDescription( p_input, psz_comments );
 
-            input_item_AddSubItem( p_current_input, p_input );
+            input_item_node_AppendItem( p_subitems, p_input );
             vlc_gc_decref( p_input );
             free( psz_mrl );
         }
@@ -351,29 +373,18 @@ static int Demux( demux_t *p_demux )
             FREENULL( psz_cdnum );
             FREENULL( psz_comments );
             i_options = 0;
-            i_parsed_duration = 0;
             i_duration = -1;
             i_start = 0;
             i_stop = 0;
             b_cleanup = false;
         }
     }
+    input_item_node_PostAndDelete( p_subitems );
     vlc_gc_decref(p_current_input);
     var_Destroy( p_demux, "m3u-extvlcopt" );
     return 0; /* Needed for correct operation of go back */
 }
 
-/**
- * @param p_demux: This object
- * @param i_query:
- * @param args: List of arguments
- */
-static int Control( demux_t *p_demux, int i_query, va_list args )
-{
-    VLC_UNUSED(p_demux); VLC_UNUSED(i_query); VLC_UNUSED(args);
-    return VLC_EGENERIC;
-}
-
 /**
  * Parses clipinfo parameter
  * @param psz_clipinfo: string containing the clipinfo parameter along with quotes