Changeset 8ad05151abe4cefca9e61318d2f21c9a8d382923
- Timestamp:
- 06/14/08 18:11:20
(3 months ago)
- Author:
- Pierre d'Herbemont <pdherbemont@videolan.org>
- git-committer:
- Pierre d'Herbemont <pdherbemont@videolan.org> 1213459880 +0200
- git-parent:
[bcab891bb6cfa062ed460c45dd0b8903de0419b0]
- git-author:
- Pierre d'Herbemont <pdherbemont@videolan.org> 1213459880 +0200
- Message:
mp4: Don't use playlist code.
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| r3561b9b |
r8ad0515 |
|
| 34 | 34 | |
|---|
| 35 | 35 | #include <vlc_demux.h> |
|---|
| 36 | | #include <vlc_playlist.h> |
|---|
| 37 | 36 | #include <vlc_md5.h> |
|---|
| 38 | 37 | #include <vlc_charset.h> |
|---|
| 39 | 38 | #include <vlc_iso_lang.h> |
|---|
| 40 | 39 | #include <vlc_meta.h> |
|---|
| | 40 | #include <vlc_input.h> |
|---|
| 41 | 41 | |
|---|
| 42 | 42 | #include "libmp4.h" |
|---|
| … | … | |
| 65 | 65 | *****************************************************************************/ |
|---|
| 66 | 66 | static int Demux ( demux_t * ); |
|---|
| 67 | | static int DemuxRef( demux_t *p_demux ){ return 0;} |
|---|
| | 67 | static int DemuxRef( demux_t *p_demux ){ (void)p_demux; return 0;} |
|---|
| 68 | 68 | static int Seek ( demux_t *, mtime_t ); |
|---|
| 69 | 69 | static int Control ( demux_t *, int, va_list ); |
|---|
| … | … | |
| 257 | 257 | return INT64_C(1000000) * p_sys->i_time / p_sys->i_timescale; |
|---|
| 258 | 258 | } |
|---|
| 259 | | |
|---|
| 260 | | /* Function to lookup the currently playing item */ |
|---|
| 261 | | static bool FindItem( demux_t *p_demux, playlist_t *p_playlist, |
|---|
| 262 | | playlist_item_t **pp_item ); |
|---|
| 263 | 259 | |
|---|
| 264 | 260 | static void LoadChapter( demux_t *p_demux ); |
|---|
| … | … | |
| 364 | 360 | if( ( p_rmra = MP4_BoxGet( p_sys->p_root, "/moov/rmra" ) ) ) |
|---|
| 365 | 361 | { |
|---|
| 366 | | playlist_t *p_playlist; |
|---|
| 367 | | playlist_item_t *p_current, *p_item_in_category; |
|---|
| 368 | 362 | int i_count = MP4_BoxCount( p_rmra, "rmda" ); |
|---|
| 369 | 363 | int i; |
|---|
| … | … | |
| 372 | 366 | msg_Dbg( p_demux, "detected playlist mov file (%d ref)", i_count ); |
|---|
| 373 | 367 | |
|---|
| 374 | | p_playlist = pl_Yield( p_demux ); |
|---|
| 375 | | if( p_playlist ) |
|---|
| 376 | | { |
|---|
| 377 | | b_play = FindItem( p_demux, p_playlist, &p_current ); |
|---|
| 378 | | p_item_in_category = playlist_ItemToNode( p_playlist, p_current, true ); |
|---|
| 379 | | p_current->p_input->i_type = ITEM_TYPE_PLAYLIST; |
|---|
| 380 | | |
|---|
| 381 | | for( i = 0; i < i_count; i++ ) |
|---|
| 382 | | { |
|---|
| 383 | | MP4_Box_t *p_rdrf = MP4_BoxGet( p_rmra, "rmda[%d]/rdrf", i ); |
|---|
| 384 | | char *psz_ref; |
|---|
| 385 | | uint32_t i_ref_type; |
|---|
| 386 | | |
|---|
| 387 | | if( !p_rdrf || !( psz_ref = strdup( p_rdrf->data.p_rdrf->psz_ref ) ) ) |
|---|
| | 368 | input_thread_t * p_input = vlc_object_find( p_demux, VLC_OBJECT_INPUT, FIND_PARENT ); |
|---|
| | 369 | input_item_t * p_current = input_GetItem( p_input ); |
|---|
| | 370 | p_current->i_type = ITEM_TYPE_PLAYLIST; |
|---|
| | 371 | |
|---|
| | 372 | for( i = 0; i < i_count; i++ ) |
|---|
| | 373 | { |
|---|
| | 374 | MP4_Box_t *p_rdrf = MP4_BoxGet( p_rmra, "rmda[%d]/rdrf", i ); |
|---|
| | 375 | char *psz_ref; |
|---|
| | 376 | uint32_t i_ref_type; |
|---|
| | 377 | |
|---|
| | 378 | if( !p_rdrf || !( psz_ref = strdup( p_rdrf->data.p_rdrf->psz_ref ) ) ) |
|---|
| | 379 | { |
|---|
| | 380 | continue; |
|---|
| | 381 | } |
|---|
| | 382 | i_ref_type = p_rdrf->data.p_rdrf->i_ref_type; |
|---|
| | 383 | |
|---|
| | 384 | msg_Dbg( p_demux, "new ref=`%s' type=%4.4s", |
|---|
| | 385 | psz_ref, (char*)&i_ref_type ); |
|---|
| | 386 | |
|---|
| | 387 | if( i_ref_type == VLC_FOURCC( 'u', 'r', 'l', ' ' ) ) |
|---|
| | 388 | { |
|---|
| | 389 | if( strstr( psz_ref, "qt5gateQT" ) ) |
|---|
| 388 | 390 | { |
|---|
| | 391 | msg_Dbg( p_demux, "ignoring pseudo ref =`%s'", psz_ref ); |
|---|
| 389 | 392 | continue; |
|---|
| 390 | 393 | } |
|---|
| 391 | | i_ref_type = p_rdrf->data.p_rdrf->i_ref_type; |
|---|
| 392 | | |
|---|
| 393 | | msg_Dbg( p_demux, "new ref=`%s' type=%4.4s", |
|---|
| 394 | | psz_ref, (char*)&i_ref_type ); |
|---|
| 395 | | |
|---|
| 396 | | if( i_ref_type == VLC_FOURCC( 'u', 'r', 'l', ' ' ) ) |
|---|
| | 394 | if( !strncmp( psz_ref, "http://", 7 ) || |
|---|
| | 395 | !strncmp( psz_ref, "rtsp://", 7 ) ) |
|---|
| 397 | 396 | { |
|---|
| 398 | | if( strstr( psz_ref, "qt5gateQT" ) ) |
|---|
| 399 | | { |
|---|
| 400 | | msg_Dbg( p_demux, "ignoring pseudo ref =`%s'", psz_ref ); |
|---|
| 401 | | continue; |
|---|
| 402 | | } |
|---|
| 403 | | if( !strncmp( psz_ref, "http://", 7 ) || |
|---|
| 404 | | !strncmp( psz_ref, "rtsp://", 7 ) ) |
|---|
| 405 | | { |
|---|
| 406 | | ; |
|---|
| 407 | | } |
|---|
| 408 | | else |
|---|
| 409 | | { |
|---|
| 410 | | char *psz_absolute; |
|---|
| 411 | | char *psz_path = strdup( p_demux->psz_path ); |
|---|
| 412 | | char *end = strrchr( psz_path, '/' ); |
|---|
| 413 | | if( end ) end[1] = '\0'; |
|---|
| 414 | | else *psz_path = '\0'; |
|---|
| 415 | | |
|---|
| 416 | | asprintf( &psz_absolute, "%s://%s%s", |
|---|
| 417 | | p_demux->psz_access, psz_path, psz_ref ); |
|---|
| 418 | | |
|---|
| 419 | | free( psz_ref ); |
|---|
| 420 | | psz_ref = psz_absolute; |
|---|
| 421 | | free( psz_path ); |
|---|
| 422 | | } |
|---|
| 423 | | if( p_current ) |
|---|
| 424 | | { |
|---|
| 425 | | input_item_t *p_input; |
|---|
| 426 | | msg_Dbg( p_demux, "adding ref = `%s'", psz_ref ); |
|---|
| 427 | | p_input = input_ItemNewExt( p_playlist, psz_ref, NULL, |
|---|
| 428 | | 0, NULL, -1 ); |
|---|
| 429 | | input_ItemCopyOptions( p_current->p_input, p_input ); |
|---|
| 430 | | /* FIXME: playlist_BothAddInput() can fail */ |
|---|
| 431 | | playlist_BothAddInput( p_playlist, p_input, |
|---|
| 432 | | p_item_in_category, |
|---|
| 433 | | PLAYLIST_APPEND, PLAYLIST_END, |
|---|
| 434 | | NULL, NULL, false ); |
|---|
| 435 | | vlc_gc_decref( p_input ); |
|---|
| 436 | | } |
|---|
| | 397 | ; |
|---|
| 437 | 398 | } |
|---|
| 438 | 399 | else |
|---|
| 439 | 400 | { |
|---|
| 440 | | msg_Err( p_demux, "unknown ref type=%4.4s FIXME (send a bug report)", |
|---|
| 441 | | (char*)&p_rdrf->data.p_rdrf->i_ref_type ); |
|---|
| | 401 | char *psz_absolute; |
|---|
| | 402 | char *psz_path = strdup( p_demux->psz_path ); |
|---|
| | 403 | char *end = strrchr( psz_path, '/' ); |
|---|
| | 404 | if( end ) end[1] = '\0'; |
|---|
| | 405 | else *psz_path = '\0'; |
|---|
| | 406 | |
|---|
| | 407 | asprintf( &psz_absolute, "%s://%s%s", |
|---|
| | 408 | p_demux->psz_access, psz_path, psz_ref ); |
|---|
| | 409 | |
|---|
| | 410 | free( psz_ref ); |
|---|
| | 411 | psz_ref = psz_absolute; |
|---|
| | 412 | free( psz_path ); |
|---|
| 442 | 413 | } |
|---|
| 443 | | free( psz_ref ); |
|---|
| 444 | | } |
|---|
| 445 | | if( b_play && p_item_in_category && |
|---|
| 446 | | p_item_in_category->i_children > 0 ) |
|---|
| 447 | | { |
|---|
| 448 | | playlist_Control( p_playlist, PLAYLIST_VIEWPLAY, true, |
|---|
| 449 | | p_item_in_category, NULL ); |
|---|
| 450 | | } |
|---|
| 451 | | vlc_object_release( p_playlist ); |
|---|
| 452 | | } |
|---|
| 453 | | else |
|---|
| 454 | | { |
|---|
| 455 | | msg_Err( p_demux, "can't find playlist" ); |
|---|
| 456 | | } |
|---|
| | 414 | input_item_t *p_input; |
|---|
| | 415 | msg_Dbg( p_demux, "adding ref = `%s'", psz_ref ); |
|---|
| | 416 | p_input = input_ItemNewExt( p_demux, psz_ref, NULL, |
|---|
| | 417 | 0, NULL, -1 ); |
|---|
| | 418 | input_ItemCopyOptions( p_current, p_input ); |
|---|
| | 419 | input_ItemAddSubItem( p_current, p_input ); |
|---|
| | 420 | vlc_gc_decref( p_input ); |
|---|
| | 421 | } |
|---|
| | 422 | else |
|---|
| | 423 | { |
|---|
| | 424 | msg_Err( p_demux, "unknown ref type=%4.4s FIXME (send a bug report)", |
|---|
| | 425 | (char*)&p_rdrf->data.p_rdrf->i_ref_type ); |
|---|
| | 426 | } |
|---|
| | 427 | free( psz_ref ); |
|---|
| | 428 | } |
|---|
| | 429 | vlc_object_release( p_input ); |
|---|
| 457 | 430 | } |
|---|
| 458 | 431 | |
|---|
| … | … | |
| 2478 | 2451 | } |
|---|
| 2479 | 2452 | } |
|---|
| 2480 | | |
|---|
| 2481 | | static bool FindItem( demux_t *p_demux, playlist_t *p_playlist, |
|---|
| 2482 | | playlist_item_t **pp_item ) |
|---|
| 2483 | | { |
|---|
| 2484 | | input_thread_t *p_input = (input_thread_t *)vlc_object_find( p_demux, VLC_OBJECT_INPUT, FIND_PARENT ); |
|---|
| 2485 | | bool b_play = var_CreateGetBool( p_demux, "playlist-autostart" ); |
|---|
| 2486 | | |
|---|
| 2487 | | *pp_item = NULL; |
|---|
| 2488 | | if( p_input ) |
|---|
| 2489 | | { |
|---|
| 2490 | | if( b_play && p_playlist->status.p_item && |
|---|
| 2491 | | p_playlist->status.p_item->p_input == input_GetItem(p_input) ) |
|---|
| 2492 | | { |
|---|
| 2493 | | msg_Dbg( p_playlist, "starting playlist playback" ); |
|---|
| 2494 | | *pp_item = p_playlist->status.p_item; |
|---|
| 2495 | | b_play = true; |
|---|
| 2496 | | } |
|---|
| 2497 | | else |
|---|
| 2498 | | { |
|---|
| 2499 | | input_item_t *p_current = input_GetItem( p_input ); |
|---|
| 2500 | | |
|---|
| 2501 | | *pp_item = playlist_ItemGetByInput( p_playlist, p_current, false ); |
|---|
| 2502 | | if( !*pp_item ) |
|---|
| 2503 | | msg_Dbg( p_playlist, "unable to find item in playlist"); |
|---|
| 2504 | | |
|---|
| 2505 | | msg_Dbg( p_playlist, "not starting playlist playback"); |
|---|
| 2506 | | b_play = false; |
|---|
| 2507 | | } |
|---|
| 2508 | | vlc_object_release( p_input ); |
|---|
| 2509 | | } |
|---|
| 2510 | | return b_play; |
|---|
| 2511 | | } |
|---|
| 2512 | | |
|---|
| 2513 | | |
|---|