vlc | branch: master | Justin Kim <[email protected]> | Sun Nov 26 00:27:41 2017 +0900| [060cf2b09f6ba1f9c3b4597f7f5b5378f5d894e6] | committer: Jean-Baptiste Kempf
access: srt: add support stream encryption For encrypted transmitting, `passphrase` and `key-length` properties are added. Signed-off-by: Justin Kim <[email protected]> Signed-off-by: Jean-Baptiste Kempf <[email protected]> > http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=060cf2b09f6ba1f9c3b4597f7f5b5378f5d894e6 --- modules/access/srt.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/modules/access/srt.c b/modules/access/srt.c index 2de24d3955..bf770a42a5 100644 --- a/modules/access/srt.c +++ b/modules/access/srt.c @@ -46,6 +46,16 @@ /* The default latency is 125 * which uses srt library internally */ #define SRT_DEFAULT_LATENCY 125 +/* Crypto key length in bytes. */ +#define SRT_KEY_LENGTH_TEXT N_("Crypto key length in bytes") +#define SRT_DEFAULT_KEY_LENGTH 16 +static const int srt_key_lengths[] = { + 16, 24, 32, +}; + +static const char *const srt_key_length_names[] = { + N_("16 bytes"), N_("24 bytes"), N_("32 bytes"), +}; struct stream_sys_t { @@ -164,6 +174,8 @@ static int Open(vlc_object_t *p_this) }, *res = NULL; int stat; + char *psz_passphrase = NULL; + p_sys = vlc_obj_malloc( p_this, sizeof( *p_sys ) ); if( unlikely( p_sys == NULL ) ) return VLC_ENOMEM; @@ -182,6 +194,8 @@ static int Open(vlc_object_t *p_this) p_stream->pf_block = BlockSRT; p_stream->pf_control = Control; + psz_passphrase = var_InheritString( p_stream, "passphrase" ); + stat = vlc_getaddrinfo( parsed_url.psz_host, parsed_url.i_port, &hints, &res ); if ( stat ) { @@ -209,6 +223,16 @@ static int Open(vlc_object_t *p_this) /* Set latency */ srt_setsockopt( p_sys->sock, 0, SRTO_TSBPDDELAY, &p_sys->i_latency, sizeof( int ) ); + if ( psz_passphrase != NULL && psz_passphrase[0] != '\0') + { + int i_key_length = var_InheritInteger( p_stream, "key-length" ); + + srt_setsockopt( p_sys->sock, 0, SRTO_PASSPHRASE, + psz_passphrase, strlen( psz_passphrase ) ); + srt_setsockopt( p_sys->sock, 0, SRTO_PBKEYLEN, + &i_key_length, sizeof( int ) ); + } + p_sys->i_poll_id = srt_epoll_create(); if ( p_sys->i_poll_id == -1 ) { @@ -237,6 +261,7 @@ static int Open(vlc_object_t *p_this) vlc_UrlClean( &parsed_url ); freeaddrinfo( res ); + free (psz_passphrase); return VLC_SUCCESS; @@ -263,6 +288,8 @@ failed: } srt_close( p_sys->sock ); + free (psz_passphrase); + return VLC_EGENERIC; } @@ -295,6 +322,10 @@ vlc_module_begin () add_integer( "poll-timeout", SRT_DEFAULT_POLL_TIMEOUT, N_("Return poll wait after timeout milliseconds (-1 = infinite)"), NULL, true ) add_integer( "latency", SRT_DEFAULT_LATENCY, N_("SRT latency (ms)"), NULL, true ) + add_password( "passphrase", "", N_("Password for stream encryption"), NULL, false ) + add_integer( "key-length", SRT_DEFAULT_KEY_LENGTH, + SRT_KEY_LENGTH_TEXT, SRT_KEY_LENGTH_TEXT, false ) + change_integer_list( srt_key_lengths, srt_key_length_names ) set_capability( "access", 0 ) add_shortcut( "srt" ) _______________________________________________ vlc-commits mailing list [email protected] https://mailman.videolan.org/listinfo/vlc-commits
