summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorFrancisco Javier Velázquez-García <francisco.velazquez@ltnglobal.com>2020-07-30 18:26:34 +0200
committerGStreamer Merge Bot <gitlab-merge-bot@gstreamer-foundation.org>2020-08-03 21:46:04 +0000
commit1ba379ded0d34d62058b4ed9db8ff4f418d6e462 (patch)
treefcfbd16207792ca2febd9652aea591e8e2567923 /ext
parent096c60f9c5380072602792161573b389a0b5cbb8 (diff)
downloadgstreamer-plugins-bad-1ba379ded0d34d62058b4ed9db8ff4f418d6e462.tar.gz
srtobject: Reset parameters before setting URI
This makes `gst_srt_object_validate_parameters` work properly since `localaddress` and `localport` will be missing if the URL did not provide them. Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1477>
Diffstat (limited to 'ext')
-rw-r--r--ext/srt/gstsrtobject.c38
1 files changed, 26 insertions, 12 deletions
diff --git a/ext/srt/gstsrtobject.c b/ext/srt/gstsrtobject.c
index 33ae2d41e..8edab3415 100644
--- a/ext/srt/gstsrtobject.c
+++ b/ext/srt/gstsrtobject.c
@@ -215,11 +215,7 @@ gst_srt_object_new (GstElement * element)
srtobject = g_new0 (GstSRTObject, 1);
srtobject->element = element;
- srtobject->parameters = gst_structure_new ("application/x-srt-params",
- "poll-timeout", G_TYPE_INT, GST_SRT_DEFAULT_POLL_TIMEOUT,
- "latency", G_TYPE_INT, GST_SRT_DEFAULT_LATENCY,
- "mode", GST_TYPE_SRT_CONNECTION_MODE, GST_SRT_DEFAULT_MODE, NULL);
-
+ srtobject->parameters = gst_structure_new_empty ("application/x-srt-params");
srtobject->sock = SRT_INVALID_SOCK;
srtobject->poll_id = srt_epoll_create ();
srtobject->listener_sock = SRT_INVALID_SOCK;
@@ -561,6 +557,14 @@ gst_srt_object_set_uint_value (GstStructure * s, const gchar * key,
}
static void
+gst_srt_object_set_int_value (GstStructure * s, const gchar * key,
+ const gchar * value)
+{
+ gst_structure_set (s, key, G_TYPE_INT,
+ (gint) g_ascii_strtoll (value, NULL, 10), NULL);
+}
+
+static void
gst_srt_object_validate_parameters (GstStructure * s, GstUri * uri)
{
GstSRTConnectionMode connection_mode = GST_SRT_CONNECTION_MODE_NONE;
@@ -618,6 +622,11 @@ gst_srt_object_set_uri (GstSRTObject * srtobject, const gchar * uri,
g_clear_pointer (&srtobject->uri, gst_uri_unref);
srtobject->uri = gst_uri_from_string (uri);
+ g_clear_pointer (&srtobject->parameters, gst_structure_free);
+ srtobject->parameters = gst_structure_new ("application/x-srt-params",
+ "poll-timeout", G_TYPE_INT, GST_SRT_DEFAULT_POLL_TIMEOUT,
+ "latency", G_TYPE_INT, GST_SRT_DEFAULT_LATENCY, NULL);
+
query_table = gst_uri_get_query_table (srtobject->uri);
GST_DEBUG_OBJECT (srtobject->element,
@@ -650,6 +659,10 @@ gst_srt_object_set_uri (GstSRTObject * srtobject, const gchar * uri,
GST_TYPE_SRT_KEY_LENGTH, key, value);
} else if (!g_strcmp0 ("streamid", key)) {
gst_srt_object_set_string_value (srtobject->parameters, key, value);
+ } else if (!g_strcmp0 ("latency", key)) {
+ gst_srt_object_set_int_value (srtobject->parameters, key, value);
+ } else if (!g_strcmp0 ("poll-timeout", key)) {
+ gst_srt_object_set_int_value (srtobject->parameters, key, value);
}
}
@@ -1005,8 +1018,16 @@ gst_srt_object_open_internal (GstSRTObject * srtobject,
srtobject->opened = FALSE;
+ if (!gst_structure_get_enum (srtobject->parameters,
+ "mode", GST_TYPE_SRT_CONNECTION_MODE, (gint *) & connection_mode)) {
+ GST_WARNING_OBJECT (srtobject->element,
+ "Cannot get connection mode information." " Use default mode");
+ connection_mode = GST_SRT_DEFAULT_MODE;
+ }
+
addr_str = gst_uri_get_host (srtobject->uri);
if (addr_str == NULL) {
+ connection_mode = GST_SRT_CONNECTION_MODE_LISTENER;
addr_str = GST_SRT_DEFAULT_LOCALADDRESS;
GST_DEBUG_OBJECT (srtobject->element,
"Given uri doesn't have hostname or address. Use any (%s) and"
@@ -1019,13 +1040,6 @@ gst_srt_object_open_internal (GstSRTObject * srtobject,
"Opening SRT socket with parameters: %" GST_PTR_FORMAT,
srtobject->parameters);
- if (!gst_structure_get_enum (srtobject->parameters,
- "mode", GST_TYPE_SRT_CONNECTION_MODE, (gint *) & connection_mode)) {
- GST_WARNING_OBJECT (srtobject->element,
- "Cannot get connection mode information." " Use default mode");
- connection_mode = GST_TYPE_SRT_CONNECTION_MODE;
- }
-
GST_OBJECT_UNLOCK (srtobject->element);
socket_address = g_inet_socket_address_new_from_string (addr_str, port);