From 91a033a85e2b3016cf978920a843607327a422bc Mon Sep 17 00:00:00 2001 From: "Jan Alexander Steffens (heftig)" Date: Tue, 25 Feb 2020 14:58:23 +0100 Subject: [PATCH] rtmp2: Allow setting flash-version In case the application has to deal with fussy servers. User agent sniffing is so last decade. Adds a property to set the Flash version on both the sink and the src. The default stays the same (IIRC, Flash plugin for Linux from 2009). --- gst/rtmp2/gstrtmp2locationhandler.c | 5 +++++ gst/rtmp2/gstrtmp2sink.c | 14 ++++++++++++++ gst/rtmp2/gstrtmp2src.c | 14 ++++++++++++++ gst/rtmp2/rtmp/rtmpclient.c | 5 ++++- 4 files changed, 37 insertions(+), 1 deletion(-) diff --git a/gst/rtmp2/gstrtmp2locationhandler.c b/gst/rtmp2/gstrtmp2locationhandler.c index 6c1eada875..49c83bd0a0 100644 --- a/gst/rtmp2/gstrtmp2locationhandler.c +++ b/gst/rtmp2/gstrtmp2locationhandler.c @@ -33,6 +33,7 @@ #define DEFAULT_PASSWORD NULL #define DEFAULT_AUTHMOD GST_RTMP_AUTHMOD_AUTO #define DEFAULT_TIMEOUT 5 +#define DEFAULT_FLASH_VERSION "LNX 10,0,32,18" G_DEFINE_INTERFACE (GstRtmpLocationHandler, gst_rtmp_location_handler, 0); @@ -88,6 +89,10 @@ gst_rtmp_location_handler_default_init (GstRtmpLocationHandlerInterface * iface) "TLS validation flags to use", G_TYPE_TLS_CERTIFICATE_FLAGS, G_TLS_CERTIFICATE_VALIDATE_ALL, G_PARAM_CONSTRUCT | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); + g_object_interface_install_property (iface, + g_param_spec_string ("flash-version", "Flash version", + "Flash version reported to the server", DEFAULT_FLASH_VERSION, + G_PARAM_CONSTRUCT | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); } static GstURIType diff --git a/gst/rtmp2/gstrtmp2sink.c b/gst/rtmp2/gstrtmp2sink.c index f0397914ee..441cb6f247 100644 --- a/gst/rtmp2/gstrtmp2sink.c +++ b/gst/rtmp2/gstrtmp2sink.c @@ -141,6 +141,7 @@ enum PROP_AUTHMOD, PROP_TIMEOUT, PROP_TLS_VALIDATION_FLAGS, + PROP_FLASH_VERSION, PROP_ASYNC_CONNECT, PROP_PEAK_KBPS, PROP_CHUNK_SIZE, @@ -201,6 +202,8 @@ gst_rtmp2_sink_class_init (GstRtmp2SinkClass * klass) g_object_class_override_property (gobject_class, PROP_TIMEOUT, "timeout"); g_object_class_override_property (gobject_class, PROP_TLS_VALIDATION_FLAGS, "tls-validation-flags"); + g_object_class_override_property (gobject_class, PROP_FLASH_VERSION, + "flash-version"); g_object_class_install_property (gobject_class, PROP_ASYNC_CONNECT, g_param_spec_boolean ("async-connect", "Async connect", @@ -323,6 +326,12 @@ gst_rtmp2_sink_set_property (GObject * object, guint property_id, self->location.tls_flags = g_value_get_flags (value); GST_OBJECT_UNLOCK (self); break; + case PROP_FLASH_VERSION: + GST_OBJECT_LOCK (self); + g_free (self->location.flash_ver); + self->location.flash_ver = g_value_dup_string (value); + GST_OBJECT_UNLOCK (self); + break; case PROP_ASYNC_CONNECT: GST_OBJECT_LOCK (self); self->async_connect = g_value_get_boolean (value); @@ -422,6 +431,11 @@ gst_rtmp2_sink_get_property (GObject * object, guint property_id, g_value_set_flags (value, self->location.tls_flags); GST_OBJECT_UNLOCK (self); break; + case PROP_FLASH_VERSION: + GST_OBJECT_LOCK (self); + g_value_set_string (value, self->location.flash_ver); + GST_OBJECT_UNLOCK (self); + break; case PROP_ASYNC_CONNECT: GST_OBJECT_LOCK (self); g_value_set_boolean (value, self->async_connect); diff --git a/gst/rtmp2/gstrtmp2src.c b/gst/rtmp2/gstrtmp2src.c index e5ba76f0da..ea79a7caf2 100644 --- a/gst/rtmp2/gstrtmp2src.c +++ b/gst/rtmp2/gstrtmp2src.c @@ -130,6 +130,7 @@ enum PROP_AUTHMOD, PROP_TIMEOUT, PROP_TLS_VALIDATION_FLAGS, + PROP_FLASH_VERSION, PROP_ASYNC_CONNECT, PROP_STATS, }; @@ -187,6 +188,8 @@ gst_rtmp2_src_class_init (GstRtmp2SrcClass * klass) g_object_class_override_property (gobject_class, PROP_TIMEOUT, "timeout"); g_object_class_override_property (gobject_class, PROP_TLS_VALIDATION_FLAGS, "tls-validation-flags"); + g_object_class_override_property (gobject_class, PROP_FLASH_VERSION, + "flash-version"); g_object_class_install_property (gobject_class, PROP_ASYNC_CONNECT, g_param_spec_boolean ("async-connect", "Async connect", @@ -292,6 +295,12 @@ gst_rtmp2_src_set_property (GObject * object, guint property_id, self->location.tls_flags = g_value_get_flags (value); GST_OBJECT_UNLOCK (self); break; + case PROP_FLASH_VERSION: + GST_OBJECT_LOCK (self); + g_free (self->location.flash_ver); + self->location.flash_ver = g_value_dup_string (value); + GST_OBJECT_UNLOCK (self); + break; case PROP_ASYNC_CONNECT: GST_OBJECT_LOCK (self); self->async_connect = g_value_get_boolean (value); @@ -371,6 +380,11 @@ gst_rtmp2_src_get_property (GObject * object, guint property_id, g_value_set_flags (value, self->location.tls_flags); GST_OBJECT_UNLOCK (self); break; + case PROP_FLASH_VERSION: + GST_OBJECT_LOCK (self); + g_value_set_string (value, self->location.flash_ver); + GST_OBJECT_UNLOCK (self); + break; case PROP_ASYNC_CONNECT: GST_OBJECT_LOCK (self); g_value_set_boolean (value, self->async_connect); diff --git a/gst/rtmp2/rtmp/rtmpclient.c b/gst/rtmp2/rtmp/rtmpclient.c index f95994f4df..fadc3c2f11 100644 --- a/gst/rtmp2/rtmp/rtmpclient.c +++ b/gst/rtmp2/rtmp/rtmpclient.c @@ -513,7 +513,10 @@ send_connect (GTask * task) } if (!flash_ver) { - flash_ver = "LNX 10,0,32,18"; + g_task_return_new_error (task, G_IO_ERROR, G_IO_ERROR_NOT_INITIALIZED, + "Flash version is not set"); + g_object_unref (task); + goto out; } if (data->auth_query) {