#include <vlc_sout.h>
#include <vlc_block.h>
-#include "vlc_httpd.h"
-#include "vlc_vod.h"
-#include "vlc_url.h"
+#include <vlc_httpd.h>
+#include <vlc_vod.h>
+#include <vlc_url.h>
#include <vlc_network.h>
#include <vlc_charset.h>
#include <vlc_strings.h>
"interfaces (address 0.0.0.0), on port 554, with no path.\nTo listen " \
"only on the local interface, use \"localhost\" as address." )
-#define THROTLE_TEXT N_( "Maximum number of connections" )
-#define THROTLE_LONGTEXT N_( "This limits the maximum number of clients " \
+#define THROTTLE_TEXT N_( "Maximum number of connections" )
+#define THROTTLE_LONGTEXT N_( "This limits the maximum number of clients " \
"that can connect to the RTSP VOD. 0 means no limit." )
#define RAWMUX_TEXT N_( "MUX for RAW RTSP transport" )
add_string ( "rtsp-host", NULL, NULL, HOST_TEXT, HOST_LONGTEXT, true )
add_string( "rtsp-raw-mux", "ts", NULL, RAWMUX_TEXT,
RAWMUX_TEXT, true )
- add_integer( "rtsp-throttle-users", 0, NULL, THROTLE_TEXT,
- THROTLE_LONGTEXT, true )
+ add_integer( "rtsp-throttle-users", 0, NULL, THROTTLE_TEXT,
+ THROTTLE_LONGTEXT, true )
add_integer( "rtsp-session-timeout", 5, NULL, SESSION_TIMEOUT_TEXT,
SESSION_TIMEOUT_LONGTEXT, true )
vlc_module_end ()
typedef struct
{
media_es_t *p_media_es;
- char *psz_ip;
int i_port;
} rtsp_client_es_t;
typedef struct
{
char *psz_session;
- int64_t i_last; /* for timeout */
bool b_playing; /* is it in "play" state */
bool b_paused; /* is it in "pause" state */
vod_media_t *p_media;
es_format_t fmt;
- int i_port;
uint8_t i_payload_type;
char *psz_rtpmap;
char *psz_fmtp;
char *psz_rtsp_control_v6;
char *psz_rtsp_path;
- int i_port;
- int i_port_audio;
- int i_port_video;
- int i_ttl;
int i_payload_type;
int64_t i_sdp_id;
int i_sdp_version;
- bool b_multicast;
-
vlc_mutex_t lock;
/* ES list */
rtsp_client_t **rtsp;
/* Infos */
- char *psz_session_name;
- char *psz_session_description;
- char *psz_session_url;
- char *psz_session_email;
mtime_t i_length;
};
RTSP_CMD_TYPE_SEEK,
RTSP_CMD_TYPE_REWIND,
RTSP_CMD_TYPE_FORWARD,
+
+ RTSP_CMD_TYPE_ADD,
+ RTSP_CMD_TYPE_DEL,
} rtsp_cmd_type_t;
/* */
{
int i_type;
int i_media_id;
- //vod_media_t *p_media;
+ vod_media_t *p_media;
char *psz_session;
char *psz_arg;
double f_arg;
static vod_media_t *MediaNew( vod_t *, const char *, input_item_t * );
static void MediaDel( vod_t *, vod_media_t * );
+static void MediaAskDel ( vod_t *, vod_media_t * );
static int MediaAddES( vod_t *, vod_media_t *, es_format_t * );
static void MediaDelES( vod_t *, vod_media_t *, es_format_t * );
p_sys->i_media_id = 0;
p_vod->pf_media_new = MediaNew;
- p_vod->pf_media_del = MediaDel;
+ p_vod->pf_media_del = MediaAskDel;
p_vod->pf_media_add_es = MediaAddES;
p_vod->pf_media_del_es = MediaDelES;
p_block_cmd = block_FifoGet( p_sys->p_fifo_cmd );
memcpy( &cmd, p_block_cmd->p_buffer, sizeof(cmd) );
block_Release( p_block_cmd );
+ if ( cmd.i_type == RTSP_CMD_TYPE_DEL )
+ MediaDel(p_vod, cmd.p_media);
free( cmd.psz_session );
free( cmd.psz_arg );
}
p_media->p_vod = p_vod;
- vlc_mutex_lock( &p_sys->lock_media );
- TAB_APPEND( p_sys->i_media, p_sys->media, p_media );
- vlc_mutex_unlock( &p_sys->lock_media );
-
vlc_mutex_init( &p_media->lock );
- p_media->psz_session_name = strdup("");
- p_media->psz_session_description = strdup("");
- p_media->psz_session_url = strdup("");
- p_media->psz_session_email = strdup("");
-
- p_media->i_port_audio = 1234;
- p_media->i_port_video = 1236;
- p_media->i_port = 1238;
+
p_media->i_payload_type = 96;
p_media->i_sdp_id = mdate();
}
vlc_mutex_unlock( &p_item->lock );
+ CommandPush( p_vod, RTSP_CMD_TYPE_ADD, p_media, NULL, 0.0, NULL );
return p_media;
}
+static void MediaAskDel ( vod_t *p_vod, vod_media_t *p_media )
+{
+ CommandPush( p_vod, RTSP_CMD_TYPE_DEL, p_media, NULL, 0.0, NULL );
+}
+
static void MediaDel( vod_t *p_vod, vod_media_t *p_media )
{
vod_sys_t *p_sys = p_vod->p_sys;
vlc_mutex_destroy( &p_media->lock );
- free( p_media->psz_session_name );
- free( p_media->psz_session_description );
- free( p_media->psz_session_url );
- free( p_media->psz_session_email );
free( p_media->psz_mux );
free( p_media );
}
p_es->p_vod = p_vod;
p_es->p_media = p_media;
-#if 0
- /* Choose the port */
- if( p_fmt->i_cat == AUDIO_ES && p_media->i_port_audio > 0 )
- {
- p_es->i_port = p_media->i_port_audio;
- p_media->i_port_audio = 0;
- }
- else if( p_fmt->i_cat == VIDEO_ES && p_media->i_port_video > 0 )
- {
- p_es->i_port = p_media->i_port_video;
- p_media->i_port_video = 0;
- }
- while( !p_es->i_port )
- {
- if( p_media->i_port != p_media->i_port_audio &&
- p_media->i_port != p_media->i_port_video )
- {
- p_es->i_port = p_media->i_port;
- p_media->i_port += 2;
- break;
- }
- p_media->i_port += 2;
- }
-#else
-
- p_es->i_port = 0;
-#endif
-
vlc_mutex_lock( &p_media->lock );
TAB_APPEND( p_media->i_es, p_media->es, p_es );
vlc_mutex_unlock( &p_media->lock );
memset( &cmd, 0, sizeof(cmd) );
cmd.i_type = i_type;
+ cmd.p_media = p_media;
if( p_media )
cmd.i_media_id = p_media->id;
if( psz_session )
if( cmd.i_type == RTSP_CMD_TYPE_NONE )
break;
+ if ( cmd.i_type == RTSP_CMD_TYPE_ADD )
+ {
+ vlc_mutex_lock( &p_sys->lock_media );
+ TAB_APPEND( p_sys->i_media, p_sys->media, cmd.p_media );
+ vlc_mutex_unlock( &p_sys->lock_media );
+ goto next;
+ }
+
+ if ( cmd.i_type == RTSP_CMD_TYPE_DEL )
+ {
+ MediaDel(p_vod, cmd.p_media);
+ goto next;
+ }
+
/* */
vlc_mutex_lock( &p_sys->lock_media );
for( i = 0; i < p_sys->i_media; i++ )
break;
}
if( i >= p_sys->i_media )
+ {
+ vlc_mutex_unlock( &p_sys->lock_media );
goto next;
+ }
p_media = p_sys->media[i];
switch( cmd.i_type )
default:
break;
}
+ vlc_mutex_unlock( &p_sys->lock_media );
next:
- vlc_mutex_unlock( &p_sys->lock_media );
free( cmd.psz_session );
free( cmd.psz_arg );
}
while( p_rtsp->i_es )
{
p_rtsp->i_es--;
- free( p_rtsp->es[p_rtsp->i_es]->psz_ip );
free( p_rtsp->es[p_rtsp->i_es] );
}
free( p_rtsp->es );
f_pos /= ((double)(p_media->i_length))/1000 /1000 / 100;
CommandPush( p_vod, RTSP_CMD_TYPE_SEEK, p_media,
psz_session, f_pos, NULL );
- break;
}
- if( psz_scale )
+ else if( psz_scale )
{
double f_scale = 0.0;
char *end;
psz_session = psz_new;
p_rtsp = RtspClientNew( p_media, psz_new );
+ if( !p_rtsp )
+ {
+ answer->i_status = 454;
+ answer->i_body = 0;
+ answer->p_body = NULL;
+ break;
+ }
}
else
{
break;
}
p_rtsp_es->i_port = i_port;
- p_rtsp_es->psz_ip = strdup( ip );
p_rtsp_es->p_media_es = p_es;
TAB_APPEND( p_rtsp->i_es, p_rtsp->es, p_rtsp_es );
{
if( p_rtsp->es[i]->p_media_es == p_es )
{
- free( p_rtsp->es[i]->psz_ip );
TAB_REMOVE( p_rtsp->i_es, p_rtsp->es, p_rtsp->es[i] );
break;
}
/* Calculate size */
i_size = sizeof( "v=0\r\n" ) +
sizeof( "o=- * * IN IP4 \r\n" ) + 10 + NI_MAXNUMERICHOST +
- sizeof( "s=*\r\n" ) + strlen( p_media->psz_session_name ) +
- sizeof( "i=*\r\n" ) + strlen( p_media->psz_session_description ) +
- sizeof( "u=*\r\n" ) + strlen( p_media->psz_session_url ) +
- sizeof( "e=*\r\n" ) + strlen( p_media->psz_session_email ) +
sizeof( "c=IN IP4 0.0.0.0\r\n" ) + 20 + 10 +
sizeof( "t=0 0\r\n" ) + /* FIXME */
sizeof( "a=tool:"PACKAGE_STRING"\r\n" ) +
p += sprintf( p, "v=0\r\n" );
p += sprintf( p, "o=- %"PRId64" %d IN IP%c %s\r\n",
p_media->i_sdp_id, p_media->i_sdp_version, ipv, ip );
- if( *p_media->psz_session_name )
- p += sprintf( p, "s=%s\r\n", p_media->psz_session_name );
- if( *p_media->psz_session_description )
- p += sprintf( p, "i=%s\r\n", p_media->psz_session_description );
- if( *p_media->psz_session_url )
- p += sprintf( p, "u=%s\r\n", p_media->psz_session_url );
- if( *p_media->psz_session_email )
- p += sprintf( p, "e=%s\r\n", p_media->psz_session_email );
p += sprintf( p, "c=IN IP%c %s\r\n", ipv, ipv == '6' ? "::" : "0.0.0.0" );
p += sprintf( p, "t=0 0\r\n" ); /* FIXME */
if( p_es->fmt.i_cat == AUDIO_ES )
{
p += sprintf( p, "m=audio %d RTP/AVP %d\r\n",
- p_es->i_port, p_es->i_payload_type );
+ 0 /* p_es->i_port */, p_es->i_payload_type );
}
else if( p_es->fmt.i_cat == VIDEO_ES )
{
p += sprintf( p, "m=video %d RTP/AVP %d\r\n",
- p_es->i_port, p_es->i_payload_type );
+ 0 /* p_es->i_port */, p_es->i_payload_type );
}
else
{