]> git.sesse.net Git - vlc/blobdiff - modules/demux/playlist/ifo.c
VLCKit: Use name instead of $1 and $2 in Pre-Compile script.
[vlc] / modules / demux / playlist / ifo.c
index 9c8ab79bb919056d6dae4ee38903d7c0411ce284..54d29db9dd48790dcde3259038a19b0f0a403eec 100644 (file)
 /*****************************************************************************
  * Preamble
  *****************************************************************************/
-#include <vlc/vlc.h>
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include <vlc_common.h>
 #include <vlc_demux.h>
 
 #include "playlist.h"
  * Local prototypes
  *****************************************************************************/
 static int Demux( demux_t *p_demux);
+static int DemuxDVD_VR( demux_t *p_demux);
 static int Control( demux_t *p_demux, int i_query, va_list args );
 
 /*****************************************************************************
  * Import_IFO: main import function
  *****************************************************************************/
-int E_(Import_IFO)( vlc_object_t *p_this )
+int Import_IFO( vlc_object_t *p_this )
 {
     demux_t *p_demux = (demux_t *)p_this;
 
-    char *psz_file = p_demux->psz_path + strlen( p_demux->psz_path )
-                     - strlen( "VIDEO_TS.IFO" );
-    /* Valid filenamed are :
+    size_t len = strlen( p_demux->psz_path );
+
+    char *psz_file = p_demux->psz_path + len - strlen( "VIDEO_TS.IFO" );
+    /* Valid filenames are :
      *  - VIDEO_TS.IFO
      *  - VTS_XX_X.IFO where X are digits
      */
-    if( strlen( p_demux->psz_path ) > strlen( "VIDEO_TS.IFO" )
+    if( len > strlen( "VIDEO_TS.IFO" )
         && ( !strcasecmp( psz_file, "VIDEO_TS.IFO" )
         || (!strncasecmp( psz_file, "VTS_", 4 )
         && !strcasecmp( psz_file + strlen( "VTS_00_0" ) , ".IFO" ) ) ) )
     {
         int i_peek;
-        const byte_t *p_peek;
+        const uint8_t *p_peek;
         i_peek = stream_Peek( p_demux->s, &p_peek, 8 );
 
-        if( strncmp( p_peek, "DVDVIDEO", 8 ) )
+        if( i_peek != 8 || memcmp( p_peek, "DVDVIDEO", 8 ) )
             return VLC_EGENERIC;
+
+        p_demux->pf_demux = Demux;
+    }
+    /* Valid filename for DVD-VR is VR_MANGR.IFO */
+    else if( len >= 12 && !strcmp( &p_demux->psz_path[len-12], "VR_MANGR.IFO" ) )
+    {
+        int i_peek;
+        const uint8_t *p_peek;
+        i_peek = stream_Peek( p_demux->s, &p_peek, 8 );
+
+        if( i_peek != 8 || memcmp( p_peek, "DVD_RTR_", 8 ) )
+            return VLC_EGENERIC;
+
+        p_demux->pf_demux = DemuxDVD_VR;
     }
     else
         return VLC_EGENERIC;
 
 //    STANDARD_DEMUX_INIT_MSG( "found valid VIDEO_TS.IFO" )
     p_demux->pf_control = Control;
-    p_demux->pf_demux = Demux;
 
     return VLC_SUCCESS;
 }
@@ -73,32 +92,59 @@ int E_(Import_IFO)( vlc_object_t *p_this )
 /*****************************************************************************
  * Deactivate: frees unused data
  *****************************************************************************/
-void E_(Close_IFO)( vlc_object_t *p_this )
+void Close_IFO( vlc_object_t *p_this )
 {
+    VLC_UNUSED(p_this);
 }
 
 static int Demux( demux_t *p_demux )
 {
-    char *psz_url = NULL;
-    size_t len = 0;
-    input_item_t *p_input;
-
-    INIT_PLAYLIST_STUFF;
+    size_t len = strlen( "dvd://" ) + strlen( p_demux->psz_path )
+               - strlen( "VIDEO_TS.IFO" );
+    char *psz_url;
 
-    len = strlen( "dvd://" ) + strlen( p_demux->psz_path )
-          - strlen( "VIDEO_TS.IFO" );
-    psz_url = (char *)malloc( len+1 );
+    psz_url = malloc( len+1 );
+    if( !psz_url )
+        return 0;
     snprintf( psz_url, len+1, "dvd://%s", p_demux->psz_path );
 
-    p_input = input_ItemNewExt( p_playlist, psz_url, psz_url, 0, NULL, -1 );
-    input_ItemAddSubItem( p_current_input, p_input );
+    input_item_t *p_current_input = GetCurrentItem(p_demux);
+    input_item_t *p_input = input_item_New( p_demux, psz_url, psz_url );
+    input_item_PostSubItem( p_current_input, p_input );
+    vlc_gc_decref( p_input );
 
-    HANDLE_PLAY_AND_RELEASE;
+    vlc_gc_decref(p_current_input);
+    free( psz_url );
 
-    return -1; /* Needed for correct operation of go back */
+    return 0; /* Needed for correct operation of go back */
 }
 
+static int DemuxDVD_VR( demux_t *p_demux )
+{
+    char *psz_url = strdup( p_demux->psz_path );
+
+    if( !psz_url )
+        return 0;
+
+    size_t len = strlen( psz_url );
+
+    strncpy( psz_url + len - 12, "VR_MOVIE.VRO", 12 );
+
+    input_item_t *p_current_input = GetCurrentItem(p_demux);
+    input_item_t *p_input = input_item_New( p_demux, psz_url, psz_url );
+    input_item_PostSubItem( p_current_input, p_input );
+
+    vlc_gc_decref( p_input );
+
+    vlc_gc_decref(p_current_input);
+    free( psz_url );
+
+    return 0; /* Needed for correct operation of go back */
+}
+
+
 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;
 }