| 1 |
#include "../pyunit.h" |
|---|
| 2 |
#include <vlc/libvlc.h> |
|---|
| 3 |
|
|---|
| 4 |
PyObject *exception_test( PyObject *self, PyObject *args ) |
|---|
| 5 |
{ |
|---|
| 6 |
libvlc_exception_t exception; |
|---|
| 7 |
|
|---|
| 8 |
libvlc_exception_init( &exception ); |
|---|
| 9 |
ASSERT( !libvlc_exception_raised( &exception) , "Exception raised" ); |
|---|
| 10 |
ASSERT( !libvlc_exception_get_message( &exception) , "Exception raised" ); |
|---|
| 11 |
|
|---|
| 12 |
libvlc_exception_raise( &exception, NULL ); |
|---|
| 13 |
ASSERT( !libvlc_exception_get_message( &exception), "Unexpected message" ); |
|---|
| 14 |
ASSERT( libvlc_exception_raised( &exception), "Exception not raised" ); |
|---|
| 15 |
|
|---|
| 16 |
libvlc_exception_raise( &exception, "test" ); |
|---|
| 17 |
ASSERT( libvlc_exception_get_message( &exception), "No Message" ); |
|---|
| 18 |
ASSERT( libvlc_exception_raised( &exception), "Exception not raised" ); |
|---|
| 19 |
|
|---|
| 20 |
libvlc_exception_clear( &exception ); |
|---|
| 21 |
ASSERT( !libvlc_exception_raised( &exception ), "Exception not cleared" ); |
|---|
| 22 |
|
|---|
| 23 |
Py_INCREF( Py_None ); |
|---|
| 24 |
return Py_None; |
|---|
| 25 |
} |
|---|
| 26 |
|
|---|
| 27 |
PyObject *create_destroy( PyObject *self, PyObject *args ) |
|---|
| 28 |
{ |
|---|
| 29 |
libvlc_instance_t *p_i1, *p_i2; |
|---|
| 30 |
char *argv1[] = { "vlc", "--quiet" }; |
|---|
| 31 |
char *argv2[]= { "vlc", "-vvv" }; |
|---|
| 32 |
int id1,id2; |
|---|
| 33 |
|
|---|
| 34 |
printf( "\n" ); |
|---|
| 35 |
|
|---|
| 36 |
libvlc_exception_t exception; |
|---|
| 37 |
libvlc_exception_init( &exception ); |
|---|
| 38 |
|
|---|
| 39 |
|
|---|
| 40 |
fprintf( stderr, "Create 1\n" ); |
|---|
| 41 |
p_i1 = libvlc_new( 2, argv1, &exception ); |
|---|
| 42 |
ASSERT( p_i1 != NULL, "Instance creation failed" ); |
|---|
| 43 |
ASSERT_NOEXCEPTION; |
|---|
| 44 |
id1 = libvlc_get_vlc_id( p_i1 ); |
|---|
| 45 |
libvlc_release( p_i1, &exception ); |
|---|
| 46 |
ASSERT_NOEXCEPTION; |
|---|
| 47 |
|
|---|
| 48 |
|
|---|
| 49 |
fprintf( stderr, "Create 2\n" ); |
|---|
| 50 |
p_i1 = libvlc_new( 2, argv1, &exception ); |
|---|
| 51 |
ASSERT( p_i1 != NULL, "Instance creation failed" ); |
|---|
| 52 |
ASSERT_NOEXCEPTION; |
|---|
| 53 |
|
|---|
| 54 |
fprintf( stderr, "Create 3\n" ); |
|---|
| 55 |
p_i2 = libvlc_new( 2, argv2, &exception ); |
|---|
| 56 |
ASSERT( p_i2 != NULL, "Instance creation failed" ); |
|---|
| 57 |
ASSERT_NOEXCEPTION; |
|---|
| 58 |
|
|---|
| 59 |
fprintf( stderr, "Destroy 1\n" ); |
|---|
| 60 |
libvlc_release( p_i1, &exception ); |
|---|
| 61 |
ASSERT_NOEXCEPTION; |
|---|
| 62 |
fprintf( stderr, "Destroy 2\n" ); |
|---|
| 63 |
libvlc_release( p_i2, &exception ); |
|---|
| 64 |
ASSERT_NOEXCEPTION; |
|---|
| 65 |
|
|---|
| 66 |
|
|---|
| 67 |
fprintf( stderr, "Create 4\n" ); |
|---|
| 68 |
p_i1 = libvlc_new( 2, argv1, &exception ); |
|---|
| 69 |
ASSERT_NOEXCEPTION; |
|---|
| 70 |
id2 = libvlc_get_vlc_id( p_i1 ); |
|---|
| 71 |
|
|---|
| 72 |
ASSERT( id1 == id2, "libvlc object ids do not match after deinit" ); |
|---|
| 73 |
|
|---|
| 74 |
Py_INCREF( Py_None ); |
|---|
| 75 |
return Py_None; |
|---|
| 76 |
} |
|---|
| 77 |
|
|---|
| 78 |
PyObject *playlist_test( PyObject *self, PyObject *args ) |
|---|
| 79 |
{ |
|---|
| 80 |
libvlc_instance_t *p_instance; |
|---|
| 81 |
char *argv[] = { "vlc", "--quiet" }; |
|---|
| 82 |
int i_id, i_playing, i_items; |
|---|
| 83 |
|
|---|
| 84 |
libvlc_exception_t exception; |
|---|
| 85 |
libvlc_exception_init( &exception ); |
|---|
| 86 |
|
|---|
| 87 |
p_instance = libvlc_new( 2, argv, &exception ); |
|---|
| 88 |
ASSERT_NOEXCEPTION; |
|---|
| 89 |
|
|---|
| 90 |
|
|---|
| 91 |
libvlc_playlist_play( p_instance, 0, 0, argv, &exception ); |
|---|
| 92 |
ASSERT( libvlc_exception_raised( &exception ), |
|---|
| 93 |
"Playlist empty and exception not raised" ); |
|---|
| 94 |
|
|---|
| 95 |
libvlc_exception_clear( &exception ); |
|---|
| 96 |
|
|---|
| 97 |
i_playing = libvlc_playlist_isplaying( p_instance, &exception ); |
|---|
| 98 |
ASSERT_NOEXCEPTION; |
|---|
| 99 |
ASSERT( i_playing == 0, "Playlist shouldn't be running" ); |
|---|
| 100 |
i_items = libvlc_playlist_items_count( p_instance, &exception ); |
|---|
| 101 |
ASSERT_NOEXCEPTION; |
|---|
| 102 |
ASSERT( i_items == 0, "Playlist should be empty" ); |
|---|
| 103 |
|
|---|
| 104 |
|
|---|
| 105 |
libvlc_exception_clear( &exception ); |
|---|
| 106 |
i_id = libvlc_playlist_add( p_instance, "test" , NULL , &exception ); |
|---|
| 107 |
ASSERT_NOEXCEPTION; |
|---|
| 108 |
ASSERT( i_id > 0 , "Returned identifier is <= 0" ); |
|---|
| 109 |
i_items = libvlc_playlist_items_count( p_instance, &exception ); |
|---|
| 110 |
ASSERT_NOEXCEPTION; |
|---|
| 111 |
ASSERT( i_items == 1, "Playlist should have 1 item" ); |
|---|
| 112 |
i_playing = libvlc_playlist_isplaying( p_instance, &exception ); |
|---|
| 113 |
ASSERT_NOEXCEPTION; |
|---|
| 114 |
ASSERT( i_playing == 0, "Playlist shouldn't be running" ); |
|---|
| 115 |
|
|---|
| 116 |
|
|---|
| 117 |
|
|---|
| 118 |
Py_INCREF( Py_None ); |
|---|
| 119 |
return Py_None; |
|---|
| 120 |
} |
|---|
| 121 |
|
|---|
| 122 |
PyObject *vlm_test( PyObject *self, PyObject *args ) |
|---|
| 123 |
{ |
|---|
| 124 |
libvlc_instance_t *p_instance; |
|---|
| 125 |
char *argv[] = { "vlc", "--quiet" }; |
|---|
| 126 |
char *ppsz_empty[] = {}; |
|---|
| 127 |
libvlc_exception_t exception; |
|---|
| 128 |
libvlc_exception_init( &exception ); |
|---|
| 129 |
|
|---|
| 130 |
p_instance = libvlc_new( 2, argv, &exception ); |
|---|
| 131 |
ASSERT_NOEXCEPTION; |
|---|
| 132 |
|
|---|
| 133 |
|
|---|
| 134 |
libvlc_vlm_set_enabled( p_instance, "test", 1, &exception ); |
|---|
| 135 |
ASSERT_EXCEPTION; |
|---|
| 136 |
libvlc_exception_clear( &exception ); |
|---|
| 137 |
libvlc_vlm_set_input( p_instance, "test", "input", &exception ); |
|---|
| 138 |
ASSERT_EXCEPTION; |
|---|
| 139 |
libvlc_exception_clear( &exception ); |
|---|
| 140 |
libvlc_vlm_del_media( p_instance, "test", &exception ); |
|---|
| 141 |
ASSERT_EXCEPTION; |
|---|
| 142 |
libvlc_exception_clear( &exception ); |
|---|
| 143 |
|
|---|
| 144 |
|
|---|
| 145 |
|
|---|
| 146 |
libvlc_vlm_add_broadcast( p_instance, "test", "input_test", "output_test", |
|---|
| 147 |
0, ppsz_empty, 1, 1, &exception ); |
|---|
| 148 |
ASSERT_NOEXCEPTION; |
|---|
| 149 |
libvlc_exception_clear( &exception ); |
|---|
| 150 |
|
|---|
| 151 |
|
|---|
| 152 |
libvlc_vlm_set_enabled( p_instance, "test", 0, &exception ); |
|---|
| 153 |
ASSERT_NOEXCEPTION; |
|---|
| 154 |
libvlc_exception_clear( &exception ); |
|---|
| 155 |
libvlc_vlm_set_output( p_instance, "test", "output_test2", &exception ); |
|---|
| 156 |
ASSERT_NOEXCEPTION; |
|---|
| 157 |
libvlc_exception_clear( &exception ); |
|---|
| 158 |
|
|---|
| 159 |
|
|---|
| 160 |
fprintf( stderr, "The code for this is not written yet\n"); |
|---|
| 161 |
|
|---|
| 162 |
|
|---|
| 163 |
fprintf( stderr, "The code for this is not written yet\n"); |
|---|
| 164 |
|
|---|
| 165 |
|
|---|
| 166 |
libvlc_vlm_del_media( p_instance, "test", &exception ); |
|---|
| 167 |
ASSERT_NOEXCEPTION; |
|---|
| 168 |
libvlc_exception_clear( &exception ); |
|---|
| 169 |
|
|---|
| 170 |
libvlc_vlm_del_media( p_instance, "test", &exception ); |
|---|
| 171 |
ASSERT_EXCEPTION; |
|---|
| 172 |
libvlc_exception_clear( &exception ); |
|---|
| 173 |
|
|---|
| 174 |
|
|---|
| 175 |
|
|---|
| 176 |
Py_INCREF( Py_None ); |
|---|
| 177 |
return Py_None; |
|---|
| 178 |
} |
|---|