2 #include <vlc/libvlc.h>
4 PyObject *exception_test( PyObject *self, PyObject *args )
6 libvlc_exception_t exception;
8 libvlc_exception_init( &exception );
9 ASSERT( !libvlc_exception_raised( &exception) , "Exception raised" );
10 ASSERT( !libvlc_exception_get_message( &exception) , "Exception raised" );
12 libvlc_exception_raise( &exception, NULL );
13 ASSERT( !libvlc_exception_get_message( &exception), "Unexpected message" );
14 ASSERT( libvlc_exception_raised( &exception), "Exception not raised" );
16 libvlc_exception_raise( &exception, "test" );
17 ASSERT( libvlc_exception_get_message( &exception), "No Message" );
18 ASSERT( libvlc_exception_raised( &exception), "Exception not raised" );
20 libvlc_exception_clear( &exception );
21 ASSERT( !libvlc_exception_raised( &exception ), "Exception not cleared" );
27 PyObject *create_destroy( PyObject *self, PyObject *args )
29 libvlc_instance_t *p_instance;
30 char *argv[] = { "vlc", "--quiet" };
32 libvlc_exception_t exception;
33 libvlc_exception_init( &exception );
35 p_instance = libvlc_new( 2, argv, &exception );
37 ASSERT( p_instance != NULL, "Instance creation failed" );
39 ASSERT( !libvlc_exception_raised( &exception ),
40 "Exception raised while creating instance" );
42 libvlc_destroy( p_instance );
48 PyObject *playlist_test( PyObject *self, PyObject *args )
50 libvlc_instance_t *p_instance;
51 char *argv[] = { "vlc", "--quiet" };
52 int i_id, i_playing, i_items;
54 libvlc_exception_t exception;
55 libvlc_exception_init( &exception );
57 p_instance = libvlc_new( 2, argv, &exception );
61 libvlc_playlist_play( p_instance, 0, 0, argv, &exception );
62 ASSERT( libvlc_exception_raised( &exception ),
63 "Playlist empty and exception not raised" );
65 libvlc_exception_clear( &exception );
67 i_playing = libvlc_playlist_isplaying( p_instance, &exception );
69 ASSERT( i_playing == 0, "Playlist shouldn't be running" );
70 i_items = libvlc_playlist_items_count( p_instance, &exception );
72 ASSERT( i_items == 0, "Playlist should be empty" );
75 libvlc_exception_clear( &exception );
76 i_id = libvlc_playlist_add( p_instance, "test" , NULL , &exception );
78 ASSERT( i_id > 0 , "Returned identifier is <= 0" );
79 i_items = libvlc_playlist_items_count( p_instance, &exception );
81 ASSERT( i_items == 1, "Playlist should have 1 item" );
82 i_playing = libvlc_playlist_isplaying( p_instance, &exception );
84 ASSERT( i_playing == 0, "Playlist shouldn't be running" );
92 PyObject *vlm_test( PyObject *self, PyObject *args )
94 libvlc_instance_t *p_instance;
95 char *argv[] = { "vlc", "--quiet" };
96 char *ppsz_empty[] = {};
97 libvlc_exception_t exception;
98 libvlc_exception_init( &exception );
100 p_instance = libvlc_new( 2, argv, &exception );
103 /* Test that working on unexisting streams fail */
104 libvlc_vlm_set_enabled( p_instance, "test", 1, &exception );
106 libvlc_exception_clear( &exception );
107 libvlc_vlm_set_input( p_instance, "test", "input", &exception );
109 libvlc_exception_clear( &exception );
110 libvlc_vlm_del_media( p_instance, "test", &exception );
112 libvlc_exception_clear( &exception );
114 /******* Broadcast *******/
115 /* Now create a media */
116 libvlc_vlm_add_broadcast( p_instance, "test", "input_test", "output_test",
117 0, ppsz_empty, 1, 1, &exception );
119 libvlc_exception_clear( &exception );
121 /* Change its parameters */
122 libvlc_vlm_set_enabled( p_instance, "test", 0, &exception );
124 libvlc_exception_clear( &exception );
125 libvlc_vlm_set_output( p_instance, "test", "output_test2", &exception );
127 libvlc_exception_clear( &exception );
129 /* Check the parameters */
130 fprintf( stderr, "The code for this is not written yet\n");
132 /* Control it a bit */
133 fprintf( stderr, "The code for this is not written yet\n");
135 /* Try to delete it */
136 libvlc_vlm_del_media( p_instance, "test", &exception );
138 libvlc_exception_clear( &exception );
140 libvlc_vlm_del_media( p_instance, "test", &exception );
142 libvlc_exception_clear( &exception );
144 /******* VOD *******/
146 Py_INCREF( Py_None );