2 * testapi.c - libvlc smoke test
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. *
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. *
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 **********************************************************************/
27 #include <vlc/libvlc.h>
36 static libvlc_exception_t ex;
38 static void catch (void)
40 if (libvlc_exception_raised (&ex))
42 fprintf (stderr, "Exception: %s\n",
43 libvlc_exception_get_message (&ex));
47 assert (libvlc_exception_get_message (&ex) == NULL);
48 libvlc_exception_clear (&ex);
51 static void test_core (const char ** argv, int argc);
52 static void test_media_list (const char ** argv, int argc);
54 static void test_core (const char ** argv, int argc)
56 libvlc_instance_t *vlc;
59 libvlc_exception_init (&ex);
60 vlc = libvlc_new (argc, argv, &ex);
63 libvlc_playlist_clear (vlc, &ex);
66 id = libvlc_playlist_add_extended (vlc, "/dev/null", "Test", 0, NULL,
70 libvlc_playlist_clear (vlc, &ex);
74 libvlc_release (vlc, &ex);
76 libvlc_release (vlc, &ex);
80 static void test_media_list (const char ** argv, int argc)
82 libvlc_instance_t *vlc;
83 libvlc_media_descriptor_t *md;
84 libvlc_media_list_t *ml;
86 libvlc_exception_init (&ex);
87 vlc = libvlc_new (argc, argv, &ex);
90 ml = libvlc_media_list_new (vlc, &ex);
93 md = libvlc_media_descriptor_new (vlc, "/dev/null", &ex);
96 libvlc_media_list_add_media_descriptor (ml, md, &ex);
98 libvlc_media_list_add_media_descriptor (ml, md, &ex);
101 assert( libvlc_media_list_count (ml, &ex) == 2 );
104 libvlc_media_descriptor_release (md);
106 libvlc_media_list_release (ml);
108 libvlc_release (vlc, &ex);
112 int main (int argc, char *argv[])
114 const char *args[argc + 3];
115 int nlibvlc_args = sizeof (args) / sizeof (args[0]);
117 alarm (30); /* Make sure "make check" does not get stuck */
122 args[3] = "--plugin-path=../modules";
123 for (int i = 1; i < argc; i++)
124 args[i + 3] = argv[i];
126 test_core (args, nlibvlc_args);
128 test_media_list (args, nlibvlc_args);