From ff840c5c525c445499baf699134f93c925cecb7d Mon Sep 17 00:00:00 2001 From: Shaya Potter Date: Mon, 7 May 2018 18:17:44 -0700 Subject: [PATCH] Playlist: add support for loading bluray by opening index.bdmv Signed-off-by: Jean-Baptiste Kempf --- modules/demux/Makefile.am | 1 + modules/demux/playlist/bdmv.c | 108 ++++++++++++++++++++++++++++++++++++++ modules/demux/playlist/playlist.c | 4 ++ modules/demux/playlist/playlist.h | 3 ++ 4 files changed, 116 insertions(+) create mode 100644 modules/demux/playlist/bdmv.c diff --git a/modules/demux/Makefile.am b/modules/demux/Makefile.am index 4df3dfcdcb..6f799e84c4 100644 --- a/modules/demux/Makefile.am +++ b/modules/demux/Makefile.am @@ -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 index 0000000000..7eb5fa25a2 --- /dev/null +++ b/modules/demux/playlist/bdmv.c @@ -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 + * + * 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 +#include +#include +#include + +#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; +} diff --git a/modules/demux/playlist/playlist.c b/modules/demux/playlist/playlist.c index f15d27c6e7..28e3453c59 100644 --- a/modules/demux/playlist/playlist.c +++ b/modules/demux/playlist/playlist.c @@ -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 ) diff --git a/modules/demux/playlist/playlist.h b/modules/demux/playlist/playlist.h index 43d0d292c5..51f3e4bcf6 100644 --- a/modules/demux/playlist/playlist.h +++ b/modules/demux/playlist/playlist.h @@ -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 * ); -- 2.11.4.GIT