vlc_renderer_discovery.h 6.19 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
/*****************************************************************************
 * 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
30
 * @ingroup interface
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
 * @{
 *
 * @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
 *
46
 * @param psz_type type of the item
47 48 49 50
 * @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
51
 * @param psz_demux_filter demux filter to use with the renderer
52 53 54 55
 * @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
 */
Thomas Guillem's avatar
Thomas Guillem committed
56
VLC_API vlc_renderer_item_t *
57 58
vlc_renderer_item_new(const char *psz_type, const char *psz_name,
                      const char *psz_uri, const char *psz_extra_sout,
59 60
                      const char *psz_demux_filter, const char *psz_icon_uri,
                      int i_flags) VLC_USED;
61 62 63 64

/**
 * Hold a renderer item, i.e. creates a new reference
 */
Thomas Guillem's avatar
Thomas Guillem committed
65 66
VLC_API vlc_renderer_item_t *
vlc_renderer_item_hold(vlc_renderer_item_t *p_item);
67 68 69 70 71

/**
 * Releases a renderer item, i.e. decrements its reference counter
 */
VLC_API void
Thomas Guillem's avatar
Thomas Guillem committed
72
vlc_renderer_item_release(vlc_renderer_item_t *p_item);
73 74 75 76 77

/**
 * Get the human readable name of a renderer item
 */
VLC_API const char *
Thomas Guillem's avatar
Thomas Guillem committed
78
vlc_renderer_item_name(const vlc_renderer_item_t *p_item);
79

80 81 82 83 84 85 86
/**
 * 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);

87 88 89 90 91 92
/**
 * 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);

93 94 95 96
/**
 * Get the sout command of a renderer item
 */
VLC_API const char *
Thomas Guillem's avatar
Thomas Guillem committed
97
vlc_renderer_item_sout(const vlc_renderer_item_t *p_item);
98 99 100 101 102

/**
 * Get the icon uri of a renderer item
 */
VLC_API const char *
Thomas Guillem's avatar
Thomas Guillem committed
103
vlc_renderer_item_icon_uri(const vlc_renderer_item_t *p_item);
104 105 106 107 108

/**
 * Get the flags of a renderer item
 */
VLC_API int
Thomas Guillem's avatar
Thomas Guillem committed
109
vlc_renderer_item_flags(const vlc_renderer_item_t *p_item);
110 111 112 113 114 115 116 117

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

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

/**
 * 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()
 */
Thomas Guillem's avatar
Thomas Guillem committed
144
VLC_API vlc_renderer_discovery_t *
145 146
vlc_rd_new(vlc_object_t *p_obj, const char *psz_name,
           const struct vlc_renderer_discovery_owner *owner) VLC_USED;
147

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

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

156 157 158 159 160 161 162 163 164
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 *);
};

Thomas Guillem's avatar
Thomas Guillem committed
165
struct vlc_renderer_discovery_t
166
{
167
    struct vlc_common_members obj;
168 169
    module_t *          p_module;

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

    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
 */
183 184 185 186 187
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);
}
188 189 190 191 192 193

/**
 * Add a new renderer item
 *
 * This will send the vlc_RendererDiscoveryItemRemoved event
 */
194 195 196 197 198
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);
}
199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220

/**
 * 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