~ubuntu-branches/ubuntu/natty/vlc/natty

« back to all changes in this revision

Viewing changes to modules/demux/playlist/ifo.c

  • Committer: Bazaar Package Importer
  • Author(s): Benjamin Drung
  • Date: 2010-06-25 01:09:16 UTC
  • mfrom: (1.1.30 upstream)
  • Revision ID: james.westby@ubuntu.com-20100625010916-asxhep2mutg6g6pd
Tags: 1.1.0-1ubuntu1
* Merge from Debian unstable, remaining changes:
  - build and install the libx264 plugin
  - add Xb-Npp header to vlc package
  - Add apport hook to include more vlc dependencies in bug reports
* Drop xulrunner patches.
* Drop 502_xulrunner_191.diff.

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
 * ifo.c: Dummy ifo demux to enable opening DVDs rips by double cliking on VIDEO_TS.IFO
3
3
 *****************************************************************************
4
4
 * Copyright (C) 2007 the VideoLAN team
5
 
 * $Id: a4ede1f6d809d20d7fd1f37fc97246da9367330f $
 
5
 * $Id: 54d29db9dd48790dcde3259038a19b0f0a403eec $
6
6
 *
7
7
 * Authors: Antoine Cellerier <dionoea @t videolan d.t org>
8
8
 *
37
37
 * Local prototypes
38
38
 *****************************************************************************/
39
39
static int Demux( demux_t *p_demux);
 
40
static int DemuxDVD_VR( demux_t *p_demux);
40
41
static int Control( demux_t *p_demux, int i_query, va_list args );
41
42
 
42
43
/*****************************************************************************
46
47
{
47
48
    demux_t *p_demux = (demux_t *)p_this;
48
49
 
49
 
    char *psz_file = p_demux->psz_path + strlen( p_demux->psz_path )
50
 
                     - strlen( "VIDEO_TS.IFO" );
51
 
    /* Valid filenamed are :
 
50
    size_t len = strlen( p_demux->psz_path );
 
51
 
 
52
    char *psz_file = p_demux->psz_path + len - strlen( "VIDEO_TS.IFO" );
 
53
    /* Valid filenames are :
52
54
     *  - VIDEO_TS.IFO
53
55
     *  - VTS_XX_X.IFO where X are digits
54
56
     */
55
 
    if( strlen( p_demux->psz_path ) > strlen( "VIDEO_TS.IFO" )
 
57
    if( len > strlen( "VIDEO_TS.IFO" )
56
58
        && ( !strcasecmp( psz_file, "VIDEO_TS.IFO" )
57
59
        || (!strncasecmp( psz_file, "VTS_", 4 )
58
60
        && !strcasecmp( psz_file + strlen( "VTS_00_0" ) , ".IFO" ) ) ) )
63
65
 
64
66
        if( i_peek != 8 || memcmp( p_peek, "DVDVIDEO", 8 ) )
65
67
            return VLC_EGENERIC;
 
68
 
 
69
        p_demux->pf_demux = Demux;
 
70
    }
 
71
    /* Valid filename for DVD-VR is VR_MANGR.IFO */
 
72
    else if( len >= 12 && !strcmp( &p_demux->psz_path[len-12], "VR_MANGR.IFO" ) )
 
73
    {
 
74
        int i_peek;
 
75
        const uint8_t *p_peek;
 
76
        i_peek = stream_Peek( p_demux->s, &p_peek, 8 );
 
77
 
 
78
        if( i_peek != 8 || memcmp( p_peek, "DVD_RTR_", 8 ) )
 
79
            return VLC_EGENERIC;
 
80
 
 
81
        p_demux->pf_demux = DemuxDVD_VR;
66
82
    }
67
83
    else
68
84
        return VLC_EGENERIC;
69
85
 
70
86
//    STANDARD_DEMUX_INIT_MSG( "found valid VIDEO_TS.IFO" )
71
87
    p_demux->pf_control = Control;
72
 
    p_demux->pf_demux = Demux;
73
88
 
74
89
    return VLC_SUCCESS;
75
90
}
84
99
 
85
100
static int Demux( demux_t *p_demux )
86
101
{
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 );
 
102
    size_t len = strlen( "dvd://" ) + strlen( p_demux->psz_path )
 
103
               - strlen( "VIDEO_TS.IFO" );
 
104
    char *psz_url;
 
105
 
 
106
    psz_url = malloc( len+1 );
 
107
    if( !psz_url )
 
108
        return 0;
96
109
    snprintf( psz_url, len+1, "dvd://%s", p_demux->psz_path );
97
110
 
98
 
    p_input = input_item_New( p_demux, psz_url, psz_url );
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
 
}
 
111
    input_item_t *p_current_input = GetCurrentItem(p_demux);
 
112
    input_item_t *p_input = input_item_New( p_demux, psz_url, psz_url );
 
113
    input_item_PostSubItem( p_current_input, p_input );
 
114
    vlc_gc_decref( p_input );
 
115
 
 
116
    vlc_gc_decref(p_current_input);
 
117
    free( psz_url );
 
118
 
 
119
    return 0; /* Needed for correct operation of go back */
 
120
}
 
121
 
 
122
static int DemuxDVD_VR( demux_t *p_demux )
 
123
{
 
124
    char *psz_url = strdup( p_demux->psz_path );
 
125
 
 
126
    if( !psz_url )
 
127
        return 0;
 
128
 
 
129
    size_t len = strlen( psz_url );
 
130
 
 
131
    strncpy( psz_url + len - 12, "VR_MOVIE.VRO", 12 );
 
132
 
 
133
    input_item_t *p_current_input = GetCurrentItem(p_demux);
 
134
    input_item_t *p_input = input_item_New( p_demux, psz_url, psz_url );
 
135
    input_item_PostSubItem( p_current_input, p_input );
 
136
 
 
137
    vlc_gc_decref( p_input );
 
138
 
 
139
    vlc_gc_decref(p_current_input);
 
140
    free( psz_url );
 
141
 
 
142
    return 0; /* Needed for correct operation of go back */
 
143
}
 
144
 
106
145
 
107
146
static int Control( demux_t *p_demux, int i_query, va_list args )
108
147
{