Commit f9d4a5ab authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

RTP out: support build without libvlc_srtp

parent c752af77
...@@ -30,15 +30,18 @@ libvlc_LTLIBRARIES += \ ...@@ -30,15 +30,18 @@ libvlc_LTLIBRARIES += \
libstream_out_smem_plugin.la \ libstream_out_smem_plugin.la \
$(NULL) $(NULL)
if HAVE_GCRYPT
# RTP plugin # RTP plugin
libvlc_LTLIBRARIES += \ libvlc_LTLIBRARIES += \
libstream_out_rtp_plugin.la libstream_out_rtp_plugin.la
libstream_out_rtp_plugin_la_SOURCES = \ libstream_out_rtp_plugin_la_SOURCES = \
rtp.c rtp.h rtpfmt.c rtcp.c rtsp.c rtp.c rtp.h rtpfmt.c rtcp.c rtsp.c
libstream_out_rtp_plugin_la_CFLAGS = $(AM_CFLAGS) -I$(top_srcdir)/libs/srtp libstream_out_rtp_plugin_la_CFLAGS = $(AM_CFLAGS)
libstream_out_rtp_plugin_la_LIBADD = $(AM_LIBADD) \ libstream_out_rtp_plugin_la_LIBADD = $(AM_LIBADD)
$(top_builddir)/libs/srtp/libvlc_srtp.la libstream_out_rtp_plugin_la_DEPENDENCIES =
libstream_out_rtp_plugin_la_DEPENDENCIES = \ if HAVE_GCRYPT
$(top_builddir)/libs/srtp/libvlc_srtp.la SRTP_CFLAGS = -I$(top_srcdir)/libs/srtp
SRTP_LIBS = $(top_builddir)/libs/srtp/libvlc_srtp.la
libstream_out_rtp_plugin_la_CFLAGS += -DHAVE_SRTP $(SRTP_CFLAGS)
libstream_out_rtp_plugin_la_LIBADD += $(SRTP_LIBS)
libstream_out_rtp_plugin_la_DEPENDENCIES += $(SRTP_LIBS)
endif endif
...@@ -40,7 +40,9 @@ ...@@ -40,7 +40,9 @@
#include <vlc_charset.h> #include <vlc_charset.h>
#include <vlc_strings.h> #include <vlc_strings.h>
#include <vlc_rand.h> #include <vlc_rand.h>
#include <srtp.h> #ifdef HAVE_SRTP
# include <srtp.h>
#endif
#include "rtp.h" #include "rtp.h"
...@@ -201,10 +203,12 @@ vlc_module_begin () ...@@ -201,10 +203,12 @@ vlc_module_begin ()
add_bool( SOUT_CFG_PREFIX "rtcp-mux", false, NULL, add_bool( SOUT_CFG_PREFIX "rtcp-mux", false, NULL,
RTCP_MUX_TEXT, RTCP_MUX_LONGTEXT, false ) RTCP_MUX_TEXT, RTCP_MUX_LONGTEXT, false )
#ifdef HAVE_SRTP
add_string( SOUT_CFG_PREFIX "key", "", NULL, add_string( SOUT_CFG_PREFIX "key", "", NULL,
SRTP_KEY_TEXT, SRTP_KEY_LONGTEXT, false ) SRTP_KEY_TEXT, SRTP_KEY_LONGTEXT, false )
add_string( SOUT_CFG_PREFIX "salt", "", NULL, add_string( SOUT_CFG_PREFIX "salt", "", NULL,
SRTP_SALT_TEXT, SRTP_SALT_LONGTEXT, false ) SRTP_SALT_TEXT, SRTP_SALT_LONGTEXT, false )
#endif
add_bool( SOUT_CFG_PREFIX "mp4a-latm", false, NULL, RFC3016_TEXT, add_bool( SOUT_CFG_PREFIX "mp4a-latm", false, NULL, RFC3016_TEXT,
RFC3016_LONGTEXT, false ) RFC3016_LONGTEXT, false )
...@@ -312,7 +316,9 @@ struct sout_stream_id_t ...@@ -312,7 +316,9 @@ struct sout_stream_id_t
/* Packetizer specific fields */ /* Packetizer specific fields */
int i_mtu; int i_mtu;
#ifdef HAVE_SRTP
srtp_session_t *srtp; srtp_session_t *srtp;
#endif
pf_rtp_packetizer_t pf_packetize; pf_rtp_packetizer_t pf_packetize;
/* Packets sinks */ /* Packets sinks */
...@@ -938,9 +944,11 @@ static sout_stream_id_t *Add( sout_stream_t *p_stream, es_format_t *p_fmt ) ...@@ -938,9 +944,11 @@ static sout_stream_id_t *Add( sout_stream_t *p_stream, es_format_t *p_fmt )
id->i_mtu = 576 - 20 - 8; /* pessimistic */ id->i_mtu = 576 - 20 - 8; /* pessimistic */
msg_Dbg( p_stream, "maximum RTP packet size: %d bytes", id->i_mtu ); msg_Dbg( p_stream, "maximum RTP packet size: %d bytes", id->i_mtu );
id->srtp = NULL;
id->pf_packetize = NULL; id->pf_packetize = NULL;
#ifdef HAVE_SRTP
id->srtp = NULL;
char *key = var_CreateGetNonEmptyString (p_stream, SOUT_CFG_PREFIX"key"); char *key = var_CreateGetNonEmptyString (p_stream, SOUT_CFG_PREFIX"key");
if (key) if (key)
{ {
...@@ -963,6 +971,7 @@ static sout_stream_id_t *Add( sout_stream_t *p_stream, es_format_t *p_fmt ) ...@@ -963,6 +971,7 @@ static sout_stream_id_t *Add( sout_stream_t *p_stream, es_format_t *p_fmt )
} }
id->i_sequence = 0; /* FIXME: awful hack for libvlc_srtp */ id->i_sequence = 0; /* FIXME: awful hack for libvlc_srtp */
} }
#endif
vlc_mutex_init( &id->lock_sink ); vlc_mutex_init( &id->lock_sink );
id->sinkc = 0; id->sinkc = 0;
...@@ -1342,8 +1351,10 @@ static int Del( sout_stream_t *p_stream, sout_stream_id_t *id ) ...@@ -1342,8 +1351,10 @@ static int Del( sout_stream_t *p_stream, sout_stream_id_t *id )
vlc_join( id->listen.thread, NULL ); vlc_join( id->listen.thread, NULL );
net_ListenClose( id->listen.fd ); net_ListenClose( id->listen.fd );
} }
#ifdef HAVE_SRTP
if( id->srtp != NULL ) if( id->srtp != NULL )
srtp_destroy( id->srtp ); srtp_destroy( id->srtp );
#endif
vlc_mutex_destroy( &id->lock_sink ); vlc_mutex_destroy( &id->lock_sink );
...@@ -1503,6 +1514,7 @@ static void* ThreadSend( vlc_object_t *p_this ) ...@@ -1503,6 +1514,7 @@ static void* ThreadSend( vlc_object_t *p_this )
block_t *out = block_FifoGet( id->p_fifo ); block_t *out = block_FifoGet( id->p_fifo );
block_cleanup_push (out); block_cleanup_push (out);
#ifdef HAVE_SRTP
if( id->srtp ) if( id->srtp )
{ /* FIXME: this is awfully inefficient */ { /* FIXME: this is awfully inefficient */
size_t len = out->i_buffer; size_t len = out->i_buffer;
...@@ -1522,8 +1534,8 @@ static void* ThreadSend( vlc_object_t *p_this ) ...@@ -1522,8 +1534,8 @@ static void* ThreadSend( vlc_object_t *p_this )
else else
out->i_buffer = len; out->i_buffer = len;
} }
if (out) if (out)
#endif
mwait (out->i_dts + i_caching); mwait (out->i_dts + i_caching);
vlc_cleanup_pop (); vlc_cleanup_pop ();
if (out == NULL) if (out == NULL)
...@@ -1538,7 +1550,9 @@ static void* ThreadSend( vlc_object_t *p_this ) ...@@ -1538,7 +1550,9 @@ static void* ThreadSend( vlc_object_t *p_this )
for( int i = 0; i < id->sinkc; i++ ) for( int i = 0; i < id->sinkc; i++ )
{ {
#ifdef HAVE_SRTP
if( !id->srtp ) /* FIXME: SRTCP support */ if( !id->srtp ) /* FIXME: SRTCP support */
#endif
SendRTCP( id->sinkv[i].rtcp, out ); SendRTCP( id->sinkv[i].rtcp, out );
if( send( id->sinkv[i].rtp_fd, out->p_buffer, len, 0 ) >= 0 ) if( send( id->sinkv[i].rtp_fd, out->p_buffer, len, 0 ) >= 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