From d98e449887c0330b4d7f847d3da69ad55915dbe8 Mon Sep 17 00:00:00 2001
From: Apertis CI <devel@lists.apertis.org>
Date: Wed, 26 May 2021 06:58:45 +0000
Subject: [PATCH] Import Upstream version 1.18.4

---
 ChangeLog                        |  62 +++++++++++
 NEWS                             | 174 +++++++++++++++++++++++++++++--
 RELEASE                          |   2 +-
 gst/gstbuffer.c                  |   4 +-
 gst/gstclock.h                   |   1 +
 gst/gstinfo.c                    |   2 +
 gst/gstmemory.c                  |   4 +-
 gst/gsttask.c                    |  60 ++++++++++-
 gstreamer.doap                   |  10 ++
 libs/gst/base/gstaggregator.c    |   2 +-
 libs/gst/base/gstbasesrc.c       |   2 +-
 libs/gst/base/gstbasetransform.c |   2 +-
 meson.build                      |   2 +-
 po/gstreamer-1.0.pot             |   2 +-
 14 files changed, 311 insertions(+), 18 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index cdb2813..46efc7f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,65 @@
+=== release 1.18.4 ===
+
+2021-03-15 17:47:24 +0000  Tim-Philipp Müller <tim@centricular.com>
+
+	* ChangeLog:
+	* NEWS:
+	* RELEASE:
+	* gstreamer.doap:
+	* meson.build:
+	  Release 1.18.4
+
+2021-03-11 15:41:16 +0100  Guillaume Desmottes <guillaume.desmottes@collabora.com>
+
+	* gst/gstclock.h:
+	  clock: define AUTO_CLEANUP_FREE_FUNC for GstClockID
+	  GstClockID is secretly a gpointer so we can't use g_autoptr(),
+	  instead user can do:
+	  g_auto (GstClockID) clock_id = 0;
+	  Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/770>
+
+2021-01-31 12:12:09 +0200  Sebastian Dröge <sebastian@centricular.com>
+
+	* gst/gstinfo.c:
+	  info: Don't leak log function user_data if the debug system is compiled out
+	  Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/743>
+
+2021-01-15 01:16:34 +0900  Seungha Yang <seungha@centricular.com>
+
+	* gst/gsttask.c:
+	  task: Use SetThreadDescription Win32 API for setting thread name
+	  Since Windows 10 1607, we can make use of SetThreadDescription() API
+	  for setting thread name. Unlike previously used exception based
+	  method, this API will preserve configured thread name on dump file.
+	  Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/741>
+
+2021-01-14 10:18:51 +0100  Marijn Suijten <marijns95@gmail.com>
+
+	* gst/gstmemory.c:
+	  gstmemory: Mark memory_map @info as `caller-allocates`
+	  Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/740>
+
+2021-01-14 10:20:41 +0100  Marijn Suijten <marijns95@gmail.com>
+
+	* gst/gstbuffer.c:
+	  gstbuffer: Mark buffer_map* @info as `caller-allocates`
+	  Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/740>
+
+2021-01-07 09:53:41 +0100  Marijn Suijten <marijns95@gmail.com>
+
+	* libs/gst/base/gstaggregator.c:
+	* libs/gst/base/gstbasesrc.c:
+	* libs/gst/base/gstbasetransform.c:
+	  gst,base: Take GstAllocationParams parameter by const ptr
+	  This parameter is only informational and should not be modified. Enforce
+	  this at compile-time and to get the right signature in G-IR.
+	  Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/740>
+
+2021-01-14 02:16:45 +0000  Tim-Philipp Müller <tim@centricular.com>
+
+	* meson.build:
+	  Back to development
+
 === release 1.18.3 ===
 
 2021-01-13 21:05:12 +0000  Tim-Philipp Müller <tim@centricular.com>
diff --git a/NEWS b/NEWS
index 1ac82bd..3ada886 100644
--- a/NEWS
+++ b/NEWS
@@ -2,13 +2,13 @@ GStreamer 1.18 Release Notes
 
 GStreamer 1.18.0 was originally released on 8 September 2020.
 
-The latest bug-fix release in the 1.18 series is 1.18.3 and was released
-on 13 January 2021.
+The latest bug-fix release in the 1.18 series is 1.18.4 and was released
+on 15 March 2021.
 
 See https://gstreamer.freedesktop.org/releases/1.18/ for the latest
 version of this document.
 
-Last updated: Wednesday 13 January 2021, 20:00 UTC (log)
+Last updated: Monday 15 March 2021, 13:00 UTC (log)
 
 Introduction
 
@@ -2717,6 +2717,168 @@ List of merge requests and issues fixed in 1.18.3
 -   List of Merge Requests applied in 1.18.3
 -   List of Issues fixed in 1.18.3
 
+1.18.4
+
+The fourth 1.18 bug-fix release (1.18.4) was released on 15 March 2021.
+
+This release only contains bugfixes and security fixes and it should be
+safe to update from 1.18.x.
+
+Highlighted bugfixes in 1.18.4
+
+-   important security fixes for ID3 tag reading, matroska and realmedia
+    parsing, and gst-libav audio decoding
+-   audiomixer, audioaggregator: input buffer handling fixes
+-   decodebin3: improve stream-selection message handling
+-   uridecodebin3: make “caps” property work
+-   wavenc: fix writing of INFO chunks in some cases
+-   v4l2: bt601 colorimetry, allow encoder resolution changes, fix
+    decoder frame rate negotiation
+-   decklinkvideosink: fix auto format detection, and fixes for 29.97fps
+    framerate output
+-   mpeg-2 video handling fixes when seeking
+-   avviddec: fix bufferpool negotiation and possible memory corruption
+    when changing resolution
+-   various stability, performance and reliability improvements
+-   memory leak fixes
+-   build fixes: rpicamsrc, qt overlay example, d3d11videosink on UWP
+
+gstreamer
+
+-   info: Don’t leak log function user_data if the debug system is
+    compiled out
+-   task: Use SetThreadDescription() Win32 API for setting thread names,
+    which preserves thread names in dump files.
+-   buffer, memory: Mark info in map functions as caller-allocates and
+    pass allocation params as const pointers where possible
+-   clock: define AUTO_CLEANUP_FREE_FUNC for GstClockID
+
+gst-plugins-base
+
+-   tag: id3v2: fix frame size check and potential invalid reads
+-   audio: Fix gst_audio_buffer_truncate() meta handling for
+    non-interleaved audio
+-   audioresample: respect buffer layout when draining
+-   audioaggregator: fix input_buffer ownership
+-   decodebin3: change stream selection message owner, so that the app
+    sends the stream-selection event to the right element
+-   rtspconnection: correct data_size when tunneled mode
+-   uridecodebin3: make caps property work
+-   video-converter: Don’t upsample invalid lines
+-   videodecoder: Fix racy critical when pool negotiation occurs during
+    flush
+-   video: Convert gst_video_info_to_caps() to take self as const ptr
+-   examples: added qt core dependency for qt overlay example
+
+gst-plugins-good
+
+-   matroskademux: header parsing fixes
+-   rpicamsrc: depend on posix threads and vchiq_arm to fix build on
+    raspios again
+-   wavenc: Fixed INFO chunk corruption, caused by odd sized data not
+    being padded
+-   wavpackdec: Add floating point format support to fix distortions in
+    some cases
+-   v4l2: recognize V4L2 bt601 colorimetry again
+-   v4l2videoenc: support resolution change stream encode
+-   v4l2h265codec: fix HEVC profile string issue
+-   v4l2object: Need keep same transfer as input caps
+-   v4l2videodec: Fix vp8 and vp9 streams can’t play on board with
+    vendor bsp
+-   v4l2videodec: fix src side frame rate negotiation
+
+gst-plugins-bad
+
+-   avwait: Don’t post messages with the mutex locked
+-   d3d11h264dec: Reconfigure decoder object on DPB size change and keep
+    track of actually configured DPB size
+-   dashsink: fix double unref of sinkpad caps
+-   decklinkvideosink: Use correct numerator for 29.97fps
+-   decklinkvideosink: fix auto format detection
+-   decklinksrc: Use a more accurate capture time
+-   d3d11videosink: Fix build error on UWP
+-   interlace: negotiation and buffer leak fixes
+-   mpegvideoparse: do not clip, so decoder receives data from keyframe
+    even if it’s before the segment start
+-   mpegtsparse: Fix switched DTS/PTS when set-timestamps=false
+-   nvh264sldec: Reopen decoder object if larger DPB size is required
+-   sdpsrc: fix double free if sdp is provided as string via the
+    property
+-   vulkan: Fix elements long name.
+
+gst-plugins-ugly
+
+-   rmdemux: Make sure we have enough data available when parsing
+    audio/video packets
+
+gst-libav
+
+-   avviddec: take the maximum of the height/coded_height
+-   viddec: don’t configure an incorrect buffer pool when receiving a
+    gap event
+-   audiodec: fix stack overflow in gst_ffmpeg_channel_layout_to_gst()
+
+gst-rtsp-server
+
+-   rtspclientsink: fix deadlock on shutdown if no data has been
+    received yet
+-   rtspclientsink: fix leaks in unit tests
+-   rtsp-stream: avoid deadlock in send_func
+-   rtsp-client: cleanup transports during TEARDOWN
+
+gstreamer-vaapi
+
+-   h264 encoder: append encoder exposure to aud
+-   postproc: Fix a problem of propose_allocation when passthrough
+-   glx: Iterate over FBConfig and select 8 bit color size
+
+gstreamer-sharp
+
+-   no changes
+
+gst-omx
+
+-   no changes
+
+gst-python
+
+-   no changes
+
+gst-editing-services
+
+-   group: Use proper group constructor
+
+gst-integration-testsuites
+
+-   no changes
+
+gst-build
+
+-   no changes
+
+Cerbero build tool and packaging changes in 1.18.4
+
+-   macOS: more BigSur fixes
+-   glib: Backport patch to set thread names on Windows 10
+
+Contributors to 1.18.4
+
+Alicia Boya García, Ashley Brighthope, Bing Song, Branko Subasic, Edward
+Hervey, Guillaume Desmottes, Haihua Hu, He Junyan, Hou Qi, Jan Alexander
+Steffens (heftig), Jeongki Kim, Jordan Petridis, Knobe, Kristofer
+Björkström, Marijn Suijten, Matthew Waters, Paul Goulpié, Philipp Zabel,
+Rafał Dzięgiel, Sebastian Dröge, Seungha Yang, Staz M, Stéphane Cerveau,
+Thibault Saunier, Tim-Philipp Müller, Víctor Manuel Jáquez Leal, Vivia
+Nikolaidou, Vladimir Menshakov,
+
+… and many others who have contributed bug reports, translations, sent
+suggestions or helped testing. Thank you all!
+
+List of merge requests and issues fixed in 1.18.4
+
+-   List of Merge Requests applied in 1.18.4
+-   List of Issues fixed in 1.18.4
+
 Schedule for 1.20
 
 Our next major feature release will be 1.20, and 1.19 will be the
@@ -2724,9 +2886,9 @@ unstable development version leading up to the stable 1.20 release. The
 development of 1.19/1.20 will happen in the git master branch.
 
 The plan for the 1.20 development cycle is yet to be confirmed, but it
-is now expected that feature freeze will take place some time in
-January/February 2021, with the first 1.20 stable release hopefully
-around February/March 2021.
+is now expected that feature freeze will take place some time in April
+2021, with the first 1.20 stable release hopefully around April/May
+2021.
 
 1.20 will be backwards-compatible to the stable 1.18, 1.16, 1.14, 1.12,
 1.10, 1.8, 1.6, 1.4, 1.2 and 1.0 release series.
diff --git a/RELEASE b/RELEASE
index f5b7a48..2e8aa8c 100644
--- a/RELEASE
+++ b/RELEASE
@@ -1,4 +1,4 @@
-This is GStreamer core 1.18.3.
+This is GStreamer core 1.18.4.
 
 The GStreamer team is thrilled to announce a new major feature release
 of your favourite cross-platform multimedia framework!
diff --git a/gst/gstbuffer.c b/gst/gstbuffer.c
index aee635c..c520a8b 100644
--- a/gst/gstbuffer.c
+++ b/gst/gstbuffer.c
@@ -1757,7 +1757,7 @@ gst_buffer_resize_range (GstBuffer * buffer, guint idx, gint length,
 /**
  * gst_buffer_map:
  * @buffer: a #GstBuffer.
- * @info: (out): info about the mapping
+ * @info: (out caller-allocates): info about the mapping
  * @flags: flags for the mapping
  *
  * This function fills @info with the #GstMapInfo of all merged memory
@@ -1787,7 +1787,7 @@ gst_buffer_map (GstBuffer * buffer, GstMapInfo * info, GstMapFlags flags)
  * @buffer: a #GstBuffer.
  * @idx: an index
  * @length: a length
- * @info: (out): info about the mapping
+ * @info: (out caller-allocates): info about the mapping
  * @flags: flags for the mapping
  *
  * This function fills @info with the #GstMapInfo of @length merged memory blocks
diff --git a/gst/gstclock.h b/gst/gstclock.h
index b9bd230..1c17e9f 100644
--- a/gst/gstclock.h
+++ b/gst/gstclock.h
@@ -642,6 +642,7 @@ gboolean                gst_clock_periodic_id_reinit    (GstClock * clock,
                                                          GstClockTime interval);
 
 G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstClock, gst_object_unref)
+G_DEFINE_AUTO_CLEANUP_FREE_FUNC(GstClockID, gst_clock_id_unref, 0)
 
 G_END_DECLS
 
diff --git a/gst/gstinfo.c b/gst/gstinfo.c
index 5d31787..d788d9b 100644
--- a/gst/gstinfo.c
+++ b/gst/gstinfo.c
@@ -2359,6 +2359,8 @@ void
 gst_debug_add_log_function (GstLogFunction func, gpointer user_data,
     GDestroyNotify notify)
 {
+  if (notify)
+    notify (user_data);
 }
 
 guint
diff --git a/gst/gstmemory.c b/gst/gstmemory.c
index 7005ad6..0eaf208 100644
--- a/gst/gstmemory.c
+++ b/gst/gstmemory.c
@@ -220,7 +220,7 @@ gst_memory_resize (GstMemory * mem, gssize offset, gsize size)
 /**
  * gst_memory_make_mapped:
  * @mem: (transfer full): a #GstMemory
- * @info: (out): pointer for info
+ * @info: (out caller-allocates): pointer for info
  * @flags: mapping flags
  *
  * Create a #GstMemory object that is mapped with @flags. If @mem is mappable
@@ -270,7 +270,7 @@ cannot_map:
 /**
  * gst_memory_map:
  * @mem: a #GstMemory
- * @info: (out): pointer for info
+ * @info: (out caller-allocates): pointer for info
  * @flags: mapping flags
  *
  * Fill @info with the pointer and sizes of the memory in @mem that can be
diff --git a/gst/gsttask.c b/gst/gsttask.c
index 6c022fb..f8df426 100644
--- a/gst/gsttask.c
+++ b/gst/gsttask.c
@@ -112,6 +112,11 @@ struct _GstTaskPrivate
 #define WIN32_LEAN_AND_MEAN
 #include <windows.h>
 
+typedef HRESULT (WINAPI * pSetThreadDescription) (HANDLE hThread,
+    PCWSTR lpThreadDescription);
+static pSetThreadDescription SetThreadDescriptionFunc = NULL;
+HMODULE kernel32_module = NULL;
+
 struct _THREADNAME_INFO
 {
   DWORD dwType;                 // must be 0x1000
@@ -121,7 +126,7 @@ struct _THREADNAME_INFO
 };
 typedef struct _THREADNAME_INFO THREADNAME_INFO;
 
-void
+static void
 SetThreadName (DWORD dwThreadID, LPCSTR szThreadName)
 {
   THREADNAME_INFO info;
@@ -137,6 +142,57 @@ SetThreadName (DWORD dwThreadID, LPCSTR szThreadName)
   __except (EXCEPTION_CONTINUE_EXECUTION) {
   }
 }
+
+static gboolean
+gst_task_win32_load_library (void)
+{
+  /* FIXME: Add support for UWP app */
+#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
+  static volatile gsize _init_once = 0;
+  if (g_once_init_enter (&_init_once)) {
+    kernel32_module = LoadLibraryW (L"kernel32.dll");
+    if (kernel32_module) {
+      SetThreadDescriptionFunc =
+          (pSetThreadDescription) GetProcAddress (kernel32_module,
+          "SetThreadDescription");
+      if (!SetThreadDescriptionFunc)
+        FreeLibrary (kernel32_module);
+    }
+    g_once_init_leave (&_init_once, 1);
+  }
+#endif
+
+  return ! !SetThreadDescriptionFunc;
+}
+
+static gboolean
+gst_task_win32_set_thread_desc (const gchar * name)
+{
+  HRESULT hr;
+  wchar_t *namew;
+
+  if (!gst_task_win32_load_library () || !name)
+    return FALSE;
+
+  namew = g_utf8_to_utf16 (name, -1, NULL, NULL, NULL);
+  if (!namew)
+    return FALSE;
+
+  hr = SetThreadDescriptionFunc (GetCurrentThread (), namew);
+
+  g_free (namew);
+  return SUCCEEDED (hr);
+}
+
+static void
+gst_task_win32_set_thread_name (const gchar * name)
+{
+  /* Prefer SetThreadDescription over exception based way if available,
+   * since thread description set by SetThreadDescription will be preserved
+   * in dump file */
+  if (!gst_task_win32_set_thread_desc (name))
+    SetThreadName ((DWORD) - 1, name);
+}
 #endif
 
 static void gst_task_finalize (GObject * object);
@@ -265,7 +321,7 @@ gst_task_configure_name (GstTask * task)
 
   /* set the thread name to something easily identifiable */
   GST_DEBUG_OBJECT (task, "Setting thread name to '%s'", name);
-  SetThreadName (-1, name);
+  gst_task_win32_set_thread_name (name);
 #endif
 }
 
diff --git a/gstreamer.doap b/gstreamer.doap
index 5c09ebb..3c957ff 100644
--- a/gstreamer.doap
+++ b/gstreamer.doap
@@ -38,6 +38,16 @@ hierarchy, and a set of media-agnostic core elements.
    </GitRepository>
  </repository>
 
+ <release>
+  <Version>
+   <revision>1.18.4</revision>
+   <branch>1.18</branch>
+   <name></name>
+   <created>2021-03-15</created>
+   <file-release rdf:resource="https://gstreamer.freedesktop.org/src/gstreamer/gstreamer-1.18.4.tar.xz" />
+  </Version>
+ </release>
+
  <release>
   <Version>
    <revision>1.18.3</revision>
diff --git a/libs/gst/base/gstaggregator.c b/libs/gst/base/gstaggregator.c
index 41fd8ba..a4cd2d2 100644
--- a/libs/gst/base/gstaggregator.c
+++ b/libs/gst/base/gstaggregator.c
@@ -1066,7 +1066,7 @@ gst_aggregator_default_negotiated_src_caps (GstAggregator * agg, GstCaps * caps)
 static gboolean
 gst_aggregator_set_allocation (GstAggregator * self,
     GstBufferPool * pool, GstAllocator * allocator,
-    GstAllocationParams * params, GstQuery * query)
+    const GstAllocationParams * params, GstQuery * query)
 {
   GstAllocator *oldalloc;
   GstBufferPool *oldpool;
diff --git a/libs/gst/base/gstbasesrc.c b/libs/gst/base/gstbasesrc.c
index e802483..e35a88f 100644
--- a/libs/gst/base/gstbasesrc.c
+++ b/libs/gst/base/gstbasesrc.c
@@ -3133,7 +3133,7 @@ pause:
 
 static gboolean
 gst_base_src_set_allocation (GstBaseSrc * basesrc, GstBufferPool * pool,
-    GstAllocator * allocator, GstAllocationParams * params)
+    GstAllocator * allocator, const GstAllocationParams * params)
 {
   GstAllocator *oldalloc;
   GstBufferPool *oldpool;
diff --git a/libs/gst/base/gstbasetransform.c b/libs/gst/base/gstbasetransform.c
index 0bdb9de..2df00f9 100644
--- a/libs/gst/base/gstbasetransform.c
+++ b/libs/gst/base/gstbasetransform.c
@@ -746,7 +746,7 @@ done:
 static gboolean
 gst_base_transform_set_allocation (GstBaseTransform * trans,
     GstBufferPool * pool, GstAllocator * allocator,
-    GstAllocationParams * params, GstQuery * query)
+    const GstAllocationParams * params, GstQuery * query)
 {
   GstAllocator *oldalloc;
   GstBufferPool *oldpool;
diff --git a/meson.build b/meson.build
index c35148f..6bdf6bd 100644
--- a/meson.build
+++ b/meson.build
@@ -1,5 +1,5 @@
 project('gstreamer', 'c',
-  version : '1.18.3',
+  version : '1.18.4',
   meson_version : '>= 0.48',
   default_options : [ 'warning_level=1',
                       'buildtype=debugoptimized' ])
diff --git a/po/gstreamer-1.0.pot b/po/gstreamer-1.0.pot
index 634ae48..0eb58c6 100644
--- a/po/gstreamer-1.0.pot
+++ b/po/gstreamer-1.0.pot
@@ -8,7 +8,7 @@ msgid ""
 msgstr ""
 "Project-Id-Version: gstreamer-1.0\n"
 "Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2021-01-13 21:05+0000\n"
+"POT-Creation-Date: 2021-03-15 17:47+0000\n"
 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
 "Language-Team: LANGUAGE <LL@li.org>\n"
-- 
GitLab