2 * media_player.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 **********************************************************************/
26 static void wait_playing(libvlc_media_player_t
*mp
)
30 state
= libvlc_media_player_get_state (mp
);
31 } while(state
!= libvlc_Playing
&&
32 state
!= libvlc_Error
&&
33 state
!= libvlc_Ended
);
35 state
= libvlc_media_player_get_state (mp
);
36 assert(state
== libvlc_Playing
|| state
== libvlc_Ended
);
39 static void wait_paused(libvlc_media_player_t
*mp
)
43 state
= libvlc_media_player_get_state (mp
);
44 } while(state
!= libvlc_Paused
&&
45 state
!= libvlc_Ended
);
47 state
= libvlc_media_player_get_state (mp
);
48 assert(state
== libvlc_Paused
|| state
== libvlc_Ended
);
51 /* Test a bunch of A/V properties. This most does nothing since the current
52 * test file contains a dummy audio track. This is a smoke test. */
53 static void test_audio_video(libvlc_media_player_t
*mp
)
55 bool fs
= libvlc_get_fullscreen(mp
);
56 libvlc_set_fullscreen(mp
, true);
57 assert(libvlc_get_fullscreen(mp
));
58 libvlc_set_fullscreen(mp
, false);
59 assert(!libvlc_get_fullscreen(mp
));
60 libvlc_toggle_fullscreen(mp
);
61 assert(libvlc_get_fullscreen(mp
));
62 libvlc_toggle_fullscreen(mp
);
63 assert(!libvlc_get_fullscreen(mp
));
64 libvlc_set_fullscreen(mp
, fs
);
65 assert(libvlc_get_fullscreen(mp
) == fs
);
67 assert(libvlc_video_get_scale(mp
) == 0.); /* default */
68 libvlc_video_set_scale(mp
, 0.); /* no-op */
69 libvlc_video_set_scale(mp
, 2.5);
70 assert(libvlc_video_get_scale(mp
) == 2.5);
71 libvlc_video_set_scale(mp
, 0.);
72 libvlc_video_set_scale(mp
, 0.); /* no-op */
73 assert(libvlc_video_get_scale(mp
) == 0.);
75 libvlc_audio_output_device_t
*aouts
= libvlc_audio_output_device_enum(mp
);
76 for (libvlc_audio_output_device_t
*e
= aouts
; e
!= NULL
; e
= e
->p_next
)
78 libvlc_audio_output_device_set( mp
, NULL
, e
->psz_device
);
80 libvlc_audio_output_device_list_release( aouts
);
83 static void test_role(libvlc_media_player_t
*mp
)
87 /* Test default value */
88 assert(libvlc_media_player_get_role(mp
) == libvlc_role_Video
);
90 for (role
= 0; libvlc_media_player_set_role(mp
, role
) == 0; role
++)
91 assert(libvlc_media_player_get_role(mp
) == role
);
93 assert(role
> libvlc_role_Last
);
96 static void test_media_player_set_media(const char** argv
, int argc
)
98 const char * file
= test_default_sample
;
100 test_log ("Testing set_media\n");
102 libvlc_instance_t
*vlc
= libvlc_new (argc
, argv
);
103 assert (vlc
!= NULL
);
105 libvlc_media_t
*md
= libvlc_media_new_path (vlc
, file
);
108 libvlc_media_player_t
*mp
= libvlc_media_player_new (vlc
);
111 libvlc_media_player_set_media (mp
, md
);
113 libvlc_media_release (md
);
115 libvlc_media_player_play (mp
);
119 libvlc_media_player_stop (mp
);
120 libvlc_media_player_release (mp
);
121 libvlc_release (vlc
);
124 static void test_media_player_play_stop(const char** argv
, int argc
)
126 libvlc_instance_t
*vlc
;
128 libvlc_media_player_t
*mi
;
129 const char * file
= test_default_sample
;
131 test_log ("Testing play and pause of %s\n", file
);
133 vlc
= libvlc_new (argc
, argv
);
134 assert (vlc
!= NULL
);
136 md
= libvlc_media_new_path (vlc
, file
);
139 mi
= libvlc_media_player_new_from_media (md
);
142 libvlc_media_release (md
);
144 libvlc_media_player_play (mi
);
148 libvlc_media_player_stop (mi
);
149 libvlc_media_player_release (mi
);
150 libvlc_release (vlc
);
153 static void test_media_player_pause_stop(const char** argv
, int argc
)
155 libvlc_instance_t
*vlc
;
157 libvlc_media_player_t
*mi
;
158 const char * file
= test_default_sample
;
160 test_log ("Testing pause and stop of %s\n", file
);
162 vlc
= libvlc_new (argc
, argv
);
163 assert (vlc
!= NULL
);
165 md
= libvlc_media_new_path (vlc
, file
);
168 mi
= libvlc_media_player_new_from_media (md
);
171 libvlc_media_release (md
);
173 test_audio_video(mi
);
176 libvlc_media_player_play (mi
);
177 test_log ("Waiting for playing\n");
179 test_audio_video(mi
);
181 libvlc_media_player_set_pause (mi
, true);
182 test_log ("Waiting for pause\n");
184 test_audio_video(mi
);
186 libvlc_media_player_stop (mi
);
187 test_audio_video(mi
);
189 libvlc_media_player_release (mi
);
190 libvlc_release (vlc
);
198 test_media_player_set_media (test_defaults_args
, test_defaults_nargs
);
199 test_media_player_play_stop (test_defaults_args
, test_defaults_nargs
);
200 test_media_player_pause_stop (test_defaults_args
, test_defaults_nargs
);