]> git.sesse.net Git - vlc/blob - test/libvlc/core.c
Revert "demux: ts: fix mpeg4desc leak"
[vlc] / test / libvlc / core.c
1 /*
2  * core.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 #include <string.h>
27
28 static void test_core (const char ** argv, int argc)
29 {
30     libvlc_instance_t *vlc;
31
32     log ("Testing core\n");
33
34     vlc = libvlc_new (argc, argv);
35     assert (vlc != NULL);
36
37     libvlc_retain (vlc);
38     libvlc_release (vlc);
39     libvlc_release (vlc);
40 }
41
42 static void test_moduledescriptionlist (libvlc_module_description_t *list)
43 {
44     libvlc_module_description_t *module = list;
45     while ( module ) {
46         assert (strlen (module->psz_name) );
47         assert (strlen (module->psz_shortname) );
48         assert (module->psz_longname == NULL || strlen (module->psz_longname));
49         assert (module->psz_help == NULL || strlen (module->psz_help));
50         module = module->p_next;
51     }    
52
53     libvlc_module_description_list_release (list);
54 }
55
56 static void test_audiovideofilterlists (const char ** argv, int argc)
57 {
58     libvlc_instance_t *vlc;
59
60     log ("Testing libvlc_(audio|video)_filter_list_get()\n");
61
62     vlc = libvlc_new (argc, argv);
63     assert (vlc != NULL);
64
65     test_moduledescriptionlist (libvlc_audio_filter_list_get (vlc));
66     test_moduledescriptionlist (libvlc_video_filter_list_get (vlc));
67
68     libvlc_release (vlc);
69 }
70
71 static void test_audio_output (void)
72 {
73     libvlc_instance_t *vlc = libvlc_new (0, NULL);
74     assert (vlc != NULL);
75
76     libvlc_audio_output_t *mods = libvlc_audio_output_list_get (vlc);
77     assert (mods != NULL);
78
79     puts ("Audio outputs:");
80     for (const libvlc_audio_output_t *o = mods; o != NULL; o = o->p_next)
81     {
82         libvlc_audio_output_device_t *devs;
83
84         printf(" %s: %s\n", o->psz_name, o->psz_description);
85
86         devs = libvlc_audio_output_device_list_get (vlc, o->psz_name);
87         if (devs == NULL)
88             continue;
89         for (const libvlc_audio_output_device_t *d = devs;
90              d != NULL;
91              d = d->p_next)
92              printf("  %s: %s\n", d->psz_device, d->psz_description);
93
94         libvlc_audio_output_device_list_release (devs);
95     }
96     libvlc_audio_output_list_release (mods);
97     libvlc_release (vlc);
98 }
99
100 int main (void)
101 {
102     test_init();
103
104     test_core (test_defaults_args, test_defaults_nargs);
105     test_audiovideofilterlists (test_defaults_args, test_defaults_nargs);
106     test_audio_output ();
107
108     return 0;
109 }