Changeset 222960cff9c3968b0c6b8c073bfa08182e3cc78a
- Timestamp:
- 11/10/07 03:02:50 (1 year ago)
- git-parent:
- Files:
-
- include/vlc_playlist.h (modified) (4 diffs)
- include/vlc_services_discovery.h (added)
- src/playlist/engine.c (modified) (2 diffs)
- src/playlist/services_discovery.c (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
include/vlc_playlist.h
rd3b42e4 r222960c 36 36 #include <vlc_input.h> 37 37 #include <vlc_events.h> 38 #include <vlc_services_discovery.h> 38 39 #include <stdio.h> 39 40 #include <stdlib.h> … … 159 160 { PLAYLIST_STOPPED,PLAYLIST_RUNNING,PLAYLIST_PAUSED } playlist_status_t; 160 161 161 162 struct services_discovery_t163 {164 VLC_COMMON_MEMBERS165 char * psz_module;166 module_t * p_module;167 168 char * psz_localized_name; /* Accessed through Setters for non class function */169 vlc_event_manager_t event_manager; /* Accessed through Setters for non class function */170 171 /* the playlist items for category and onelevel */172 playlist_item_t* p_cat;173 playlist_item_t* p_one;174 175 services_discovery_sys_t *p_sys;176 void (*pf_run) ( services_discovery_t *);177 };178 179 162 /** Structure containing information about the playlist */ 180 163 struct playlist_t … … 182 165 VLC_COMMON_MEMBERS 183 166 184 /* pp_sd & i_sd are for internal use ONLY. Understood ? it's PRIVATE ! */ 185 services_discovery_t **pp_sd; /**< Loaded service discovery modules */ 186 int i_sd; /**< Number of service discovery modules */ 167 struct playlist_services_discovery_support_t { 168 /* the playlist items for category and onelevel */ 169 playlist_item_t* p_cat; 170 playlist_item_t* p_one; 171 services_discovery_t * p_sd; /**< Loaded service discovery modules */ 172 } ** pp_sds; 173 int i_sds; /**< Number of service discovery modules */ 187 174 188 175 int i_enabled; /**< How many items are enabled ? */ … … 417 404 VLC_EXPORT( playlist_item_t *, playlist_GetPrevLeaf, ( playlist_t *p_playlist, playlist_item_t *p_root, playlist_item_t *p_item, vlc_bool_t b_ena, vlc_bool_t b_unplayed ) ); 418 405 VLC_EXPORT( playlist_item_t *, playlist_GetLastLeaf, ( playlist_t *p_playlist, playlist_item_t *p_root ) ); 419 420 /***********************************************************************421 * Service Discovery422 ***********************************************************************/423 424 /* Get the services discovery modules names to use in Create(), in a null425 * terminated string array. Array and string must be freed after use. */426 VLC_EXPORT( char **, services_discovery_GetServicesNames, ( vlc_object_t * p_super ) );427 428 /* Creation of a service_discovery object */429 VLC_EXPORT( services_discovery_t *, services_discovery_Create, ( vlc_object_t * p_super, const char * psz_service_name ) );430 VLC_EXPORT( void, services_discovery_Destroy, ( services_discovery_t * p_this ) );431 VLC_EXPORT( int, services_discovery_Start, ( services_discovery_t * p_this ) );432 VLC_EXPORT( void, services_discovery_Stop, ( services_discovery_t * p_this ) );433 434 /* Read info from discovery object */435 VLC_EXPORT( char *, services_discovery_GetLocalizedName, ( services_discovery_t * p_this ) );436 437 /* Receive event notification (prefered way to get new items) */438 VLC_EXPORT( vlc_event_manager_t *, services_discovery_EventManager, ( services_discovery_t * p_this ) );439 440 /* Used by services_discovery to post update about their items */441 VLC_EXPORT( void, services_discovery_SetLocalizedName, ( services_discovery_t * p_this, const char * ) );442 /* About the psz_category, it is a legacy way to add info to the item,443 * for more options, directly set the (meta) data on the input item */444 VLC_EXPORT( void, services_discovery_AddItem, ( services_discovery_t * p_this, input_item_t * p_item, const char * psz_category ) );445 VLC_EXPORT( void, services_discovery_RemoveItem, ( services_discovery_t * p_this, input_item_t * p_item ) );446 406 447 407 /*********************************************************************** src/playlist/engine.c
rd3b42e4 r222960c 67 67 } 68 68 69 TAB_INIT( p_playlist->i_sd , p_playlist->pp_sd);69 TAB_INIT( p_playlist->i_sds, p_playlist->pp_sds ); 70 70 71 71 p_parent->p_libvlc->p_playlist = p_playlist; … … 438 438 } 439 439 440 while( p_playlist->i_sd )440 while( p_playlist->i_sds ) 441 441 { 442 442 playlist_ServicesDiscoveryRemove( p_playlist, 443 p_playlist->pp_sd [0]->psz_module );443 p_playlist->pp_sds[0]->p_sd->psz_module ); 444 444 } 445 445 src/playlist/services_discovery.c
r393b8a0 r222960c 253 253 for (;;) 254 254 { 255 struct playlist_services_discovery_support_t * p_sds; 255 256 playlist_item_t * p_cat; 256 257 playlist_item_t * p_one; … … 294 295 PL_UNLOCK; 295 296 } 296 p_sd->p_cat = p_cat;297 p_sd->p_one = p_one;298 297 299 298 vlc_event_attach( services_discovery_EventManager( p_sd ), … … 319 318 services_discovery_Start( p_sd ); 320 319 320 /* Free in playlist_ServicesDiscoveryRemove */ 321 p_sds = malloc( sizeof(struct playlist_services_discovery_support_t) ); 322 if( !p_sds ) 323 { 324 msg_Err( p_playlist, "No more memory" ); 325 return VLC_ENOMEM; 326 } 327 p_sds->p_sd = p_sd; 328 p_sds->p_one = p_one; 329 p_sds->p_cat = p_cat; 330 321 331 PL_LOCK; 322 TAB_APPEND( p_playlist->i_sd , p_playlist->pp_sd, p_sd);332 TAB_APPEND( p_playlist->i_sds, p_playlist->pp_sds, p_sds ); 323 333 PL_UNLOCK; 324 334 } … … 330 340 const char *psz_module ) 331 341 { 342 struct playlist_services_discovery_support_t * p_sds = NULL; 332 343 int i; 333 struct services_discovery_t *p_sd = NULL;334 344 335 345 PL_LOCK; 336 for( i = 0 ; i< p_playlist->i_sd ; i ++ )337 { 338 if( !strcmp( psz_module, p_playlist->pp_sd [i]->psz_module ) )339 { 340 p_sd = p_playlist->pp_sd[i];341 REMOVE_ELEM( p_playlist->pp_sd , p_playlist->i_sd, i );346 for( i = 0 ; i< p_playlist->i_sds ; i ++ ) 347 { 348 if( !strcmp( psz_module, p_playlist->pp_sds[i]->p_sd->psz_module ) ) 349 { 350 p_sds = p_playlist->pp_sds[i]; 351 REMOVE_ELEM( p_playlist->pp_sds, p_playlist->i_sds, i ); 342 352 break; 343 353 } … … 345 355 PL_UNLOCK; 346 356 347 if( p_sd == NULL)357 if( !p_sds || !p_sds->p_sd ) 348 358 { 349 359 msg_Warn( p_playlist, "module %s is not loaded", psz_module ); … … 351 361 } 352 362 353 services_discovery_Stop( p_sd );354 355 vlc_event_detach( services_discovery_EventManager( p_sd ),363 services_discovery_Stop( p_sds->p_sd ); 364 365 vlc_event_detach( services_discovery_EventManager( p_sds->p_sd ), 356 366 vlc_ServicesDiscoveryItemAdded, 357 367 playlist_sd_item_added, 358 p_sd ->p_one );359 360 vlc_event_detach( services_discovery_EventManager( p_sd ),368 p_sds->p_one ); 369 370 vlc_event_detach( services_discovery_EventManager( p_sds->p_sd ), 361 371 vlc_ServicesDiscoveryItemAdded, 362 372 playlist_sd_item_added, 363 p_sd ->p_cat );364 365 vlc_event_detach( services_discovery_EventManager( p_sd ),373 p_sds->p_cat ); 374 375 vlc_event_detach( services_discovery_EventManager( p_sds->p_sd ), 366 376 vlc_ServicesDiscoveryItemRemoved, 367 377 playlist_sd_item_removed, 368 p_sd ->p_one );369 370 vlc_event_detach( services_discovery_EventManager( p_sd ),378 p_sds->p_one ); 379 380 vlc_event_detach( services_discovery_EventManager( p_sds->p_sd ), 371 381 vlc_ServicesDiscoveryItemRemoved, 372 382 playlist_sd_item_removed, 373 p_sd ->p_cat );383 p_sds->p_cat ); 374 384 375 385 /* Remove the sd playlist node if it exists */ 376 386 PL_LOCK; 377 if( p_sd ->p_cat != p_playlist->p_root_category &&378 p_sd ->p_one != p_playlist->p_root_onelevel )379 { 380 playlist_NodeDelete( p_playlist, p_sd ->p_cat, VLC_TRUE, VLC_FALSE );381 playlist_NodeDelete( p_playlist, p_sd ->p_one, VLC_TRUE, VLC_FALSE );387 if( p_sds->p_cat != p_playlist->p_root_category && 388 p_sds->p_one != p_playlist->p_root_onelevel ) 389 { 390 playlist_NodeDelete( p_playlist, p_sds->p_cat, VLC_TRUE, VLC_FALSE ); 391 playlist_NodeDelete( p_playlist, p_sds->p_one, VLC_TRUE, VLC_FALSE ); 382 392 } 383 393 PL_UNLOCK; 384 394 385 services_discovery_Destroy( p_sd );395 services_discovery_Destroy( p_sds->p_sd ); 386 396 387 397 return VLC_SUCCESS; … … 394 404 PL_LOCK; 395 405 396 for( i = 0 ; i< p_playlist->i_sd ; i ++ )397 { 398 if( !strcmp( psz_module, p_playlist->pp_sd [i]->psz_module ) )406 for( i = 0 ; i< p_playlist->i_sds ; i ++ ) 407 { 408 if( !strcmp( psz_module, p_playlist->pp_sds[i]->p_sd->psz_module ) ) 399 409 { 400 410 PL_UNLOCK;
