rtmp2: Allow setting flash-version
authorJan Alexander Steffens (heftig) <jsteffens@make.tv>
Tue, 25 Feb 2020 13:58:23 +0000 (14:58 +0100)
committerJan Alexander Steffens (heftig) <jsteffens@make.tv>
Tue, 25 Feb 2020 14:10:28 +0000 (15:10 +0100)
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
gst/rtmp2/gstrtmp2sink.c
gst/rtmp2/gstrtmp2src.c
gst/rtmp2/rtmp/rtmpclient.c

index 6c1eada..49c83bd 100644 (file)
@@ -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
index f039791..441cb6f 100644 (file)
@@ -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);
index e5ba76f..ea79a7c 100644 (file)
@@ -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);
index f95994f..fadc3c2 100644 (file)
@@ -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) {