]> git.sesse.net Git - vlc/blob - test/libvlc/media.c
Use var_InheritString for --decklink-video-connection.
[vlc] / test / libvlc / media.c
1 /*
2  * media_player.c - libvlc smoke test
3  *
4  * $Id$
5  */
6
7 /**********************************************************************
8  *  Copyright (C) 2010 Pierre d'Herbemont.                            *
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     // We use this image file because "empty.voc" has no track.
37     const char * file = SRCDIR"/samples/image.jpg";
38
39     log ("Testing set_media\n");
40
41     libvlc_instance_t *vlc = libvlc_new (argc, argv);
42     assert (vlc != NULL);
43
44     libvlc_media_t *media = libvlc_media_new_path (vlc, file);
45     assert (media != NULL);
46
47     volatile int received = false;
48
49     // Check to see if we are properly receiving the event.
50     libvlc_event_manager_t *em = libvlc_media_event_manager (media);
51     libvlc_event_attach (em, libvlc_MediaParsedChanged, preparsed_changed, (void*)&received);
52
53     // Parse the media. This is synchronous.
54     libvlc_media_parse(media);
55
56     // Wait to see if we properly receive preparsed.
57     while (!received);
58
59     // We are good, now check Elementary Stream info.
60     libvlc_media_track_info_t *tracks = NULL;
61     int num = libvlc_media_get_tracks_info(media, &tracks);
62
63 #warning libvlc_media_get_tracks_info is a broken function.
64     // This is broken.
65     // assert(num == 1);
66     if (num != 1)
67         printf("WARNING: libvlc_media_get_tracks_info is not working.");
68
69     if (num > 0)
70         free(tracks);
71
72     libvlc_media_release (media);
73     libvlc_release (vlc);
74 }
75
76 int main (void)
77 {
78     test_init();
79
80     test_media_preparsed (test_defaults_args, test_defaults_nargs);
81
82     return 0;
83 }