modules/misc/rtsp.c: implement support for raw udp transport for muxed streams

also replaces x-playnow hack with a slightly less ugly hack

vlc vod server can now serve about 5 seconds of video to amino stbs
parent 90e32697
...@@ -132,6 +132,7 @@ struct vod_media_t ...@@ -132,6 +132,7 @@ struct vod_media_t
int i_es; int i_es;
media_es_t **es; media_es_t **es;
char *psz_mux; char *psz_mux;
int b_raw;
/* RTSP client */ /* RTSP client */
int i_rtsp; int i_rtsp;
...@@ -626,6 +627,7 @@ static int RtspCallback( httpd_callback_sys_t *p_args, httpd_client_t *cl, ...@@ -626,6 +627,7 @@ static int RtspCallback( 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;
rtsp_client_t *p_rtsp; rtsp_client_t *p_rtsp;
int i_port = 0;
if( answer == NULL || query == NULL ) return VLC_SUCCESS; if( answer == NULL || query == NULL ) return VLC_SUCCESS;
...@@ -648,9 +650,14 @@ static int RtspCallback( httpd_callback_sys_t *p_args, httpd_client_t *cl, ...@@ -648,9 +650,14 @@ static int RtspCallback( httpd_callback_sys_t *p_args, httpd_client_t *cl,
{ {
rtsp_client_t *p_rtsp; rtsp_client_t *p_rtsp;
char ip[NI_MAXNUMERICHOST]; char ip[NI_MAXNUMERICHOST];
int i_port = atoi( strstr( psz_transport, "client_port=" ) + i_port = atoi( strstr( psz_transport, "client_port=" ) +
strlen("client_port=") ); strlen("client_port=") );
if( strstr( psz_transport, "MP2T/H2221/UDP" ) ||
strstr( psz_transport, "RAW/RAW/UDP" ) )
{
p_media->b_raw = 1;
}
if( httpd_ClientIP( cl, ip ) == NULL ) if( httpd_ClientIP( cl, ip ) == NULL )
{ {
answer->i_status = 500; answer->i_status = 500;
...@@ -683,9 +690,6 @@ static int RtspCallback( httpd_callback_sys_t *p_args, httpd_client_t *cl, ...@@ -683,9 +690,6 @@ static int RtspCallback( httpd_callback_sys_t *p_args, httpd_client_t *cl,
} }
} }
if( psz_playnow ) /* support option: x-playNow */
goto rtsp_play_now;
answer->i_status = 200; answer->i_status = 200;
answer->psz_status = strdup( "OK" ); answer->psz_status = strdup( "OK" );
answer->i_body = 0; answer->i_body = 0;
...@@ -701,36 +705,11 @@ static int RtspCallback( httpd_callback_sys_t *p_args, httpd_client_t *cl, ...@@ -701,36 +705,11 @@ static int RtspCallback( httpd_callback_sys_t *p_args, httpd_client_t *cl,
answer->i_body = 0; answer->i_body = 0;
answer->p_body = NULL; answer->p_body = NULL;
} }
break; if( !psz_playnow )
} break;
case HTTPD_MSG_DESCRIBE:
{
char *psz_sdp =
SDPGenerate( p_media, cl );
if( psz_sdp != NULL )
{
answer->i_status = 200;
answer->psz_status = strdup( "OK" );
httpd_MsgAdd( answer, "Content-type", "%s", "application/sdp" );
answer->p_body = (uint8_t *)psz_sdp;
answer->i_body = strlen( psz_sdp );
}
else
{
answer->i_status = 500;
answer->psz_status = strdup( "Internal server error" );
answer->p_body = NULL;
answer->i_body = 0;
}
break;
} }
case HTTPD_MSG_PLAY: case HTTPD_MSG_PLAY:
rtsp_play_now: /* This avoids code duplications although it is ugly. */
{ {
char *psz_output, ip[NI_MAXNUMERICHOST]; char *psz_output, ip[NI_MAXNUMERICHOST];
int i, i_port_audio = 0, i_port_video = 0; int i, i_port_audio = 0, i_port_video = 0;
...@@ -741,7 +720,8 @@ rtsp_play_now: /* This avoids code duplications although it is ugly. */ ...@@ -741,7 +720,8 @@ rtsp_play_now: /* This avoids code duplications although it is ugly. */
answer->i_body = 0; answer->i_body = 0;
answer->p_body = NULL; answer->p_body = NULL;
psz_session = httpd_MsgGet( query, "Session" ); if( !psz_session )
psz_session = httpd_MsgGet( query, "Session" );
msg_Dbg( p_vod, "HTTPD_MSG_PLAY for session: %s", psz_session ); msg_Dbg( p_vod, "HTTPD_MSG_PLAY for session: %s", psz_session );
p_rtsp = RtspClientGet( p_media, psz_session ); p_rtsp = RtspClientGet( p_media, psz_session );
...@@ -771,8 +751,16 @@ rtsp_play_now: /* This avoids code duplications although it is ugly. */ ...@@ -771,8 +751,16 @@ rtsp_play_now: /* This avoids code duplications although it is ugly. */
if( p_media->psz_mux ) if( p_media->psz_mux )
{ {
asprintf( &psz_output, "rtp{dst=%s,port=%i,mux=%s}", if( p_media->b_raw )
ip, i_port_video, p_media->psz_mux ); {
asprintf( &psz_output, "std{access=udp,dst=%s:%i,mux=%s}",
ip, i_port, p_media->psz_mux );
}
else
{
asprintf( &psz_output, "rtp{dst=%s,port=%i,mux=%s}",
ip, i_port_video, p_media->psz_mux );
}
} }
else else
{ {
...@@ -786,6 +774,30 @@ rtsp_play_now: /* This avoids code duplications although it is ugly. */ ...@@ -786,6 +774,30 @@ rtsp_play_now: /* This avoids code duplications although it is ugly. */
break; break;
} }
case HTTPD_MSG_DESCRIBE:
{
char *psz_sdp =
SDPGenerate( p_media, cl );
if( psz_sdp != NULL )
{
answer->i_status = 200;
answer->psz_status = strdup( "OK" );
httpd_MsgAdd( answer, "Content-type", "%s", "application/sdp" );
answer->p_body = (uint8_t *)psz_sdp;
answer->i_body = strlen( psz_sdp );
}
else
{
answer->i_status = 500;
answer->psz_status = strdup( "Internal server error" );
answer->p_body = NULL;
answer->i_body = 0;
}
break;
}
case HTTPD_MSG_PAUSE: case HTTPD_MSG_PAUSE:
psz_session = httpd_MsgGet( query, "Session" ); psz_session = httpd_MsgGet( query, "Session" );
msg_Dbg( p_vod, "HTTPD_MSG_PAUSE for session: %s", psz_session ); msg_Dbg( p_vod, "HTTPD_MSG_PAUSE for session: %s", psz_session );
...@@ -913,9 +925,6 @@ static int RtspCallbackES( httpd_callback_sys_t *p_args, httpd_client_t *cl, ...@@ -913,9 +925,6 @@ static int RtspCallbackES( httpd_callback_sys_t *p_args, httpd_client_t *cl,
p_rtsp_es->p_media_es = p_es; p_rtsp_es->p_media_es = p_es;
TAB_APPEND( p_rtsp->i_es, p_rtsp->es, p_rtsp_es ); TAB_APPEND( p_rtsp->i_es, p_rtsp->es, p_rtsp_es );
if( psz_playnow ) /* support option: x-playNow */
goto rtsp_play_now;
answer->i_status = 200; answer->i_status = 200;
answer->psz_status = strdup( "OK" ); answer->psz_status = strdup( "OK" );
answer->i_body = 0; answer->i_body = 0;
...@@ -931,42 +940,10 @@ static int RtspCallbackES( httpd_callback_sys_t *p_args, httpd_client_t *cl, ...@@ -931,42 +940,10 @@ static int RtspCallbackES( httpd_callback_sys_t *p_args, httpd_client_t *cl,
answer->i_body = 0; answer->i_body = 0;
answer->p_body = NULL; answer->p_body = NULL;
} }
break; if( !psz_playnow )
break;
case HTTPD_MSG_TEARDOWN:
answer->i_status = 200;
answer->psz_status = strdup( "OK" );
answer->i_body = 0;
answer->p_body = NULL;
psz_session = httpd_MsgGet( query, "Session" );
msg_Dbg( p_vod, "HTTPD_MSG_TEARDOWN for session: %s", psz_session);
p_rtsp = RtspClientGet( p_media, psz_session );
if( !p_rtsp ) break;
for( i = 0; i < p_rtsp->i_es; i++ )
{
if( p_rtsp->es[i]->p_media_es == p_es )
{
if( p_rtsp->es[i]->psz_ip ) free( p_rtsp->es[i]->psz_ip );
TAB_REMOVE( p_rtsp->i_es, p_rtsp->es, p_rtsp->es[i] );
break;
}
}
if( !p_rtsp->i_es )
{
vod_MediaControl( p_vod, p_media, psz_session,
VOD_MEDIA_STOP );
RtspClientDel( p_media, p_rtsp );
}
break;
case HTTPD_MSG_PLAY: case HTTPD_MSG_PLAY:
/* This avoids code duplications although it is ugly. */
rtsp_play_now:
/* This is kind of a kludge. Should we only support Aggregate /* This is kind of a kludge. Should we only support Aggregate
* Operations ? */ * Operations ? */
psz_session = httpd_MsgGet( query, "Session" ); psz_session = httpd_MsgGet( query, "Session" );
...@@ -997,6 +974,36 @@ rtsp_play_now: ...@@ -997,6 +974,36 @@ rtsp_play_now:
answer->p_body = NULL; answer->p_body = NULL;
break; break;
case HTTPD_MSG_TEARDOWN:
answer->i_status = 200;
answer->psz_status = strdup( "OK" );
answer->i_body = 0;
answer->p_body = NULL;
psz_session = httpd_MsgGet( query, "Session" );
msg_Dbg( p_vod, "HTTPD_MSG_TEARDOWN for session: %s", psz_session);
p_rtsp = RtspClientGet( p_media, psz_session );
if( !p_rtsp ) break;
for( i = 0; i < p_rtsp->i_es; i++ )
{
if( p_rtsp->es[i]->p_media_es == p_es )
{
if( p_rtsp->es[i]->psz_ip ) free( p_rtsp->es[i]->psz_ip );
TAB_REMOVE( p_rtsp->i_es, p_rtsp->es, p_rtsp->es[i] );
break;
}
}
if( !p_rtsp->i_es )
{
vod_MediaControl( p_vod, p_media, psz_session,
VOD_MEDIA_STOP );
RtspClientDel( p_media, p_rtsp );
}
break;
case HTTPD_MSG_PAUSE: case HTTPD_MSG_PAUSE:
/* This is kind of a kludge. Should we only support Aggregate /* This is kind of a kludge. Should we only support Aggregate
* Operations ? */ * Operations ? */
......
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