vlc_renderer_discovery.h 6.16 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
/*****************************************************************************
 * vlc_renderer_discovery.h : Renderer Discovery functions
 *****************************************************************************
 * Copyright (C) 2016 VLC authors and VideoLAN
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation; either version 2.1 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program; if not, write to the Free Software Foundation,
 * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
 *****************************************************************************/

#ifndef VLC_RENDERER_DISCOVERY_H
#define VLC_RENDERER_DISCOVERY_H 1

#include <vlc_input.h>
#include <vlc_probe.h>
#include <vlc_url.h>

/**
 * @defgroup vlc_renderer VLC renderer discovery
 * @{
 *
 * @file
 * This file declares VLC renderer discvoery structures and functions
 *
 * @defgroup vlc_renderer_item VLC renderer items returned by the discovery
 * @{
 */

#define VLC_RENDERER_CAN_AUDIO 0x0001
#define VLC_RENDERER_CAN_VIDEO 0x0002

/**
 * Create a new renderer item
 *
45
 * @param psz_type type of the item
46 47 48 49
 * @param psz_name name of the item
 * @param psz_uri uri of the renderer item, must contains a valid protocol and
 * a valid host
 * @param psz_extra_sout extra sout options
50
 * @param psz_demux_filter demux filter to use with the renderer
51 52 53 54
 * @param psz_icon_uri icon uri of the renderer item
 * @param i_flags flags for the item
 * @return a renderer item or NULL in case of error
 */
55
VLC_API vlc_renderer_item_t *
56 57
vlc_renderer_item_new(const char *psz_type, const char *psz_name,
                      const char *psz_uri, const char *psz_extra_sout,
58 59
                      const char *psz_demux_filter, const char *psz_icon_uri,
                      int i_flags) VLC_USED;
60 61 62 63

/**
 * Hold a renderer item, i.e. creates a new reference
 */
64 65
VLC_API vlc_renderer_item_t *
vlc_renderer_item_hold(vlc_renderer_item_t *p_item);
66 67 68 69 70

/**
 * Releases a renderer item, i.e. decrements its reference counter
 */
VLC_API void
71
vlc_renderer_item_release(vlc_renderer_item_t *p_item);
72 73 74 75 76

/**
 * Get the human readable name of a renderer item
 */
VLC_API const char *
77
vlc_renderer_item_name(const vlc_renderer_item_t *p_item);
78

79 80 81 82 83 84 85
/**
 * Get the type (not translated) of a renderer item. For now, the type can only
 * be "chromecast" ("upnp", "airplay" may come later).
 */
VLC_API const char *
vlc_renderer_item_type(const vlc_renderer_item_t *p_item);

86 87 88 89 90 91
/**
 * Get the demux filter to use with a renderer item
 */
VLC_API const char *
vlc_renderer_item_demux_filter(const vlc_renderer_item_t *p_item);

92 93 94 95
/**
 * Get the sout command of a renderer item
 */
VLC_API const char *
96
vlc_renderer_item_sout(const vlc_renderer_item_t *p_item);
97 98 99 100 101

/**
 * Get the icon uri of a renderer item
 */
VLC_API const char *
102
vlc_renderer_item_icon_uri(const vlc_renderer_item_t *p_item);
103 104 105 106 107

/**
 * Get the flags of a renderer item
 */
VLC_API int
108
vlc_renderer_item_flags(const vlc_renderer_item_t *p_item);
109 110 111 112 113 114 115 116

/**
 * @}
 * @defgroup vlc_renderer_discovery VLC renderer discovery interface
 * @{
 */

typedef struct vlc_renderer_discovery_sys vlc_renderer_discovery_sys;
117
struct vlc_renderer_discovery_owner;
118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142

/**
 * Return a list of renderer discovery modules
 *
 * @param pppsz_names a pointer to a list of module name, NULL terminated
 * @param pppsz_longnames a pointer to a list of module longname, NULL
 * terminated
 *
 * @return VLC_SUCCESS on success, or VLC_EGENERIC on error
 */
VLC_API int
vlc_rd_get_names(vlc_object_t *p_obj, char ***pppsz_names,
                 char ***pppsz_longnames) VLC_USED;
#define vlc_rd_get_names(a, b, c) \
        vlc_rd_get_names(VLC_OBJECT(a), b, c)

/**
 * Create a new renderer discovery module
 *
 * @param psz_name name of the module to load, see vlc_rd_get_names() to get
 * the list of names
 *
 * @return a valid vlc_renderer_discovery, need to be released with
 * vlc_rd_release()
 */
143
VLC_API vlc_renderer_discovery_t *
144 145
vlc_rd_new(vlc_object_t *p_obj, const char *psz_name,
           const struct vlc_renderer_discovery_owner *owner) VLC_USED;
146

147
VLC_API void vlc_rd_release(vlc_renderer_discovery_t *p_rd);
148 149 150 151 152 153 154

/**
 * @}
 * @defgroup vlc_renderer_discovery_module VLC renderer module
 * @{
 */

155 156 157 158 159 160 161 162 163
struct vlc_renderer_discovery_owner
{
    void *sys;
    void (*item_added)(struct vlc_renderer_discovery_t *,
                       struct vlc_renderer_item_t *);
    void (*item_removed)(struct vlc_renderer_discovery_t *,
                         struct vlc_renderer_item_t *);
};

164
struct vlc_renderer_discovery_t
165 166 167 168
{
    VLC_COMMON_MEMBERS
    module_t *          p_module;

169
    struct vlc_renderer_discovery_owner owner;
170 171 172 173 174 175 176 177 178 179 180 181

    char *              psz_name;
    config_chain_t *    p_cfg;

    vlc_renderer_discovery_sys *p_sys;
};

/**
 * Add a new renderer item
 *
 * This will send the vlc_RendererDiscoveryItemAdded event
 */
182 183 184 185 186
static inline void vlc_rd_add_item(vlc_renderer_discovery_t * p_rd,
                                   vlc_renderer_item_t * p_item)
{
    p_rd->owner.item_added(p_rd, p_item);
}
187 188 189 190 191 192

/**
 * Add a new renderer item
 *
 * This will send the vlc_RendererDiscoveryItemRemoved event
 */
193 194 195 196 197
static inline void vlc_rd_remove_item(vlc_renderer_discovery_t * p_rd,
                                      vlc_renderer_item_t * p_item)
{
    p_rd->owner.item_removed(p_rd, p_item);
}
198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219

/**
 * Renderer Discovery proble helpers
 */
VLC_API int
vlc_rd_probe_add(vlc_probe_t *p_probe, const char *psz_name,
                 const char *psz_longname);

#define VLC_RD_PROBE_HELPER(name, longname) \
static int vlc_rd_probe_open(vlc_object_t *obj) \
{ \
    return vlc_rd_probe_add((struct vlc_probe_t *)obj, name, longname); \
}

#define VLC_RD_PROBE_SUBMODULE \
    add_submodule() \
        set_capability("renderer probe", 100) \
        set_callbacks(vlc_rd_probe_open, NULL)

/** @} @} */

#endif