| 1 |
|
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 |
|
|---|
| 16 |
|
|---|
| 17 |
|
|---|
| 18 |
|
|---|
| 19 |
|
|---|
| 20 |
|
|---|
| 21 |
|
|---|
| 22 |
|
|---|
| 23 |
|
|---|
| 24 |
|
|---|
| 25 |
|
|---|
| 26 |
|
|---|
| 27 |
|
|---|
| 28 |
|
|---|
| 29 |
|
|---|
| 30 |
|
|---|
| 31 |
|
|---|
| 32 |
|
|---|
| 33 |
|
|---|
| 34 |
|
|---|
| 35 |
|
|---|
| 36 |
|
|---|
| 37 |
|
|---|
| 38 |
|
|---|
| 39 |
|
|---|
| 40 |
|
|---|
| 41 |
|
|---|
| 42 |
|
|---|
| 43 |
|
|---|
| 44 |
|
|---|
| 45 |
|
|---|
| 46 |
|
|---|
| 47 |
|
|---|
| 48 |
|
|---|
| 49 |
|
|---|
| 50 |
|
|---|
| 51 |
#ifdef HAVE_CONFIG_H |
|---|
| 52 |
# include "config.h" |
|---|
| 53 |
#endif |
|---|
| 54 |
|
|---|
| 55 |
#include <vlc_common.h> |
|---|
| 56 |
#include <vlc_demux.h> |
|---|
| 57 |
|
|---|
| 58 |
#include "playlist.h" |
|---|
| 59 |
#include "vlc_xml.h" |
|---|
| 60 |
|
|---|
| 61 |
struct demux_sys_t |
|---|
| 62 |
{ |
|---|
| 63 |
input_item_t *p_current_input; |
|---|
| 64 |
|
|---|
| 65 |
xml_t *p_xml; |
|---|
| 66 |
xml_reader_t *p_xml_reader; |
|---|
| 67 |
}; |
|---|
| 68 |
|
|---|
| 69 |
typedef enum { FULLSCREEN_NORMAL, |
|---|
| 70 |
FULLSCREEN_DOUBLE, |
|---|
| 71 |
FULLSCREEN_HALF, |
|---|
| 72 |
FULLSCREEN_CURRENT, |
|---|
| 73 |
FULLSCREEN_FULL } qtl_fullscreen_t; |
|---|
| 74 |
const char* ppsz_fullscreen[] = { "normal", "double", "half", "current", "full" }; |
|---|
| 75 |
typedef enum { LOOP_TRUE, |
|---|
| 76 |
LOOP_FALSE, |
|---|
| 77 |
LOOP_PALINDROME } qtl_loop_t; |
|---|
| 78 |
const char* ppsz_loop[] = { "true", "false", "palindrome" }; |
|---|
| 79 |
|
|---|
| 80 |
|
|---|
| 81 |
|
|---|
| 82 |
|
|---|
| 83 |
static int Demux( demux_t *p_demux); |
|---|
| 84 |
static int Control( demux_t *p_demux, int i_query, va_list args ); |
|---|
| 85 |
|
|---|
| 86 |
|
|---|
| 87 |
|
|---|
| 88 |
|
|---|
| 89 |
int Import_QTL( vlc_object_t *p_this ) |
|---|
| 90 |
{ |
|---|
| 91 |
DEMUX_BY_EXTENSION_MSG( ".qtl", "using QuickTime Media Link reader" ); |
|---|
| 92 |
p_demux->p_sys->p_xml = NULL; |
|---|
| 93 |
p_demux->p_sys->p_xml_reader = NULL; |
|---|
| 94 |
return VLC_SUCCESS; |
|---|
| 95 |
} |
|---|
| 96 |
|
|---|
| 97 |
|
|---|
| 98 |
|
|---|
| 99 |
|
|---|
| 100 |
void Close_QTL( vlc_object_t *p_this ) |
|---|
| 101 |
{ |
|---|
| 102 |
demux_t *p_demux = (demux_t *)p_this; |
|---|
| 103 |
demux_sys_t *p_sys = p_demux->p_sys; |
|---|
| 104 |
|
|---|
| 105 |
if( p_sys->p_xml_reader ) |
|---|
| 106 |
xml_ReaderDelete( p_sys->p_xml, p_sys->p_xml_reader ); |
|---|
| 107 |
if( p_sys->p_xml ) |
|---|
| 108 |
xml_Delete( p_sys->p_xml ); |
|---|
| 109 |
free( p_sys ); |
|---|
| 110 |
} |
|---|
| 111 |
|
|---|
| 112 |
static int Demux( demux_t *p_demux ) |
|---|
| 113 |
{ |
|---|
| 114 |
demux_sys_t *p_sys = p_demux->p_sys; |
|---|
| 115 |
xml_t *p_xml; |
|---|
| 116 |
xml_reader_t *p_xml_reader; |
|---|
| 117 |
char *psz_eltname = NULL; |
|---|
| 118 |
input_item_t *p_input; |
|---|
| 119 |
|
|---|
| 120 |
|
|---|
| 121 |
bool b_autoplay = false; |
|---|
| 122 |
bool b_controler = true; |
|---|
| 123 |
qtl_fullscreen_t fullscreen = false; |
|---|
| 124 |
char *psz_href = NULL; |
|---|
| 125 |
bool b_kioskmode = false; |
|---|
| 126 |
qtl_loop_t loop = LOOP_FALSE; |
|---|
| 127 |
int i_movieid = -1; |
|---|
| 128 |
char *psz_moviename = NULL; |
|---|
| 129 |
bool b_playeveryframe = false; |
|---|
| 130 |
char *psz_qtnext = NULL; |
|---|
| 131 |
bool b_quitwhendone = false; |
|---|
| 132 |
char *psz_src = NULL; |
|---|
| 133 |
char *psz_mimetype = NULL; |
|---|
| 134 |
int i_volume = 100; |
|---|
| 135 |
|
|---|
| 136 |
INIT_PLAYLIST_STUFF; |
|---|
| 137 |
|
|---|
| 138 |
p_sys->p_current_input = p_current_input; |
|---|
| 139 |
|
|---|
| 140 |
p_xml = p_sys->p_xml = xml_Create( p_demux ); |
|---|
| 141 |
if( !p_xml ) return -1; |
|---|
| 142 |
|
|---|
| 143 |
p_xml_reader = xml_ReaderCreate( p_xml, p_demux->s ); |
|---|
| 144 |
if( !p_xml_reader ) return -1; |
|---|
| 145 |
p_sys->p_xml_reader = p_xml_reader; |
|---|
| 146 |
|
|---|
| 147 |
|
|---|
| 148 |
if( xml_ReaderRead( p_xml_reader ) != 1 ) |
|---|
| 149 |
{ |
|---|
| 150 |
msg_Err( p_demux, "invalid file (no root node)" ); |
|---|
| 151 |
return -1; |
|---|
| 152 |
} |
|---|
| 153 |
|
|---|
| 154 |
if( xml_ReaderNodeType( p_xml_reader ) != XML_READER_STARTELEM || |
|---|
| 155 |
( psz_eltname = xml_ReaderName( p_xml_reader ) ) == NULL || |
|---|
| 156 |
strcmp( psz_eltname, "embed" ) ) |
|---|
| 157 |
{ |
|---|
| 158 |
msg_Err( p_demux, "invalid root node %i, %s", |
|---|
| 159 |
xml_ReaderNodeType( p_xml_reader ), psz_eltname ); |
|---|
| 160 |
free( psz_eltname ); |
|---|
| 161 |
|
|---|
| 162 |
|
|---|
| 163 |
msg_Dbg( p_demux, "trying to read one more node" ); |
|---|
| 164 |
xml_ReaderRead( p_xml_reader ); |
|---|
| 165 |
if( xml_ReaderNodeType( p_xml_reader ) != XML_READER_STARTELEM || |
|---|
| 166 |
( psz_eltname = xml_ReaderName( p_xml_reader ) ) == NULL || |
|---|
| 167 |
strcmp( psz_eltname, "embed" ) ) |
|---|
| 168 |
{ |
|---|
| 169 |
msg_Err( p_demux, "invalid root node %i, %s", |
|---|
| 170 |
xml_ReaderNodeType( p_xml_reader ), psz_eltname ); |
|---|
| 171 |
free( psz_eltname ); |
|---|
| 172 |
return -1; |
|---|
| 173 |
} |
|---|
| 174 |
} |
|---|
| 175 |
free( psz_eltname ); |
|---|
| 176 |
|
|---|
| 177 |
while( xml_ReaderNextAttr( p_sys->p_xml_reader ) == VLC_SUCCESS ) |
|---|
| 178 |
{ |
|---|
| 179 |
char *psz_attrname = xml_ReaderName( p_sys->p_xml_reader ); |
|---|
| 180 |
char *psz_attrvalue = xml_ReaderValue( p_sys->p_xml_reader ); |
|---|
| 181 |
|
|---|
| 182 |
if( !psz_attrname || !psz_attrvalue ) |
|---|
| 183 |
{ |
|---|
| 184 |
free( psz_attrname ); |
|---|
| 185 |
free( psz_attrvalue ); |
|---|
| 186 |
return -1; |
|---|
| 187 |
} |
|---|
| 188 |
|
|---|
| 189 |
if( !strcmp( psz_attrname, "autoplay" ) ) |
|---|
| 190 |
{ |
|---|
| 191 |
if( !strcmp( psz_attrvalue, "true" ) ) |
|---|
| 192 |
{ |
|---|
| 193 |
b_autoplay = true; |
|---|
| 194 |
} |
|---|
| 195 |
else |
|---|
| 196 |
{ |
|---|
| 197 |
b_autoplay = false; |
|---|
| 198 |
} |
|---|
| 199 |
} |
|---|
| 200 |
else if( !strcmp( psz_attrname, "controler" ) ) |
|---|
| 201 |
{ |
|---|
| 202 |
if( !strcmp( psz_attrvalue, "false" ) ) |
|---|
| 203 |
{ |
|---|
| 204 |
b_controler = false; |
|---|
| 205 |
} |
|---|
| 206 |
else |
|---|
| 207 |
{ |
|---|
| 208 |
b_controler = true; |
|---|
| 209 |
} |
|---|
| 210 |
} |
|---|
| 211 |
else if( !strcmp( psz_attrname, "fullscreen" ) ) |
|---|
| 212 |
{ |
|---|
| 213 |
if( !strcmp( psz_attrvalue, "double" ) ) |
|---|
| 214 |
{ |
|---|
| 215 |
fullscreen = FULLSCREEN_DOUBLE; |
|---|
| 216 |
} |
|---|
| 217 |
else if( !strcmp( psz_attrvalue, "half" ) ) |
|---|
| 218 |
{ |
|---|
| 219 |
fullscreen = FULLSCREEN_HALF; |
|---|
| 220 |
} |
|---|
| 221 |
else if( !strcmp( psz_attrvalue, "current" ) ) |
|---|
| 222 |
{ |
|---|
| 223 |
fullscreen = FULLSCREEN_CURRENT; |
|---|
| 224 |
} |
|---|
| 225 |
else if( !strcmp( psz_attrvalue, "full" ) ) |
|---|
| 226 |
{ |
|---|
| 227 |
fullscreen = FULLSCREEN_FULL; |
|---|
| 228 |
} |
|---|
| 229 |
else |
|---|
| 230 |
{ |
|---|
| 231 |
fullscreen = FULLSCREEN_NORMAL; |
|---|
| 232 |
} |
|---|
| 233 |
} |
|---|
| 234 |
else if( !strcmp( psz_attrname, "href" ) ) |
|---|
| 235 |
{ |
|---|
| 236 |
psz_href = psz_attrvalue; |
|---|
| 237 |
psz_attrvalue = NULL; |
|---|
| 238 |
} |
|---|
| 239 |
else if( !strcmp( psz_attrname, "kioskmode" ) ) |
|---|
| 240 |
{ |
|---|
| 241 |
if( !strcmp( psz_attrvalue, "true" ) ) |
|---|
| 242 |
{ |
|---|
| 243 |
b_kioskmode = true; |
|---|
| 244 |
} |
|---|
| 245 |
else |
|---|
| 246 |
{ |
|---|
| 247 |
b_kioskmode = false; |
|---|
| 248 |
} |
|---|
| 249 |
} |
|---|
| 250 |
else if( !strcmp( psz_attrname, "loop" ) ) |
|---|
| 251 |
{ |
|---|
| 252 |
if( !strcmp( psz_attrvalue, "true" ) ) |
|---|
| 253 |
{ |
|---|
| 254 |
loop = LOOP_TRUE; |
|---|
| 255 |
} |
|---|
| 256 |
else if( !strcmp( psz_attrvalue, "palindrome" ) ) |
|---|
| 257 |
{ |
|---|
| 258 |
loop = LOOP_PALINDROME; |
|---|
| 259 |
} |
|---|
| 260 |
else |
|---|
| 261 |
{ |
|---|
| 262 |
loop = LOOP_FALSE; |
|---|
| 263 |
} |
|---|
| 264 |
} |
|---|
| 265 |
else if( !strcmp( psz_attrname, "movieid" ) ) |
|---|
| 266 |
{ |
|---|
| 267 |
i_movieid = atoi( psz_attrvalue ); |
|---|
| 268 |
} |
|---|
| 269 |
else if( !strcmp( psz_attrname, "moviename" ) ) |
|---|
| 270 |
{ |
|---|
| 271 |
psz_moviename = psz_attrvalue; |
|---|
| 272 |
psz_attrvalue = NULL; |
|---|
| 273 |
} |
|---|
| 274 |
else if( !strcmp( psz_attrname, "playeveryframe" ) ) |
|---|
| 275 |
{ |
|---|
| 276 |
if( !strcmp( psz_attrvalue, "true" ) ) |
|---|
| 277 |
{ |
|---|
| 278 |
b_playeveryframe = true; |
|---|
| 279 |
} |
|---|
| 280 |
else |
|---|
| 281 |
{ |
|---|
| 282 |
b_playeveryframe = false; |
|---|
| 283 |
} |
|---|
| 284 |
} |
|---|
| 285 |
else if( !strcmp( psz_attrname, "qtnext" ) ) |
|---|
| 286 |
{ |
|---|
| 287 |
psz_qtnext = psz_attrvalue; |
|---|
| 288 |
psz_attrvalue = NULL; |
|---|
| 289 |
} |
|---|
| 290 |
else if( !strcmp( psz_attrname, "quitwhendone" ) ) |
|---|
| 291 |
{ |
|---|
| 292 |
if( !strcmp( psz_attrvalue, "true" ) ) |
|---|
| 293 |
{ |
|---|
| 294 |
b_quitwhendone = true; |
|---|
| 295 |
} |
|---|
| 296 |
else |
|---|
| 297 |
{ |
|---|
| 298 |
b_quitwhendone = false; |
|---|
| 299 |
} |
|---|
| 300 |
} |
|---|
| 301 |
else if( !strcmp( psz_attrname, "src" ) ) |
|---|
| 302 |
{ |
|---|
| 303 |
psz_src = psz_attrvalue; |
|---|
| 304 |
psz_attrvalue = NULL; |
|---|
| 305 |
} |
|---|
| 306 |
else if( !strcmp( psz_attrname, "mimetype" ) ) |
|---|
| 307 |
{ |
|---|
| 308 |
psz_mimetype = psz_attrvalue; |
|---|
| 309 |
psz_attrvalue = NULL; |
|---|
| 310 |
} |
|---|
| 311 |
else if( !strcmp( psz_attrname, "volume" ) ) |
|---|
| 312 |
{ |
|---|
| 313 |
i_volume = atoi( psz_attrvalue ); |
|---|
| 314 |
} |
|---|
| 315 |
else |
|---|
| 316 |
{ |
|---|
| 317 |
msg_Dbg( p_demux, "Attribute %s with value %s isn't valid", |
|---|
| 318 |
psz_attrname, psz_attrvalue ); |
|---|
| 319 |
} |
|---|
| 320 |
free( psz_attrname ); |
|---|
| 321 |
free( psz_attrvalue ); |
|---|
| 322 |
} |
|---|
| 323 |
|
|---|
| 324 |
msg_Dbg( p_demux, "autoplay: %s (unused by VLC)", |
|---|
| 325 |
b_autoplay==true ? "true": "false" ); |
|---|
| 326 |
msg_Dbg( p_demux, "controler: %s (unused by VLC)", |
|---|
| 327 |
b_controler==true?"true": "false" ); |
|---|
| 328 |
msg_Dbg( p_demux, "fullscreen: %s (unused by VLC)", |
|---|
| 329 |
ppsz_fullscreen[fullscreen] ); |
|---|
| 330 |
msg_Dbg( p_demux, "href: %s", psz_href ); |
|---|
| 331 |
msg_Dbg( p_demux, "kioskmode: %s (unused by VLC)", |
|---|
| 332 |
b_kioskmode==true?"true":"false" ); |
|---|
| 333 |
msg_Dbg( p_demux, "loop: %s (unused by VLC)", ppsz_loop[loop] ); |
|---|
| 334 |
msg_Dbg( p_demux, "movieid: %d (unused by VLC)", i_movieid ); |
|---|
| 335 |
msg_Dbg( p_demux, "moviename: %s", psz_moviename ); |
|---|
| 336 |
msg_Dbg( p_demux, "playeverframe: %s (unused by VLC)", |
|---|
| 337 |
b_playeveryframe==true?"true":"false" ); |
|---|
| 338 |
msg_Dbg( p_demux, "qtnext: %s", psz_qtnext ); |
|---|
| 339 |
msg_Dbg( p_demux, "quitwhendone: %s (unused by VLC)", |
|---|
| 340 |
b_quitwhendone==true?"true":"false" ); |
|---|
| 341 |
msg_Dbg( p_demux, "src: %s", psz_src ); |
|---|
| 342 |
msg_Dbg( p_demux, "mimetype: %s", psz_mimetype ); |
|---|
| 343 |
msg_Dbg( p_demux, "volume: %d (unused by VLC)", i_volume ); |
|---|
| 344 |
|
|---|
| 345 |
|
|---|
| 346 |
if( !psz_src ) |
|---|
| 347 |
{ |
|---|
| 348 |
msg_Err( p_demux, "Mandatory attribute 'src' not found" ); |
|---|
| 349 |
} |
|---|
| 350 |
else |
|---|
| 351 |
{ |
|---|
| 352 |
p_input = input_item_NewExt( p_demux, |
|---|
| 353 |
psz_src, psz_moviename, 0, NULL, -1 ); |
|---|
| 354 |
#define SADD_INFO( type, field ) if( field ) { input_item_AddInfo( \ |
|---|
| 355 |
p_input, "QuickTime Media Link", _(type), "%s", field ) ; } |
|---|
| 356 |
SADD_INFO( "href", psz_href ); |
|---|
| 357 |
SADD_INFO( "mime type", psz_mimetype ); |
|---|
| 358 |
input_item_AddSubItem( p_current_input, p_input ); |
|---|
| 359 |
vlc_gc_decref( p_input ); |
|---|
| 360 |
if( psz_qtnext ) |
|---|
| 361 |
{ |
|---|
| 362 |
p_input = input_item_NewExt( p_demux, |
|---|
| 363 |
psz_qtnext, NULL, 0, NULL, -1 ); |
|---|
| 364 |
input_item_AddSubItem( p_current_input, p_input ); |
|---|
| 365 |
vlc_gc_decref( p_input ); |
|---|
| 366 |
} |
|---|
| 367 |
} |
|---|
| 368 |
|
|---|
| 369 |
HANDLE_PLAY_AND_RELEASE; |
|---|
| 370 |
|
|---|
| 371 |
free( psz_href ); |
|---|
| 372 |
free( psz_moviename ); |
|---|
| 373 |
free( psz_qtnext ); |
|---|
| 374 |
free( psz_src ); |
|---|
| 375 |
free( psz_mimetype ); |
|---|
| 376 |
|
|---|
| 377 |
return 0; |
|---|
| 378 |
} |
|---|
| 379 |
|
|---|
| 380 |
static int Control( demux_t *p_demux, int i_query, va_list args ) |
|---|
| 381 |
{ |
|---|
| 382 |
VLC_UNUSED(p_demux); VLC_UNUSED(i_query); VLC_UNUSED(args); |
|---|
| 383 |
return VLC_EGENERIC; |
|---|
| 384 |
} |
|---|