[vlc-devel] [PATCH] srt: add streamid option

Marvin Scholz epirat07 at gmail.com
Wed Oct 28 10:35:33 CET 2020


Hi,

On 28 Oct 2020, at 0:57, Ÿnérant wrote:

> diff --git a/modules/access/srt.c b/modules/access/srt.c
> index 499a300196..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;

Instead of a separate bool for this, maybe just always strdup?

>      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;
> +    }
>          }
>      }
>
> @@ -164,7 +171,7 @@ static bool srt_schedule_reconnect(stream_t 
> *p_stream)
>
>      /* Set latency */
>      srt_set_socket_option( strm_obj, SRT_PARAM_LATENCY, p_sys->sock,
> -            SRTO_TSBPDDELAY, &i_latency, sizeof(i_latency) );
> +            SRTO_LATENCY, &i_latency, sizeof(i_latency) );

This change seems unrelated to this patch?

>
>      /* set passphrase */
>      if (psz_passphrase != NULL && psz_passphrase[0] != '\0') {
> @@ -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 0b66f24a8a..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;
> +            }
>          }
>      }
>
> @@ -155,7 +162,7 @@ static bool 
> srt_schedule_reconnect(sout_access_out_t
> *p_access)
>
>      /* Set latency */
>      srt_set_socket_option( access_obj, SRT_PARAM_LATENCY, 
> p_sys->sock,
> -            SRTO_TSBPDDELAY, &i_latency, sizeof(i_latency) );
> +            SRTO_LATENCY, &i_latency, sizeof(i_latency) );
>
>      /* set passphrase */
>      if (psz_passphrase != NULL && psz_passphrase[0] != '\0') {
> @@ -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" )
> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> https://mailman.videolan.org/listinfo/vlc-devel


More information about the vlc-devel mailing list