[vlc-devel] [PATCH v2] srt: add stream ID option
Thomas Guillem
thomas at gllm.fr
Wed Nov 4 11:33:54 CET 2020
Sorry the for delay, I just merged your patch.
Best,
Thomas
On Tue, Nov 3, 2020, at 21:31, Ÿnérant wrote:
> Any news? Maybe I didn't comment on my patch:
> This patch allows the use of the streamid option when using the SRT protocol.
> For example, we can query the URL srt://localhost:9710?streamid=demo
> if a stream server is listening on localhost:9710 that supports multiple streams
> on the same server. Like the others already implemented, this parameter can
> be overwritten in the settings of the transport.
>
> In a future patch, it may be good to support the full options.
> The complete list can be found here:
> https://github.com/Haivision/srt/blob/master/docs/APISocketOptions.md#list-of-options
> A human-friendly version of this list can be found in the ffmpeg documentation:
> https://ffmpeg.org/ffmpeg-all.html#srt
>
> Le mer. 28 oct. 2020 à 14:36, Yohann D'ANELLO <ynerant at crans.org> a écrit :
>> From: Yohann D'ANELLO <yohann.danello at gmail.com>
>>
>> Signed-off-by: Yohann D'ANELLO <yohann.danello at gmail.com>
>> ---
>> modules/access/srt.c | 18 ++++++++++++++++++
>> modules/access/srt_common.c | 4 ++++
>> modules/access/srt_common.h | 2 ++
>> modules/access_output/srt.c | 18 ++++++++++++++++++
>> 4 files changed, 42 insertions(+)
>>
>> diff --git a/modules/access/srt.c b/modules/access/srt.c
>> index d7ef51fccf..ae8ba2a84f 100644
>> --- a/modules/access/srt.c
>> +++ b/modules/access/srt.c
>> @@ -97,6 +97,8 @@ static bool srt_schedule_reconnect(stream_t *p_stream)
>> int stat;
>> char *psz_passphrase = var_InheritString( p_stream, SRT_PARAM_PASSPHRASE );
>> bool passphrase_needs_free = true;
>> + char *psz_streamid = var_InheritString( p_stream, SRT_PARAM_STREAMID );
>> + bool streamid_needs_free = true;
>> char *url = NULL;
>> srt_params_t params;
>> struct addrinfo hints = {
>> @@ -145,6 +147,11 @@ static bool srt_schedule_reconnect(stream_t *p_stream)
>> passphrase_needs_free = false;
>> psz_passphrase = (char *) params.passphrase;
>> }
>> + if (params.streamid != NULL ) {
>> + free( psz_streamid );
>> + streamid_needs_free = false;
>> + psz_streamid = (char *) params.streamid;
>> + }
>> }
>> }
>>
>> @@ -177,6 +184,12 @@ static bool srt_schedule_reconnect(stream_t *p_stream)
>> SRTO_PASSPHRASE, psz_passphrase, strlen(psz_passphrase) );
>> }
>>
>> + /* set stream id */
>> + if (psz_streamid != NULL && psz_streamid[0] != '\0') {
>> + srt_set_socket_option( strm_obj, SRT_PARAM_STREAMID, p_sys->sock,
>> + SRTO_STREAMID, psz_streamid, strlen(psz_streamid) );
>> + }
>> +
>> /* set maximum payload size */
>> srt_set_socket_option( strm_obj, SRT_PARAM_PAYLOAD_SIZE, p_sys->sock,
>> SRTO_PAYLOADSIZE, &i_payload_size, sizeof(i_payload_size) );
>> @@ -211,6 +224,8 @@ out:
>>
>> if (passphrase_needs_free)
>> free( psz_passphrase );
>> + if (streamid_needs_free)
>> + free( psz_streamid );
>> freeaddrinfo( res );
>> free( url );
>>
>> @@ -429,6 +444,9 @@ vlc_module_begin ()
>> add_integer( SRT_PARAM_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 )
>> + add_string(SRT_PARAM_STREAMID, "",
>> + N_(" SRT Stream ID"), NULL, false)
>> + change_safe()
>>
>> set_capability("access", 0)
>> add_shortcut("srt")
>> diff --git a/modules/access/srt_common.c b/modules/access/srt_common.c
>> index be6a9732cb..c1b6dc3751 100644
>> --- a/modules/access/srt_common.c
>> +++ b/modules/access/srt_common.c
>> @@ -107,6 +107,7 @@ bool srt_parse_url(char* url, srt_params_t* params)
>> params->key_length = -1;
>> params->payload_size = -1;
>> params->bandwidth_overhead_limit = -1;
>> + params->streamid = NULL;
>>
>> /* Parse URL parameters */
>> query = find( url, '?' );
>> @@ -127,6 +128,9 @@ bool srt_parse_url(char* url, srt_params_t* params)
>> } else if (strcmp( local_params[i].key, SRT_PARAM_PASSPHRASE )
>> == 0) {
>> params->passphrase = val;
>> + } else if (strcmp( local_params[i].key, SRT_PARAM_STREAMID )
>> + == 0) {
>> + params->streamid = val;
>> } else if (strcmp( local_params[i].key, SRT_PARAM_PAYLOAD_SIZE )
>> == 0) {
>> int temp = atoi( val );
>> diff --git a/modules/access/srt_common.h b/modules/access/srt_common.h
>> index c2322d5755..5f2a11a242 100644
>> --- a/modules/access/srt_common.h
>> +++ b/modules/access/srt_common.h
>> @@ -39,6 +39,7 @@
>> #define SRT_PARAM_CHUNK_SIZE "chunk-size"
>> #define SRT_PARAM_POLL_TIMEOUT "poll-timeout"
>> #define SRT_PARAM_KEY_LENGTH "key-length"
>> +#define SRT_PARAM_STREAMID "streamid"
>>
>>
>> #define SRT_DEFAULT_BANDWIDTH_OVERHEAD_LIMIT 25
>> @@ -68,6 +69,7 @@ typedef struct srt_params {
>> int key_length;
>> int payload_size;
>> int bandwidth_overhead_limit;
>> + const char* streamid;
>> } srt_params_t;
>>
>> bool srt_parse_url(char* url, srt_params_t* params);
>> diff --git a/modules/access_output/srt.c b/modules/access_output/srt.c
>> index 3d579eb1bd..afd11dc484 100644
>> --- a/modules/access_output/srt.c
>> +++ b/modules/access_output/srt.c
>> @@ -68,6 +68,8 @@ static bool srt_schedule_reconnect(sout_access_out_t *p_access)
>> int i_payload_size = var_InheritInteger( p_access, SRT_PARAM_PAYLOAD_SIZE );
>> char *psz_passphrase = var_InheritString( p_access, SRT_PARAM_PASSPHRASE );
>> bool passphrase_needs_free = true;
>> + char *psz_streamid = var_InheritString( p_access, SRT_PARAM_STREAMID );
>> + bool streamid_needs_free = true;
>> int i_max_bandwidth_limit =
>> var_InheritInteger( p_access, SRT_PARAM_BANDWIDTH_OVERHEAD_LIMIT );
>> char *url = NULL;
>> @@ -136,6 +138,11 @@ static bool srt_schedule_reconnect(sout_access_out_t *p_access)
>> passphrase_needs_free = false;
>> psz_passphrase = (char *) params.passphrase;
>> }
>> + if (params.streamid != NULL) {
>> + free( psz_streamid );
>> + streamid_needs_free = false;
>> + psz_streamid = (char *) params.streamid;
>> + }
>> }
>> }
>>
>> @@ -168,6 +175,12 @@ static bool srt_schedule_reconnect(sout_access_out_t *p_access)
>> SRTO_PASSPHRASE, psz_passphrase, strlen(psz_passphrase) );
>> }
>>
>> + /* set streamid */
>> + if (psz_streamid != NULL && psz_streamid[0] != '\0') {
>> + srt_set_socket_option( access_obj, SRT_PARAM_STREAMID, p_sys->sock,
>> + SRTO_STREAMID, psz_streamid, strlen(psz_streamid) );
>> + }
>> +
>> /* set maximumu payload size */
>> srt_set_socket_option( access_obj, SRT_PARAM_PAYLOAD_SIZE, p_sys->sock,
>> SRTO_PAYLOADSIZE, &i_payload_size, sizeof(i_payload_size) );
>> @@ -204,6 +217,8 @@ out:
>>
>> if (passphrase_needs_free)
>> free( psz_passphrase );
>> + if (streamid_needs_free)
>> + free( psz_streamid );
>> free( psz_dst_addr );
>> free( url );
>> freeaddrinfo( res );
>> @@ -444,6 +459,9 @@ vlc_module_begin()
>> add_integer( SRT_PARAM_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 )
>> + add_string(SRT_PARAM_STREAMID, "",
>> + N_(" SRT Stream ID"), NULL, false)
>> + change_safe()
>>
>> set_capability( "sout access", 0 )
>> add_shortcut( "srt" )
>> --
>> 2.29.1
>>
> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> https://mailman.videolan.org/listinfo/vlc-devel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/vlc-devel/attachments/20201104/3d1f20cf/attachment.html>
More information about the vlc-devel
mailing list