[meta-freescale] [PATCH v2 2/6] gstreamer1.0: Add NXP specific patches

Stefan Agner stefan at agner.ch
Tue Dec 19 15:06:42 PST 2017


From: Stefan Agner <stefan.agner at toradex.com>

Add NXP specific patches from morty-4.9.51-mx8_beta branch. This
allows to use imx-gst1.0-plugin 4.3.1 with gstreamer 1.12.2.

Signed-off-by: Stefan Agner <stefan.agner at toradex.com>
---
 .../0001-handle-base-parse-error.patch             | 35 ++++++++
 ...ith-gst-inspect-Chris-Lord-chris-openedha.patch | 32 ++++++++
 ...e-unset-FLAG_DISCONT-when-push-to-adapter.patch | 33 ++++++++
 ...e-Need-push-adapter-remainning-data-in-pa.patch | 51 ++++++++++++
 ...or-should-proceed-non-active-pad-buffer-e.patch | 51 ++++++++++++
 ...0006-poll-Add-check-if-can-read-event-API.patch | 95 ++++++++++++++++++++++
 ...or-Need-flush-when-set-active-pad-and-the.patch | 68 ++++++++++++++++
 .../gstreamer/gstreamer1.0_1.12.%.bbappend         | 16 ++++
 8 files changed, 381 insertions(+)
 create mode 100644 recipes-multimedia/gstreamer/gstreamer1.0/0001-handle-base-parse-error.patch
 create mode 100644 recipes-multimedia/gstreamer/gstreamer1.0/0002-Fix-crash-with-gst-inspect-Chris-Lord-chris-openedha.patch
 create mode 100644 recipes-multimedia/gstreamer/gstreamer1.0/0003-baseparse-unset-FLAG_DISCONT-when-push-to-adapter.patch
 create mode 100644 recipes-multimedia/gstreamer/gstreamer1.0/0004-gstbaseparse-Need-push-adapter-remainning-data-in-pa.patch
 create mode 100644 recipes-multimedia/gstreamer/gstreamer1.0/0005-inputselector-should-proceed-non-active-pad-buffer-e.patch
 create mode 100644 recipes-multimedia/gstreamer/gstreamer1.0/0006-poll-Add-check-if-can-read-event-API.patch
 create mode 100644 recipes-multimedia/gstreamer/gstreamer1.0/0007-inputselector-Need-flush-when-set-active-pad-and-the.patch
 create mode 100644 recipes-multimedia/gstreamer/gstreamer1.0_1.12.%.bbappend

diff --git a/recipes-multimedia/gstreamer/gstreamer1.0/0001-handle-base-parse-error.patch b/recipes-multimedia/gstreamer/gstreamer1.0/0001-handle-base-parse-error.patch
new file mode 100644
index 00000000..3aaa6360
--- /dev/null
+++ b/recipes-multimedia/gstreamer/gstreamer1.0/0001-handle-base-parse-error.patch
@@ -0,0 +1,35 @@
+From 01b047cbb5e326fb3980bb6fc5206a82ea401170 Mon Sep 17 00:00:00 2001
+From: Lyon Wang <lyon.wang at freescale.com>
+Date: Wed, 14 Oct 2015 14:15:11 +0800
+Subject: [PATCH 1/7] handle base parse error
+
+There is no need to send GST_ELEMENT_ERROR
+becuase ohter tracks may still good to play.
+no need to end the element, just print error message is enough
+
+Upstream-Status: Submitted [https://bugzilla.gnome.org/show_bug.cgi?id=741542]
+
+Signed-off-by: Lyon Wang <lyon.wang at freescale.com>
+---
+ libs/gst/base/gstbaseparse.c | 5 +++--
+ 1 file changed, 3 insertions(+), 2 deletions(-)
+
+diff --git a/libs/gst/base/gstbaseparse.c b/libs/gst/base/gstbaseparse.c
+index df67dd0..2f45d23 100644
+--- a/libs/gst/base/gstbaseparse.c
++++ b/libs/gst/base/gstbaseparse.c
+@@ -1324,8 +1324,9 @@ gst_base_parse_sink_event_default (GstBaseParse * parse, GstEvent * event)
+       /* If we STILL have zero frames processed, fire an error */
+       if (parse->priv->framecount == 0 && !parse->priv->saw_gaps &&
+           !parse->priv->first_buffer) {
+-        GST_ELEMENT_ERROR (parse, STREAM, WRONG_TYPE,
+-            ("No valid frames found before end of stream"), (NULL));
++      /*  GST_ELEMENT_ERROR (parse, STREAM, WRONG_TYPE,
++            ("No valid frames found before end of stream"), (NULL));*/
++        GST_ERROR_OBJECT(parse, "No valid frames decoded before end of stream");
+       }
+ 
+       if (!parse->priv->saw_gaps
+-- 
+1.9.1
+
diff --git a/recipes-multimedia/gstreamer/gstreamer1.0/0002-Fix-crash-with-gst-inspect-Chris-Lord-chris-openedha.patch b/recipes-multimedia/gstreamer/gstreamer1.0/0002-Fix-crash-with-gst-inspect-Chris-Lord-chris-openedha.patch
new file mode 100644
index 00000000..1bd381b6
--- /dev/null
+++ b/recipes-multimedia/gstreamer/gstreamer1.0/0002-Fix-crash-with-gst-inspect-Chris-Lord-chris-openedha.patch
@@ -0,0 +1,32 @@
+From 1bd9b30040ad23d86faa577baeb1c6734f39150f Mon Sep 17 00:00:00 2001
+From: Carlos Rafael Giani <dv at pseudoterminal.org>
+Date: Sat, 6 Apr 2013 23:52:11 +0200
+Subject: [PATCH 2/7] Fix crash with gst-inspect Chris Lord
+ <chris at openedhand.com>
+
+Upstream-Status: Pending
+
+Signed-off-by: Carlos Rafael Giani <dv at pseudoterminal.org>
+
+Conflicts:
+	tools/gst-inspect.c
+---
+ tools/gst-inspect.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/tools/gst-inspect.c b/tools/gst-inspect.c
+index e420e4c..95983bc 100644
+--- a/tools/gst-inspect.c
++++ b/tools/gst-inspect.c
+@@ -1548,7 +1548,7 @@ main (int argc, char *argv[])
+   g_option_context_add_main_entries (ctx, options, GETTEXT_PACKAGE);
+   g_option_context_add_group (ctx, gst_init_get_option_group ());
+   if (!g_option_context_parse (ctx, &argc, &argv, &err)) {
+-    g_printerr ("Error initializing: %s\n", err->message);
++    g_printerr ("Error initializing: %s\n", err ? err->message : "(null)");
+     g_clear_error (&err);
+     g_option_context_free (ctx);
+     return -1;
+-- 
+1.9.1
+
diff --git a/recipes-multimedia/gstreamer/gstreamer1.0/0003-baseparse-unset-FLAG_DISCONT-when-push-to-adapter.patch b/recipes-multimedia/gstreamer/gstreamer1.0/0003-baseparse-unset-FLAG_DISCONT-when-push-to-adapter.patch
new file mode 100644
index 00000000..9758d9c5
--- /dev/null
+++ b/recipes-multimedia/gstreamer/gstreamer1.0/0003-baseparse-unset-FLAG_DISCONT-when-push-to-adapter.patch
@@ -0,0 +1,33 @@
+From 95d80584413c60cfe302cb2b55f59ffdca2a67b9 Mon Sep 17 00:00:00 2001
+From: Lyon Wang <lyon.wang at freescale.com>
+Date: Wed, 4 Nov 2015 18:16:52 +0800
+Subject: [PATCH 3/7] [baseparse] unset FLAG_DISCONT when push to adapter
+
+Since DISCONT flag will be handled by priv->discont flag.
+There is no need to copy DISCONT flag to adapter.
+Otherwise, the DISCONT flag will alwasys been set on each frame,
+for the first chain in buffer.
+
+
+Upstream-Status: Pending [https://bugzilla.gnome.org/show_bug.cgi?id=757575]
+
+Signed-off-by: Lyon Wang <lyon.wang at freescale.com>
+---
+ libs/gst/base/gstbaseparse.c | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/libs/gst/base/gstbaseparse.c b/libs/gst/base/gstbaseparse.c
+index 2f45d23..3c52887 100644
+--- a/libs/gst/base/gstbaseparse.c
++++ b/libs/gst/base/gstbaseparse.c
+@@ -3157,6 +3157,7 @@ gst_base_parse_chain (GstPad * pad, GstObject * parent, GstBuffer * buffer)
+         parse->priv->discont = TRUE;
+       }
+     }
++    GST_BUFFER_FLAG_UNSET(buffer, GST_BUFFER_FLAG_DISCONT);
+     gst_adapter_push (parse->priv->adapter, buffer);
+   }
+ 
+-- 
+1.9.1
+
diff --git a/recipes-multimedia/gstreamer/gstreamer1.0/0004-gstbaseparse-Need-push-adapter-remainning-data-in-pa.patch b/recipes-multimedia/gstreamer/gstreamer1.0/0004-gstbaseparse-Need-push-adapter-remainning-data-in-pa.patch
new file mode 100644
index 00000000..303e1082
--- /dev/null
+++ b/recipes-multimedia/gstreamer/gstreamer1.0/0004-gstbaseparse-Need-push-adapter-remainning-data-in-pa.patch
@@ -0,0 +1,51 @@
+From b7f3a53b5d43c40fc1432c12f2ca314c5dbf403b Mon Sep 17 00:00:00 2001
+From: Lyon Wang <lyon.wang at nxp.com>
+Date: Fri, 15 Jan 2016 17:30:14 +0800
+Subject: [PATCH 4/7] [gstbaseparse] Need push adapter remainning data in pass
+ through mode
+
+When switching to pass through mode, there might be remainning
+data in the adpater, and it will be no chance to push to downstream when
+in pass through mode.
+So need check adapter available data and push downstream to avoid missing data
+
+package: gstreamer1.0
+Upstream-Status: Pending [https://bugzilla.gnome.org/show_bug.cgi?id=760513]
+
+Signed-off-by: Lyon Wang <lyon.wang at nxp.com>
+---
+ libs/gst/base/gstbaseparse.c | 15 +++++++++++++++
+ 1 file changed, 15 insertions(+)
+ mode change 100644 => 100755 libs/gst/base/gstbaseparse.c
+
+diff --git a/libs/gst/base/gstbaseparse.c b/libs/gst/base/gstbaseparse.c
+old mode 100644
+new mode 100755
+index 3c52887..6d3eacf
+--- a/libs/gst/base/gstbaseparse.c
++++ b/libs/gst/base/gstbaseparse.c
+@@ -3138,6 +3138,21 @@ gst_base_parse_chain (GstPad * pad, GstObject * parent, GstBuffer * buffer)
+             && parse->priv->passthrough)) {
+       GstBaseParseFrame frame;
+ 
++    av = gst_adapter_available (parse->priv->adapter);
++    if (av) {
++      tmpbuf = gst_adapter_take_buffer (parse->priv->adapter, av);
++
++      if (parse->priv->upstream_format == GST_FORMAT_TIME) {
++        tmpbuf = gst_buffer_make_writable (tmpbuf);
++        GST_BUFFER_PTS (tmpbuf) = parse->priv->next_pts;
++        GST_BUFFER_DTS (tmpbuf) = parse->priv->next_dts;
++        GST_BUFFER_DURATION (tmpbuf) = GST_CLOCK_TIME_NONE;
++      }
++
++      ret = gst_pad_push (parse->srcpad, tmpbuf);
++
++    }
++
+       gst_base_parse_frame_init (&frame);
+       frame.buffer = gst_buffer_make_writable (buffer);
+       ret = gst_base_parse_push_frame (parse, &frame);
+-- 
+1.9.1
+
diff --git a/recipes-multimedia/gstreamer/gstreamer1.0/0005-inputselector-should-proceed-non-active-pad-buffer-e.patch b/recipes-multimedia/gstreamer/gstreamer1.0/0005-inputselector-should-proceed-non-active-pad-buffer-e.patch
new file mode 100644
index 00000000..f35ca044
--- /dev/null
+++ b/recipes-multimedia/gstreamer/gstreamer1.0/0005-inputselector-should-proceed-non-active-pad-buffer-e.patch
@@ -0,0 +1,51 @@
+From 7f7398acb5dc5fdc904f6684eab2bb072be25de7 Mon Sep 17 00:00:00 2001
+From: Song Bing <bing.song at nxp.com>
+Date: Wed, 11 May 2016 16:57:23 +0800
+Subject: [PATCH 5/7] inputselector: should proceed non-active pad buffer even
+ if active pad reach eos
+
+non-active pad will be blocked if active pad reach eos in inputselector.
+Which will cause all pipeline be blocked.
+Inputselector should proceed non-active pad buffer based on clock even
+if active pad reach eos
+Change to sync with clock for better user experience.
+
+
+Upstream-Status: Pending [https://bugzilla.gnome.org/show_bug.cgi?id=766261]
+
+Signed-off-by: Song Bing bing.song at nxp.com
+---
+ plugins/elements/gstinputselector.c | 10 ++++++++--
+ 1 file changed, 8 insertions(+), 2 deletions(-)
+
+diff --git a/plugins/elements/gstinputselector.c b/plugins/elements/gstinputselector.c
+index f3f95e6..f6e1993 100644
+--- a/plugins/elements/gstinputselector.c
++++ b/plugins/elements/gstinputselector.c
+@@ -772,7 +772,7 @@ gst_input_selector_wait_running_time (GstInputSelector * sel,
+     }
+ 
+     cur_running_time = GST_CLOCK_TIME_NONE;
+-    if (sel->sync_mode == GST_INPUT_SELECTOR_SYNC_MODE_CLOCK) {
++    if (sel->sync_mode == GST_INPUT_SELECTOR_SYNC_MODE_CLOCK || active_selpad->eos) {
+       clock = gst_element_get_clock (GST_ELEMENT_CAST (sel));
+       if (clock) {
+         GstClockTime base_time;
+@@ -823,7 +823,13 @@ gst_input_selector_wait_running_time (GstInputSelector * sel,
+           "Waiting for active streams to advance. %" GST_TIME_FORMAT " >= %"
+           GST_TIME_FORMAT, GST_TIME_ARGS (running_time),
+           GST_TIME_ARGS (cur_running_time));
+-      GST_INPUT_SELECTOR_WAIT (sel);
++      if (active_selpad->eos) {
++        GST_INPUT_SELECTOR_UNLOCK (sel);
++        g_usleep (5000);
++        GST_INPUT_SELECTOR_LOCK (sel);
++      } else {
++        GST_INPUT_SELECTOR_WAIT (sel);
++      }
+     } else {
+       GST_INPUT_SELECTOR_UNLOCK (sel);
+       break;
+-- 
+1.9.1
+
diff --git a/recipes-multimedia/gstreamer/gstreamer1.0/0006-poll-Add-check-if-can-read-event-API.patch b/recipes-multimedia/gstreamer/gstreamer1.0/0006-poll-Add-check-if-can-read-event-API.patch
new file mode 100644
index 00000000..9a6cf470
--- /dev/null
+++ b/recipes-multimedia/gstreamer/gstreamer1.0/0006-poll-Add-check-if-can-read-event-API.patch
@@ -0,0 +1,95 @@
+From 6daed66db8a147783acc117b76afa2e779c8c12c Mon Sep 17 00:00:00 2001
+From: Song Bing <bing.song at nxp.com>
+Date: Thu, 20 Aug 2015 14:57:46 +0800
+Subject: [PATCH 6/7] poll: Add check if can read event API
+
+Need check if can read event of buffer for video decoder based on
+V4L2 driver. Add the API for it.
+
+
+Upstream-Status: Pending [https://bugzilla.gnome.org/show_bug.cgi?id=752962]
+
+Signed-off-by: Song Bing bing.song at nxp.com
+---
+ gst/gstpoll.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++
+ gst/gstpoll.h |  1 +
+ 2 files changed, 53 insertions(+)
+
+diff --git a/gst/gstpoll.c b/gst/gstpoll.c
+index fd672ed..084f6f7 100644
+--- a/gst/gstpoll.c
++++ b/gst/gstpoll.c
+@@ -1242,6 +1242,58 @@ gst_poll_fd_can_read (const GstPoll * set, GstPollFD * fd)
+   return res;
+ }
+ 
++static gboolean
++gst_poll_fd_can_read_pri_unlocked (const GstPoll * set, GstPollFD * fd)
++{
++  gboolean res = FALSE;
++  gint idx;
++
++  idx = find_index (set->active_fds, fd);
++  if (idx >= 0) {
++#ifndef G_OS_WIN32
++    struct pollfd *pfd = &g_array_index (set->active_fds, struct pollfd, idx);
++
++    res = (pfd->revents & POLLPRI) != 0;
++#else
++    WinsockFd *wfd = &g_array_index (set->active_fds, WinsockFd, idx);
++
++    res = (wfd->events.lNetworkEvents & FD_ACCEPT) != 0;
++#endif
++  } else {
++    GST_WARNING ("%p: couldn't find fd !", set);
++  }
++  GST_DEBUG ("%p: fd (fd:%d, idx:%d) %d", set, fd->fd, fd->idx, res);
++
++  return res;
++}
++
++/**
++ * gst_poll_fd_can_read_pri:
++ * @set: a file descriptor set.
++ * @fd: a file descriptor.
++ *
++ * Check if @fd in @set has data to be read.
++ *
++ * Returns: %TRUE if the descriptor has data to be read.
++ */
++gboolean
++gst_poll_fd_can_read_pri (const GstPoll * set, GstPollFD * fd)
++{
++  gboolean res = FALSE;
++
++  g_return_val_if_fail (set != NULL, FALSE);
++  g_return_val_if_fail (fd != NULL, FALSE);
++  g_return_val_if_fail (fd->fd >= 0, FALSE);
++
++  g_mutex_lock (&((GstPoll *) set)->lock);
++
++  res = gst_poll_fd_can_read_pri_unlocked (set, fd);
++
++  g_mutex_unlock (&((GstPoll *) set)->lock);
++
++  return res;
++}
++
+ /**
+  * gst_poll_fd_can_write:
+  * @set: a file descriptor set.
+diff --git a/gst/gstpoll.h b/gst/gstpoll.h
+index ef6dcea..0513648 100644
+--- a/gst/gstpoll.h
++++ b/gst/gstpoll.h
+@@ -79,6 +79,7 @@ void            gst_poll_fd_ignored       (GstPoll *set, GstPollFD *fd);
+ gboolean        gst_poll_fd_has_closed    (const GstPoll *set, GstPollFD *fd);
+ gboolean        gst_poll_fd_has_error     (const GstPoll *set, GstPollFD *fd);
+ gboolean        gst_poll_fd_can_read      (const GstPoll *set, GstPollFD *fd);
++gboolean        gst_poll_fd_can_read_pri  (const GstPoll *set, GstPollFD *fd);
+ gboolean        gst_poll_fd_can_write     (const GstPoll *set, GstPollFD *fd);
+ 
+ gint            gst_poll_wait             (GstPoll *set, GstClockTime timeout);
+-- 
+1.9.1
+
diff --git a/recipes-multimedia/gstreamer/gstreamer1.0/0007-inputselector-Need-flush-when-set-active-pad-and-the.patch b/recipes-multimedia/gstreamer/gstreamer1.0/0007-inputselector-Need-flush-when-set-active-pad-and-the.patch
new file mode 100644
index 00000000..c5d329b6
--- /dev/null
+++ b/recipes-multimedia/gstreamer/gstreamer1.0/0007-inputselector-Need-flush-when-set-active-pad-and-the.patch
@@ -0,0 +1,68 @@
+From 9860e95c4c6bcec422b6c83a2650ef76dd6a5488 Mon Sep 17 00:00:00 2001
+From: Song Bing <bing.song at nxp.com>
+Date: Wed, 10 May 2017 11:24:46 +0800
+Subject: [PATCH 7/7] inputselector: Need flush when set active pad and then
+ seek in PAUSE state
+
+
+Upstream-Status: Pending [https://bugzilla.gnome.org/show_bug.cgi?id=782417]
+
+Signed-off-by: Song Bing bing.song at nxp.com
+---
+ plugins/elements/gstinputselector.c | 11 ++++++++++-
+ 1 file changed, 10 insertions(+), 1 deletion(-)
+
+diff --git a/plugins/elements/gstinputselector.c b/plugins/elements/gstinputselector.c
+index f6e1993..54400dd 100644
+--- a/plugins/elements/gstinputselector.c
++++ b/plugins/elements/gstinputselector.c
+@@ -161,6 +161,7 @@ struct _GstSelectorPad
+   guint32 segment_seqnum;       /* sequence number of the current segment */
+ 
+   gboolean events_pending;      /* TRUE if sticky events need to be updated */
++  gboolean flush_events_pending;/* unblock old active track */
+ 
+   gboolean sending_cached_buffers;
+   GQueue *cached_buffers;
+@@ -339,6 +340,7 @@ gst_selector_pad_reset (GstSelectorPad * pad)
+   pad->eos = FALSE;
+   pad->eos_sent = FALSE;
+   pad->events_pending = FALSE;
++  pad->flush_events_pending = FALSE;
+   pad->discont = FALSE;
+   pad->flushing = FALSE;
+   gst_segment_init (&pad->segment, GST_FORMAT_UNDEFINED);
+@@ -557,6 +559,8 @@ gst_selector_pad_event (GstPad * pad, GstObject * parent, GstEvent * event)
+       selpad->flushing = TRUE;
+       sel->eos = FALSE;
+       selpad->group_done = FALSE;
++      if (selpad->flush_events_pending)
++        forward = TRUE;
+       GST_INPUT_SELECTOR_BROADCAST (sel);
+       break;
+     case GST_EVENT_FLUSH_STOP:
+@@ -1136,6 +1140,7 @@ gst_selector_pad_chain (GstPad * pad, GstObject * parent, GstBuffer * buf)
+     buf = gst_buffer_ref (buf);
+   res = gst_pad_push (sel->srcpad, buf);
+   GST_LOG_OBJECT (pad, "Buffer %p forwarded result=%d", buf, res);
++  selpad->flush_events_pending = FALSE;
+ 
+   GST_INPUT_SELECTOR_LOCK (sel);
+ 
+@@ -1389,8 +1394,12 @@ gst_input_selector_set_active_pad (GstInputSelector * self, GstPad * pad)
+   active_pad_p = &self->active_sinkpad;
+   gst_object_replace ((GstObject **) active_pad_p, GST_OBJECT_CAST (pad));
+ 
+-  if (old && old != new)
++  if (old && old != new) {
+     gst_pad_push_event (GST_PAD_CAST (old), gst_event_new_reconfigure ());
++    /* Old will be blocked on gst_pad_push() when set active pad in PAUSE
++     * state. Need flush when set active pad and then seek in PAUSE state */
++    old->flush_events_pending = TRUE;
++  }
+   if (new)
+     gst_pad_push_event (GST_PAD_CAST (new), gst_event_new_reconfigure ());
+ 
+-- 
+1.9.1
+
diff --git a/recipes-multimedia/gstreamer/gstreamer1.0_1.12.%.bbappend b/recipes-multimedia/gstreamer/gstreamer1.0_1.12.%.bbappend
new file mode 100644
index 00000000..c99d1f20
--- /dev/null
+++ b/recipes-multimedia/gstreamer/gstreamer1.0_1.12.%.bbappend
@@ -0,0 +1,16 @@
+FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"
+
+DEPENDS += " elfutils"
+
+SRC_URI_IMX_PATCHES = " \
+    file://0001-handle-base-parse-error.patch \
+    file://0002-Fix-crash-with-gst-inspect-Chris-Lord-chris-openedha.patch \
+    file://0003-baseparse-unset-FLAG_DISCONT-when-push-to-adapter.patch \
+    file://0004-gstbaseparse-Need-push-adapter-remainning-data-in-pa.patch \
+    file://0005-inputselector-should-proceed-non-active-pad-buffer-e.patch \
+    file://0006-poll-Add-check-if-can-read-event-API.patch \
+    file://0007-inputselector-Need-flush-when-set-active-pad-and-the.patch \
+"
+
+SRC_URI_append_mx6 = "${SRC_URI_IMX_PATCHES}"
+SRC_URI_append_mx7 = "${SRC_URI_IMX_PATCHES}"
-- 
2.13.6



More information about the meta-freescale mailing list