Changeset 7b32ae177048eb0bc36b6f7610b9e8a1fb22fead
- Timestamp:
- 20/10/07 19:56:00 (1 year ago)
- git-parent:
- Files:
-
- include/vlc/libvlc.h (modified) (1 diff)
- include/vlc/libvlc_structures.h (modified) (2 diffs)
- include/vlc_events.h (modified) (2 diffs)
- include/vlc_input.h (modified) (3 diffs)
- src/control/libvlc_internal.h (modified) (1 diff)
- src/control/media_descriptor.c (modified) (6 diffs)
- src/control/media_instance.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
include/vlc/libvlc.h
r1524a41 r7b32ae1 190 190 libvlc_exception_t * p_e ); 191 191 192 VLC_PUBLIC_API vlc_int64_t 193 libvlc_media_descriptor_get_duration( libvlc_media_descriptor_t * p_md, 194 libvlc_exception_t * p_e ); 195 196 VLC_PUBLIC_API vlc_bool_t 197 libvlc_media_descriptor_is_preparsed( libvlc_media_descriptor_t * p_md, 198 libvlc_exception_t * p_e ); 199 200 VLC_PUBLIC_API void 201 libvlc_media_descriptor_set_user_data( libvlc_media_descriptor_t * p_md, 202 void * p_new_user_data, 203 libvlc_exception_t * p_e); 204 VLC_PUBLIC_API void * 205 libvlc_media_descriptor_get_user_data( libvlc_media_descriptor_t * p_md, 206 libvlc_exception_t * p_e); 207 192 208 /** @}*/ 193 209 include/vlc/libvlc_structures.h
r145a649 r7b32ae1 297 297 libvlc_MediaDescriptorMetaChanged, 298 298 libvlc_MediaDescriptorSubItemAdded, 299 libvlc_MediaDescriptorDurationChanged, 300 libvlc_MediaDescriptorPreparsedChanged, 299 301 300 302 libvlc_MediaInstancePlayed, … … 334 336 libvlc_media_descriptor_t * new_child; 335 337 } media_descriptor_subitem_added; 336 338 struct 339 { 340 vlc_int64_t new_duration; 341 } media_descriptor_duration_changed; 342 struct 343 { 344 int new_status; 345 } media_descriptor_preparsed_changed; 346 337 347 /* media instance */ 338 348 struct include/vlc_events.h
r6ee1e19 r7b32ae1 115 115 vlc_InputItemMetaChanged, 116 116 vlc_InputItemSubItemAdded, 117 vlc_InputItemDurationChanged, 118 vlc_InputItemPreparsedChanged, 117 119 118 120 /* Service Discovery event */ … … 137 139 input_item_t * p_new_child; 138 140 } input_item_subitem_added; 139 141 struct vlc_input_item_duration_changed 142 { 143 mtime_t new_duration; 144 } input_item_duration_changed; 145 struct vlc_input_item_preparsed_changed 146 { 147 int new_status; 148 } input_item_preparsed_changed; 149 140 150 /* Service discovery events */ 141 151 struct vlc_services_discovery_item_added include/vlc_input.h
rf516f42 r7b32ae1 121 121 vlc_event_manager_register_event_type( &p_i->event_manager, 122 122 vlc_InputItemSubItemAdded ); 123 vlc_event_manager_register_event_type( &p_i->event_manager, 124 vlc_InputItemDurationChanged ); 125 vlc_event_manager_register_event_type( &p_i->event_manager, 126 vlc_InputItemPreparsedChanged ); 123 127 } 124 128 … … 303 307 static inline void input_item_SetDuration( input_item_t * p_i, mtime_t i_duration ) 304 308 { 309 vlc_bool_t send_event = VLC_FALSE; 310 305 311 vlc_mutex_lock( &p_i->lock ); 306 p_i->i_duration = i_duration; 312 if( p_i->i_duration != i_duration ) 313 { 314 p_i->i_duration = i_duration; 315 send_event = VLC_TRUE; 316 } 307 317 vlc_mutex_unlock( &p_i->lock ); 318 319 if ( send_event == VLC_TRUE ) 320 { 321 vlc_event_t event; 322 event.type = vlc_InputItemDurationChanged; 323 event.u.input_item_duration_changed.new_duration = i_duration; 324 vlc_event_send( &p_i->event_manager, &event ); 325 } 326 308 327 return; 309 328 } … … 311 330 static inline void input_item_SetPreparsed( input_item_t *p_i, vlc_bool_t preparsed ) 312 331 { 332 vlc_bool_t send_event = VLC_FALSE; 333 313 334 if( !p_i->p_meta ) 314 335 p_i->p_meta = vlc_meta_New(); 315 336 337 vlc_mutex_lock( &p_i->lock ); 338 int new_status; 316 339 if( preparsed ) 317 p_i->p_meta->i_status |=ITEM_PREPARSED;340 new_status = p_i->p_meta->i_status | ITEM_PREPARSED; 318 341 else 319 p_i->p_meta->i_status &= ~ITEM_PREPARSED; 342 new_status = p_i->p_meta->i_status & ~ITEM_PREPARSED; 343 if ( p_i->p_meta->i_status != new_status ) 344 { 345 p_i->p_meta->i_status = new_status; 346 send_event = VLC_TRUE; 347 } 348 349 vlc_mutex_unlock( &p_i->lock ); 350 351 if ( send_event == VLC_TRUE ) 352 { 353 vlc_event_t event; 354 event.type = vlc_InputItemPreparsedChanged; 355 event.u.input_item_preparsed_changed.new_status = new_status; 356 vlc_event_send( &p_i->event_manager, &event ); 357 } 320 358 } 321 359 src/control/libvlc_internal.h
ra83d27a r7b32ae1 89 89 struct libvlc_media_list_t *p_subitems; /* A media descriptor can have 90 90 * Sub item */ 91 void *p_user_data; /* Allows for VLC.framework to hook into media descriptor without creating a new VLCMedia object. */ 91 92 }; 92 93 src/control/media_descriptor.c
r6ee1e19 r7b32ae1 125 125 } 126 126 127 /************************************************************************** 128 * input_item_duration_changed (Private) (vlc event Callback) 129 **************************************************************************/ 130 static void input_item_duration_changed( const vlc_event_t *p_event, 131 void * user_data ) 132 { 133 libvlc_media_descriptor_t * p_md = user_data; 134 libvlc_event_t event; 135 136 /* Construct the event */ 137 event.type = libvlc_MediaDescriptorDurationChanged; 138 event.u.media_descriptor_duration_changed.new_duration = 139 p_event->u.input_item_duration_changed.new_duration; 140 141 /* Send the event */ 142 libvlc_event_send( p_md->p_event_manager, &event ); 143 } 144 145 /************************************************************************** 146 * input_item_preparsed_changed (Private) (vlc event Callback) 147 **************************************************************************/ 148 static void input_item_preparsed_changed( const vlc_event_t *p_event, 149 void * user_data ) 150 { 151 libvlc_media_descriptor_t * p_md = user_data; 152 libvlc_event_t event; 153 154 /* Construct the event */ 155 event.type = libvlc_MediaDescriptorPreparsedChanged; 156 event.u.media_descriptor_preparsed_changed.new_status = 157 p_event->u.input_item_preparsed_changed.new_status; 158 159 /* Send the event */ 160 libvlc_event_send( p_md->p_event_manager, &event ); 161 } 127 162 128 163 /************************************************************************** … … 139 174 input_item_meta_changed, 140 175 p_md ); 176 vlc_event_attach( &p_md->p_input_item->event_manager, 177 vlc_InputItemDurationChanged, 178 input_item_duration_changed, 179 p_md ); 180 vlc_event_attach( &p_md->p_input_item->event_manager, 181 vlc_InputItemPreparsedChanged, 182 input_item_preparsed_changed, 183 p_md ); 141 184 } 142 185 … … 153 196 vlc_InputItemMetaChanged, 154 197 input_item_meta_changed, 198 p_md ); 199 vlc_event_detach( &p_md->p_input_item->event_manager, 200 vlc_InputItemDurationChanged, 201 input_item_duration_changed, 202 p_md ); 203 vlc_event_detach( &p_md->p_input_item->event_manager, 204 vlc_InputItemPreparsedChanged, 205 input_item_preparsed_changed, 155 206 p_md ); 156 207 } … … 198 249 p_md->b_preparsed = VLC_FALSE; 199 250 p_md->i_refcount = 1; 251 p_md->p_user_data = NULL; // VLC.framework hook 200 252 201 253 /* A media descriptor can be a playlist. When you open a playlist … … 210 262 libvlc_event_manager_register_event_type( p_md->p_event_manager, 211 263 libvlc_MediaDescriptorSubItemAdded, p_e ); 264 libvlc_event_manager_register_event_type( p_md->p_event_manager, 265 libvlc_MediaDescriptorDurationChanged, p_e ); 212 266 213 267 vlc_gc_incref( p_md->p_input_item ); … … 463 517 return p_md->p_event_manager; 464 518 } 519 520 /************************************************************************** 521 * Get duration of media_descriptor object. 522 **************************************************************************/ 523 vlc_int64_t 524 libvlc_media_descriptor_get_duration( libvlc_media_descriptor_t * p_md, 525 libvlc_exception_t * p_e ) 526 { 527 if( p_md && p_md->p_input_item) 528 { 529 return input_item_GetDuration( p_md->p_input_item ); 530 } 531 else 532 { 533 return -1; 534 } 535 } 536 537 /************************************************************************** 538 * Get preparsed status for media_descriptor object. 539 **************************************************************************/ 540 vlc_bool_t 541 libvlc_media_descriptor_is_preparsed( libvlc_media_descriptor_t * p_md, 542 libvlc_exception_t * p_e ) 543 { 544 if( p_md && p_md->p_input_item) 545 { 546 return input_item_IsPreparsed( p_md->p_input_item ); 547 } 548 else 549 { 550 return VLC_FALSE; 551 } 552 } 553 554 /************************************************************************** 555 * Sets media descriptor's user_data. user_data is specialized data 556 * accessed by the host application, VLC.framework uses it as a pointer to 557 * an native object that references a libvlc_media_descriptor_t pointer 558 **************************************************************************/ 559 void 560 libvlc_media_descriptor_set_user_data( libvlc_media_descriptor_t * p_md, 561 void * p_new_user_data, 562 libvlc_exception_t * p_e ) 563 { 564 if( p_md ) 565 { 566 p_md->p_user_data = p_new_user_data; 567 } 568 } 569 570 /************************************************************************** 571 * Get media descriptor's user_data. user_data is specialized data 572 * accessed by the host application, VLC.framework uses it as a pointer to 573 * an native object that references a libvlc_media_descriptor_t pointer 574 **************************************************************************/ 575 void * 576 libvlc_media_descriptor_get_user_data( libvlc_media_descriptor_t * p_md, 577 libvlc_exception_t * p_e ) 578 { 579 if( p_md ) 580 { 581 return p_md->p_user_data; 582 } 583 else 584 { 585 return NULL; 586 } 587 } src/control/media_instance.c
r50b8eb2 r7b32ae1 308 308 { 309 309 libvlc_event_manager_release( p_mi->p_event_manager ); 310 libvlc_exception_clear( &p_e ); 310 311 free( p_mi ); 311 312 return; /* no need to worry about no input thread */
