Changeset 141e740fbee112b7d8ac61e5842d85670eda7399
- Timestamp:
- 24/12/07 19:45:10
(1 year ago)
- Author:
- Pierre d'Herbemont <pdherbemont@videolan.org>
- git-committer:
- Pierre d'Herbemont <pdherbemont@videolan.org> 1198521910 +0000
- git-parent:
[f2c77da9820cf07e455417f2636561cc338759b4]
- git-author:
- Pierre d'Herbemont <pdherbemont@videolan.org> 1198521910 +0000
- Message:
control/media_descriptor.c: Publish an Event plus a method to get the media_descriptor state, which is buffering, playing, error, nothing special. This is a bit controversial as we need a media_instance to set that state, and this is media_instance dependant. However, this is a nice shortcut.
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| raf1e3b5 |
r141e740 |
|
| 197 | 197 | libvlc_exception_t *p_e ); |
|---|
| 198 | 198 | |
|---|
| | 199 | VLC_PUBLIC_API libvlc_state_t libvlc_media_descriptor_get_state( |
|---|
| | 200 | libvlc_media_descriptor_t *p_meta_desc, |
|---|
| | 201 | libvlc_exception_t *p_e ); |
|---|
| | 202 | |
|---|
| 199 | 203 | /* Tags */ |
|---|
| 200 | 204 | VLC_PUBLIC_API void libvlc_media_descriptor_add_tag( libvlc_media_descriptor_t *p_md, |
|---|
| rb269d0e |
r141e740 |
|
| 123 | 123 | typedef enum libvlc_state_t |
|---|
| 124 | 124 | { |
|---|
| | 125 | libvlc_NothingSpecial, |
|---|
| 125 | 126 | libvlc_Stopped, |
|---|
| 126 | 127 | libvlc_Opening, |
|---|
| … | … | |
| 300 | 301 | libvlc_MediaDescriptorPreparsedChanged, |
|---|
| 301 | 302 | libvlc_MediaDescriptorFreed, |
|---|
| | 303 | libvlc_MediaDescriptorStateChanged, |
|---|
| 302 | 304 | |
|---|
| 303 | 305 | libvlc_MediaInstancePlayed, |
|---|
| … | … | |
| 356 | 358 | libvlc_media_descriptor_t * md; |
|---|
| 357 | 359 | } media_descriptor_freed; |
|---|
| | 360 | struct |
|---|
| | 361 | { |
|---|
| | 362 | libvlc_state_t new_state; |
|---|
| | 363 | } media_descriptor_state_changed; |
|---|
| 358 | 364 | |
|---|
| 359 | 365 | /* media instance */ |
|---|
| rb269d0e |
r141e740 |
|
| 88 | 88 | libvlc_instance_t *p_libvlc_instance; |
|---|
| 89 | 89 | vlc_dictionary_t tags; /* To be merged with core's meta soon */ |
|---|
| | 90 | libvlc_state_t state; |
|---|
| 90 | 91 | struct libvlc_media_list_t *p_subitems; /* A media descriptor can have |
|---|
| 91 | 92 | * Sub item */ |
|---|
| … | … | |
| 292 | 293 | VLC_EXPORT (libvlc_media_descriptor_t *, libvlc_media_descriptor_duplicate, |
|---|
| 293 | 294 | ( libvlc_media_descriptor_t * ) ); |
|---|
| | 295 | |
|---|
| | 296 | VLC_EXPORT (void, libvlc_media_descriptor_set_state, |
|---|
| | 297 | ( libvlc_media_descriptor_t *, libvlc_state_t, libvlc_exception_t * ) ); |
|---|
| 294 | 298 | |
|---|
| 295 | 299 | /* Media List View */ |
|---|
| r5b32403 |
r141e740 |
|
| 249 | 249 | p_md->b_preparsed = VLC_FALSE; |
|---|
| 250 | 250 | p_md->i_refcount = 1; |
|---|
| 251 | | p_md->p_user_data = NULL; // VLC.framework hook |
|---|
| | 251 | p_md->p_user_data = NULL; |
|---|
| | 252 | |
|---|
| | 253 | p_md->state = libvlc_NothingSpecial; |
|---|
| 252 | 254 | |
|---|
| 253 | 255 | /* A media descriptor can be a playlist. When you open a playlist |
|---|
| … | … | |
| 266 | 268 | libvlc_event_manager_register_event_type( p_md->p_event_manager, |
|---|
| 267 | 269 | libvlc_MediaDescriptorDurationChanged, p_e ); |
|---|
| | 270 | libvlc_event_manager_register_event_type( p_md->p_event_manager, |
|---|
| | 271 | libvlc_MediaDescriptorStateChanged, p_e ); |
|---|
| 268 | 272 | |
|---|
| 269 | 273 | vlc_gc_incref( p_md->p_input_item ); |
|---|
| … | … | |
| 452 | 456 | |
|---|
| 453 | 457 | /************************************************************************** |
|---|
| | 458 | * Getter for state information |
|---|
| | 459 | * Can be error, playing, buffering, NothingSpecial. |
|---|
| | 460 | **************************************************************************/ |
|---|
| | 461 | |
|---|
| | 462 | libvlc_state_t |
|---|
| | 463 | libvlc_media_descriptor_get_state( libvlc_media_descriptor_t *p_md, |
|---|
| | 464 | libvlc_exception_t *p_e ) |
|---|
| | 465 | { |
|---|
| | 466 | (void)p_e; |
|---|
| | 467 | return p_md->state; |
|---|
| | 468 | } |
|---|
| | 469 | |
|---|
| | 470 | /************************************************************************** |
|---|
| | 471 | * Setter for state information (LibVLC Internal) |
|---|
| | 472 | **************************************************************************/ |
|---|
| | 473 | |
|---|
| | 474 | void |
|---|
| | 475 | libvlc_media_descriptor_set_state( libvlc_media_descriptor_t *p_md, |
|---|
| | 476 | libvlc_state_t state, |
|---|
| | 477 | libvlc_exception_t *p_e ) |
|---|
| | 478 | { |
|---|
| | 479 | (void)p_e; |
|---|
| | 480 | libvlc_event_t event; |
|---|
| | 481 | |
|---|
| | 482 | p_md->state = state; |
|---|
| | 483 | |
|---|
| | 484 | /* Construct the event */ |
|---|
| | 485 | event.type = libvlc_MediaDescriptorStateChanged; |
|---|
| | 486 | event.u.media_descriptor_state_changed.new_state = state; |
|---|
| | 487 | |
|---|
| | 488 | /* Send the event */ |
|---|
| | 489 | libvlc_event_send( p_md->p_event_manager, &event ); |
|---|
| | 490 | } |
|---|
| | 491 | |
|---|
| | 492 | /************************************************************************** |
|---|
| 454 | 493 | * Add a tag |
|---|
| 455 | 494 | **************************************************************************/ |
|---|
| r7a35ff7 |
r141e740 |
|
| 28 | 28 | #include "libvlc.h" |
|---|
| 29 | 29 | |
|---|
| | 30 | static const libvlc_state_t vlc_to_libvlc_state_array[] = |
|---|
| | 31 | { |
|---|
| | 32 | [INIT_S] = libvlc_Opening, |
|---|
| | 33 | [OPENING_S] = libvlc_Opening, |
|---|
| | 34 | [BUFFERING_S] = libvlc_Buffering, |
|---|
| | 35 | [PLAYING_S] = libvlc_Playing, |
|---|
| | 36 | [PAUSE_S] = libvlc_Paused, |
|---|
| | 37 | [END_S] = libvlc_Ended, |
|---|
| | 38 | [ERROR_S] = libvlc_Error, |
|---|
| | 39 | }; |
|---|
| | 40 | static inline libvlc_state_t vlc_to_libvlc_state( int vlc_state ) |
|---|
| | 41 | { |
|---|
| | 42 | if( vlc_state < 0 || vlc_state > 6 ) |
|---|
| | 43 | return libvlc_Stopped; |
|---|
| | 44 | |
|---|
| | 45 | return vlc_to_libvlc_state_array[vlc_state]; |
|---|
| | 46 | } |
|---|
| | 47 | |
|---|
| 30 | 48 | /* |
|---|
| 31 | 49 | * Release the associated input thread |
|---|
| … | … | |
| 115 | 133 | libvlc_event_t event; |
|---|
| 116 | 134 | |
|---|
| | 135 | printf("input_state_changed!!!!!!!!\n"); |
|---|
| 117 | 136 | if( newval.i_int == oldval.i_int ) |
|---|
| 118 | 137 | return VLC_SUCCESS; /* No change since last time, don't propagate */ |
|---|
| … | … | |
| 121 | 140 | { |
|---|
| 122 | 141 | case END_S: |
|---|
| | 142 | libvlc_media_descriptor_set_state( p_mi->p_md, libvlc_NothingSpecial, NULL); |
|---|
| 123 | 143 | event.type = libvlc_MediaInstanceReachedEnd; |
|---|
| 124 | 144 | break; |
|---|
| 125 | 145 | case PAUSE_S: |
|---|
| | 146 | libvlc_media_descriptor_set_state( p_mi->p_md, libvlc_Playing, NULL); |
|---|
| 126 | 147 | event.type = libvlc_MediaInstancePaused; |
|---|
| 127 | 148 | break; |
|---|
| 128 | 149 | case PLAYING_S: |
|---|
| | 150 | printf("PLAYING_S!!!!!!!!\n"); |
|---|
| | 151 | libvlc_media_descriptor_set_state( p_mi->p_md, libvlc_Playing, NULL); |
|---|
| | 152 | event.type = libvlc_MediaInstancePlayed; |
|---|
| | 153 | break; |
|---|
| | 154 | case ERROR_S: |
|---|
| | 155 | libvlc_media_descriptor_set_state( p_mi->p_md, libvlc_Error, NULL); |
|---|
| 129 | 156 | event.type = libvlc_MediaInstancePlayed; |
|---|
| 130 | 157 | break; |
|---|
| … | … | |
| 730 | 757 | } |
|---|
| 731 | 758 | |
|---|
| 732 | | static const libvlc_state_t vlc_to_libvlc_state[] = |
|---|
| 733 | | { |
|---|
| 734 | | [INIT_S] = libvlc_Opening, |
|---|
| 735 | | [OPENING_S] = libvlc_Opening, |
|---|
| 736 | | [BUFFERING_S] = libvlc_Buffering, |
|---|
| 737 | | [PLAYING_S] = libvlc_Playing, |
|---|
| 738 | | [PAUSE_S] = libvlc_Paused, |
|---|
| 739 | | [END_S] = libvlc_Ended, |
|---|
| 740 | | [ERROR_S] = libvlc_Error, |
|---|
| 741 | | }; |
|---|
| 742 | | |
|---|
| 743 | 759 | libvlc_state_t libvlc_media_instance_get_state( |
|---|
| 744 | 760 | libvlc_media_instance_t *p_mi, |
|---|
| … | … | |
| 755 | 771 | vlc_object_release( p_input_thread ); |
|---|
| 756 | 772 | |
|---|
| 757 | | if( val.i_int < 0 || val.i_int > 6 ) |
|---|
| 758 | | return libvlc_Stopped; |
|---|
| 759 | | |
|---|
| 760 | | return vlc_to_libvlc_state[val.i_int]; |
|---|
| 761 | | } |
|---|
| | 773 | return vlc_to_libvlc_state(val.i_int); |
|---|
| | 774 | } |
|---|