Commit dd153084 authored by Gildas Bazin's avatar Gildas Bazin

* src/misc/vlm.c: added support for the 'mux' option for VOD.

   This option tells the vod server to send an encapsulated stream.
* modules/misc/rtsp.c: support for mp2t (MPEG TS) and mp2p (MPEG PS) mux types.
* doc/vlm.txt: update for the mux option.
parent 5e129a68
...@@ -102,6 +102,12 @@ Note: an element is a media or a schedule. ...@@ -102,6 +102,12 @@ Note: an element is a media or a schedule.
If a media with "loop" option receives the "play" command If a media with "loop" option receives the "play" command
and finally finishes to play the last input of the list, it and finally finishes to play the last input of the list, it
will automatically restart to play the input list. will automatically restart to play the input list.
mux (mux_name)
Used for vod only.
Only needs to be specified if you want the elementary streams
to be sent encapsulated instead of raw. The (mux_name) should be
a fourcc describing the encapsulation type (eg. mp2t for MPEG TS,
or mp2t for MPEG PS).
Schedule Properties Syntax: Schedule Properties Syntax:
enabled|disabled enabled|disabled
......
...@@ -70,6 +70,7 @@ typedef struct ...@@ -70,6 +70,7 @@ typedef struct
/* only for vod */ /* only for vod */
vod_media_t *vod_media; vod_media_t *vod_media;
char *psz_vod_output; char *psz_vod_output;
char *psz_mux;
/* actual input instances */ /* actual input instances */
int i_instance; int i_instance;
......
...@@ -127,6 +127,7 @@ struct vod_media_t ...@@ -127,6 +127,7 @@ struct vod_media_t
/* ES list */ /* ES list */
int i_es; int i_es;
media_es_t **es; media_es_t **es;
char *psz_mux;
/* RTSP client */ /* RTSP client */
int i_rtsp; int i_rtsp;
...@@ -265,6 +266,7 @@ static vod_media_t *MediaNew( vod_t *p_vod, char *psz_name, ...@@ -265,6 +266,7 @@ static vod_media_t *MediaNew( vod_t *p_vod, char *psz_name,
memset( p_media, 0, sizeof(vod_media_t) ); memset( p_media, 0, sizeof(vod_media_t) );
p_media->es = 0; p_media->es = 0;
p_media->psz_mux = 0;
p_media->rtsp = 0; p_media->rtsp = 0;
asprintf( &p_media->psz_rtsp_path, "%s%s", p_sys->psz_path, psz_name ); asprintf( &p_media->psz_rtsp_path, "%s%s", p_sys->psz_path, psz_name );
...@@ -347,6 +349,7 @@ static int MediaAddES( vod_t *p_vod, vod_media_t *p_media, es_format_t *p_fmt ) ...@@ -347,6 +349,7 @@ static int MediaAddES( vod_t *p_vod, vod_media_t *p_media, es_format_t *p_fmt )
char *psz_urlc; char *psz_urlc;
memset( p_es, 0, sizeof(media_es_t) ); memset( p_es, 0, sizeof(media_es_t) );
p_media->psz_mux = NULL;
/* TODO: update SDP, etc... */ /* TODO: update SDP, etc... */
asprintf( &psz_urlc, "%s/trackid=%d", asprintf( &psz_urlc, "%s/trackid=%d",
...@@ -424,6 +427,16 @@ static int MediaAddES( vod_t *p_vod, vod_media_t *p_media, es_format_t *p_fmt ) ...@@ -424,6 +427,16 @@ static int MediaAddES( vod_t *p_vod, vod_media_t *p_media, es_format_t *p_fmt )
free( p_hexa ); free( p_hexa );
} }
break; break;
case VLC_FOURCC( 'm', 'p', '2', 't' ):
p_media->psz_mux = "ts";
p_es->i_payload_type = 33;
p_es->psz_rtpmap = strdup( "MP2T/90000" );
break;
case VLC_FOURCC( 'm', 'p', '2', 'p' ):
p_media->psz_mux = "ps";
p_es->i_payload_type = p_media->i_payload_type++;
p_es->psz_rtpmap = strdup( "MP2P/90000" );
break;
default: default:
msg_Err( p_vod, "cannot add this stream (unsupported " msg_Err( p_vod, "cannot add this stream (unsupported "
...@@ -648,8 +661,17 @@ static int RtspCallback( httpd_callback_sys_t *p_args, httpd_client_t *cl, ...@@ -648,8 +661,17 @@ static int RtspCallback( httpd_callback_sys_t *p_args, httpd_client_t *cl,
i_port_video = p_rtsp->es[i]->i_port; i_port_video = p_rtsp->es[i]->i_port;
} }
asprintf( &psz_output, "rtp{dst=%s,port-video=%i,port-audio=%i}", if( p_media->psz_mux )
ip, i_port_video, i_port_audio ); {
asprintf( &psz_output, "rtp{dst=%s,port=%i,mux=%s}",
ip, i_port_video, p_media->psz_mux );
}
else
{
asprintf( &psz_output, "rtp{dst=%s,port-video=%i,"
"port-audio=%i}", ip, i_port_video, i_port_audio );
}
vod_MediaControl( p_vod, p_media, psz_session, VOD_MEDIA_PLAY, vod_MediaControl( p_vod, p_media, psz_session, VOD_MEDIA_PLAY,
psz_output ); psz_output );
free( psz_output ); free( psz_output );
......
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
* Preamble * Preamble
*****************************************************************************/ *****************************************************************************/
#include <stdlib.h> /* malloc(), free() */ #include <stdlib.h> /* malloc(), free() */
#include <ctype.h> /* tolower() */
#include <vlc/vlc.h> #include <vlc/vlc.h>
...@@ -648,6 +649,20 @@ static int ExecuteCommand(vlm_t *vlm, char *command, vlm_message_t **p_message) ...@@ -648,6 +649,20 @@ static int ExecuteCommand(vlm_t *vlm, char *command, vlm_message_t **p_message)
{ {
vlm_MediaSetup( vlm, media, p_command[i], NULL ); vlm_MediaSetup( vlm, media, p_command[i], NULL );
} }
else if( i + 1 >= i_command && !strcmp( p_command[i], "mux" ) )
{
if( media->i_type != VOD_TYPE )
{
message = vlm_MessageNew( p_command[0],
"mux only available for broadcast" );
}
else
{
vlm_MediaSetup( vlm, media, p_command[i],
p_command[i+1] );
i++;
}
}
else if( strcmp( p_command[i], "loop" ) == 0 || else if( strcmp( p_command[i], "loop" ) == 0 ||
strcmp( p_command[i], "unloop" ) == 0 ) strcmp( p_command[i], "unloop" ) == 0 )
{ {
...@@ -771,6 +786,7 @@ static vlm_media_t *vlm_MediaNew( vlm_t *vlm, char *psz_name, int i_type ) ...@@ -771,6 +786,7 @@ static vlm_media_t *vlm_MediaNew( vlm_t *vlm, char *psz_name, int i_type )
media->b_loop = VLC_FALSE; media->b_loop = VLC_FALSE;
media->vod_media = NULL; media->vod_media = NULL;
media->psz_vod_output = NULL; media->psz_vod_output = NULL;
media->psz_mux = NULL;
media->i_input = 0; media->i_input = 0;
media->input = NULL; media->input = NULL;
media->psz_output = NULL; media->psz_output = NULL;
...@@ -824,6 +840,7 @@ static void vlm_MediaDelete( vlm_t *vlm, vlm_media_t *media, char *psz_name ) ...@@ -824,6 +840,7 @@ static void vlm_MediaDelete( vlm_t *vlm, vlm_media_t *media, char *psz_name )
if( media->input ) free( media->input ); if( media->input ) free( media->input );
if( media->psz_output ) free( media->psz_output ); if( media->psz_output ) free( media->psz_output );
if( media->psz_mux ) free( media->psz_mux );
while( media->i_option-- ) free( media->option[media->i_option] ); while( media->i_option-- ) free( media->option[media->i_option] );
if( media->option ) free( media->option ); if( media->option ) free( media->option );
...@@ -852,6 +869,12 @@ static int vlm_MediaSetup( vlm_t *vlm, vlm_media_t *media, char *psz_cmd, ...@@ -852,6 +869,12 @@ static int vlm_MediaSetup( vlm_t *vlm, vlm_media_t *media, char *psz_cmd,
{ {
media->b_enabled = VLC_FALSE; media->b_enabled = VLC_FALSE;
} }
else if( strcmp( psz_cmd, "mux" ) == 0 )
{
if( media->psz_mux ) free( media->psz_mux );
media->psz_mux = NULL;
if( psz_value ) media->psz_mux = strdup( psz_value );
}
else if( strcmp( psz_cmd, "input" ) == 0 ) else if( strcmp( psz_cmd, "input" ) == 0 )
{ {
char *input; char *input;
...@@ -941,6 +964,26 @@ static int vlm_MediaSetup( vlm_t *vlm, vlm_media_t *media, char *psz_cmd, ...@@ -941,6 +964,26 @@ static int vlm_MediaSetup( vlm_t *vlm, vlm_media_t *media, char *psz_cmd,
} }
free( psz_output ); free( psz_output );
if( media->psz_mux )
{
input_item_t item;
es_format_t es, *p_es = &es;
char fourcc[5];
sprintf( fourcc, "%4.4s", media->psz_mux );
fourcc[0] = tolower(fourcc[0]); fourcc[1] = tolower(fourcc[1]);
fourcc[2] = tolower(fourcc[2]); fourcc[3] = tolower(fourcc[3]);
item = media->item;
item.i_es = 1;
item.es = &p_es;
es_format_Init( &es, VIDEO_ES, *((int *)fourcc) );
media->vod_media =
vlm->vod->pf_media_new( vlm->vod, media->psz_name, &item );
return VLC_SUCCESS;
}
media->vod_media = media->vod_media =
vlm->vod->pf_media_new( vlm->vod, media->psz_name, vlm->vod->pf_media_new( vlm->vod, media->psz_name,
&media->item ); &media->item );
...@@ -1396,6 +1439,10 @@ static vlm_message_t *vlm_Show( vlm_t *vlm, vlm_media_t *media, ...@@ -1396,6 +1439,10 @@ static vlm_message_t *vlm_Show( vlm_t *vlm, vlm_media_t *media,
vlm_MessageNew( "loop", media->b_loop ? vlm_MessageNew( "loop", media->b_loop ?
"yes" : "no" ) ); "yes" : "no" ) );
if( media->i_type == VOD_TYPE && media->psz_mux )
vlm_MessageAdd( msg_media,
vlm_MessageNew( "mux", media->psz_mux ) );
msg_child = vlm_MessageAdd( msg_media, msg_child = vlm_MessageAdd( msg_media,
vlm_MessageNew( "inputs", NULL ) ); vlm_MessageNew( "inputs", NULL ) );
...@@ -1529,7 +1576,7 @@ static vlm_message_t *vlm_Show( vlm_t *vlm, vlm_media_t *media, ...@@ -1529,7 +1576,7 @@ static vlm_message_t *vlm_Show( vlm_t *vlm, vlm_media_t *media,
} }
else if( psz_filter && strcmp( psz_filter, "media") == 0 ) else if( psz_filter && strcmp( psz_filter, "media" ) == 0 )
{ {
int i, j; int i, j;
vlm_message_t *msg; vlm_message_t *msg;
...@@ -1554,6 +1601,10 @@ static vlm_message_t *vlm_Show( vlm_t *vlm, vlm_media_t *media, ...@@ -1554,6 +1601,10 @@ static vlm_message_t *vlm_Show( vlm_t *vlm, vlm_media_t *media,
vlm_MessageNew( "enabled", m->b_enabled ? vlm_MessageNew( "enabled", m->b_enabled ?
"yes" : "no" ) ); "yes" : "no" ) );
if( m->i_type == VOD_TYPE && m->psz_mux )
vlm_MessageAdd( msg_media,
vlm_MessageNew( "mux", m->psz_mux ) );
msg_instance = vlm_MessageAdd( msg_media, msg_instance = vlm_MessageAdd( msg_media,
vlm_MessageNew( "instances", 0 ) ); vlm_MessageNew( "instances", 0 ) );
......
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