Playlist: add support for loading bluray by opening index.bdmv
authorShaya Potter <spotter@gmail.com>
Tue, 8 May 2018 01:17:44 +0000 (18:17 -0700)
committerJean-Baptiste Kempf <jb@videolan.org>
Thu, 17 May 2018 22:24:13 +0000 (00:24 +0200)
Signed-off-by: Jean-Baptiste Kempf <jb@videolan.org>
modules/demux/Makefile.am
modules/demux/playlist/bdmv.c [new file with mode: 0644]
modules/demux/playlist/playlist.c
modules/demux/playlist/playlist.h

index 4df3dfc..6f799e8 100644 (file)
@@ -221,6 +221,7 @@ demux_LTLIBRARIES += libmpgv_plugin.la
 libplaylist_plugin_la_SOURCES = \
        demux/playlist/asx.c \
        demux/playlist/b4s.c \
+       demux/playlist/bdmv.c \
        demux/playlist/dvb.c \
        demux/playlist/ifo.c \
        demux/playlist/itml.c \
diff --git a/modules/demux/playlist/bdmv.c b/modules/demux/playlist/bdmv.c
new file mode 100644 (file)
index 0000000..7eb5fa2
--- /dev/null
@@ -0,0 +1,108 @@
+/*****************************************************************************
+ * bdmv.c: Dummy bdmv demux - opens BluRays rips via index.bdmv
+ *****************************************************************************
+ * Copyright (C) 2018 VLC authors and VideoLAN
+ * $Id$
+ *
+ * Authors: Shaya Potter <spotter@gmail.com>
+ *
+ * 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 Lesser General Public License for more details.
+ *
+ * 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.
+ *****************************************************************************/
+
+/*****************************************************************************
+ * Preamble
+ *****************************************************************************/
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include <vlc_common.h>
+#include <vlc_access.h>
+#include <vlc_url.h>
+#include <assert.h>
+
+#include "playlist.h"
+
+/*****************************************************************************
+ * Local prototypes
+ *****************************************************************************/
+static int ReadBR( stream_t *, input_item_node_t * );
+
+static const char *StreamLocation( const stream_t *s )
+{
+    return s->psz_filepath ? s->psz_filepath : s->psz_url;
+}
+
+/*****************************************************************************
+ * Import_BDMV: main import function
+ *****************************************************************************/
+int Import_BDMV( vlc_object_t *p_this )
+{
+    stream_t *p_stream = (stream_t *)p_this;
+
+    CHECK_FILE(p_stream);
+
+    if( !stream_HasExtension( p_stream, ".BDMV" ) )
+        return VLC_EGENERIC;
+
+    const char *psz_location = StreamLocation( p_stream );
+    if( psz_location == NULL )
+        return VLC_EGENERIC;
+
+    size_t len = strlen( psz_location );
+    if( len < 15 )
+        return VLC_EGENERIC;
+
+    const char *psz_probe;
+    const char *psz_file = &psz_location[len - 10];
+    /* Valid filenames are :
+     *  - INDEX.BDMV
+     */
+    if( !strncasecmp( psz_file, "INDEX", 5 ) )
+    {
+        psz_probe = "INDX0200";
+        p_stream->pf_readdir = ReadBR;
+    }
+    else
+        return VLC_EGENERIC;
+
+    const uint8_t *p_peek;
+    ssize_t i_peek = vlc_stream_Peek( p_stream->s, &p_peek, 8 );
+    if( i_peek < 8 || memcmp( p_peek, psz_probe, 8 ) )
+        return VLC_EGENERIC;
+
+    p_stream->pf_control = access_vaDirectoryControlHelper;
+
+    return VLC_SUCCESS;
+}
+
+static int ReadBR( stream_t *p_stream, input_item_node_t *node )
+{
+    const char *psz_loc = StreamLocation(p_stream);
+
+    // 10 character in INDEX.BDMV, 5 character in BDMV/, subtract 15
+    char *psz_url = strndup( psz_loc, strlen( psz_loc) - 15 );
+    if( !psz_url )
+        return VLC_ENOMEM;
+
+    input_item_t *p_input = input_item_New( psz_url, psz_url );
+    input_item_AddOption( p_input, "demux=bluray", VLC_INPUT_OPTION_TRUSTED );
+    input_item_node_AppendItem( node, p_input );
+    input_item_Release( p_input );
+
+    free( psz_url );
+
+    return VLC_SUCCESS;
+}
index f15d27c..28e3453 100644 (file)
@@ -114,6 +114,10 @@ vlc_module_begin ()
         set_capability( "stream_filter", 312 )
         set_callbacks( Import_IFO, NULL )
     add_submodule ()
+       set_description( N_("Dummy BDMV demux") )
+       set_capability( "stream_filter", 312 )
+       set_callbacks( Import_BDMV, NULL )
+    add_submodule ()
         set_description( N_("iTunes Music Library importer") )
         add_shortcut( "itml" )
         set_capability( "stream_filter", 310 )
index 43d0d29..51f3e4b 100644 (file)
@@ -52,6 +52,9 @@ int Import_QTL ( vlc_object_t * );
 int Import_IFO ( vlc_object_t * );
 void Close_IFO ( vlc_object_t * );
 
+int Import_BDMV ( vlc_object_t * );
+void Close_BDMV ( vlc_object_t * );
+
 int Import_iTML ( vlc_object_t * );
 
 int Import_WPL ( vlc_object_t * );