1 /*****************************************************************************
2 * renderer_discoverer.c - libvlc smoke test
3 *****************************************************************************
4 * Copyright © 2016 VLC authors, and VideoLAN
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU Lesser General Public License as published by
8 * the Free Software Foundation; either version 2.1 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public License
17 * along with this program; if not, write to the Free Software Foundation,
18 * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
19 *****************************************************************************/
26 item_event(const libvlc_renderer_item_t
*p_item
, const char *psz_event
)
28 test_log("item %s: name: '%s', type: '%s', flags: 0x%X\n", psz_event
,
29 libvlc_renderer_item_name(p_item
), libvlc_renderer_item_type(p_item
),
30 libvlc_renderer_item_flags(p_item
));
34 renderer_discoverer_item_added(const struct libvlc_event_t
*p_ev
, void *p_data
)
37 item_event(p_ev
->u
.renderer_discoverer_item_added
.item
, "added");
41 renderer_discoverer_item_deleted(const struct libvlc_event_t
*p_ev
, void *p_data
)
44 item_event(p_ev
->u
.renderer_discoverer_item_deleted
.item
, "deleted");
48 test_discoverer(libvlc_instance_t
*p_vlc
, const char *psz_name
)
50 test_log("creating and starting discoverer %s\n", psz_name
);
52 libvlc_renderer_discoverer_t
*p_rd
=
53 libvlc_renderer_discoverer_new(p_vlc
, psz_name
);
56 libvlc_event_manager_t
*p_evm
= libvlc_renderer_discoverer_event_manager(p_rd
);
60 i_ret
= libvlc_event_attach(p_evm
, libvlc_RendererDiscovererItemAdded
,
61 renderer_discoverer_item_added
, NULL
);
63 i_ret
= libvlc_event_attach(p_evm
, libvlc_RendererDiscovererItemDeleted
,
64 renderer_discoverer_item_deleted
, NULL
);
67 if (libvlc_renderer_discoverer_start(p_rd
) == -1)
69 test_log("warn: could not start md (not critical)\n");
73 test_log("Press any keys to stop\n");
75 libvlc_renderer_discoverer_stop(p_rd
);
78 libvlc_renderer_discoverer_release(p_rd
);
82 main(int i_argc
, char *ppsz_argv
[])
86 char *psz_test_name
= i_argc
> 1 ? ppsz_argv
[1] : NULL
;
88 libvlc_instance_t
*p_vlc
= libvlc_new(test_defaults_nargs
,
90 assert(p_vlc
!= NULL
);
92 if (psz_test_name
!= NULL
)
94 /* Test a specific service discovery from command line */
96 test_discoverer(p_vlc
, psz_test_name
);
97 libvlc_release(p_vlc
);
101 test_log("== getting the list of renderer_discoverer ==\n");
103 libvlc_rd_description_t
**pp_services
;
105 libvlc_renderer_discoverer_list_get(p_vlc
, &pp_services
);
108 test_log("warn: no discoverers (not critical)\n");
111 assert(pp_services
!= NULL
);
113 for (unsigned int i
= 0; i
< i_count
; ++i
)
115 libvlc_rd_description_t
*p_service
= pp_services
[i
];
117 test_log("= discoverer: name: '%s', longname: '%s' =\n",
118 p_service
->psz_name
, p_service
->psz_longname
);
121 libvlc_renderer_discoverer_list_release(pp_services
, i_count
);
124 libvlc_release(p_vlc
);