From 73c6530d400e8758fa30215b1a17b62d92cd3703 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Olivier=20Cr=C3=AAte?= Date: Tue, 22 Jan 2019 14:34:23 -0500 Subject: srt: Accepts URIs without host to go into listener mode Just setting a URI without a hostname should directly go into listener mode. --- ext/srt/gstsrtobject.c | 60 +++++++++++++++++++++++++++----------------------- ext/srt/gstsrtsink.c | 4 ++-- ext/srt/gstsrtsrc.c | 2 +- 3 files changed, 36 insertions(+), 30 deletions(-) (limited to 'ext') diff --git a/ext/srt/gstsrtobject.c b/ext/srt/gstsrtobject.c index 9b4483e6d..aa201ad7a 100644 --- a/ext/srt/gstsrtobject.c +++ b/ext/srt/gstsrtobject.c @@ -440,8 +440,8 @@ gst_srt_object_install_properties_helper (GObjectClass * gobject_class) } static void -gst_srt_object_set_enum_value (GstStructure * s, GType enum_type, gpointer key, - gpointer value) +gst_srt_object_set_enum_value (GstStructure * s, GType enum_type, + gconstpointer key, gconstpointer value) { GEnumClass *enum_class; GEnumValue *enum_value; @@ -517,6 +517,7 @@ gst_srt_object_set_uri (GstSRTObject * srtobject, const gchar * uri, GHashTable *query_table = NULL; GHashTableIter iter; gpointer key, value; + const char *addr_str; if (srtobject->opened) { g_warning @@ -544,29 +545,34 @@ gst_srt_object_set_uri (GstSRTObject * srtobject, const gchar * uri, gst_uri_get_host (srtobject->uri), gst_uri_get_port (srtobject->uri), query_table == NULL ? 0 : g_hash_table_size (query_table)); - if (!query_table) { - GST_DEBUG_OBJECT (srtobject->element, "No parameters from uri"); - return TRUE; - } - - g_hash_table_iter_init (&iter, query_table); - while (g_hash_table_iter_next (&iter, &key, &value)) { - if (!g_strcmp0 ("mode", key)) { - gst_srt_object_set_enum_value (srtobject->parameters, - GST_TYPE_SRT_CONNECTION_MODE, key, value); - } else if (!g_strcmp0 ("localaddress", key)) { - gst_srt_object_set_string_value (srtobject->parameters, key, value); - } else if (!g_strcmp0 ("localport", key)) { - gst_srt_object_set_uint_value (srtobject->parameters, key, value); - } else if (!g_strcmp0 ("passphrase", key)) { - gst_srt_object_set_string_value (srtobject->parameters, key, value); - } else if (!g_strcmp0 ("pbkeylen", key)) { - gst_srt_object_set_enum_value (srtobject->parameters, - GST_TYPE_SRT_KEY_LENGTH_BITS, key, value); + addr_str = gst_uri_get_host (srtobject->uri); + if (addr_str) + gst_srt_object_set_enum_value (srtobject->parameters, + GST_TYPE_SRT_CONNECTION_MODE, "mode", "caller"); + else + gst_srt_object_set_enum_value (srtobject->parameters, + GST_TYPE_SRT_CONNECTION_MODE, "mode", "listener"); + + if (query_table) { + g_hash_table_iter_init (&iter, query_table); + while (g_hash_table_iter_next (&iter, &key, &value)) { + if (!g_strcmp0 ("mode", key)) { + gst_srt_object_set_enum_value (srtobject->parameters, + GST_TYPE_SRT_CONNECTION_MODE, key, value); + } else if (!g_strcmp0 ("localaddress", key)) { + gst_srt_object_set_string_value (srtobject->parameters, key, value); + } else if (!g_strcmp0 ("localport", key)) { + gst_srt_object_set_uint_value (srtobject->parameters, key, value); + } else if (!g_strcmp0 ("passphrase", key)) { + gst_srt_object_set_string_value (srtobject->parameters, key, value); + } else if (!g_strcmp0 ("pbkeylen", key)) { + gst_srt_object_set_enum_value (srtobject->parameters, + GST_TYPE_SRT_KEY_LENGTH_BITS, key, value); + } } - } - g_hash_table_unref (query_table); + g_hash_table_unref (query_table); + } gst_srt_object_validate_parameters (srtobject->parameters, srtobject->uri); @@ -954,10 +960,10 @@ gst_srt_object_open_full (GstSRTObject * srtobject, addr_str = gst_uri_get_host (srtobject->uri); if (addr_str == NULL) { - addr_str = GST_SRT_DEFAULT_LOCALADDRESS; - GST_WARNING_OBJECT (srtobject->element, - "Given uri doesn't have hostname or address. Use default localaddress (%s)", - addr_str); + addr_str = "0.0.0.0"; + GST_DEBUG_OBJECT (srtobject->element, + "Given uri doesn't have hostname or address. Use any (%s) and" + " setting listener mode", addr_str); } socket_address = diff --git a/ext/srt/gstsrtsink.c b/ext/srt/gstsrtsink.c index 14a4452b5..074bd0f16 100644 --- a/ext/srt/gstsrtsink.c +++ b/ext/srt/gstsrtsink.c @@ -29,11 +29,11 @@ * * Examples * |[ - * gst-launch-1.0 -v audiotestsrc ! srtsink uri://host?mode=caller + * gst-launch-1.0 -v audiotestsrc ! srtsink uri=srt://host * ]| This pipeline shows how to serve SRT packets through the default port. * * |[ - * gst-launch-1.0 -v audiotestsrc ! srtsink uri://host:port?mode=listener + * gst-launch-1.0 -v audiotestsrc ! srtsink uri=srt://:port * ]| This pipeline shows how to wait SRT callers. * * diff --git a/ext/srt/gstsrtsrc.c b/ext/srt/gstsrtsrc.c index 3931bfcab..cfaa7ba70 100644 --- a/ext/srt/gstsrtsrc.c +++ b/ext/srt/gstsrtsrc.c @@ -33,7 +33,7 @@ * ]| This pipeline shows how to connect SRT server by setting #GstSRTSrc:uri property. * * |[ - * gst-launch-1.0 -v srtsrc uri="srt://127.0.0.1:7001?mode=listener" ! fakesink + * gst-launch-1.0 -v srtsrc uri="srt://:7001?mode=listener" ! fakesink * ]| This pipeline shows how to wait SRT connection by setting #GstSRTSrc:uri property. * * |[ -- cgit v1.2.1