sout: display: handle SOUT_STREAM_ID_SPU_HIGHLIGHT
[vlc.git] / include / vlc_services_discovery.h
blob1f5305b788e521ca75b3c26f84a2b656240fbc9a
1 /*****************************************************************************
2 * vlc_services_discovery.h : Services Discover functions
3 *****************************************************************************
4 * Copyright (C) 1999-2004 VLC authors and VideoLAN
5 * $Id$
7 * Authors: Pierre d'Herbemont <pdherbemont # videolan.org>
9 * This program is free software; you can redistribute it and/or modify it
10 * under the terms of the GNU Lesser General Public License as published by
11 * the Free Software Foundation; either version 2.1 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public License
20 * along with this program; if not, write to the Free Software Foundation,
21 * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22 *****************************************************************************/
24 #ifndef VLC_SERVICES_DISCOVERY_H_
25 #define VLC_SERVICES_DISCOVERY_H_
27 #include <vlc_input.h>
28 #include <vlc_probe.h>
30 /**
31 * \file
32 * This file lists functions and structures for service discovery (SD) in vlc
35 # ifdef __cplusplus
36 extern "C" {
37 # endif
39 /**
40 * @{
43 struct services_discovery_callbacks
45 void (*item_added)(struct services_discovery_t *sd, input_item_t *parent,
46 input_item_t *item, const char *category);
47 void (*item_removed)(struct services_discovery_t *sd, input_item_t *item);
50 struct services_discovery_owner_t
52 const struct services_discovery_callbacks *cbs;
53 void *sys; /**< Private data for the owner callbacks */
56 /**
57 * Main service discovery structure to build a SD module
59 struct services_discovery_t
61 struct vlc_common_members obj;
62 module_t * p_module; /**< Loaded module */
64 char *psz_name; /**< Main name of the SD */
65 config_chain_t *p_cfg; /**< Configuration for the SD */
67 const char *description; /**< Human-readable name */
69 /** Control function
70 * \see services_discovery_command_e
72 int ( *pf_control ) ( services_discovery_t *, int, va_list );
74 void *p_sys; /**< Custom private data */
76 struct services_discovery_owner_t owner; /**< Owner callbacks */
79 /**
80 * Service discovery categories
81 * \see vlc_sd_probe_Add
83 enum services_discovery_category_e
85 SD_CAT_DEVICES = 1, /**< Devices, like portable music players */
86 SD_CAT_LAN, /**< LAN/WAN services, like Upnp or SAP */
87 SD_CAT_INTERNET, /**< Internet or Website channels services */
88 SD_CAT_MYCOMPUTER /**< Computer services, like Discs or Apps */
91 /**
92 * Service discovery control commands
94 enum services_discovery_command_e
96 SD_CMD_SEARCH = 1, /**< arg1 = query */
97 SD_CMD_DESCRIPTOR /**< arg1 = services_discovery_descriptor_t* */
101 * Service discovery capabilities
103 enum services_discovery_capability_e
105 SD_CAP_SEARCH = 1 /**< One can search in the SD */
109 * Service discovery descriptor
110 * \see services_discovery_command_e
112 typedef struct
114 char *psz_short_desc; /**< The short description, human-readable */
115 char *psz_icon_url; /**< URL to the icon that represents it */
116 char *psz_url; /**< URL for the service */
117 int i_capabilities; /**< \see services_discovery_capability_e */
118 } services_discovery_descriptor_t;
121 /***********************************************************************
122 * Service Discovery
123 ***********************************************************************/
126 * Ask for a research in the SD
127 * @param p_sd: the Service Discovery
128 * @param i_control: the command to issue
129 * @param args: the argument list
130 * @return VLC_SUCCESS in case of success, the error code overwise
132 static inline int vlc_sd_control( services_discovery_t *p_sd, int i_control, va_list args )
134 if( p_sd->pf_control )
135 return p_sd->pf_control( p_sd, i_control, args );
136 else
137 return VLC_EGENERIC;
140 /* Get the services discovery modules names to use in Create(), in a null
141 * terminated string array. Array and string must be freed after use. */
142 VLC_API char ** vlc_sd_GetNames( vlc_object_t *, char ***, int ** ) VLC_USED;
143 #define vlc_sd_GetNames(obj, pln, pcat ) \
144 vlc_sd_GetNames(VLC_OBJECT(obj), pln, pcat)
147 * Creates a services discoverer.
149 VLC_API services_discovery_t *vlc_sd_Create(vlc_object_t *parent,
150 const char *chain, const struct services_discovery_owner_t *owner)
151 VLC_USED;
153 VLC_API void vlc_sd_Destroy( services_discovery_t * );
156 * Added top-level service callback.
158 * This is a convenience wrapper for services_discovery_AddSubItem().
159 * It covers the most comomn case wherby the added item is a top-level service,
160 * i.e. it has no parent node.
162 static inline void services_discovery_AddItem(services_discovery_t *sd,
163 input_item_t *item)
165 sd->owner.cbs->item_added(sd, NULL, item, NULL);
169 * Added service callback.
171 * A services discovery module invokes this function when it "discovers" a new
172 * service, i.e. a new input item.
174 * @note This callback does not take ownership of the input item; it might
175 * however (and most probably will) add one of more references to the item.
177 * The caller is responsible for releasing its own reference(s) eventually.
178 * Keeping a reference is necessary to call services_discovery_RemoveItem() or
179 * to alter the item later. However, if the caller will never remove nor alter
180 * the item, it can drop its reference(s) immediately.
182 * @param sd services discoverer / services discovery module instance
183 * @param item input item to add
185 static inline void services_discovery_AddSubItem(services_discovery_t *sd,
186 input_item_t *parent,
187 input_item_t *item)
189 sd->owner.cbs->item_added(sd, parent, item, NULL);
193 * Added service backward compatibility callback.
195 * @param category Optional name of a group that the item belongs in
196 * (for backward compatibility with legacy modules)
198 VLC_DEPRECATED
199 static inline void services_discovery_AddItemCat(services_discovery_t *sd,
200 input_item_t *item,
201 const char *category)
203 sd->owner.cbs->item_added(sd, NULL, item, category);
207 * Removed service callback.
209 * A services discovery module invokes this function when it senses that a
210 * service is no longer available.
212 static inline void services_discovery_RemoveItem(services_discovery_t *sd,
213 input_item_t *item)
215 sd->owner.cbs->item_removed(sd, item);
218 /* SD probing */
220 VLC_API int vlc_sd_probe_Add(vlc_probe_t *, const char *, const char *, int category);
222 #define VLC_SD_PROBE_SUBMODULE \
223 add_submodule() \
224 set_capability( "services probe", 100 ) \
225 set_callbacks( vlc_sd_probe_Open, NULL )
227 #define VLC_SD_PROBE_HELPER(name, longname, cat) \
228 static int vlc_sd_probe_Open (vlc_object_t *obj) \
230 return vlc_sd_probe_Add ((struct vlc_probe_t *)obj, name, \
231 longname, cat); \
234 /** @} */
235 # ifdef __cplusplus
237 # endif
239 #endif