1 /*****************************************************************************
2 * bdmv.c: Dummy bdmv demux - opens BluRays rips via index.bdmv
3 *****************************************************************************
4 * Copyright (C) 2018 VLC authors and VideoLAN
7 * Authors: Shaya Potter <spotter@gmail.com>
9 * This program is free software; you can redistribute it and/or modify it
10 * under the terms of the GNU Lesser General Public License as published by
11 * the Free Software Foundation; either version 2.1 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public License
20 * along with this program; if not, write to the Free Software Foundation,
21 * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22 *****************************************************************************/
24 /*****************************************************************************
26 *****************************************************************************/
31 #include <vlc_common.h>
32 #include <vlc_access.h>
38 /*****************************************************************************
40 *****************************************************************************/
41 static int ReadBR( stream_t
*, input_item_node_t
* );
43 static const char *StreamLocation( const stream_t
*s
)
45 return s
->psz_filepath
? s
->psz_filepath
: s
->psz_url
;
48 /*****************************************************************************
49 * Import_BDMV: main import function
50 *****************************************************************************/
51 int Import_BDMV( vlc_object_t
*p_this
)
53 stream_t
*p_stream
= (stream_t
*)p_this
;
57 if( !stream_HasExtension( p_stream
, ".BDMV" ) )
60 const char *psz_location
= StreamLocation( p_stream
);
61 if( psz_location
== NULL
)
64 size_t len
= strlen( psz_location
);
68 const char *psz_probe
;
69 const char *psz_file
= &psz_location
[len
- 10];
70 /* Valid filenames are :
73 if( !strncasecmp( psz_file
, "INDEX", 5 ) )
75 psz_probe
= "INDX0200";
76 p_stream
->pf_readdir
= ReadBR
;
81 const uint8_t *p_peek
;
82 ssize_t i_peek
= vlc_stream_Peek( p_stream
->s
, &p_peek
, 8 );
83 if( i_peek
< 8 || memcmp( p_peek
, psz_probe
, 8 ) )
86 p_stream
->pf_control
= access_vaDirectoryControlHelper
;
91 static int ReadBR( stream_t
*p_stream
, input_item_node_t
*node
)
93 const char *psz_loc
= StreamLocation(p_stream
);
95 // 10 character in INDEX.BDMV, 5 character in BDMV/, subtract 15
96 char *psz_url
= strndup( psz_loc
, strlen( psz_loc
) - 15 );
100 input_item_t
*p_input
= input_item_New( psz_url
, psz_url
);
101 input_item_AddOption( p_input
, "demux=bluray", VLC_INPUT_OPTION_TRUSTED
);
102 input_item_node_AppendItem( node
, p_input
);
103 input_item_Release( p_input
);