Commit 3fa37fdc authored by Jean-Paul Saman's avatar Jean-Paul Saman

Add support for X-Playnow RTSP option

parent 24f39790
...@@ -651,8 +651,10 @@ static int RtspCallback( httpd_callback_sys_t *p_args, httpd_client_t *cl, ...@@ -651,8 +651,10 @@ static int RtspCallback( httpd_callback_sys_t *p_args, httpd_client_t *cl,
char *psz_transport = NULL; char *psz_transport = NULL;
char *psz_playnow = NULL; /* support option: x-playNow */ char *psz_playnow = NULL; /* support option: x-playNow */
char *psz_session = NULL; char *psz_session = NULL;
char *psz_cseq = NULL;
rtsp_client_t *p_rtsp; rtsp_client_t *p_rtsp;
int i_port = 0; int i_port = 0;
int i_cseq = 0;
if( answer == NULL || query == NULL ) return VLC_SUCCESS; if( answer == NULL || query == NULL ) return VLC_SUCCESS;
...@@ -756,7 +758,8 @@ static int RtspCallback( httpd_callback_sys_t *p_args, httpd_client_t *cl, ...@@ -756,7 +758,8 @@ static int RtspCallback( httpd_callback_sys_t *p_args, httpd_client_t *cl,
answer->p_body = NULL; answer->p_body = NULL;
} }
if( !psz_playnow || !*psz_playnow ) /* Intentional fall-through on x-playNow option in RTSP request */
if( !psz_playnow )
break; break;
} }
...@@ -891,8 +894,9 @@ static int RtspCallback( httpd_callback_sys_t *p_args, httpd_client_t *cl, ...@@ -891,8 +894,9 @@ static int RtspCallback( httpd_callback_sys_t *p_args, httpd_client_t *cl,
httpd_MsgAdd( answer, "Server", "VLC Server" ); httpd_MsgAdd( answer, "Server", "VLC Server" );
httpd_MsgAdd( answer, "Content-Length", "%d", answer->i_body ); httpd_MsgAdd( answer, "Content-Length", "%d", answer->i_body );
httpd_MsgAdd( answer, "Cseq", "%d", psz_cseq = httpd_MsgGet( query, "Cseq" );
atoi( 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" ); httpd_MsgAdd( answer, "Cache-Control", "%s", "no-cache" );
if( psz_session ) if( psz_session )
...@@ -914,6 +918,8 @@ static int RtspCallbackES( httpd_callback_sys_t *p_args, httpd_client_t *cl, ...@@ -914,6 +918,8 @@ static int RtspCallbackES( httpd_callback_sys_t *p_args, httpd_client_t *cl,
char *psz_playnow = NULL; /* support option: x-playNow */ char *psz_playnow = NULL; /* support option: x-playNow */
char *psz_session = NULL; char *psz_session = NULL;
char *psz_position = NULL; char *psz_position = NULL;
char *psz_cseq = NULL;
int i_cseq = 0;
int i; int i;
if( answer == NULL || query == NULL ) return VLC_SUCCESS; if( answer == NULL || query == NULL ) return VLC_SUCCESS;
...@@ -1021,7 +1027,8 @@ static int RtspCallbackES( httpd_callback_sys_t *p_args, httpd_client_t *cl, ...@@ -1021,7 +1027,8 @@ static int RtspCallbackES( httpd_callback_sys_t *p_args, httpd_client_t *cl,
answer->p_body = NULL; answer->p_body = NULL;
} }
if( !psz_playnow || !*psz_playnow ) /* Intentional fall-through on x-playNow option in RTSP request */
if( !psz_playnow )
break; break;
case HTTPD_MSG_PLAY: case HTTPD_MSG_PLAY:
...@@ -1116,8 +1123,12 @@ static int RtspCallbackES( httpd_callback_sys_t *p_args, httpd_client_t *cl, ...@@ -1116,8 +1123,12 @@ static int RtspCallbackES( httpd_callback_sys_t *p_args, httpd_client_t *cl,
httpd_MsgAdd( answer, "Server", "VLC Server" ); httpd_MsgAdd( answer, "Server", "VLC Server" );
httpd_MsgAdd( answer, "Content-Length", "%d", answer->i_body ); httpd_MsgAdd( answer, "Content-Length", "%d", answer->i_body );
httpd_MsgAdd( answer, "Cseq", "%d", psz_cseq = httpd_MsgGet( query, "Cseq" );
atoi( 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" ); httpd_MsgAdd( answer, "Cache-Control", "%s", "no-cache" );
if( psz_session ) if( psz_session )
......
...@@ -770,7 +770,6 @@ static char *SDPGenerate( const sout_stream_t *p_stream, ...@@ -770,7 +770,6 @@ static char *SDPGenerate( const sout_stream_t *p_stream,
const char *psz_destination, vlc_bool_t b_rtsp ) const char *psz_destination, vlc_bool_t b_rtsp )
{ {
sout_stream_sys_t *p_sys = p_stream->p_sys; sout_stream_sys_t *p_sys = p_stream->p_sys;
sout_instance_t *p_sout = p_stream->p_sout;
int i_size; int i_size;
char *psz_sdp, *p, ipv; char *psz_sdp, *p, ipv;
int i; int i;
...@@ -1497,6 +1496,9 @@ static rtsp_client_t *RtspClientNew( sout_stream_t *p_stream, char *psz_session ...@@ -1497,6 +1496,9 @@ static rtsp_client_t *RtspClientNew( sout_stream_t *p_stream, char *psz_session
static rtsp_client_t *RtspClientGet( sout_stream_t *p_stream, char *psz_session ) static rtsp_client_t *RtspClientGet( sout_stream_t *p_stream, char *psz_session )
{ {
int i; int i;
if( psz_session ) return NULL;
for( i = 0; i < p_stream->p_sys->i_rtsp; i++ ) for( i = 0; i < p_stream->p_sys->i_rtsp; i++ )
{ {
if( !strcmp( p_stream->p_sys->rtsp[i]->psz_session, psz_session ) ) if( !strcmp( p_stream->p_sys->rtsp[i]->psz_session, psz_session ) )
...@@ -1561,6 +1563,8 @@ static int RtspCallback( httpd_callback_sys_t *p_args, ...@@ -1561,6 +1563,8 @@ static int RtspCallback( httpd_callback_sys_t *p_args,
sout_stream_sys_t *p_sys = p_stream->p_sys; sout_stream_sys_t *p_sys = p_stream->p_sys;
char *psz_destination = p_sys->psz_destination; char *psz_destination = p_sys->psz_destination;
char *psz_session = NULL; char *psz_session = NULL;
char *psz_cseq = NULL;
int i_cseq = 0;
if( answer == NULL || query == NULL ) if( answer == NULL || query == NULL )
{ {
...@@ -1673,7 +1677,12 @@ static int RtspCallback( httpd_callback_sys_t *p_args, ...@@ -1673,7 +1677,12 @@ static int RtspCallback( httpd_callback_sys_t *p_args,
} }
httpd_MsgAdd( answer, "Server", PACKAGE_STRING ); httpd_MsgAdd( answer, "Server", PACKAGE_STRING );
httpd_MsgAdd( answer, "Content-Length", "%d", answer->i_body ); 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" ); httpd_MsgAdd( answer, "Cache-Control", "%s", "no-cache" );
if( psz_session ) if( psz_session )
...@@ -1689,9 +1698,11 @@ static int RtspCallbackId( httpd_callback_sys_t *p_args, ...@@ -1689,9 +1698,11 @@ static int RtspCallbackId( httpd_callback_sys_t *p_args,
{ {
sout_stream_id_t *id = (sout_stream_id_t*)p_args; sout_stream_id_t *id = (sout_stream_id_t*)p_args;
sout_stream_t *p_stream = id->p_stream; 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; 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 ) if( answer == NULL || query == NULL )
{ {
...@@ -1719,7 +1730,7 @@ static int RtspCallbackId( httpd_callback_sys_t *p_args, ...@@ -1719,7 +1730,7 @@ static int RtspCallbackId( httpd_callback_sys_t *p_args,
answer->i_body = 0; answer->i_body = 0;
answer->p_body = NULL; answer->p_body = NULL;
psz_session = httpd_MsgGet( query, "Session" ); psz_session = httpd_MsgGet( query, "Session" );
if( *psz_session == 0 ) if( !psz_session )
{ {
psz_session = malloc( 100 ); psz_session = malloc( 100 );
sprintf( psz_session, "%d", rand() ); sprintf( psz_session, "%d", rand() );
...@@ -1750,7 +1761,7 @@ static int RtspCallbackId( httpd_callback_sys_t *p_args, ...@@ -1750,7 +1761,7 @@ static int RtspCallbackId( httpd_callback_sys_t *p_args,
//fprintf( stderr, "HTTPD_MSG_SETUP: unicast ip=%s port=%d\n", ip, i_port ); //fprintf( stderr, "HTTPD_MSG_SETUP: unicast ip=%s port=%d\n", ip, i_port );
psz_session = httpd_MsgGet( query, "Session" ); psz_session = httpd_MsgGet( query, "Session" );
if( *psz_session == 0 ) if( !psz_session )
{ {
psz_session = malloc( 100 ); psz_session = malloc( 100 );
sprintf( psz_session, "%d", rand() ); sprintf( psz_session, "%d", rand() );
...@@ -1819,7 +1830,12 @@ static int RtspCallbackId( httpd_callback_sys_t *p_args, ...@@ -1819,7 +1830,12 @@ static int RtspCallbackId( httpd_callback_sys_t *p_args,
} }
httpd_MsgAdd( answer, "Server", "VLC Server" ); httpd_MsgAdd( answer, "Server", "VLC Server" );
httpd_MsgAdd( answer, "Content-Length", "%d", answer->i_body ); 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" ); httpd_MsgAdd( answer, "Cache-Control", "%s", "no-cache" );
if( psz_session ) if( psz_session )
......
...@@ -367,6 +367,7 @@ static int httpd_FileCallBack( httpd_callback_sys_t *p_sys, httpd_client_t *cl, ...@@ -367,6 +367,7 @@ static int httpd_FileCallBack( httpd_callback_sys_t *p_sys, httpd_client_t *cl,
httpd_file_t *file = (httpd_file_t*)p_sys; httpd_file_t *file = (httpd_file_t*)p_sys;
uint8_t *psz_args = query->psz_args; uint8_t *psz_args = query->psz_args;
uint8_t **pp_body, *p_body; uint8_t **pp_body, *p_body;
char *psz_connection = NULL;
int *pi_body, i_body; int *pi_body, i_body;
if( answer == NULL || query == NULL ) if( answer == NULL || query == NULL )
...@@ -410,10 +411,10 @@ static int httpd_FileCallBack( httpd_callback_sys_t *p_sys, httpd_client_t *cl, ...@@ -410,10 +411,10 @@ static int httpd_FileCallBack( httpd_callback_sys_t *p_sys, httpd_client_t *cl,
} }
/* We respect client request */ /* 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_MsgAdd( answer, "Connection", psz_connection );
httpd_MsgGet( &cl->query, "Connection" ) );
} }
httpd_MsgAdd( answer, "Content-Length", "%d", answer->i_body ); httpd_MsgAdd( answer, "Content-Length", "%d", answer->i_body );
...@@ -1342,7 +1343,7 @@ char *httpd_MsgGet( httpd_message_t *msg, char *name ) ...@@ -1342,7 +1343,7 @@ char *httpd_MsgGet( httpd_message_t *msg, char *name )
return msg->value[i]; return msg->value[i];
} }
} }
return ""; return NULL;
} }
void httpd_MsgAdd( httpd_message_t *msg, char *name, char *psz_value, ... ) void httpd_MsgAdd( httpd_message_t *msg, char *name, char *psz_value, ... )
...@@ -2052,6 +2053,7 @@ static void httpd_HostThread( httpd_host_t *host ) ...@@ -2052,6 +2053,7 @@ static void httpd_HostThread( httpd_host_t *host )
} }
else if( i_msg == HTTPD_MSG_OPTIONS ) else if( i_msg == HTTPD_MSG_OPTIONS )
{ {
char *psz_cseq = NULL;
int i_cseq; int i_cseq;
/* unimplemented */ /* unimplemented */
...@@ -2064,7 +2066,11 @@ static void httpd_HostThread( httpd_host_t *host ) ...@@ -2064,7 +2066,11 @@ static void httpd_HostThread( httpd_host_t *host )
answer->i_body = 0; answer->i_body = 0;
answer->p_body = NULL; 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, "Cseq", "%d", i_cseq );
httpd_MsgAdd( answer, "Server", "VLC Server" ); httpd_MsgAdd( answer, "Server", "VLC Server" );
httpd_MsgAdd( answer, "Public", "DESCRIBE, SETUP, " httpd_MsgAdd( answer, "Public", "DESCRIBE, SETUP, "
...@@ -2157,7 +2163,8 @@ static void httpd_HostThread( httpd_host_t *host ) ...@@ -2157,7 +2163,8 @@ static void httpd_HostThread( httpd_host_t *host )
char *id; char *id;
asprintf( &id, "%s:%s", url->psz_user, url->psz_password ); 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( !strncasecmp( b64, "BASIC", 5 ) )
{ {
...@@ -2292,13 +2299,29 @@ static void httpd_HostThread( httpd_host_t *host ) ...@@ -2292,13 +2299,29 @@ static void httpd_HostThread( httpd_host_t *host )
{ {
if( cl->i_mode == HTTPD_CLIENT_FILE || cl->answer.i_body_offset == 0 ) 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; cl->url = NULL;
if( ( cl->query.i_proto == HTTPD_PROTO_HTTP && if( psz_connection )
( ( 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" ) ) ) ) || b_connection = ( strcasecmp( psz_connection, "Close" ) == 0 );
( cl->query.i_proto == HTTPD_PROTO_RTSP && b_keepalive = ( strcasecmp( psz_connection, "Keep-Alive" ) == 0 );
strcasecmp( httpd_MsgGet( &cl->query, "Connection" ), "Close" ) && }
strcasecmp( httpd_MsgGet( &cl->answer, "Connection" ), "Close" ) ) )
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_MsgClean( &cl->query );
httpd_MsgInit( &cl->query ); httpd_MsgInit( &cl->query );
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment