+static void default_live555_callback( RTSPClient* client, int result_code, char* result_string )
+{
+ RTSPClientVlc *client_vlc = static_cast<RTSPClientVlc *> ( client );
+ demux_sys_t *p_sys = client_vlc->p_sys;
+ delete []result_string;
+ p_sys->i_live555_ret = result_code;
+ p_sys->b_error = p_sys->i_live555_ret != 0;
+ p_sys->event = 1;
+}
+
+/* return true if the RTSP command succeeded */
+static bool wait_Live555_response( demux_t *p_demux, int i_timeout = 0 /* ms */ )
+{
+ TaskToken task;
+ demux_sys_t * p_sys = p_demux->p_sys;
+ p_sys->event = 0;
+ if( i_timeout > 0 )
+ {
+ /* Create a task that will be called if we wait more than timeout ms */
+ task = p_sys->scheduler->scheduleDelayedTask( i_timeout*1000, TaskInterrupt,
+ p_demux );
+ }
+ p_sys->event = 0;
+ p_sys->b_error = true;
+ p_sys->i_live555_ret = 0;
+ p_sys->scheduler->doEventLoop( &p_sys->event );
+ //here, if b_error is true and i_live555_ret = 0 we didn't receive a response
+ if( i_timeout > 0 )
+ {
+ /* remove the task */
+ p_sys->scheduler->unscheduleDelayedTask( task );
+ }
+ return !p_sys->b_error;
+}
+
+static void continueAfterDESCRIBE( RTSPClient* client, int result_code,
+ char* result_string )
+{
+ RTSPClientVlc *client_vlc = static_cast<RTSPClientVlc *> ( client );
+ demux_sys_t *p_sys = client_vlc->p_sys;
+ char* sdpDescription = result_string;
+ p_sys->i_live555_ret = result_code;
+ if ( result_code != 0 )
+ {
+ delete[] sdpDescription;
+ return;
+ }
+ free( p_sys->p_sdp );
+ p_sys->p_sdp = NULL;
+ if( sdpDescription )
+ {
+ p_sys->p_sdp = strdup( sdpDescription );
+ delete[] sdpDescription;
+ }
+ p_sys->b_error = false;
+ p_sys->event = 1;
+}
+
+static void continueAfterOPTIONS( RTSPClient* client, int result_code,
+ char* result_string )
+{
+ RTSPClientVlc *client_vlc = static_cast<RTSPClientVlc *> (client);
+ demux_sys_t *p_sys = client_vlc->p_sys;
+ p_sys->i_live555_ret = result_code;
+ if ( result_code != 0 )
+ {
+ p_sys->b_error = true;
+ p_sys->event = 1;
+ }
+ else
+ {
+ p_sys->b_get_param = (bool)strstr( result_string, "GET_PARAMETER" );
+ client->sendDescribeCommand( continueAfterDESCRIBE );
+ }
+ delete[] result_string;
+}
+