From 048d70357796e3e9ec11a8f8d91d85a43c637bde Mon Sep 17 00:00:00 2001 From: Alex Ashley Date: Wed, 9 Aug 2017 15:10:56 +0100 Subject: curlhttpsrc: set http-version default if curl does not have HTTP2 feature present If the version of the curl library is recent enough to allow support for HTTP2 (i.e. CURL_VERSION_HTTP2 is defined) but does not actually have that feature enabled, the call to g_object_class_install_property() uses an incorrect default value for the "http-version" property. The default should be 1.1 if HTTP2 is not supported by libcurl or if not enabled by libcurl. https://bugzilla.gnome.org/show_bug.cgi?id=786049 --- ext/curl/gstcurlhttpsrc.c | 12 ++++++++++-- ext/curl/gstcurlhttpsrc.h | 7 ------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/ext/curl/gstcurlhttpsrc.c b/ext/curl/gstcurlhttpsrc.c index 10fb0259e..705647751 100644 --- a/ext/curl/gstcurlhttpsrc.c +++ b/ext/curl/gstcurlhttpsrc.c @@ -176,6 +176,7 @@ gst_curl_http_src_class_init (GstCurlHttpSrcClass * klass) GstBaseSrcClass *gstbasesrc_class; GstPushSrcClass *gstpushsrc_class; const gchar *http_env; + GstCurlHttpVersion default_http_version; gobject_class = (GObjectClass *) klass; gstelement_class = (GstElementClass *) klass; @@ -201,6 +202,13 @@ gst_curl_http_src_class_init (GstCurlHttpSrcClass * klass) gst_static_pad_template_get (&srcpadtemplate)); gst_curl_http_src_curl_capabilities = curl_version_info (CURLVERSION_NOW); +#ifdef CURL_VERSION_HTTP2 + if (gst_curl_http_src_curl_capabilities->features & CURL_VERSION_HTTP2) { + default_http_version = GSTCURL_HTTP_VERSION_2_0; + } else +#endif + default_http_version = GSTCURL_HTTP_VERSION_1_1; + http_env = g_getenv ("GST_CURL_HTTP_VER"); if (http_env != NULL) { GST_INFO_OBJECT (klass, "Seen env var GST_CURL_HTTP_VER with value %s", @@ -221,10 +229,10 @@ gst_curl_http_src_class_init (GstCurlHttpSrcClass * klass) unsupported_http_version: GST_WARNING_OBJECT (klass, "Unsupported HTTP version: %s. Fallback to default", http_env); - pref_http_ver = DEFAULT_HTTP_VERSION; + pref_http_ver = default_http_version; } } else { - pref_http_ver = DEFAULT_HTTP_VERSION; + pref_http_ver = default_http_version; } gst_curl_http_src_default_useragent = diff --git a/ext/curl/gstcurlhttpsrc.h b/ext/curl/gstcurlhttpsrc.h index 244488ade..72af6dc3b 100644 --- a/ext/curl/gstcurlhttpsrc.h +++ b/ext/curl/gstcurlhttpsrc.h @@ -102,13 +102,6 @@ typedef enum GSTCURL_HTTP_VERSION_MAX } GstCurlHttpVersion; -#ifdef CURL_VERSION_HTTP2 -#define DEFAULT_HTTP_VERSION GSTCURL_HTTP_VERSION_2_0 -#else -#define DEFAULT_HTTP_VERSION GSTCURL_HTTP_VERSION_1_1 -#endif - - struct _GstCurlHttpSrcMultiTaskContext { GstTask *task; -- cgit v1.2.3