root/modules/demux/playlist/ifo.c
| Revision d11fd0d1e5433a5299fbf0f0150178178ebd3f83, 3.8 kB (checked in by Pierre d'Herbemont <pdherbemont@videolan.org>, 4 months ago) | |
|---|---|
| |
| Line | |
|---|---|
| 1 | /***************************************************************************** |
| 2 | * ifo.c: Dummy ifo demux to enable opening DVDs rips by double cliking on VIDEO_TS.IFO |
| 3 | ***************************************************************************** |
| 4 | * Copyright (C) 2007 the VideoLAN team |
| 5 | * $Id$ |
| 6 | * |
| 7 | * Authors: Antoine Cellerier <dionoea @t videolan d.t org> |
| 8 | * |
| 9 | * This program is free software; you can redistribute it and/or modify |
| 10 | * it under the terms of the GNU General Public License as published by |
| 11 | * the Free Software Foundation; either version 2 of the License, or |
| 12 | * (at your option) any later version. |
| 13 | * |
| 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 General Public License for more details. |
| 18 | * |
| 19 | * You should have received a copy of the GNU General Public License |
| 20 | * along with this program; if not, write to the Free Software |
| 21 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. |
| 22 | *****************************************************************************/ |
| 23 | |
| 24 | /***************************************************************************** |
| 25 | * Preamble |
| 26 | *****************************************************************************/ |
| 27 | #ifdef HAVE_CONFIG_H |
| 28 | # include "config.h" |
| 29 | #endif |
| 30 | |
| 31 | #include <vlc_common.h> |
| 32 | #include <vlc_demux.h> |
| 33 | |
| 34 | #include "playlist.h" |
| 35 | |
| 36 | /***************************************************************************** |
| 37 | * Local prototypes |
| 38 | *****************************************************************************/ |
| 39 | static int Demux( demux_t *p_demux); |
| 40 | static int Control( demux_t *p_demux, int i_query, va_list args ); |
| 41 | |
| 42 | /***************************************************************************** |
| 43 | * Import_IFO: main import function |
| 44 | *****************************************************************************/ |
| 45 | int Import_IFO( vlc_object_t *p_this ) |
| 46 | { |
| 47 | demux_t *p_demux = (demux_t *)p_this; |
| 48 | |
| 49 | char *psz_file = p_demux->psz_path + strlen( p_demux->psz_path ) |
| 50 | - strlen( "VIDEO_TS.IFO" ); |
| 51 | /* Valid filenamed are : |
| 52 | * - VIDEO_TS.IFO |
| 53 | * - VTS_XX_X.IFO where X are digits |
| 54 | */ |
| 55 | if( strlen( p_demux->psz_path ) > strlen( "VIDEO_TS.IFO" ) |
| 56 | && ( !strcasecmp( psz_file, "VIDEO_TS.IFO" ) |
| 57 | || (!strncasecmp( psz_file, "VTS_", 4 ) |
| 58 | && !strcasecmp( psz_file + strlen( "VTS_00_0" ) , ".IFO" ) ) ) ) |
| 59 | { |
| 60 | int i_peek; |
| 61 | const uint8_t *p_peek; |
| 62 | i_peek = stream_Peek( p_demux->s, &p_peek, 8 ); |
| 63 | |
| 64 | if( i_peek != 8 || memcmp( p_peek, "DVDVIDEO", 8 ) ) |
| 65 | return VLC_EGENERIC; |
| 66 | } |
| 67 | else |
| 68 | return VLC_EGENERIC; |
| 69 | |
| 70 | // STANDARD_DEMUX_INIT_MSG( "found valid VIDEO_TS.IFO" ) |
| 71 | p_demux->pf_control = Control; |
| 72 | p_demux->pf_demux = Demux; |
| 73 | |
| 74 | return VLC_SUCCESS; |
| 75 | } |
| 76 | |
| 77 | /***************************************************************************** |
| 78 | * Deactivate: frees unused data |
| 79 | *****************************************************************************/ |
| 80 | void Close_IFO( vlc_object_t *p_this ) |
| 81 | { |
| 82 | VLC_UNUSED(p_this); |
| 83 | } |
| 84 | |
| 85 | static int Demux( demux_t *p_demux ) |
| 86 | { |
| 87 | char *psz_url = NULL; |
| 88 | size_t len = 0; |
| 89 | input_item_t *p_input; |
| 90 | |
| 91 | INIT_PLAYLIST_STUFF; |
| 92 | |
| 93 | len = strlen( "dvd://" ) + strlen( p_demux->psz_path ) |
| 94 | - strlen( "VIDEO_TS.IFO" ); |
| 95 | psz_url = (char *)malloc( len+1 ); |
| 96 | snprintf( psz_url, len+1, "dvd://%s", p_demux->psz_path ); |
| 97 | |
| 98 | p_input = input_item_NewExt( p_demux, psz_url, psz_url, 0, NULL, -1 ); |
| 99 | input_item_AddSubItem( p_current_input, p_input ); |
| 100 | vlc_gc_decref( p_input ); |
| 101 | |
| 102 | HANDLE_PLAY_AND_RELEASE; |
| 103 | |
| 104 | return 0; /* Needed for correct operation of go back */ |
| 105 | } |
| 106 | |
| 107 | static int Control( demux_t *p_demux, int i_query, va_list args ) |
| 108 | { |
| 109 | VLC_UNUSED(p_demux); VLC_UNUSED(i_query); VLC_UNUSED(args); |
| 110 | return VLC_EGENERIC; |
| 111 | } |
Note: See TracBrowser for help on using the browser.
