]> git.sesse.net Git - vlc/blob - test/libvlc/media.c
03efe263ad54c23532bb821634d56f28209d2a55
[vlc] / test / libvlc / media.c
1 /*
2  * media_player.c - libvlc smoke test
3  *
4  * $Id$
5  */
6
7 /**********************************************************************
8  *  Copyright (C) 2007 RĂ©mi Denis-Courmont.                           *
9  *  This program is free software; you can redistribute and/or modify *
10  *  it under the terms of the GNU General Public License as published *
11  *  by the Free Software Foundation; version 2 of the license, or (at *
12  *  your option) any later version.                                   *
13  *                                                                    *
14  *  This program is distributed in the hope that it will be useful,   *
15  *  but WITHOUT ANY WARRANTY; without even the implied warranty of    *
16  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.              *
17  *  See the GNU General Public License for more details.              *
18  *                                                                    *
19  *  You should have received a copy of the GNU General Public License *
20  *  along with this program; if not, you can get it from:             *
21  *  http://www.gnu.org/copyleft/gpl.html                              *
22  **********************************************************************/
23
24 #include "test.h"
25
26 static void preparsed_changed(const libvlc_event_t *event, void *user_data)
27 {
28     (void)event;
29
30     int *received = user_data;
31     *received = true;
32 }
33
34 static void test_media_preparsed(const char** argv, int argc)
35 {
36     const char * file = test_default_sample;
37
38     log ("Testing set_media\n");
39
40     libvlc_instance_t *vlc = libvlc_new (argc, argv);
41     assert (vlc != NULL);
42
43     libvlc_media_t *media = libvlc_media_new_path (vlc, file);
44     assert (media != NULL);
45
46     int received = false;
47
48     // Force preparsing. FIXME - Expose a better API for that.
49     libvlc_media_es_t *es;
50     int num = libvlc_media_get_es(media, &es);
51     free(es);
52
53     libvlc_event_manager_t *em = libvlc_media_event_manager (media);
54     libvlc_event_attach (em, libvlc_MediaPreparsedChanged, preparsed_changed, &received);
55
56     // Wait to see if we properly receive preparsed.
57     while (!received);
58
59     // We are good, now check Elementary Stream info.
60     num = libvlc_media_get_es(media, &es);
61     assert(num > 0);
62     free(es);
63
64     libvlc_media_release (media);
65     libvlc_release (vlc);
66 }
67
68 int main (void)
69 {
70     test_init();
71
72     test_media_preparsed (test_defaults_args, test_defaults_nargs);
73
74     return 0;
75 }