VLC  4.0.0-dev
Data Structures | Typedefs | Functions
Collaboration diagram for Media source:

Data Structures

struct  vlc_media_tree
 Media source API aims to manage "services discovery" easily from UI clients. More...
 
struct  vlc_media_tree_callbacks
 Callbacks to receive media tree events. More...
 
struct  vlc_media_source_t
 Media source. More...
 
struct  vlc_media_source_meta
 Structure containing the description of a media source. More...
 

Typedefs

typedef struct vlc_media_tree vlc_media_tree_t
 Media source API aims to manage "services discovery" easily from UI clients. More...
 
typedef struct vlc_media_tree_listener_id vlc_media_tree_listener_id
 Listener for media tree events. More...
 
typedef struct vlc_media_source_t vlc_media_source_t
 Media source. More...
 
typedef struct vlc_media_source_provider_t vlc_media_source_provider_t
 Media source provider (opaque pointer), used to get media sources. More...
 
typedef struct vlc_media_source_meta_list vlc_media_source_meta_list_t
 List of media source metadata (opaque). More...
 

Functions

VLC_EXPORT vlc_media_tree_listener_idvlc_media_tree_AddListener (vlc_media_tree_t *tree, const struct vlc_media_tree_callbacks *cbs, void *userdata, bool notify_current_state)
 Add a listener. More...
 
VLC_EXPORT void vlc_media_tree_RemoveListener (vlc_media_tree_t *tree, vlc_media_tree_listener_id *listener)
 Remove a listener. More...
 
VLC_EXPORT void vlc_media_tree_Lock (vlc_media_tree_t *)
 Lock the media tree (non-recursive). More...
 
VLC_EXPORT void vlc_media_tree_Unlock (vlc_media_tree_t *)
 Unlock the media tree. More...
 
VLC_EXPORT bool vlc_media_tree_Find (vlc_media_tree_t *tree, const input_item_t *media, input_item_node_t **result, input_item_node_t **result_parent)
 Find the node containing the requested input item (and its parent). More...
 
VLC_EXPORT void vlc_media_tree_Preparse (vlc_media_tree_t *tree, libvlc_int_t *libvlc, input_item_t *media, void *id)
 Preparse a media, and expand it in the media tree on subitems added. More...
 
VLC_EXPORT void vlc_media_tree_PreparseCancel (libvlc_int_t *libvlc, void *id)
 Cancel a media tree preparse request. More...
 
VLC_EXPORT void vlc_media_source_Hold (vlc_media_source_t *)
 Increase the media source reference count. More...
 
VLC_EXPORT void vlc_media_source_Release (vlc_media_source_t *)
 Decrease the media source reference count. More...
 
VLC_EXPORT vlc_media_source_provider_tvlc_media_source_provider_Get (libvlc_int_t *)
 Return the media source provider associated to the libvlc instance. More...
 
VLC_EXPORT vlc_media_source_tvlc_media_source_provider_GetMediaSource (vlc_media_source_provider_t *, const char *name)
 Return the media source identified by psz_name. More...
 
VLC_EXPORT vlc_media_source_meta_list_tvlc_media_source_provider_List (vlc_media_source_provider_t *, enum services_discovery_category_e category)
 Return the list of metadata of available media sources. More...
 
VLC_EXPORT size_t vlc_media_source_meta_list_Count (vlc_media_source_meta_list_t *)
 Return the number of items in the list. More...
 
VLC_EXPORT struct vlc_media_source_metavlc_media_source_meta_list_Get (vlc_media_source_meta_list_t *, size_t index)
 Return the item at index. More...
 
VLC_EXPORT void vlc_media_source_meta_list_Delete (vlc_media_source_meta_list_t *)
 Delete the list. More...
 

Detailed Description

Typedef Documentation

◆ vlc_media_source_meta_list_t

List of media source metadata (opaque).

◆ vlc_media_source_provider_t

Media source provider (opaque pointer), used to get media sources.

◆ vlc_media_source_t

Media source.

A media source is associated to a "service discovery". It stores the detected media in a media tree.

◆ vlc_media_tree_listener_id

Listener for media tree events.

◆ vlc_media_tree_t

Media source API aims to manage "services discovery" easily from UI clients.

A "media source provider", associated to the libvlc instance, allows to retrieve media sources (each associated to a services discovery module).

Requesting a services discovery that is not open will automatically open it. If several "clients" request the same media source (i.e. by requesting the same name), they will receive the same (refcounted) media source instance. As soon as a media source is released by all its clients, the associated services discovery is closed.

Each media source holds a media tree, used to store both the media detected by the services discovery and the media detected by preparsing. Clients may listen to the tree to be notified of changes.

To preparse a media belonging to a media tree, use vlc_media_tree_Preparse(). If subitems are detected during the preparsing, the media tree is updated accordingly. Media tree.

Nodes must be traversed with locked held (vlc_media_tree_Lock()).

Function Documentation

◆ vlc_media_source_Hold()

VLC_EXPORT void vlc_media_source_Hold ( vlc_media_source_t )

Increase the media source reference count.

References ms_priv, media_source_private_t::rc, and vlc_atomic_rc_inc().

Referenced by vlc_media_source_provider_GetMediaSource().

◆ vlc_media_source_meta_list_Count()

VLC_EXPORT size_t vlc_media_source_meta_list_Count ( vlc_media_source_meta_list_t )

Return the number of items in the list.

References list.

◆ vlc_media_source_meta_list_Delete()

VLC_EXPORT void vlc_media_source_meta_list_Delete ( vlc_media_source_meta_list_t )

Delete the list.

Any struct vlc_media_source_meta retrieved from this list become invalid after this call.

References list, and vlc_vector_destroy.

◆ vlc_media_source_meta_list_Get()

VLC_EXPORT struct vlc_media_source_meta* vlc_media_source_meta_list_Get ( vlc_media_source_meta_list_t ,
size_t  index 
)

Return the item at index.

References list.

◆ vlc_media_source_provider_Get()

VLC_EXPORT vlc_media_source_provider_t* vlc_media_source_provider_Get ( libvlc_int_t )

Return the media source provider associated to the libvlc instance.

References libvlc_priv(), and libvlc_priv_t::media_source_provider.

◆ vlc_media_source_provider_GetMediaSource()

VLC_EXPORT vlc_media_source_t* vlc_media_source_provider_GetMediaSource ( vlc_media_source_provider_t ,
const char *  name 
)

Return the media source identified by psz_name.

The resulting media source must be released by vlc_media_source_Release().

References vlc_media_source_provider_t::lock, name, vlc_media_source_Hold(), vlc_media_source_provider_Add(), vlc_media_source_provider_Find(), vlc_mutex_lock(), and vlc_mutex_unlock().

◆ vlc_media_source_provider_List()

VLC_EXPORT vlc_media_source_meta_list_t* vlc_media_source_provider_List ( vlc_media_source_provider_t ,
enum services_discovery_category_e  category 
)

Return the list of metadata of available media sources.

If category is not 0, then only media sources for the requested category are listed.

The result must be deleted by vlc_media_source_meta_list_Delete() (if not null).

Return NULL either on error or on empty list (this is due to the behavior of the underlying vlc_sd_GetNames()).

Parameters
providerthe media source provider
categorythe category to list (0 for all)

References list, vlc_media_source_meta::name, p, unlikely, vlc_sd_GetNames, vlc_vector_destroy, vlc_vector_init, and vlc_vector_push.

◆ vlc_media_source_Release()

VLC_EXPORT void vlc_media_source_Release ( vlc_media_source_t )

Decrease the media source reference count.

Destroy the media source and close the associated "service discovery" if it reaches 0.

References ms_priv, media_source_private_t::rc, vlc_atomic_rc_dec(), and vlc_media_source_Delete().

◆ vlc_media_tree_AddListener()

VLC_EXPORT vlc_media_tree_listener_id* vlc_media_tree_AddListener ( vlc_media_tree_t tree,
const struct vlc_media_tree_callbacks cbs,
void *  userdata,
bool  notify_current_state 
)

Add a listener.

The lock must NOT be held.

Parameters
treethe media tree, unlocked
cbsthe callbacks (must be valid until the listener is removed)
userdatauserdata provided as a parameter in callbacks
notify_current_statetrue to notify the current state immediately via callbacks

References vlc_media_tree_listener_id::cbs, media_tree_private_t::listeners, mt_priv, vlc_media_tree_listener_id::node, unlikely, vlc_media_tree_listener_id::userdata, vlc_list_append(), vlc_media_tree_Lock(), vlc_media_tree_NotifyCurrentState(), and vlc_media_tree_Unlock().

Referenced by test_media_tree_callbacks(), and test_media_tree_callbacks_on_add_listener().

◆ vlc_media_tree_Find()

VLC_EXPORT bool vlc_media_tree_Find ( vlc_media_tree_t tree,
const input_item_t media,
input_item_node_t **  result,
input_item_node_t **  result_parent 
)

Find the node containing the requested input item (and its parent).

Parameters
treethe media tree, locked
resultpoint to the matching node if the function returns true [OUT]
result_parentif not NULL, point to the matching node parent if the function returns true [OUT]
Return values
trueif item was found
falseif item was not found

References vlc_media_tree::root, vlc_media_tree_AssertLocked(), and vlc_media_tree_FindNodeByMedia().

◆ vlc_media_tree_Lock()

VLC_EXPORT void vlc_media_tree_Lock ( vlc_media_tree_t )

◆ vlc_media_tree_Preparse()

VLC_EXPORT void vlc_media_tree_Preparse ( vlc_media_tree_t tree,
libvlc_int_t libvlc,
input_item_t media,
void *  id 
)

Preparse a media, and expand it in the media tree on subitems added.

Parameters
treethe media tree (not necessarily locked)
libvlcthe libvlc instance
mediathe media to preparse
ida task identifier

References input_item_t::i_preparse_depth, input_preparser_callbacks, META_REQUEST_OPTION_DO_INTERACT, META_REQUEST_OPTION_SCOPE_ANY, vlc_MetadataRequest(), and VLC_UNUSED.

◆ vlc_media_tree_PreparseCancel()

VLC_EXPORT void vlc_media_tree_PreparseCancel ( libvlc_int_t libvlc,
void *  id 
)

Cancel a media tree preparse request.

Parameters
libvlcthe libvlc instance
idthe preparse task id

References libvlc_MetadataCancel(), and VLC_UNUSED.

◆ vlc_media_tree_RemoveListener()

VLC_EXPORT void vlc_media_tree_RemoveListener ( vlc_media_tree_t tree,
vlc_media_tree_listener_id listener 
)

Remove a listener.

The lock must NOT be held.

Parameters
treethe media tree, unlocked
listenerthe listener identifier returned by vlc_media_tree_AddListener()

References vlc_media_tree_listener_id::node, vlc_list_remove(), vlc_media_tree_Lock(), and vlc_media_tree_Unlock().

Referenced by test_media_tree_callbacks(), and test_media_tree_callbacks_on_add_listener().

◆ vlc_media_tree_Unlock()

VLC_EXPORT void vlc_media_tree_Unlock ( vlc_media_tree_t )