#include <vlc_rand.h>
#ifdef HAVE_SRTP
# include <srtp.h>
+# include <gcrypt.h>
+# include <vlc_gcrypt.h>
#endif
#include "rtp.h"
# define IPPROTO_UDPLITE 136
#endif
+#include <ctype.h>
#include <errno.h>
-
#include <assert.h>
/*****************************************************************************
#define NAME_LONGTEXT N_( \
"This is the name of the session that will be announced in the SDP " \
"(Session Descriptor)." )
+#define CAT_TEXT N_("Session category")
+#define CAT_LONGTEXT N_( \
+ "This allows you to specify a category for the session, " \
+ "that will be announced if you choose to use SAP." )
#define DESC_TEXT N_("Session description")
#define DESC_LONGTEXT N_( \
"This allows you to give a short description with details about the stream, " \
#define SRTP_KEY_TEXT N_("SRTP key (hexadecimal)")
#define SRTP_KEY_LONGTEXT N_( \
"RTP packets will be integrity-protected and ciphered "\
- "with this Secure RTP master shared secret key.")
+ "with this Secure RTP master shared secret key. "\
+ "This must be a 32-character-long hexadecimal string.")
#define SRTP_SALT_TEXT N_("SRTP salt (hexadecimal)")
#define SRTP_SALT_LONGTEXT N_( \
- "Secure RTP requires a (non-secret) master salt value.")
+ "Secure RTP requires a (non-secret) master salt value. " \
+ "This must be a 28-character-long hexadecimal string.")
static const char *const ppsz_protos[] = {
"dccp", "sctp", "tcp", "udp", "udplite",
#define RFC3016_LONGTEXT N_( \
"This allows you to stream MPEG4 LATM audio streams (see RFC3016)." )
-#define RTSP_HOST_TEXT N_( "RTSP host address" )
-#define RTSP_HOST_LONGTEXT N_( \
- "This defines the address, port and path the RTSP VOD server will listen " \
- "on.\nSyntax is address:port/path. The default is to listen on all "\
- "interfaces (address 0.0.0.0), on port 554, with no path.\nTo listen " \
- "only on the local interface, use \"localhost\" as address." )
-
#define RTSP_TIMEOUT_TEXT N_( "RTSP session timeout (s)" )
#define RTSP_TIMEOUT_LONGTEXT N_( "RTSP sessions will be closed after " \
"not receiving any RTSP request for this long. Setting it to a " \
"negative value or zero disables timeouts. The default is 60 (one " \
"minute)." )
+#define RTSP_USER_TEXT N_("Username")
+#define RTSP_USER_LONGTEXT N_("User name that will be " \
+ "requested to access the stream." )
+#define RTSP_PASS_TEXT N_("Password")
+#define RTSP_PASS_LONGTEXT N_("Password that will be " \
+ "requested to access the stream." )
+
static int Open ( vlc_object_t * );
static void Close( vlc_object_t * );
add_string( SOUT_CFG_PREFIX "name", "", NAME_TEXT,
NAME_LONGTEXT, true )
+ add_string( SOUT_CFG_PREFIX "cat", "", CAT_TEXT, CAT_LONGTEXT, true )
add_string( SOUT_CFG_PREFIX "description", "", DESC_TEXT,
DESC_LONGTEXT, true )
add_string( SOUT_CFG_PREFIX "url", "", URL_TEXT,
add_string( SOUT_CFG_PREFIX "proto", "udp", PROTO_TEXT,
PROTO_LONGTEXT, false )
- change_string_list( ppsz_protos, ppsz_protocols, NULL )
+ change_string_list( ppsz_protos, ppsz_protocols )
add_integer( SOUT_CFG_PREFIX "port", 5004, PORT_TEXT,
PORT_LONGTEXT, true )
add_integer( SOUT_CFG_PREFIX "port-audio", 0, PORT_AUDIO_TEXT,
set_capability( "vod server", 10 )
set_callbacks( OpenVoD, CloseVoD )
add_shortcut( "rtsp" )
- add_string ( "rtsp-host", NULL, RTSP_HOST_TEXT,
- RTSP_HOST_LONGTEXT, true )
add_integer( "rtsp-timeout", 60, RTSP_TIMEOUT_TEXT,
RTSP_TIMEOUT_LONGTEXT, true )
+ add_string( "sout-rtsp-user", "",
+ RTSP_USER_TEXT, RTSP_USER_LONGTEXT, true )
+ add_password( "sout-rtsp-pwd", "",
+ RTSP_PASS_TEXT, RTSP_PASS_LONGTEXT, true )
vlc_module_end ()
* Exported prototypes
*****************************************************************************/
static const char *const ppsz_sout_options[] = {
- "dst", "name", "port", "port-audio", "port-video", "*sdp", "ttl", "mux",
- "sap", "description", "url", "email", "phone",
- "proto", "rtcp-mux", "caching", "key", "salt",
+ "dst", "name", "cat", "port", "port-audio", "port-video", "*sdp", "ttl",
+ "mux", "sap", "description", "url", "email", "phone",
+ "proto", "rtcp-mux", "caching",
+#ifdef HAVE_SRTP
+ "key", "salt",
+#endif
"mp4a-latm", NULL
};
static int Open( vlc_object_t *p_this )
{
sout_stream_t *p_stream = (sout_stream_t*)p_this;
- sout_instance_t *p_sout = p_stream->p_sout;
sout_stream_sys_t *p_sys = NULL;
config_chain_t *p_cfg = NULL;
char *psz;
}
p_sys->p_grab = GrabberCreate( p_stream );
- p_sys->p_mux = sout_MuxNew( p_sout, psz, p_sys->p_grab );
+ p_sys->p_mux = sout_MuxNew( p_stream->p_sout, psz, p_sys->p_grab );
free( psz );
if( p_sys->p_mux == NULL )
p_stream->pf_del = Del;
p_stream->pf_send = Send;
}
+ p_stream->pace_nocontrol = true;
if( var_GetBool( p_stream, SOUT_CFG_PREFIX"sap" ) )
SDPHandleUrl( p_stream, "sap" );
free( psz );
}
- /* update p_sout->i_out_pace_nocontrol */
- p_stream->p_sout->i_out_pace_nocontrol++;
-
if( p_sys->p_mux != NULL )
{
sout_stream_id_t *id = Add( p_stream, NULL );
sout_stream_t *p_stream = (sout_stream_t*)p_this;
sout_stream_sys_t *p_sys = p_stream->p_sys;
- /* update p_sout->i_out_pace_nocontrol */
- p_stream->p_sout->i_out_pace_nocontrol--;
-
if( p_sys->p_mux )
{
assert( p_sys->i_es <= 1 );
goto out;
}
- p_sys->rtsp = RtspSetup( VLC_OBJECT(p_stream), NULL, &url );
+ if( url.psz_host != NULL && *url.psz_host )
+ {
+ msg_Warn( p_stream, "\"%s\" RTSP host might be ignored in "
+ "multiple-host configurations, use at your own risks.",
+ url.psz_host );
+ msg_Info( p_stream, "Consider passing --rtsp-host=IP on the "
+ "command line instead." );
+
+ var_Create( p_stream, "rtsp-host", VLC_VAR_STRING );
+ var_SetString( p_stream, "rtsp-host", url.psz_host );
+ }
+ if( url.i_port != 0 )
+ {
+ /* msg_Info( p_stream, "Consider passing --rtsp-port=%u on "
+ "the command line instead.", url.i_port ); */
+
+ var_Create( p_stream, "rtsp-port", VLC_VAR_INTEGER );
+ var_SetInteger( p_stream, "rtsp-port", url.i_port );
+ }
+
+ p_sys->rtsp = RtspSetup( VLC_OBJECT(p_stream), NULL, url.psz_path );
if( p_sys->rtsp == NULL )
msg_Err( p_stream, "cannot export SDP as RTSP" );
}
sdp_AddAttribute( &psz_sdp, "setup", "passive" );
if( p_sys->proto == IPPROTO_DCCP )
sdp_AddAttribute( &psz_sdp, "dccp-service-code",
- "SC:RTP%c", toupper( mime_major[0] ) );
+ "SC:RTP%c",
+ toupper( (unsigned char)mime_major[0] ) );
}
}
out:
uint32_t rtp_compute_ts( unsigned i_clock_rate, int64_t i_pts )
{
- /* NOTE: this plays nice with offsets because the calculations are
- * linear. */
- return i_pts * (int64_t)i_clock_rate / CLOCK_FREQ;
+ /* This is an overflow-proof way of doing:
+ * return i_pts * (int64_t)i_clock_rate / CLOCK_FREQ;
+ *
+ * NOTE: this plays nice with offsets because the (equivalent)
+ * calculations are linear. */
+ lldiv_t q = lldiv(i_pts, CLOCK_FREQ);
+ return q.quot * (int64_t)i_clock_rate
+ + q.rem * (int64_t)i_clock_rate / CLOCK_FREQ;
}
/** Add an ES as a new RTP stream */
char *key = var_GetNonEmptyString (p_stream, SOUT_CFG_PREFIX"key");
if (key)
{
+ vlc_gcrypt_init ();
id->srtp = srtp_create (SRTP_ENCR_AES_CM, SRTP_AUTH_HMAC_SHA1, 10,
SRTP_PRF_AES_CM, SRTP_RCC_MODE1);
if (id->srtp == NULL)
static int SapSetup( sout_stream_t *p_stream )
{
sout_stream_sys_t *p_sys = p_stream->p_sys;
- sout_instance_t *p_sout = p_stream->p_sout;
/* Remove the previous session */
if( p_sys->p_session != NULL)
{
- sout_AnnounceUnRegister( p_sout, p_sys->p_session);
+ sout_AnnounceUnRegister( p_stream, p_sys->p_session);
p_sys->p_session = NULL;
}
if( p_sys->i_es > 0 && p_sys->psz_sdp && *p_sys->psz_sdp )
- p_sys->p_session = sout_AnnounceRegisterSDP( p_sout,
+ p_sys->p_session = sout_AnnounceRegisterSDP( p_stream,
p_sys->psz_sdp,
p_sys->psz_destination );
{
sout_stream_sys_t *p_sys = p_stream->p_sys;
- p_sys->p_httpd_host = httpd_HostNew( VLC_OBJECT(p_stream), url->psz_host,
- url->i_port > 0 ? url->i_port : 80 );
+ p_sys->p_httpd_host = vlc_http_HostNew( VLC_OBJECT(p_stream) );
if( p_sys->p_httpd_host )
{
p_sys->p_httpd_file = httpd_FileNew( p_sys->p_httpd_host,
url->psz_path ? url->psz_path : "/",
"application/sdp",
- NULL, NULL, NULL,
+ NULL, NULL,
HttpCallback, (void*)p_sys );
}
if( p_sys->p_httpd_file == NULL )
****************************************************************************/
static void* ThreadSend( void *data )
{
-#ifdef WIN32
-# define ECONNREFUSED WSAECONNREFUSED
-# define ENOPROTOOPT WSAENOPROTOOPT
-# define EHOSTUNREACH WSAEHOSTUNREACH
-# define ENETUNREACH WSAENETUNREACH
-# define ENETDOWN WSAENETDOWN
+#ifdef _WIN32
# define ENOBUFS WSAENOBUFS
# define EAGAIN WSAEWOULDBLOCK
# define EWOULDBLOCK WSAEWOULDBLOCK
/* As per RFC 2326, session identifiers are at least 8 bytes long */
strncpy((char *)&i_ts_init, psz_vod_session, sizeof(uint64_t));
i_ts_init ^= (uintptr_t)p_media;
- /* Limit the timestamp to 48 bytes, this is enough and allows us
+ /* Limit the timestamp to 48 bits, this is enough and allows us
* to stay away from overflows */
i_ts_init &= 0xFFFFFFFFFFFF;
return i_ts_init;
if( p_sys->packet == NULL )
{
/* allocate a new packet */
- p_sys->packet = block_New( p_stream, id->i_mtu );
+ p_sys->packet = block_Alloc( id->i_mtu );
rtp_packetize_common( id, p_sys->packet, 1, i_dts );
p_sys->packet->i_dts = i_dts;
p_sys->packet->i_length = p_buffer->i_length / i_packet;