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_i1
, *p_i2
;
30 char *argv1
[] = { "vlc", "--quiet" };
31 char *argv2
[]= { "vlc", "-vvv" };
36 libvlc_exception_t exception
;
37 libvlc_exception_init( &exception
);
39 /* Create and destroy a single instance */
40 fprintf( stderr
, "Create 1\n" );
41 p_i1
= libvlc_new( 2, argv1
, &exception
);
42 ASSERT( p_i1
!= NULL
, "Instance creation failed" );
44 id1
= libvlc_get_vlc_id( p_i1
);
45 libvlc_release( p_i1
, &exception
);
48 /* Create and destroy two instances */
49 fprintf( stderr
, "Create 2\n" );
50 p_i1
= libvlc_new( 2, argv1
, &exception
);
51 ASSERT( p_i1
!= NULL
, "Instance creation failed" );
54 fprintf( stderr
, "Create 3\n" );
55 p_i2
= libvlc_new( 2, argv2
, &exception
);
56 ASSERT( p_i2
!= NULL
, "Instance creation failed" );
59 fprintf( stderr
, "Destroy 1\n" );
60 libvlc_release( p_i1
, &exception
);
62 fprintf( stderr
, "Destroy 2\n" );
63 libvlc_release( p_i2
, &exception
);
67 fprintf( stderr
, "Create 4\n" );
68 p_i1
= libvlc_new( 2, argv1
, &exception
);
70 id2
= libvlc_get_vlc_id( p_i1
);
72 ASSERT( id1
== id2
, "libvlc object ids do not match after deinit" );
78 PyObject
*playlist_test( PyObject
*self
, PyObject
*args
)
80 libvlc_instance_t
*p_instance
;
81 char *argv
[] = { "vlc", "--quiet" };
82 int i_id
, i_playing
, i_items
;
84 libvlc_exception_t exception
;
85 libvlc_exception_init( &exception
);
87 p_instance
= libvlc_new( 2, argv
, &exception
);
91 libvlc_playlist_play( p_instance
, 0, 0, argv
, &exception
);
92 ASSERT( libvlc_exception_raised( &exception
),
93 "Playlist empty and exception not raised" );
95 libvlc_exception_clear( &exception
);
97 i_playing
= libvlc_playlist_isplaying( p_instance
, &exception
);
99 ASSERT( i_playing
== 0, "Playlist shouldn't be running" );
100 i_items
= libvlc_playlist_items_count( p_instance
, &exception
);
102 ASSERT( i_items
== 0, "Playlist should be empty" );
105 libvlc_exception_clear( &exception
);
106 i_id
= libvlc_playlist_add( p_instance
, "test" , NULL
, &exception
);
108 ASSERT( i_id
> 0 , "Returned identifier is <= 0" );
109 i_items
= libvlc_playlist_items_count( p_instance
, &exception
);
111 ASSERT( i_items
== 1, "Playlist should have 1 item" );
112 i_playing
= libvlc_playlist_isplaying( p_instance
, &exception
);
114 ASSERT( i_playing
== 0, "Playlist shouldn't be running" );
118 Py_INCREF( Py_None
);
122 PyObject
*vlm_test( PyObject
*self
, PyObject
*args
)
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
);
130 p_instance
= libvlc_new( 2, argv
, &exception
);
133 /* Test that working on unexisting streams fail */
134 libvlc_vlm_set_enabled( p_instance
, "test", 1, &exception
);
136 libvlc_exception_clear( &exception
);
137 libvlc_vlm_set_input( p_instance
, "test", "input", &exception
);
139 libvlc_exception_clear( &exception
);
140 libvlc_vlm_del_media( p_instance
, "test", &exception
);
142 libvlc_exception_clear( &exception
);
144 /******* Broadcast *******/
145 /* Now create a media */
146 libvlc_vlm_add_broadcast( p_instance
, "test", "input_test", "output_test",
147 0, ppsz_empty
, 1, 1, &exception
);
149 libvlc_exception_clear( &exception
);
151 /* Change its parameters */
152 libvlc_vlm_set_enabled( p_instance
, "test", 0, &exception
);
154 libvlc_exception_clear( &exception
);
155 libvlc_vlm_set_output( p_instance
, "test", "output_test2", &exception
);
157 libvlc_exception_clear( &exception
);
159 /* Check the parameters */
160 fprintf( stderr
, "The code for this is not written yet\n");
162 /* Control it a bit */
163 fprintf( stderr
, "The code for this is not written yet\n");
165 /* Try to delete it */
166 libvlc_vlm_del_media( p_instance
, "test", &exception
);
168 libvlc_exception_clear( &exception
);
170 libvlc_vlm_del_media( p_instance
, "test", &exception
);
172 libvlc_exception_clear( &exception
);
174 /******* VOD *******/
176 Py_INCREF( Py_None
);