Skip to content
Snippets Groups Projects
Commit e19fdb24 authored by Yohann D'ANELLO's avatar Yohann D'ANELLO Committed by Hugo Beauzée-Luyssen
Browse files

srt: add stream ID option

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



Signed-off-by: default avatarThomas Guillem <thomas@gllm.fr>
(cherry picked from commit a55c95a9)

Signed-off-by: default avatarSteve Lhomme <robux4@ycbcr.xyz>
parent 8db1f5e9
No related branches found
Tags 1.0.0-pre2
No related merge requests found
......@@ -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 );
......@@ -436,6 +451,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")
......
......@@ -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 );
......
......@@ -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);
......
......@@ -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 );
......@@ -448,6 +463,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" )
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment