[vlc-commits] renderer: add vlc_renderer_item_type
Thomas Guillem
git at videolan.org
Tue Sep 20 11:10:04 CEST 2016
vlc | branch: master | Thomas Guillem <thomas at gllm.fr> | Tue Sep 20 10:28:13 2016 +0200| [4fbe397b3172c1cccb7b5cd6dc1c30a60afe0fed] | committer: Thomas Guillem
renderer: add vlc_renderer_item_type
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=4fbe397b3172c1cccb7b5cd6dc1c30a60afe0fed
---
include/vlc_renderer_discovery.h | 14 +++++++++++---
modules/services_discovery/microdns.c | 3 ++-
src/libvlccore.sym | 1 +
src/misc/renderer_discovery.c | 19 ++++++++++++++++---
4 files changed, 30 insertions(+), 7 deletions(-)
diff --git a/include/vlc_renderer_discovery.h b/include/vlc_renderer_discovery.h
index 585dcf2..e922df2 100644
--- a/include/vlc_renderer_discovery.h
+++ b/include/vlc_renderer_discovery.h
@@ -43,6 +43,7 @@
/**
* Create a new renderer item
*
+ * @param psz_type type of the item
* @param psz_name name of the item
* @param psz_uri uri of the renderer item, must contains a valid protocol and
* a valid host
@@ -52,9 +53,9 @@
* @return a renderer item or NULL in case of error
*/
VLC_API vlc_renderer_item_t *
-vlc_renderer_item_new(const char *psz_name, const char *psz_uri,
- const char *psz_extra_sout, const char *psz_icon_uri,
- int i_flags) VLC_USED;
+vlc_renderer_item_new(const char *psz_type, const char *psz_name,
+ const char *psz_uri, const char *psz_extra_sout,
+ const char *psz_icon_uri, int i_flags) VLC_USED;
/**
* Hold a renderer item, i.e. creates a new reference
@@ -75,6 +76,13 @@ VLC_API const char *
vlc_renderer_item_name(const vlc_renderer_item_t *p_item);
/**
+ * 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);
+
+/**
* Get the sout command of a renderer item
*/
VLC_API const char *
diff --git a/modules/services_discovery/microdns.c b/modules/services_discovery/microdns.c
index 641e306..fb417a6 100644
--- a/modules/services_discovery/microdns.c
+++ b/modules/services_discovery/microdns.c
@@ -192,7 +192,8 @@ items_add_renderer( struct discovery_sys *p_sys, vlc_renderer_discovery_t *p_rd,
const char *psz_extra_uri = i_flags & VLC_RENDERER_CAN_VIDEO ? NULL : "video=0";
vlc_renderer_item_t *p_renderer_item =
- vlc_renderer_item_new( psz_name, psz_uri, psz_extra_uri, psz_icon_uri, i_flags );
+ vlc_renderer_item_new( "chromecast", psz_name, psz_uri, psz_extra_uri,
+ psz_icon_uri, i_flags );
if( p_renderer_item == NULL )
{
free( psz_uri );
diff --git a/src/libvlccore.sym b/src/libvlccore.sym
index e3fd6e5..d9d94e0 100644
--- a/src/libvlccore.sym
+++ b/src/libvlccore.sym
@@ -764,6 +764,7 @@ vlc_renderer_item_new
vlc_renderer_item_hold
vlc_renderer_item_release
vlc_renderer_item_name
+vlc_renderer_item_type
vlc_renderer_item_sout
vlc_renderer_item_icon_uri
vlc_renderer_item_flags
diff --git a/src/misc/renderer_discovery.c b/src/misc/renderer_discovery.c
index 4ef03d7..a8ad1c0 100644
--- a/src/misc/renderer_discovery.c
+++ b/src/misc/renderer_discovery.c
@@ -35,6 +35,7 @@
struct vlc_renderer_item_t
{
char *psz_name;
+ char *psz_type;
char *psz_sout;
char *psz_icon_uri;
int i_flags;
@@ -45,15 +46,16 @@ static void
item_free(vlc_renderer_item_t *p_item)
{
free(p_item->psz_name);
+ free(p_item->psz_type);
free(p_item->psz_sout);
free(p_item->psz_icon_uri);
free(p_item);
}
vlc_renderer_item_t *
-vlc_renderer_item_new(const char *psz_name, const char *psz_uri,
- const char *psz_extra_sout, const char *psz_icon_uri,
- int i_flags)
+vlc_renderer_item_new(const char *psz_type, const char *psz_name,
+ const char *psz_uri, const char *psz_extra_sout,
+ const char *psz_icon_uri, int i_flags)
{
assert(psz_uri != NULL);
vlc_renderer_item_t *p_item = NULL;
@@ -67,6 +69,9 @@ vlc_renderer_item_new(const char *psz_name, const char *psz_uri,
if (unlikely(p_item == NULL))
goto error;
+ if ((p_item->psz_type = strdup(psz_type)) == NULL)
+ goto error;
+
if (psz_name != NULL)
p_item->psz_name = strdup(psz_name);
else if (asprintf(&p_item->psz_name, "%s (%s)", url.psz_protocol,
@@ -105,6 +110,14 @@ vlc_renderer_item_name(const vlc_renderer_item_t *p_item)
}
const char *
+vlc_renderer_item_type(const vlc_renderer_item_t *p_item)
+{
+ assert(p_item != NULL);
+
+ return p_item->psz_type;
+}
+
+const char *
vlc_renderer_item_sout(const vlc_renderer_item_t *p_item)
{
assert(p_item != NULL);
More information about the vlc-commits
mailing list