Commit 99e83fd4 authored by Gildas Bazin's avatar Gildas Bazin

* modules/misc/rtsp.c, src/misc/vlm.c: VOD RTSP support is beginning to work.

parent b6be61a2
...@@ -69,6 +69,7 @@ typedef struct ...@@ -69,6 +69,7 @@ typedef struct
/* only for vod */ /* only for vod */
vod_media_t *vod_media; vod_media_t *vod_media;
char *psz_vod_output;
/* actual input instances */ /* actual input instances */
int i_instance; int i_instance;
......
...@@ -37,6 +37,32 @@ struct vod_t ...@@ -37,6 +37,32 @@ struct vod_t
int (*pf_media_add_es)( vod_t *, vod_media_t *, es_format_t * ); int (*pf_media_add_es)( vod_t *, vod_media_t *, es_format_t * );
void (*pf_media_del_es)( vod_t *, vod_media_t *, es_format_t * ); void (*pf_media_del_es)( vod_t *, vod_media_t *, es_format_t * );
/* Owner properties */
int (*pf_media_control) ( void *, vod_media_t *, char *, int, va_list );
void *p_data;
};
static inline int vod_MediaControl( vod_t *p_vod, vod_media_t *p_media,
char *psz_id, int i_query, ... )
{
va_list args;
int i_result;
if( !p_vod->pf_media_control ) return VLC_EGENERIC;
va_start( args, i_query );
i_result = p_vod->pf_media_control( p_vod->p_data, p_media, psz_id,
i_query, args );
va_end( args );
return i_result;
}
enum vod_query_e
{
VOD_MEDIA_PLAY, /* arg1= double * res= */
VOD_MEDIA_PAUSE, /* arg1= double * res= */
VOD_MEDIA_STOP, /* arg1= double res=can fail */
VOD_MEDIA_SEEK, /* arg1= double * res= */
}; };
#endif #endif
...@@ -577,6 +577,8 @@ static int RtspCallback( httpd_callback_sys_t *p_args, httpd_client_t *cl, ...@@ -577,6 +577,8 @@ static int RtspCallback( httpd_callback_sys_t *p_args, httpd_client_t *cl,
case HTTPD_MSG_PLAY: case HTTPD_MSG_PLAY:
{ {
rtsp_client_t *rtsp; rtsp_client_t *rtsp;
char *psz_output, *ip;
int i, i_port_audio = 0, i_port_video = 0;
/* for now only multicast so easy */ /* for now only multicast so easy */
answer->i_status = 200; answer->i_status = 200;
...@@ -588,17 +590,34 @@ static int RtspCallback( httpd_callback_sys_t *p_args, httpd_client_t *cl, ...@@ -588,17 +590,34 @@ static int RtspCallback( httpd_callback_sys_t *p_args, httpd_client_t *cl,
msg_Dbg( p_vod, "HTTPD_MSG_PLAY for session: %s", psz_session ); msg_Dbg( p_vod, "HTTPD_MSG_PLAY for session: %s", psz_session );
rtsp = RtspClientGet( p_media, psz_session ); rtsp = RtspClientGet( p_media, psz_session );
if( rtsp && !rtsp->b_playing ) if( !rtsp || rtsp->b_playing ) break;
if( !(ip = httpd_ClientIP( cl )) ) break;
rtsp->b_playing = VLC_TRUE;
/* FIXME for != 1 video and 1 audio */
for( i = 0; i < p_media->i_es; i++ )
{ {
rtsp->b_playing = VLC_TRUE; if( p_media->es[i]->fmt.i_cat == AUDIO_ES )
/* TODO: do something useful */ i_port_audio = p_media->es[i]->i_port;
if( p_media->es[i]->fmt.i_cat == VIDEO_ES )
i_port_video = p_media->es[i]->i_port;
} }
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,
psz_output );
free( psz_output );
free( ip );
break; 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 );
vod_MediaControl( p_vod, p_media, psz_session, VOD_MEDIA_PAUSE );
/* TODO: do something useful */ /* TODO: do something useful */
return VLC_EGENERIC; return VLC_EGENERIC;
...@@ -616,11 +635,10 @@ static int RtspCallback( httpd_callback_sys_t *p_args, httpd_client_t *cl, ...@@ -616,11 +635,10 @@ static int RtspCallback( httpd_callback_sys_t *p_args, httpd_client_t *cl,
msg_Dbg( p_vod, "HTTPD_MSG_TEARDOWN for session: %s", psz_session); msg_Dbg( p_vod, "HTTPD_MSG_TEARDOWN for session: %s", psz_session);
rtsp = RtspClientGet( p_media, psz_session ); rtsp = RtspClientGet( p_media, psz_session );
if( rtsp ) if( !rtsp ) break;
{
/* TODO: do something useful */ vod_MediaControl( p_vod, p_media, psz_session, VOD_MEDIA_STOP );
RtspClientDel( p_media, rtsp ); RtspClientDel( p_media, rtsp );
}
break; break;
} }
......
...@@ -62,6 +62,8 @@ static void vlm_ScheduleDelete( vlm_t *, vlm_schedule_t *, char *); ...@@ -62,6 +62,8 @@ static void vlm_ScheduleDelete( vlm_t *, vlm_schedule_t *, char *);
static int vlm_ScheduleSetup( vlm_schedule_t *, char *, char *); static int vlm_ScheduleSetup( vlm_schedule_t *, char *, char *);
static vlm_schedule_t *vlm_ScheduleSearch( vlm_t *, char *); static vlm_schedule_t *vlm_ScheduleSearch( vlm_t *, char *);
static int vlm_MediaVodControl( void *, vod_media_t *, char *, int, va_list );
static int ExecuteCommand( vlm_t *, char *, vlm_message_t **); static int ExecuteCommand( vlm_t *, char *, vlm_message_t **);
static int Manage( vlc_object_t* ); static int Manage( vlc_object_t* );
...@@ -755,6 +757,9 @@ static vlm_media_t *vlm_MediaNew( vlm_t *vlm, char *psz_name, int i_type ) ...@@ -755,6 +757,9 @@ static vlm_media_t *vlm_MediaNew( vlm_t *vlm, char *psz_name, int i_type )
free( media ); free( media );
return NULL; return NULL;
} }
vlm->vod->p_data = vlm;
vlm->vod->pf_media_control = vlm_MediaVodControl;
} }
if( i_type == VOD_TYPE ) vlm->i_vod++; if( i_type == VOD_TYPE ) vlm->i_vod++;
...@@ -762,6 +767,7 @@ static vlm_media_t *vlm_MediaNew( vlm_t *vlm, char *psz_name, int i_type ) ...@@ -762,6 +767,7 @@ static vlm_media_t *vlm_MediaNew( vlm_t *vlm, char *psz_name, int i_type )
media->b_enabled = VLC_FALSE; media->b_enabled = VLC_FALSE;
media->b_loop = VLC_FALSE; media->b_loop = VLC_FALSE;
media->vod_media = NULL; media->vod_media = NULL;
media->psz_vod_output = NULL;
media->i_input = 0; media->i_input = 0;
media->input = NULL; media->input = NULL;
media->psz_output = NULL; media->psz_output = NULL;
...@@ -960,11 +966,14 @@ static int vlm_MediaControl( vlm_t *vlm, vlm_media_t *media, char *psz_id, ...@@ -960,11 +966,14 @@ static int vlm_MediaControl( vlm_t *vlm, vlm_media_t *media, char *psz_id,
vlc_input_item_Init( VLC_OBJECT(vlm), &p_instance->item ); vlc_input_item_Init( VLC_OBJECT(vlm), &p_instance->item );
p_instance->p_input = 0; p_instance->p_input = 0;
if( media->psz_output != NULL ) if( media->psz_output != NULL || media->psz_vod_output != NULL )
{ {
p_instance->item.ppsz_options = malloc( sizeof( char* ) ); p_instance->item.ppsz_options = malloc( sizeof( char* ) );
asprintf( &p_instance->item.ppsz_options[0], "sout=%s", asprintf( &p_instance->item.ppsz_options[0], "sout=%s%s%s",
media->psz_output ); media->psz_output ? media->psz_output : "",
(media->psz_output && media->psz_vod_output) ?
":" : media->psz_vod_output ? "#" : "",
media->psz_vod_output ? media->psz_vod_output : "" );
p_instance->item.i_options = 1; p_instance->item.i_options = 1;
} }
...@@ -1957,6 +1966,56 @@ static char *vlm_Save( vlm_t *vlm ) ...@@ -1957,6 +1966,56 @@ static char *vlm_Save( vlm_t *vlm )
return save; return save;
} }
/*****************************************************************************
* Manage:
*****************************************************************************/
static int vlm_MediaVodControl( void *p_private, vod_media_t *p_vod_media,
char *psz_id, int i_query, va_list args )
{
vlm_t *vlm = (vlm_t *)p_private;
int i, i_ret = VLC_EGENERIC;
if( !p_private || !p_vod_media ) return VLC_EGENERIC;
vlc_mutex_lock( &vlm->lock );
/* Find media */
for( i = 0; i < vlm->i_media; i++ )
{
if( p_vod_media == vlm->media[i]->vod_media ) break;
}
if( i == vlm->i_media )
{
vlc_mutex_unlock( &vlm->lock );
return VLC_EGENERIC;
}
switch( i_query )
{
case VOD_MEDIA_PLAY:
vlm->media[i]->psz_vod_output = (char *)va_arg( args, char * );
i_ret = vlm_MediaControl( vlm, vlm->media[i], psz_id, "play", 0 );
vlm->media[i]->psz_vod_output = 0;
break;
case VOD_MEDIA_PAUSE:
i_ret = vlm_MediaControl( vlm, vlm->media[i], psz_id, "pause", 0 );
break;
case VOD_MEDIA_STOP:
i_ret = vlm_MediaControl( vlm, vlm->media[i], psz_id, "stop", 0 );
break;
default:
break;
}
vlc_mutex_unlock( &vlm->lock );
return i_ret;
}
/***************************************************************************** /*****************************************************************************
* Manage: * Manage:
*****************************************************************************/ *****************************************************************************/
......
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