char *psz_transport = NULL;
char *psz_playnow = NULL; /* support option: x-playNow */
char *psz_session = NULL;
+ char *psz_cseq = NULL;
rtsp_client_t *p_rtsp;
int i_port = 0;
+ int i_cseq = 0;
if( answer == NULL || query == NULL ) return VLC_SUCCESS;
answer->p_body = NULL;
}
- if( !psz_playnow || !*psz_playnow )
+ /* Intentional fall-through on x-playNow option in RTSP request */
+ if( !psz_playnow )
break;
}
httpd_MsgAdd( answer, "Server", "VLC Server" );
httpd_MsgAdd( answer, "Content-Length", "%d", answer->i_body );
- httpd_MsgAdd( answer, "Cseq", "%d",
- atoi( httpd_MsgGet( query, "Cseq" ) ) );
+ psz_cseq = httpd_MsgGet( query, "Cseq" );
+ psz_cseq ? i_cseq = atoi( psz_cseq ) : 0;
+ httpd_MsgAdd( answer, "Cseq", "%d", i_cseq );
httpd_MsgAdd( answer, "Cache-Control", "%s", "no-cache" );
if( psz_session )
char *psz_playnow = NULL; /* support option: x-playNow */
char *psz_session = NULL;
char *psz_position = NULL;
+ char *psz_cseq = NULL;
+ int i_cseq = 0;
int i;
if( answer == NULL || query == NULL ) return VLC_SUCCESS;
answer->p_body = NULL;
}
- if( !psz_playnow || !*psz_playnow )
+ /* Intentional fall-through on x-playNow option in RTSP request */
+ if( !psz_playnow )
break;
case HTTPD_MSG_PLAY:
httpd_MsgAdd( answer, "Server", "VLC Server" );
httpd_MsgAdd( answer, "Content-Length", "%d", answer->i_body );
- httpd_MsgAdd( answer, "Cseq", "%d",
- atoi( httpd_MsgGet( query, "Cseq" ) ) );
+ psz_cseq = httpd_MsgGet( query, "Cseq" );
+ if (psz_cseq)
+ i_cseq = atoi( psz_cseq );
+ else
+ i_cseq = 0;
+ httpd_MsgAdd( answer, "Cseq", "%d", i_cseq );
httpd_MsgAdd( answer, "Cache-Control", "%s", "no-cache" );
if( psz_session )
const char *psz_destination, vlc_bool_t b_rtsp )
{
sout_stream_sys_t *p_sys = p_stream->p_sys;
- sout_instance_t *p_sout = p_stream->p_sout;
int i_size;
char *psz_sdp, *p, ipv;
int i;
static rtsp_client_t *RtspClientGet( sout_stream_t *p_stream, char *psz_session )
{
int i;
+
+ if( psz_session ) return NULL;
+
for( i = 0; i < p_stream->p_sys->i_rtsp; i++ )
{
if( !strcmp( p_stream->p_sys->rtsp[i]->psz_session, psz_session ) )
{
sout_stream_t *p_stream = (sout_stream_t*)p_args;
sout_stream_sys_t *p_sys = p_stream->p_sys;
- char *psz_destination = p_sys->psz_destination;
- char *psz_session = NULL;
+ char *psz_destination = p_sys->psz_destination;
+ char *psz_session = NULL;
+ char *psz_cseq = NULL;
+ int i_cseq = 0;
if( answer == NULL || query == NULL )
{
}
httpd_MsgAdd( answer, "Server", PACKAGE_STRING );
httpd_MsgAdd( answer, "Content-Length", "%d", answer->i_body );
- httpd_MsgAdd( answer, "Cseq", "%d", atoi( httpd_MsgGet( query, "Cseq" ) ) );
+ psz_cseq = httpd_MsgGet( query, "Cseq" );
+ if( psz_cseq )
+ i_cseq = atoi( psz_cseq );
+ else
+ i_cseq = 0;
+ httpd_MsgAdd( answer, "Cseq", "%d", i_cseq );
httpd_MsgAdd( answer, "Cache-Control", "%s", "no-cache" );
if( psz_session )
return VLC_SUCCESS;
}
-static int RtspCallbackId( httpd_callback_sys_t *p_args,
+static int RtspCallbackId( httpd_callback_sys_t *p_args,
httpd_client_t *cl,
httpd_message_t *answer, httpd_message_t *query )
{
sout_stream_id_t *id = (sout_stream_id_t*)p_args;
sout_stream_t *p_stream = id->p_stream;
- sout_instance_t *p_sout = p_stream->p_sout;
sout_stream_sys_t *p_sys = p_stream->p_sys;
- char *psz_session = NULL;
+ char *psz_session = NULL;
+ char *psz_cseq = NULL;
+ int i_cseq = 0;
+
if( answer == NULL || query == NULL )
{
answer->i_body = 0;
answer->p_body = NULL;
psz_session = httpd_MsgGet( query, "Session" );
- if( *psz_session == 0 )
+ if( !psz_session )
{
psz_session = malloc( 100 );
sprintf( psz_session, "%d", rand() );
//fprintf( stderr, "HTTPD_MSG_SETUP: unicast ip=%s port=%d\n", ip, i_port );
psz_session = httpd_MsgGet( query, "Session" );
- if( *psz_session == 0 )
+ if( !psz_session )
{
psz_session = malloc( 100 );
sprintf( psz_session, "%d", rand() );
}
httpd_MsgAdd( answer, "Server", "VLC Server" );
httpd_MsgAdd( answer, "Content-Length", "%d", answer->i_body );
- httpd_MsgAdd( answer, "Cseq", "%d", atoi( httpd_MsgGet( query, "Cseq" ) ) );
+ psz_cseq = httpd_MsgGet( query, "Cseq" );
+ if( psz_cseq )
+ i_cseq = atoi( psz_cseq );
+ else
+ i_cseq = 0;
+ httpd_MsgAdd( answer, "Cseq", "%d", i_cseq );
httpd_MsgAdd( answer, "Cache-Control", "%s", "no-cache" );
if( psz_session )
httpd_file_t *file = (httpd_file_t*)p_sys;
uint8_t *psz_args = query->psz_args;
uint8_t **pp_body, *p_body;
+ char *psz_connection = NULL;
int *pi_body, i_body;
if( answer == NULL || query == NULL )
}
/* We respect client request */
- if( strcmp( httpd_MsgGet( &cl->query, "Connection" ), "" ) )
+ psz_connection = httpd_MsgGet( &cl->query, "Connection" );
+ if( psz_connection != NULL )
{
- httpd_MsgAdd( answer, "Connection",
- httpd_MsgGet( &cl->query, "Connection" ) );
+ httpd_MsgAdd( answer, "Connection", psz_connection );
}
httpd_MsgAdd( answer, "Content-Length", "%d", answer->i_body );
return msg->value[i];
}
}
- return "";
+ return NULL;
}
void httpd_MsgAdd( httpd_message_t *msg, char *name, char *psz_value, ... )
}
else if( i_msg == HTTPD_MSG_OPTIONS )
{
+ char *psz_cseq = NULL;
int i_cseq;
/* unimplemented */
answer->i_body = 0;
answer->p_body = NULL;
- i_cseq = atoi( httpd_MsgGet( query, "Cseq" ) );
+ psz_cseq = httpd_MsgGet( query, "Cseq" );
+ if( psz_cseq )
+ i_cseq = atoi( psz_cseq );
+ else
+ i_cseq = 0;
httpd_MsgAdd( answer, "Cseq", "%d", i_cseq );
httpd_MsgAdd( answer, "Server", "VLC Server" );
httpd_MsgAdd( answer, "Public", "DESCRIBE, SETUP, "
char *id;
asprintf( &id, "%s:%s", url->psz_user, url->psz_password );
- auth = malloc( strlen(b64) + 1 );
+ if( b64 ) auth = malloc( strlen(b64) + 1 );
+ else auth = malloc( strlen("") + 1 );
if( !strncasecmp( b64, "BASIC", 5 ) )
{
{
if( cl->i_mode == HTTPD_CLIENT_FILE || cl->answer.i_body_offset == 0 )
{
+ char *psz_connection = httpd_MsgGet( &cl->answer, "Connection" );
+ char *psz_query = httpd_MsgGet( &cl->query, "Connection" );
+ vlc_bool_t b_connection = VLC_FALSE;
+ vlc_bool_t b_keepalive = VLC_FALSE;
+ vlc_bool_t b_query = VLC_FALSE;
+
cl->url = NULL;
- if( ( cl->query.i_proto == HTTPD_PROTO_HTTP &&
- ( ( cl->answer.i_version == 0 && !strcasecmp( httpd_MsgGet( &cl->answer, "Connection" ), "Keep-Alive" ) ) ||
- ( cl->answer.i_version == 1 && strcasecmp( httpd_MsgGet( &cl->answer, "Connection" ), "Close" ) ) ) ) ||
- ( cl->query.i_proto == HTTPD_PROTO_RTSP &&
- strcasecmp( httpd_MsgGet( &cl->query, "Connection" ), "Close" ) &&
- strcasecmp( httpd_MsgGet( &cl->answer, "Connection" ), "Close" ) ) )
+ if( psz_connection )
+ {
+ b_connection = ( strcasecmp( psz_connection, "Close" ) == 0 );
+ b_keepalive = ( strcasecmp( psz_connection, "Keep-Alive" ) == 0 );
+ }
+
+ if( psz_query )
+ {
+ b_query = ( strcasecmp( psz_query, "Close" ) == 0 );
+ }
+
+ if( ( ( cl->query.i_proto == HTTPD_PROTO_HTTP ) &&
+ ( ( cl->answer.i_version == 0 && b_keepalive ) ||
+ ( cl->answer.i_version == 1 && !b_connection ) ) ) ||
+ ( ( cl->query.i_proto == HTTPD_PROTO_RTSP ) &&
+ !b_query && !b_connection ) )
{
httpd_MsgClean( &cl->query );
httpd_MsgInit( &cl->query );