vlc_services_discovery.h

Go to the documentation of this file.
00001 /*****************************************************************************
00002  * vlc_services_discovery.h : Services Discover functions
00003  *****************************************************************************
00004  * Copyright (C) 1999-2004 VLC authors and VideoLAN
00005  * $Id: d9c231b28f3ec075343e0f8016792b8fa33f60f5 $
00006  *
00007  * Authors: Pierre d'Herbemont <pdherbemont # videolan.org>
00008  *
00009  * This program is free software; you can redistribute it and/or modify it
00010  * under the terms of the GNU Lesser General Public License as published by
00011  * the Free Software Foundation; either version 2.1 of the License, or
00012  * (at your option) any later version.
00013  *
00014  * This program is distributed in the hope that it will be useful,
00015  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00016  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00017  * GNU Lesser General Public License for more details.
00018  *
00019  * You should have received a copy of the GNU Lesser General Public License
00020  * along with this program; if not, write to the Free Software Foundation,
00021  * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
00022  *****************************************************************************/
00023 
00024 #ifndef VLC_SERVICES_DISCOVERY_H_
00025 #define VLC_SERVICES_DISCOVERY_H_
00026 
00027 #include <vlc_input.h>
00028 #include <vlc_events.h>
00029 #include <vlc_probe.h>
00030 
00031 /**
00032  * \file
00033  * This file lists functions and structures for service discovery (SD) in vlc
00034  */
00035 
00036 # ifdef __cplusplus
00037 extern "C" {
00038 # endif
00039 
00040 /**
00041  * @{
00042  */
00043 
00044 /**
00045  * Main service discovery structure to build a SD module
00046  */
00047 struct services_discovery_t
00048 {
00049     VLC_COMMON_MEMBERS
00050     module_t *          p_module;             /**< Loaded module */
00051 
00052     /**< Event manager
00053      * You should access it through setters, outside of the core */
00054     vlc_event_manager_t event_manager;
00055 
00056     char *psz_name;                           /**< Main name of the SD */
00057     config_chain_t *p_cfg;                    /**< Configuration for the SD */
00058 
00059     /** Control function
00060      * \see services_discovery_command_e
00061      */
00062     int ( *pf_control ) ( services_discovery_t *, int, va_list );
00063 
00064     services_discovery_sys_t *p_sys;          /**< Custom private data */
00065 };
00066 
00067 /**
00068  * Service discovery categories
00069  * \see vlc_sd_probe_Add
00070  */
00071 enum services_discovery_category_e
00072 {
00073     SD_CAT_DEVICES = 1,           /**< Devices, like portable music players */
00074     SD_CAT_LAN,                   /**< LAN/WAN services, like Upnp or SAP */
00075     SD_CAT_INTERNET,              /**< Internet or Website channels services */
00076     SD_CAT_MYCOMPUTER             /**< Computer services, like Discs or Apps */
00077 };
00078 
00079 /**
00080  * Service discovery control commands
00081  */
00082 enum services_discovery_command_e
00083 {
00084     SD_CMD_SEARCH = 1,          /**< arg1 = query */
00085     SD_CMD_DESCRIPTOR           /**< arg1 = services_discovery_descriptor_t* */
00086 };
00087 
00088 /**
00089  * Service discovery capabilities
00090  */
00091 enum services_discovery_capability_e
00092 {
00093     SD_CAP_SEARCH = 1           /**< One can search in the SD */
00094 };
00095 
00096 /**
00097  * Service discovery descriptor
00098  * \see services_discovery_command_e
00099  */
00100 typedef struct
00101 {
00102     char *psz_short_desc;       /**< The short description, human-readable */
00103     char *psz_icon_url;         /**< URL to the icon that represents it */
00104     char *psz_url;              /**< URL for the service */
00105     int   i_capabilities;       /**< \see services_discovery_capability_e */
00106 } services_discovery_descriptor_t;
00107 
00108 
00109 /***********************************************************************
00110  * Service Discovery
00111  ***********************************************************************/
00112 
00113 /**
00114  * Ask for a research in the SD
00115  * @param p_sd: the Service Discovery
00116  * @param i_control: the command to issue
00117  * @param args: the argument list
00118  * @return VLC_SUCCESS in case of success, the error code overwise
00119  */
00120 static inline int vlc_sd_control( services_discovery_t *p_sd, int i_control, va_list args )
00121 {
00122     if( p_sd->pf_control )
00123         return p_sd->pf_control( p_sd, i_control, args );
00124     else
00125         return VLC_EGENERIC;
00126 }
00127 
00128 /* Get the services discovery modules names to use in Create(), in a null
00129  * terminated string array. Array and string must be freed after use. */
00130 VLC_API char ** vlc_sd_GetNames( vlc_object_t *, char ***, int ** ) VLC_USED;
00131 #define vlc_sd_GetNames(obj, pln, pcat ) \
00132         vlc_sd_GetNames(VLC_OBJECT(obj), pln, pcat)
00133 
00134 /* Creation of a services_discovery object */
00135 VLC_API services_discovery_t * vlc_sd_Create( vlc_object_t *, const char * ) VLC_USED;
00136 VLC_API bool vlc_sd_Start( services_discovery_t * );
00137 VLC_API void vlc_sd_Stop( services_discovery_t * );
00138 VLC_API void vlc_sd_Destroy( services_discovery_t * );
00139 
00140 /**
00141  * Helper to stop and destroy the Service Discovery
00142  */
00143 static inline void vlc_sd_StopAndDestroy( services_discovery_t * p_this )
00144 {
00145     vlc_sd_Stop( p_this );
00146     vlc_sd_Destroy( p_this );
00147 }
00148 
00149 /* Read info from discovery object */
00150 VLC_API char * services_discovery_GetLocalizedName( services_discovery_t * p_this ) VLC_USED;
00151 
00152 /* Receive event notification (preferred way to get new items) */
00153 VLC_API vlc_event_manager_t * services_discovery_EventManager( services_discovery_t * p_this ) VLC_USED;
00154 
00155 /* Used by services_discovery to post update about their items */
00156     /* About the psz_category, it is a legacy way to add info to the item,
00157      * for more options, directly set the (meta) data on the input item */
00158 VLC_API void services_discovery_AddItem( services_discovery_t * p_this, input_item_t * p_item, const char * psz_category );
00159 VLC_API void services_discovery_RemoveItem( services_discovery_t * p_this, input_item_t * p_item );
00160 VLC_API void services_discovery_RemoveAll( services_discovery_t * p_sd );
00161 
00162 
00163 /* SD probing */
00164 
00165 VLC_API int vlc_sd_probe_Add(vlc_probe_t *, const char *, const char *, int category);
00166 
00167 #define VLC_SD_PROBE_SUBMODULE \
00168     add_submodule() \
00169         set_capability( "services probe", 100 ) \
00170         set_callbacks( vlc_sd_probe_Open, NULL )
00171 
00172 #define VLC_SD_PROBE_HELPER(name, longname, cat) \
00173 static int vlc_sd_probe_Open (vlc_object_t *obj) \
00174 { \
00175     return vlc_sd_probe_Add ((struct vlc_probe_t *)obj, \
00176                              name "{longname=\"" longname "\"}", \
00177                              longname, cat); \
00178 }
00179 
00180 /** @} */
00181 # ifdef __cplusplus
00182 }
00183 # endif
00184 
00185 #endif
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines