From 120031ab5520fadebd79bd6e3054a77a5e6f3e64 Mon Sep 17 00:00:00 2001 From: Mark Nauwelaerts Date: Thu, 23 Feb 2012 21:16:18 +0100 Subject: faad: discard frame upon decoding error --- ext/faad/gstfaad.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'ext') diff --git a/ext/faad/gstfaad.c b/ext/faad/gstfaad.c index 4dd73eba8..30f6dd9f8 100644 --- a/ext/faad/gstfaad.c +++ b/ext/faad/gstfaad.c @@ -806,6 +806,8 @@ decode_failed: { GST_AUDIO_DECODER_ERROR (faad, 1, STREAM, DECODE, (NULL), ("decoding error: %s", faacDecGetErrorMessage (info.error)), ret); + if (ret == GST_FLOW_OK) + gst_audio_decoder_finish_frme (dec, NULL, 1); goto out; } negotiation_failed: -- cgit v1.2.3 From fa9f035ca8ff16577b736d9114e263b0a45c8694 Mon Sep 17 00:00:00 2001 From: Mark Nauwelaerts Date: Thu, 23 Feb 2012 22:04:24 +0100 Subject: faad: fixup nasty typo breaking compilation --- ext/faad/gstfaad.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'ext') diff --git a/ext/faad/gstfaad.c b/ext/faad/gstfaad.c index 30f6dd9f8..3fee59ed6 100644 --- a/ext/faad/gstfaad.c +++ b/ext/faad/gstfaad.c @@ -807,7 +807,7 @@ decode_failed: GST_AUDIO_DECODER_ERROR (faad, 1, STREAM, DECODE, (NULL), ("decoding error: %s", faacDecGetErrorMessage (info.error)), ret); if (ret == GST_FLOW_OK) - gst_audio_decoder_finish_frme (dec, NULL, 1); + gst_audio_decoder_finish_frame (dec, NULL, 1); goto out; } negotiation_failed: -- cgit v1.2.3 From b84271faa6510475079c7578e23ca60d19321141 Mon Sep 17 00:00:00 2001 From: Stefan Sauer Date: Tue, 13 Dec 2011 23:43:59 +0100 Subject: resindvd: send duration message on duration updates When we know a new duration, report it. Add more logging. --- ext/resindvd/resindvdsrc.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'ext') diff --git a/ext/resindvd/resindvdsrc.c b/ext/resindvd/resindvdsrc.c index 53320752b..76139aa52 100644 --- a/ext/resindvd/resindvdsrc.c +++ b/ext/resindvd/resindvdsrc.c @@ -1036,6 +1036,7 @@ rsn_dvdsrc_step (resinDvdSrc * src, gboolean have_dvd_lock) break; case DVDNAV_CELL_CHANGE:{ dvdnav_cell_change_event_t *event = (dvdnav_cell_change_event_t *) data; + GstMessage *message; src->pgc_duration = MPEGTIME_TO_GSTTIME (event->pgc_length); /* event->cell_start has the wrong time - it doesn't handle @@ -1049,6 +1050,10 @@ rsn_dvdsrc_step (resinDvdSrc * src, gboolean have_dvd_lock) GST_TIME_FORMAT, GST_TIME_ARGS (src->pgc_duration), GST_TIME_ARGS (src->cur_position)); + message = gst_message_new_duration (GST_OBJECT (src), GST_FORMAT_TIME, + src->pgc_duration); + gst_element_post_message (GST_ELEMENT (src), message); + rsn_dvdsrc_prepare_streamsinfo_event (src); src->need_tag_update = TRUE; @@ -2485,6 +2490,9 @@ rsn_dvdsrc_src_query (GstBaseSrc * basesrc, GstQuery * query) if (format == GST_FORMAT_TIME) { if (src->pgc_duration != GST_CLOCK_TIME_NONE) { val = src->pgc_duration; + + GST_DEBUG_OBJECT (src, "duration : %" GST_TIME_FORMAT, + GST_TIME_ARGS (val)); gst_query_set_duration (query, format, val); res = TRUE; } -- cgit v1.2.3 From d68c6bfa9f5d9121eed115a1e73d293fab6b5ed2 Mon Sep 17 00:00:00 2001 From: Sreerenj Balachandran Date: Wed, 2 Nov 2011 11:02:11 +0200 Subject: Initial Commit: Adding Wayland Video Sink --- configure.ac | 27 ++ ext/Makefile.am | 8 + ext/wayland/Makefile.am | 13 + ext/wayland/gstwaylandsink.c | 586 +++++++++++++++++++++++++++++++++++++++++++ ext/wayland/gstwaylandsink.h | 102 ++++++++ 5 files changed, 736 insertions(+) create mode 100644 ext/wayland/Makefile.am create mode 100755 ext/wayland/gstwaylandsink.c create mode 100755 ext/wayland/gstwaylandsink.h (limited to 'ext') diff --git a/configure.ac b/configure.ac index 72f327293..96c884918 100644 --- a/configure.ac +++ b/configure.ac @@ -828,6 +828,31 @@ AG_GST_CHECK_FEATURE(DIRECTFB, [directfb], dfbvideosink , [ ]) ]) +dnl **** Wayland **** +translit(dnm, m, l) AM_CONDITIONAL(USE_WAYLAND, true) +AG_GST_CHECK_FEATURE(WAYLAND, [wayland sink], wayland , [ + PKG_CHECK_MODULES(WAYLAND, wayland-client >= 0.1, [ + AC_CHECK_HEADER(wayland-client.h, HAVE_WAYLAND_CLIENT="yes", HAVE_WAYLAND_CLIENT="no") + AC_CHECK_HEADER(wayland-client-protocol.h, HAVE_WAYLAND_CLIENT_PROTOCOL="yes", HAVE_WAYLAND_CLIENT_PROTOCOL="no") + if test "x$HAVE_WAYLAND_CLIENT" = "xno"; then + AC_MSG_RESULT(wayland-client.h could not be found.) + HAVE_WAYLAND="no" + elif test "x$HAVE_WAYLAND_CLIENT_PROTOCOL" = "xno"; then + AC_MSG_RESULT(wayland-client-protocol.h could not be found.) + HAVE_WAYLAND="no" + else + HAVE_WAYLAND="yes" + WAYLAND_LIBS="-lwayland-client" + fi + ], [ + AC_MSG_RESULT(no wayland.) + HAVE_WAYLAND="no" + ]) +WAYLAND_CFLAGS="" +AC_SUBST(WAYLAND_CFLAGS) +AC_SUBST(WAYLAND_LIBS) +]) + dnl **** Dirac **** translit(dnm, m, l) AM_CONDITIONAL(USE_DIRAC, true) AG_GST_CHECK_FEATURE(DIRAC, [dirac], dirac, [ @@ -1804,6 +1829,7 @@ AM_CONDITIONAL(USE_CURL, false) AM_CONDITIONAL(USE_DC1394, false) AM_CONDITIONAL(USE_DECKLINK, false) AM_CONDITIONAL(USE_DIRECTFB, false) +AM_CONDITIONAL(USE_WAYLAND, false) AM_CONDITIONAL(USE_DIRAC, false) AM_CONDITIONAL(USE_DTS, false) AM_CONDITIONAL(USE_DIVX, false) @@ -2062,6 +2088,7 @@ ext/curl/Makefile ext/dc1394/Makefile ext/dirac/Makefile ext/directfb/Makefile +ext/wayland/Makefile ext/divx/Makefile ext/dts/Makefile ext/faac/Makefile diff --git a/ext/Makefile.am b/ext/Makefile.am index a1636f690..0d57dc3bb 100644 --- a/ext/Makefile.am +++ b/ext/Makefile.am @@ -94,6 +94,12 @@ else DIRECTFB_DIR= endif +if USE_WAYLAND +WAYLAND_DIR=wayland +else +WAYLAND_DIR= +endif + if USE_DIVX DIVX_DIR=divx else @@ -409,6 +415,7 @@ SUBDIRS=\ $(DC1394_DIR) \ $(DIRAC_DIR) \ $(DIRECTFB_DIR) \ + $(WAYLAND_DIR) \ $(DIVX_DIR) \ $(DTS_DIR) \ $(RESINDVD_DIR) \ @@ -469,6 +476,7 @@ DIST_SUBDIRS = \ dc1394 \ dirac \ directfb \ + wayland \ faac \ faad \ flite \ diff --git a/ext/wayland/Makefile.am b/ext/wayland/Makefile.am new file mode 100644 index 000000000..122e8f09e --- /dev/null +++ b/ext/wayland/Makefile.am @@ -0,0 +1,13 @@ +plugin_LTLIBRARIES = libgstwaylandsink.la + +libgstwaylandsink_la_SOURCES = gstwaylandsink.c +libgstwaylandsink_la_CFLAGS = $(GST_CFLAGS) $(GST_PLUGINS_BASE_CFLAGS) \ + $(WAYLAND_CFLAGS) +libgstwaylandsink_la_LIBADD = $(GST_PLUGINS_BASE_LIBS) \ + -lgstvideo-$(GST_MAJORMINOR) \ + -lgstinterfaces-$(GST_MAJORMINOR) \ + $(WAYLAND_LIBS) $(LIBOIL_LIBS) +libgstwaylandsink_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS) +libgstwaylandsink_la_LIBTOOLFLAGS = --tag=disable-static + +noinst_HEADERS = gstwaylandsink.h diff --git a/ext/wayland/gstwaylandsink.c b/ext/wayland/gstwaylandsink.c new file mode 100755 index 000000000..43c9d46f2 --- /dev/null +++ b/ext/wayland/gstwaylandsink.c @@ -0,0 +1,586 @@ +/* + * GStreamer Wayland video sink + * + * Copyright: Intel Corporation + * Copyright: Sreerenj Balachandran + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free + * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + + +/* The waylandsink is currently just a prototype . It creates its own window and render the decoded video frames to that.*/ + +/* FixMe: Needs to add more synchronization stuffs */ +/* FixMe: Remove the extra memcopy by giving buffer to decoder with buffer_alloc*/ +/* FixMe: Add signals so that the application/compositor is responsible for rendering */ +/* FixMe: Add h/w decoding support: buffers/libva surface */ +/* FixMe: Add the interfaces */ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "gstwaylandsink.h" + +#include +#include + +/* signals */ +enum +{ + SIGNAL_0, + SIGNAL_FRAME_READY, + LAST_SIGNAL +}; + +/* Properties */ +/*Fixme: Not yet implemented */ +enum +{ + PROP_0, + PROP_WAYLAND_DISPLAY +}; + +GST_DEBUG_CATEGORY (gstwayland_debug); +#define GST_CAT_DEFAULT gstwayland_debug + +static GstStaticPadTemplate sink_template = GST_STATIC_PAD_TEMPLATE ("sink", + GST_PAD_SINK, + GST_PAD_ALWAYS, + GST_STATIC_CAPS ("video/x-raw-rgb, " + "framerate = (fraction) [ 0, MAX ], " + "endianness = (int) 4321," + "red_mask = (int) 65280, " + "green_mask = (int) 16711680, " + "blue_mask = (int) -16777216," + "width = (int) [ 1, MAX ], " "height = (int) [ 1, MAX ] ")); + +GType gst_wayland_sink_get_type (void); + +/*Fixme: Add more interfaces */ +GST_BOILERPLATE (GstWayLandSink, gst_wayland_sink, GstVideoSink, + GST_TYPE_VIDEO_SINK); + +static void gst_wayland_sink_get_property (GObject * object, + guint prop_id, GValue * value, GParamSpec * pspec); +static void gst_wayland_sink_set_property (GObject * object, + guint prop_id, const GValue * value, GParamSpec * pspec); +static void gst_wayland_sink_dispose (GObject * object); +static void gst_wayland_sink_finalize (GObject * object); + +static GstCaps *gst_wayland_sink_get_caps (GstBaseSink * bsink); +static gboolean gst_wayland_sink_set_caps (GstBaseSink * bsink, GstCaps * caps); +static gboolean gst_wayland_sink_start (GstBaseSink * bsink); +static gboolean gst_wayland_sink_stop (GstBaseSink * bsink); +static gboolean gst_wayland_sink_unlock (GstBaseSink * bsink); +static gboolean gst_wayland_sink_unlock_stop (GstBaseSink * bsink); +static gboolean gst_wayland_sink_preroll (GstBaseSink * bsink, + GstBuffer * buffer); +static gboolean gst_wayland_sink_render (GstBaseSink * bsink, + GstBuffer * buffer); + +static gboolean create_shm_buffer (GstWayLandSink * sink); +static int event_mask_update (uint32_t mask, void *data); +static void sync_callback (void *data); +static struct display *create_display (void); +static void display_handle_global (struct wl_display *display, uint32_t id, + const char *interface, uint32_t version, void *data); +static void compositor_handle_visual (void *data, + struct wl_compositor *compositor, uint32_t id, uint32_t token); +static void redraw (struct wl_surface *surface, void *data, uint32_t time); +static struct window *create_window (GstWayLandSink * sink, + struct display *display, int width, int height); + +static guint gst_wayland_sink_signals[LAST_SIGNAL] = { 0 }; + +static void +gst_wayland_sink_base_init (gpointer gclass) +{ + + GstElementClass *element_class = GST_ELEMENT_CLASS (gclass); + + gst_element_class_add_pad_template (element_class, + gst_static_pad_template_get (&sink_template)); + + gst_element_class_set_details_simple (element_class, + "wayland video sink", "Sink/Video", + "Output to wayland surface", + "Sreerenj Balachandran ,"); +} + +static void +gst_wayland_sink_class_init (GstWayLandSinkClass * klass) +{ + GObjectClass *gobject_class; + GstElementClass *gstelement_class; + GstBaseSinkClass *gstbasesink_class; + + gobject_class = (GObjectClass *) klass; + gstelement_class = (GstElementClass *) klass; + gstbasesink_class = (GstBaseSinkClass *) klass; + + gobject_class->set_property = gst_wayland_sink_set_property; + gobject_class->get_property = gst_wayland_sink_get_property; + gobject_class->dispose = GST_DEBUG_FUNCPTR (gst_wayland_sink_dispose); + gobject_class->finalize = GST_DEBUG_FUNCPTR (gst_wayland_sink_finalize); + + gstbasesink_class->get_caps = GST_DEBUG_FUNCPTR (gst_wayland_sink_get_caps); + gstbasesink_class->set_caps = GST_DEBUG_FUNCPTR (gst_wayland_sink_set_caps); + gstbasesink_class->start = GST_DEBUG_FUNCPTR (gst_wayland_sink_start); + gstbasesink_class->unlock = GST_DEBUG_FUNCPTR (gst_wayland_sink_unlock); + gstbasesink_class->unlock_stop = + GST_DEBUG_FUNCPTR (gst_wayland_sink_unlock_stop); + gstbasesink_class->stop = GST_DEBUG_FUNCPTR (gst_wayland_sink_stop); + gstbasesink_class->preroll = GST_DEBUG_FUNCPTR (gst_wayland_sink_preroll); + gstbasesink_class->render = GST_DEBUG_FUNCPTR (gst_wayland_sink_render); + + g_object_class_install_property (gobject_class, PROP_WAYLAND_DISPLAY, + g_param_spec_pointer ("wayland-display", "WayLand Display", + "WayLand Display id created by the application ", + G_PARAM_READWRITE)); + + /*Fixme: not using now */ + gst_wayland_sink_signals[SIGNAL_FRAME_READY] = + g_signal_new ("frame-ready", + G_TYPE_FROM_CLASS (klass), + G_SIGNAL_RUN_LAST, + 0, NULL, NULL, + g_cclosure_marshal_VOID__POINTER, G_TYPE_NONE, 1, G_TYPE_POINTER); + + parent_class = g_type_class_peek_parent (klass); +} + +static void +gst_wayland_sink_init (GstWayLandSink * sink, + GstWayLandSinkClass * wayland_sink_class) +{ + + sink->caps = NULL; + + sink->buffer_cond = g_cond_new (); + sink->buffer_lock = g_mutex_new (); + + sink->wayland_cond = g_cond_new (); + sink->wayland_lock = g_mutex_new (); + + sink->render_finish = TRUE; +} + +static void +gst_wayland_sink_get_property (GObject * object, + guint prop_id, GValue * value, GParamSpec * pspec) +{ + GstWayLandSink *sink = GST_WAYLAND_SINK (object); + + switch (prop_id) { + case PROP_WAYLAND_DISPLAY: + g_value_set_pointer (value, sink->display); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } +} + +static void +gst_wayland_sink_set_property (GObject * object, + guint prop_id, const GValue * value, GParamSpec * pspec) +{ + GstWayLandSink *sink = GST_WAYLAND_SINK (object); + + switch (prop_id) { + case PROP_WAYLAND_DISPLAY: + sink->display = g_value_get_pointer (value); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } +} + +static void +gst_wayland_sink_dispose (GObject * object) +{ + GstWayLandSink *sink = GST_WAYLAND_SINK (object); + + G_OBJECT_CLASS (parent_class)->dispose (object); +} + +static void +gst_wayland_sink_finalize (GObject * object) +{ + GstWayLandSink *sink = GST_WAYLAND_SINK (object); + + gst_caps_replace (&sink->caps, NULL); + + free (sink->display); + free (sink->window); + + g_cond_free (sink->buffer_cond); + g_cond_free (sink->wayland_cond); + g_mutex_free (sink->buffer_lock); + g_mutex_free (sink->wayland_lock); + + G_OBJECT_CLASS (parent_class)->finalize (object); +} + + +static GstCaps * +gst_wayland_sink_get_caps (GstBaseSink * bsink) +{ + return gst_caps_copy (gst_static_pad_template_get_caps (&sink_template)); +} + +static int +event_mask_update (uint32_t mask, void *data) +{ + struct display *d = data; + + d->mask = mask; + + return 0; +} + +static void +sync_callback (void *data) +{ + int *done = data; + + *done = 1; +} + +static const struct wl_compositor_listener compositor_listener = { + compositor_handle_visual, +}; + +static void +display_handle_global (struct wl_display *display, uint32_t id, + const char *interface, uint32_t version, void *data) +{ + struct display *d = data; + + if (strcmp (interface, "wl_compositor") == 0) { + d->compositor = wl_compositor_create (display, id, 1); + wl_compositor_add_listener (d->compositor, &compositor_listener, d); + } else if (strcmp (interface, "wl_shell") == 0) { + d->shell = wl_shell_create (display, id, 1); + } else if (strcmp (interface, "wl_shm") == 0) { + d->shm = wl_shm_create (display, id, 1); + } + +} + +static struct display * +create_display (void) +{ + struct display *display; + int done; + + display = malloc (sizeof *display); + display->display = wl_display_connect (NULL); + + wl_display_add_global_listener (display->display, + display_handle_global, display); + wl_display_iterate (display->display, WL_DISPLAY_READABLE); + + wl_display_get_fd (display->display, event_mask_update, display); + + wl_display_sync_callback (display->display, sync_callback, &done); + + while (!display->xrgb_visual) { + wl_display_iterate (display->display, display->mask); + } + + return display; +} + +static gboolean +create_shm_buffer (GstWayLandSink * sink) +{ + char filename[] = "/tmp/wayland-shm-XXXXXX"; + struct wl_buffer *wbuffer; + int i, fd, size, stride; + static void *data; + + GST_DEBUG_OBJECT (sink, "Creating wayland-shm buffers"); + + wl_display_iterate (sink->display->display, sink->display->mask); + + fd = mkstemp (filename); + if (fd < 0) { + fprintf (stderr, "open %s failed: %m\n", filename); + exit (0); + } + + stride = sink->width * 4; + size = stride * sink->height; + + if (ftruncate (fd, size) < 0) { + fprintf (stderr, "ftruncate failed: %m\n"); + close (fd); + exit (0); + } + + data = mmap (NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); + unlink (filename); + if (data == MAP_FAILED) { + fprintf (stderr, "mmap failed: %m\n"); + close (fd); + exit (0); + } + + wbuffer = wl_shm_create_buffer (sink->display->shm, fd, + sink->width, sink->height, stride, sink->display->xrgb_visual); + + close (fd); + + sink->window->buffer = wbuffer; + wl_surface_attach (sink->window->surface, sink->window->buffer, 0, 0); + sink->MapAddr = data; + + return TRUE; +} + +static gboolean +gst_wayland_sink_set_caps (GstBaseSink * bsink, GstCaps * caps) +{ + GstWayLandSink *sink = GST_WAYLAND_SINK (bsink); + const GstStructure *structure; + GstFlowReturn result = GST_FLOW_OK; + GstCaps *allowed_caps; + gboolean ret = TRUE; + GstCaps *intersection; + const GValue *fps; + + GST_LOG_OBJECT (sink, "set caps %" GST_PTR_FORMAT, caps); + + structure = gst_caps_get_structure (caps, 0); + + allowed_caps = gst_pad_get_caps (GST_BASE_SINK_PAD (bsink)); + + /* We intersect those caps with our template to make sure they are correct */ + intersection = gst_caps_intersect (allowed_caps, caps); + gst_caps_unref (allowed_caps); + + if (gst_caps_is_empty (intersection)) { + gst_caps_unref (intersection); + return FALSE; + } + + structure = gst_caps_get_structure (caps, 0); + + ret &= gst_structure_get_int (structure, "width", &sink->width); + ret &= gst_structure_get_int (structure, "height", &sink->height); + + if (!ret) + return FALSE; + + gst_caps_replace (&sink->caps, caps); + + gst_caps_unref (intersection); + + if (!create_shm_buffer (sink)) { + GST_ERROR_OBJECT (sink, "Failed to create the wayland buffers.."); + return FALSE; + } + + return TRUE; +} + +static void +compositor_handle_visual (void *data, + struct wl_compositor *compositor, uint32_t id, uint32_t token) +{ + struct display *d = data; + + switch (token) { + case WL_COMPOSITOR_VISUAL_XRGB32: + d->xrgb_visual = wl_visual_create (d->display, id, 1); + break; + } +} + +static void +redraw (struct wl_surface *surface, void *data, uint32_t time) +{ + + GstWayLandSink *sink = (GstWayLandSink *) data; + g_mutex_lock (sink->wayland_lock); + + sink->render_finish = TRUE; + + g_mutex_unlock (sink->wayland_lock); +} + +static struct window * +create_window (GstWayLandSink * sink, struct display *display, int width, + int height) +{ + struct window *window; + struct wl_visual *visual; + void *data; + + g_mutex_lock (sink->wayland_lock); + + window = malloc (sizeof *window); + window->display = display; + window->width = width; + window->height = height; + window->surface = wl_compositor_create_surface (display->compositor); + + wl_shell_set_toplevel (display->shell, window->surface); + + g_mutex_unlock (sink->wayland_lock); + return window; +} + + +static gboolean +gst_wayland_sink_start (GstBaseSink * bsink) +{ + GstWayLandSink *sink = (GstWayLandSink *) bsink; + gboolean result = TRUE; + + GST_DEBUG_OBJECT (sink, "start"); + + if (!sink->display) + sink->display = create_display (); + if (!sink->window) + sink->window = create_window (sink, sink->display, 1280, 720); + + return result; +} + +static gboolean +gst_wayland_sink_unlock (GstBaseSink * bsink) +{ + GstWayLandSink *sink = (GstWayLandSink *) bsink; + + GST_DEBUG_OBJECT (sink, "unlock"); + + g_mutex_lock (sink->buffer_lock); + + sink->unlock = TRUE; + + g_mutex_unlock (sink->buffer_lock); + + return TRUE; +} + +static gboolean +gst_wayland_sink_unlock_stop (GstBaseSink * bsink) +{ + GstWayLandSink *sink = (GstWayLandSink *) bsink; + + GST_DEBUG_OBJECT (sink, "unlock_stop"); + + g_mutex_lock (sink->buffer_lock); + + sink->unlock = FALSE; + + g_mutex_unlock (sink->buffer_lock); + + return TRUE; +} + + +static gboolean +gst_wayland_sink_stop (GstBaseSink * bsink) +{ + GstWayLandSink *sink = (GstWayLandSink *) bsink; + + GST_DEBUG_OBJECT (sink, "stop"); + + return TRUE; +} + +static GstFlowReturn +gst_wayland_sink_preroll (GstBaseSink * bsink, GstBuffer * buffer) +{ + GST_DEBUG_OBJECT (bsink, "preroll buffer %p, data = %p", buffer, + GST_BUFFER_DATA (buffer)); + return gst_wayland_sink_render (bsink, buffer); +} + +static GstFlowReturn +gst_wayland_sink_render (GstBaseSink * bsink, GstBuffer * buffer) +{ + GstWayLandSink *sink = GST_WAYLAND_SINK (bsink); + + if (sink->render_finish) { + GST_LOG_OBJECT (sink, + "render buffer %p, data = %p, timestamp = %" GST_TIME_FORMAT, buffer, + GST_BUFFER_DATA (buffer), + GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (buffer))); + + /*Fixme: remove the memcpy and add memory allocation stuffs to buff_alloc */ + guint8 *src = GST_BUFFER_DATA (buffer); + guint len = GST_BUFFER_SIZE (buffer) / sink->height; + + /*for (i = 0; i < sink->height; i++) { + memcpy (data, src, len); + src += len; + data += len; + } */ + + memcpy (sink->MapAddr, src, GST_BUFFER_SIZE (buffer)); + + sink->render_finish = FALSE; + + wl_buffer_damage (sink->window->buffer, 0, 0, sink->width, sink->height); + + wl_surface_damage (sink->window->surface, 0, 0, sink->width, sink->height); + + wl_display_frame_callback (sink->display->display, + sink->window->surface, redraw, sink); + + wl_display_iterate (sink->display->display, sink->display->mask); + + } else { + GST_LOG_OBJECT (sink, + "Waiting to get the signal from compositor to render the next frame.."); + g_usleep (50000); + sink->render_finish = TRUE; + } + return GST_FLOW_OK; +} + +static gboolean +plugin_init (GstPlugin * plugin) +{ + GST_DEBUG_CATEGORY_INIT (gstwayland_debug, "waylandsink", 0, + " wayland video sink"); + + return gst_element_register (plugin, "waylandsink", GST_RANK_MARGINAL, + GST_TYPE_WAYLAND_SINK); +} + +GST_PLUGIN_DEFINE (GST_VERSION_MAJOR, + GST_VERSION_MINOR, + "waylandsink", + "WayLand Video Sink", plugin_init, VERSION, "LGPL", "gst-wayland", "") diff --git a/ext/wayland/gstwaylandsink.h b/ext/wayland/gstwaylandsink.h new file mode 100755 index 000000000..71d6cfc75 --- /dev/null +++ b/ext/wayland/gstwaylandsink.h @@ -0,0 +1,102 @@ +/* + * GStreamer Wayland video sink + * Copyright (C) 2011 Intel Corporation + * Copyright (C) 2011 Sreerenj Balachandran + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free + * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#ifndef __GST_WAYLAND_VIDEO_SINK_H__ +#define __GST_WAYLAND_VIDEO_SINK_H__ + +#include +#include +#include + +#include +#include + +#define GST_TYPE_WAYLAND_SINK \ + (gst_wayland_sink_get_type()) +#define GST_WAYLAND_SINK(obj) \ + (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_WAYLAND_SINK,GstWayLandSink)) +#define GST_WAYLAND_SINK_CLASS(klass) \ + (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_WAYLAND_SINK,GstWayLandSinkClass)) +#define GST_IS_WAYLAND_SINK(obj) \ + (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_WAYLAND_SINK)) +#define GST_IS_WAYLAND_SINK_CLASS(klass) \ + (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_WAYLAND_SINK)) +#define GST_WAYLAND_SINK_GET_CLASS(inst) \ + (G_TYPE_INSTANCE_GET_CLASS ((inst), GST_TYPE_WAYLAND_SINK, GstWayLandSinkClass)) + +struct display +{ + struct wl_display *display; + struct wl_visual *xrgb_visual; + struct wl_compositor *compositor; + struct wl_shell *shell; + struct wl_shm *shm; + uint32_t mask; +}; + +struct window +{ + struct display *display; + int width, height; + struct wl_surface *surface; + struct wl_buffer *buffer; + void *data; +}; + +typedef struct _GstWayLandSink GstWayLandSink; +typedef struct _GstWayLandSinkClass GstWayLandSinkClass; + +struct _GstWayLandSink +{ + + GstVideoSink parent; + + GstCaps *caps; + + struct display *display; + struct window *window; + + GCond *buffer_cond; + GMutex *buffer_lock; + + GCond *wayland_cond; + GMutex *wayland_lock; + + gboolean unlock; + + guint width, height, depth, size; + + void *MapAddr; + gboolean render_finish; + +}; + +struct _GstWayLandSinkClass +{ + GstVideoSinkClass parent; + +}; + +GType +gst_wayland_sink_get_type (void) + G_GNUC_CONST; + +G_END_DECLS +#endif /* __GST_WAYLAND_VIDEO_SINK_H__ */ -- cgit v1.2.3 From b5a778012267fe28d84133bb0daaa4c51e72f36d Mon Sep 17 00:00:00 2001 From: Sreerenj Balachandran Date: Wed, 2 Nov 2011 13:51:13 +0200 Subject: More Fixes: * Adding buffer_alloc * perform buffer_damage before surface_attach * Fix typo, Remove Dead code etc. --- ext/wayland/gstwaylandsink.c | 402 +++++++++++++++++++++++++++++-------------- ext/wayland/gstwaylandsink.h | 49 +++--- 2 files changed, 298 insertions(+), 153 deletions(-) (limited to 'ext') diff --git a/ext/wayland/gstwaylandsink.c b/ext/wayland/gstwaylandsink.c index 43c9d46f2..a78f8fbb3 100755 --- a/ext/wayland/gstwaylandsink.c +++ b/ext/wayland/gstwaylandsink.c @@ -20,13 +20,7 @@ */ -/* The waylandsink is currently just a prototype . It creates its own window and render the decoded video frames to that.*/ - -/* FixMe: Needs to add more synchronization stuffs */ -/* FixMe: Remove the extra memcopy by giving buffer to decoder with buffer_alloc*/ -/* FixMe: Add signals so that the application/compositor is responsible for rendering */ -/* FixMe: Add h/w decoding support: buffers/libva surface */ -/* FixMe: Add the interfaces */ +/* The waylandsink is creating its own window and render the decoded video frames to that.*/ #ifdef HAVE_CONFIG_H #include @@ -48,7 +42,6 @@ #include "gstwaylandsink.h" #include -#include /* signals */ enum @@ -79,32 +72,36 @@ static GstStaticPadTemplate sink_template = GST_STATIC_PAD_TEMPLATE ("sink", "green_mask = (int) 16711680, " "blue_mask = (int) -16777216," "width = (int) [ 1, MAX ], " "height = (int) [ 1, MAX ] ")); - -GType gst_wayland_sink_get_type (void); +GType gst_wlbuffer_get_type (void); /*Fixme: Add more interfaces */ -GST_BOILERPLATE (GstWayLandSink, gst_wayland_sink, GstVideoSink, +GST_BOILERPLATE (GstWaylandSink, gst_wayland_sink, GstVideoSink, GST_TYPE_VIDEO_SINK); +static void gst_wlbuffer_finalize (GstWlBuffer * wbuffer); +static GstBufferClass *wlbuffer_parent_class = NULL; + static void gst_wayland_sink_get_property (GObject * object, guint prop_id, GValue * value, GParamSpec * pspec); static void gst_wayland_sink_set_property (GObject * object, guint prop_id, const GValue * value, GParamSpec * pspec); static void gst_wayland_sink_dispose (GObject * object); static void gst_wayland_sink_finalize (GObject * object); - static GstCaps *gst_wayland_sink_get_caps (GstBaseSink * bsink); static gboolean gst_wayland_sink_set_caps (GstBaseSink * bsink, GstCaps * caps); static gboolean gst_wayland_sink_start (GstBaseSink * bsink); static gboolean gst_wayland_sink_stop (GstBaseSink * bsink); -static gboolean gst_wayland_sink_unlock (GstBaseSink * bsink); -static gboolean gst_wayland_sink_unlock_stop (GstBaseSink * bsink); +static GstFlowReturn +gst_wayland_sink_buffer_alloc (GstBaseSink * bsink, guint64 offset, guint size, + GstCaps * caps, GstBuffer ** buf); static gboolean gst_wayland_sink_preroll (GstBaseSink * bsink, GstBuffer * buffer); static gboolean gst_wayland_sink_render (GstBaseSink * bsink, GstBuffer * buffer); +static void gst_wayland_bufferpool_clear (GstWaylandSink * sink); +static void +gst_wayland_buffer_destroy (GstWaylandSink * sink, GstWlBuffer * buffer); -static gboolean create_shm_buffer (GstWayLandSink * sink); static int event_mask_update (uint32_t mask, void *data); static void sync_callback (void *data); static struct display *create_display (void); @@ -113,10 +110,75 @@ static void display_handle_global (struct wl_display *display, uint32_t id, static void compositor_handle_visual (void *data, struct wl_compositor *compositor, uint32_t id, uint32_t token); static void redraw (struct wl_surface *surface, void *data, uint32_t time); -static struct window *create_window (GstWayLandSink * sink, +static struct window *create_window (GstWaylandSink * sink, struct display *display, int width, int height); -static guint gst_wayland_sink_signals[LAST_SIGNAL] = { 0 }; +static void +gst_wlbuffer_init (GstWlBuffer * buffer, gpointer g_class) +{ + buffer->wbuffer = NULL; + buffer->wlsink = NULL; +} + +static void +gst_wlbuffer_class_init (gpointer g_class, gpointer class_data) +{ + GstMiniObjectClass *mini_object_class = GST_MINI_OBJECT_CLASS (g_class); + + wlbuffer_parent_class = g_type_class_peek_parent (g_class); + + mini_object_class->finalize = (GstMiniObjectFinalizeFunction) + gst_wlbuffer_finalize; +} + +GType +gst_wlbuffer_get_type (void) +{ + static GType _gst_wlbuffer_type; + + if (G_UNLIKELY (_gst_wlbuffer_type == 0)) { + static const GTypeInfo wlbuffer_info = { + sizeof (GstBufferClass), + NULL, + NULL, + gst_wlbuffer_class_init, + NULL, + NULL, + sizeof (GstWlBuffer), + 0, + (GInstanceInitFunc) gst_wlbuffer_init, + NULL + }; + _gst_wlbuffer_type = g_type_register_static (GST_TYPE_BUFFER, + "GstWlBuffer", &wlbuffer_info, 0); + } + return _gst_wlbuffer_type; +} + +static void +gst_wlbuffer_finalize (GstWlBuffer * wbuffer) +{ + GstWaylandSink *sink = NULL; + + g_return_if_fail (wbuffer != NULL); + + GST_DEBUG_OBJECT (sink, "Finalizing the WlBuffer"); + sink = wbuffer->wlsink; + if (!sink) { + GST_WARNING_OBJECT (wbuffer, "No sink.."); + goto beach; + } + + GST_DEBUG_OBJECT (sink, "recycling buffer %p in pool", wbuffer); + /* need to increment the refcount again to recycle */ + gst_buffer_ref (GST_BUFFER (wbuffer)); + g_mutex_lock (sink->pool_lock); + sink->buffer_pool = g_slist_prepend (sink->buffer_pool, wbuffer); + g_mutex_unlock (sink->pool_lock); + +beach: + return; +} static void gst_wayland_sink_base_init (gpointer gclass) @@ -134,7 +196,7 @@ gst_wayland_sink_base_init (gpointer gclass) } static void -gst_wayland_sink_class_init (GstWayLandSinkClass * klass) +gst_wayland_sink_class_init (GstWaylandSinkClass * klass) { GObjectClass *gobject_class; GstElementClass *gstelement_class; @@ -152,50 +214,39 @@ gst_wayland_sink_class_init (GstWayLandSinkClass * klass) gstbasesink_class->get_caps = GST_DEBUG_FUNCPTR (gst_wayland_sink_get_caps); gstbasesink_class->set_caps = GST_DEBUG_FUNCPTR (gst_wayland_sink_set_caps); gstbasesink_class->start = GST_DEBUG_FUNCPTR (gst_wayland_sink_start); - gstbasesink_class->unlock = GST_DEBUG_FUNCPTR (gst_wayland_sink_unlock); - gstbasesink_class->unlock_stop = - GST_DEBUG_FUNCPTR (gst_wayland_sink_unlock_stop); + gstbasesink_class->buffer_alloc = + GST_DEBUG_FUNCPTR (gst_wayland_sink_buffer_alloc); gstbasesink_class->stop = GST_DEBUG_FUNCPTR (gst_wayland_sink_stop); gstbasesink_class->preroll = GST_DEBUG_FUNCPTR (gst_wayland_sink_preroll); gstbasesink_class->render = GST_DEBUG_FUNCPTR (gst_wayland_sink_render); g_object_class_install_property (gobject_class, PROP_WAYLAND_DISPLAY, - g_param_spec_pointer ("wayland-display", "WayLand Display", - "WayLand Display id created by the application ", + g_param_spec_pointer ("wayland-display", "Wayland Display", + "Wayland Display id created by the application ", G_PARAM_READWRITE)); - /*Fixme: not using now */ - gst_wayland_sink_signals[SIGNAL_FRAME_READY] = - g_signal_new ("frame-ready", - G_TYPE_FROM_CLASS (klass), - G_SIGNAL_RUN_LAST, - 0, NULL, NULL, - g_cclosure_marshal_VOID__POINTER, G_TYPE_NONE, 1, G_TYPE_POINTER); - parent_class = g_type_class_peek_parent (klass); } static void -gst_wayland_sink_init (GstWayLandSink * sink, - GstWayLandSinkClass * wayland_sink_class) +gst_wayland_sink_init (GstWaylandSink * sink, + GstWaylandSinkClass * wayland_sink_class) { sink->caps = NULL; - sink->buffer_cond = g_cond_new (); - sink->buffer_lock = g_mutex_new (); + sink->pool_lock = g_mutex_new (); + sink->buffer_pool = NULL; - sink->wayland_cond = g_cond_new (); sink->wayland_lock = g_mutex_new (); - sink->render_finish = TRUE; } static void gst_wayland_sink_get_property (GObject * object, guint prop_id, GValue * value, GParamSpec * pspec) { - GstWayLandSink *sink = GST_WAYLAND_SINK (object); + GstWaylandSink *sink = GST_WAYLAND_SINK (object); switch (prop_id) { case PROP_WAYLAND_DISPLAY: @@ -211,7 +262,7 @@ static void gst_wayland_sink_set_property (GObject * object, guint prop_id, const GValue * value, GParamSpec * pspec) { - GstWayLandSink *sink = GST_WAYLAND_SINK (object); + GstWaylandSink *sink = GST_WAYLAND_SINK (object); switch (prop_id) { case PROP_WAYLAND_DISPLAY: @@ -226,24 +277,29 @@ gst_wayland_sink_set_property (GObject * object, static void gst_wayland_sink_dispose (GObject * object) { - GstWayLandSink *sink = GST_WAYLAND_SINK (object); - G_OBJECT_CLASS (parent_class)->dispose (object); } static void gst_wayland_sink_finalize (GObject * object) { - GstWayLandSink *sink = GST_WAYLAND_SINK (object); + GstWaylandSink *sink = GST_WAYLAND_SINK (object); + GST_DEBUG_OBJECT (sink, "Finalizing the sink.."); gst_caps_replace (&sink->caps, NULL); - + free (sink->display); free (sink->window); - - g_cond_free (sink->buffer_cond); - g_cond_free (sink->wayland_cond); - g_mutex_free (sink->buffer_lock); + + if (sink->pool_lock) { + g_mutex_free (sink->pool_lock); + sink->pool_lock = NULL; + } + + if (sink->buffer_pool) { + gst_wayland_bufferpool_clear (sink); + } + g_mutex_free (sink->wayland_lock); G_OBJECT_CLASS (parent_class)->finalize (object); @@ -306,6 +362,7 @@ create_display (void) wl_display_add_global_listener (display->display, display_handle_global, display); + wl_display_iterate (display->display, WL_DISPLAY_READABLE); wl_display_get_fd (display->display, event_mask_update, display); @@ -319,29 +376,38 @@ create_display (void) return display; } -static gboolean -create_shm_buffer (GstWayLandSink * sink) +static GstWlBuffer * +wayland_buffer_create (GstWaylandSink * sink) { - char filename[] = "/tmp/wayland-shm-XXXXXX"; - struct wl_buffer *wbuffer; - int i, fd, size, stride; + char filename[1024]; + int fd, size, stride; static void *data; + static int init = 0; + GstWlBuffer *wbuffer; GST_DEBUG_OBJECT (sink, "Creating wayland-shm buffers"); - wl_display_iterate (sink->display->display, sink->display->mask); + wbuffer = (GstWlBuffer *) gst_mini_object_new (GST_TYPE_WLBUFFER); + wbuffer->wlsink = gst_object_ref (sink); + + if (!init) { + wl_display_iterate (sink->display->display, sink->display->mask); + init++; + } + + snprintf (filename, 256, "%s-%d-%s", "/tmp/wayland-shm", init, "XXXXXX"); fd = mkstemp (filename); if (fd < 0) { - fprintf (stderr, "open %s failed: %m\n", filename); + GST_ERROR_OBJECT (sink, "open %s failed:", filename); exit (0); } - stride = sink->width * 4; - size = stride * sink->height; + stride = sink->video_width * 4; + size = stride * sink->video_height; if (ftruncate (fd, size) < 0) { - fprintf (stderr, "ftruncate failed: %m\n"); + GST_ERROR_OBJECT (sink, "ftruncate failed:"); close (fd); exit (0); } @@ -354,28 +420,102 @@ create_shm_buffer (GstWayLandSink * sink) exit (0); } - wbuffer = wl_shm_create_buffer (sink->display->shm, fd, - sink->width, sink->height, stride, sink->display->xrgb_visual); + wbuffer->wbuffer = wl_shm_create_buffer (sink->display->shm, fd, + sink->video_width, sink->video_height, stride, + sink->display->xrgb_visual); close (fd); - sink->window->buffer = wbuffer; - wl_surface_attach (sink->window->surface, sink->window->buffer, 0, 0); - sink->MapAddr = data; + GST_BUFFER_DATA (wbuffer) = data; + GST_BUFFER_SIZE (wbuffer) = size; + + return wbuffer; + +} + +static void +gst_wayland_buffer_destroy (GstWaylandSink * sink, GstWlBuffer * buffer) +{ + if (buffer->wlsink) { + buffer->wlsink = NULL; + gst_object_unref (sink); + } + + GST_MINI_OBJECT_CLASS (wlbuffer_parent_class)->finalize (GST_MINI_OBJECT + (buffer)); +} + +static void +gst_wayland_bufferpool_clear (GstWaylandSink * sink) +{ + g_mutex_lock (sink->pool_lock); + while (sink->buffer_pool) { + GstWlBuffer *buffer = sink->buffer_pool->data; + + sink->buffer_pool = g_slist_delete_link (sink->buffer_pool, + sink->buffer_pool); + gst_wayland_buffer_destroy (sink, buffer); + } + g_mutex_unlock (sink->pool_lock); +} + +static GstFlowReturn +gst_wayland_sink_buffer_alloc (GstBaseSink * bsink, guint64 offset, guint size, + GstCaps * caps, GstBuffer ** buf) +{ + GstWaylandSink *sink = GST_WAYLAND_SINK (bsink); + GstWlBuffer *buffer = NULL; + GstFlowReturn ret = GST_FLOW_OK; + GstStructure *structure = NULL; + GstCaps *desired_caps = NULL; + + GST_LOG_OBJECT (sink, "a buffer of %u bytes was requested with caps " + "%" GST_PTR_FORMAT " and offset %" G_GUINT64_FORMAT, size, caps, offset); + + desired_caps = gst_caps_copy (caps); + structure = gst_caps_get_structure (desired_caps, 0); + + if (gst_structure_get_int (structure, "width", &sink->video_width) && + gst_structure_get_int (structure, "height", &sink->video_height)) { + sink->bpp = size / sink->video_width / sink->video_height; + } + + g_mutex_lock (sink->pool_lock); + while (sink->buffer_pool) { + buffer = (GstWlBuffer *) sink->buffer_pool->data; + + if (buffer) { + sink->buffer_pool = + g_slist_delete_link (sink->buffer_pool, sink->buffer_pool); + } else { + break; + } + } + + g_mutex_unlock (sink->pool_lock); + + if (!buffer) + buffer = wayland_buffer_create (sink); + + if (buffer) + gst_buffer_set_caps (GST_BUFFER (buffer), caps); + + *buf = GST_BUFFER (buffer); + + gst_caps_unref (desired_caps); + + return ret; - return TRUE; } static gboolean gst_wayland_sink_set_caps (GstBaseSink * bsink, GstCaps * caps) { - GstWayLandSink *sink = GST_WAYLAND_SINK (bsink); + GstWaylandSink *sink = GST_WAYLAND_SINK (bsink); const GstStructure *structure; - GstFlowReturn result = GST_FLOW_OK; GstCaps *allowed_caps; gboolean ret = TRUE; GstCaps *intersection; - const GValue *fps; GST_LOG_OBJECT (sink, "set caps %" GST_PTR_FORMAT, caps); @@ -394,8 +534,8 @@ gst_wayland_sink_set_caps (GstBaseSink * bsink, GstCaps * caps) structure = gst_caps_get_structure (caps, 0); - ret &= gst_structure_get_int (structure, "width", &sink->width); - ret &= gst_structure_get_int (structure, "height", &sink->height); + ret &= gst_structure_get_int (structure, "width", &sink->video_width); + ret &= gst_structure_get_int (structure, "height", &sink->video_height); if (!ret) return FALSE; @@ -404,11 +544,6 @@ gst_wayland_sink_set_caps (GstBaseSink * bsink, GstCaps * caps) gst_caps_unref (intersection); - if (!create_shm_buffer (sink)) { - GST_ERROR_OBJECT (sink, "Failed to create the wayland buffers.."); - return FALSE; - } - return TRUE; } @@ -429,7 +564,7 @@ static void redraw (struct wl_surface *surface, void *data, uint32_t time) { - GstWayLandSink *sink = (GstWayLandSink *) data; + GstWaylandSink *sink = (GstWaylandSink *) data; g_mutex_lock (sink->wayland_lock); sink->render_finish = TRUE; @@ -438,12 +573,10 @@ redraw (struct wl_surface *surface, void *data, uint32_t time) } static struct window * -create_window (GstWayLandSink * sink, struct display *display, int width, +create_window (GstWaylandSink * sink, struct display *display, int width, int height) { struct window *window; - struct wl_visual *visual; - void *data; g_mutex_lock (sink->wayland_lock); @@ -453,7 +586,7 @@ create_window (GstWayLandSink * sink, struct display *display, int width, window->height = height; window->surface = wl_compositor_create_surface (display->compositor); - wl_shell_set_toplevel (display->shell, window->surface); + //wl_shell_set_toplevel (display->shell, window->surface); g_mutex_unlock (sink->wayland_lock); return window; @@ -463,7 +596,7 @@ create_window (GstWayLandSink * sink, struct display *display, int width, static gboolean gst_wayland_sink_start (GstBaseSink * bsink) { - GstWayLandSink *sink = (GstWayLandSink *) bsink; + GstWaylandSink *sink = (GstWaylandSink *) bsink; gboolean result = TRUE; GST_DEBUG_OBJECT (sink, "start"); @@ -476,43 +609,10 @@ gst_wayland_sink_start (GstBaseSink * bsink) return result; } -static gboolean -gst_wayland_sink_unlock (GstBaseSink * bsink) -{ - GstWayLandSink *sink = (GstWayLandSink *) bsink; - - GST_DEBUG_OBJECT (sink, "unlock"); - - g_mutex_lock (sink->buffer_lock); - - sink->unlock = TRUE; - - g_mutex_unlock (sink->buffer_lock); - - return TRUE; -} - -static gboolean -gst_wayland_sink_unlock_stop (GstBaseSink * bsink) -{ - GstWayLandSink *sink = (GstWayLandSink *) bsink; - - GST_DEBUG_OBJECT (sink, "unlock_stop"); - - g_mutex_lock (sink->buffer_lock); - - sink->unlock = FALSE; - - g_mutex_unlock (sink->buffer_lock); - - return TRUE; -} - - static gboolean gst_wayland_sink_stop (GstBaseSink * bsink) { - GstWayLandSink *sink = (GstWayLandSink *) bsink; + GstWaylandSink *sink = (GstWaylandSink *) bsink; GST_DEBUG_OBJECT (sink, "stop"); @@ -530,31 +630,67 @@ gst_wayland_sink_preroll (GstBaseSink * bsink, GstBuffer * buffer) static GstFlowReturn gst_wayland_sink_render (GstBaseSink * bsink, GstBuffer * buffer) { - GstWayLandSink *sink = GST_WAYLAND_SINK (bsink); + GstWaylandSink *sink = GST_WAYLAND_SINK (bsink); + gboolean mem_cpy = TRUE; + GstVideoRectangle src, dst, res; - if (sink->render_finish) { - GST_LOG_OBJECT (sink, - "render buffer %p, data = %p, timestamp = %" GST_TIME_FORMAT, buffer, - GST_BUFFER_DATA (buffer), - GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (buffer))); - - /*Fixme: remove the memcpy and add memory allocation stuffs to buff_alloc */ - guint8 *src = GST_BUFFER_DATA (buffer); - guint len = GST_BUFFER_SIZE (buffer) / sink->height; + GST_LOG_OBJECT (sink, + "render buffer %p, data = %p, timestamp = %" GST_TIME_FORMAT, buffer, + GST_BUFFER_DATA (buffer), GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (buffer))); - /*for (i = 0; i < sink->height; i++) { - memcpy (data, src, len); - src += len; - data += len; - } */ - - memcpy (sink->MapAddr, src, GST_BUFFER_SIZE (buffer)); + if (sink->render_finish) { + if (GST_IS_WLBUFFER (buffer)) { + GstWlBuffer *tmp_buffer = (GstWlBuffer *) buffer; + + /* Does it have a waylandbuffer ? */ + if (tmp_buffer->wbuffer) { + mem_cpy = FALSE; + GST_DEBUG_OBJECT (sink, "we have a buffer (%p) we allocated " + "ourselves and it has a wayland buffer, no memcpy then", buffer); + sink->window->buffer = tmp_buffer->wbuffer; + } else { + /* No wayland buffer, that's a malloc */ + GST_DEBUG_OBJECT (sink, "we have a buffer (%p) we allocated " + "ourselves but it does not hold a wayland buffer", buffer); + } + } else { + /* Not our baby! */ + GST_DEBUG_OBJECT (sink, "we have a buffer (%p) we did not allocate", + buffer); + } + + if (mem_cpy) { + + GstWlBuffer *wlbuf = wayland_buffer_create (sink); + /*Fixme: remove the memcpy and add memory allocation stuffs to buff_alloc */ + /*guint8 *src = GST_BUFFER_DATA (buffer); + guint len = GST_BUFFER_SIZE (buffer) / sink->height; + + for (i = 0; i < sink->height; i++) { + memcpy (data, src, len); + src += len; + data += len; + } */ + + memcpy (GST_BUFFER_DATA (wlbuf), GST_BUFFER_DATA (buffer), + GST_BUFFER_SIZE (buffer)); + sink->window->buffer = wlbuf->wbuffer; + } + + src.w = sink->video_width; + src.h = sink->video_height; + dst.w = sink->window->width; + dst.h = sink->window->height; + + gst_video_sink_center_rect (src, dst, &res, FALSE); sink->render_finish = FALSE; - wl_buffer_damage (sink->window->buffer, 0, 0, sink->width, sink->height); + wl_buffer_damage (sink->window->buffer, 0, 0, res.w, res.h); + + wl_surface_attach (sink->window->surface, sink->window->buffer, 0, 0); - wl_surface_damage (sink->window->surface, 0, 0, sink->width, sink->height); + wl_surface_damage (sink->window->surface, 0, 0, res.w, res.h); wl_display_frame_callback (sink->display->display, sink->window->surface, redraw, sink); @@ -583,4 +719,4 @@ plugin_init (GstPlugin * plugin) GST_PLUGIN_DEFINE (GST_VERSION_MAJOR, GST_VERSION_MINOR, "waylandsink", - "WayLand Video Sink", plugin_init, VERSION, "LGPL", "gst-wayland", "") + "Wayland Video Sink", plugin_init, VERSION, "LGPL", "gst-wayland", "") diff --git a/ext/wayland/gstwaylandsink.h b/ext/wayland/gstwaylandsink.h index 71d6cfc75..75c5a9ac8 100755 --- a/ext/wayland/gstwaylandsink.h +++ b/ext/wayland/gstwaylandsink.h @@ -26,20 +26,19 @@ #include #include -#include #define GST_TYPE_WAYLAND_SINK \ (gst_wayland_sink_get_type()) #define GST_WAYLAND_SINK(obj) \ - (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_WAYLAND_SINK,GstWayLandSink)) + (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_WAYLAND_SINK,GstWaylandSink)) #define GST_WAYLAND_SINK_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_WAYLAND_SINK,GstWayLandSinkClass)) + (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_WAYLAND_SINK,GstWaylandSinkClass)) #define GST_IS_WAYLAND_SINK(obj) \ (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_WAYLAND_SINK)) #define GST_IS_WAYLAND_SINK_CLASS(klass) \ (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_WAYLAND_SINK)) #define GST_WAYLAND_SINK_GET_CLASS(inst) \ - (G_TYPE_INSTANCE_GET_CLASS ((inst), GST_TYPE_WAYLAND_SINK, GstWayLandSinkClass)) + (G_TYPE_INSTANCE_GET_CLASS ((inst), GST_TYPE_WAYLAND_SINK, GstWaylandSinkClass)) struct display { @@ -57,13 +56,26 @@ struct window int width, height; struct wl_surface *surface; struct wl_buffer *buffer; - void *data; }; -typedef struct _GstWayLandSink GstWayLandSink; -typedef struct _GstWayLandSinkClass GstWayLandSinkClass; +typedef struct _GstWaylandSink GstWaylandSink; +typedef struct _GstWaylandSinkClass GstWaylandSinkClass; -struct _GstWayLandSink +#define GST_TYPE_WLBUFFER (gst_wlbuffer_get_type()) +#define GST_IS_WLBUFFER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_WLBUFFER)) +#define GST_WLBUFFER (obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_WLBUFFER, GstWlBuffer)) + +typedef struct _GstWlBuffer GstWlBuffer; + +struct _GstWlBuffer { + GstBuffer buffer; /* Extending GstBuffer */ + + struct wl_buffer *wbuffer; + + GstWaylandSink *wlsink; +}; + +struct _GstWaylandSink { GstVideoSink parent; @@ -73,30 +85,27 @@ struct _GstWayLandSink struct display *display; struct window *window; - GCond *buffer_cond; - GMutex *buffer_lock; + GMutex *pool_lock; + GSList *buffer_pool; - GCond *wayland_cond; GMutex *wayland_lock; - gboolean unlock; + gint video_width; + gint video_height; + guint bpp; - guint width, height, depth, size; - - void *MapAddr; gboolean render_finish; - + }; -struct _GstWayLandSinkClass +struct _GstWaylandSinkClass { GstVideoSinkClass parent; }; -GType -gst_wayland_sink_get_type (void) - G_GNUC_CONST; +GType gst_wayland_sink_get_type (void) G_GNUC_CONST; +GType gst_dfbsurface_get_type (void); G_END_DECLS #endif /* __GST_WAYLAND_VIDEO_SINK_H__ */ -- cgit v1.2.3 From 775643d60ea67c43895ca778bd1dbb8506d30722 Mon Sep 17 00:00:00 2001 From: Sreerenj Balachandran Date: Wed, 2 Nov 2011 16:23:02 +0200 Subject: Update with new APIs in wayland-client. --- ext/wayland/gstwaylandsink.c | 64 ++++++++++++-------------------------------- ext/wayland/gstwaylandsink.h | 2 +- 2 files changed, 18 insertions(+), 48 deletions(-) (limited to 'ext') diff --git a/ext/wayland/gstwaylandsink.c b/ext/wayland/gstwaylandsink.c index a78f8fbb3..6a7218ae4 100755 --- a/ext/wayland/gstwaylandsink.c +++ b/ext/wayland/gstwaylandsink.c @@ -103,13 +103,10 @@ static void gst_wayland_buffer_destroy (GstWaylandSink * sink, GstWlBuffer * buffer); static int event_mask_update (uint32_t mask, void *data); -static void sync_callback (void *data); static struct display *create_display (void); static void display_handle_global (struct wl_display *display, uint32_t id, const char *interface, uint32_t version, void *data); -static void compositor_handle_visual (void *data, - struct wl_compositor *compositor, uint32_t id, uint32_t token); -static void redraw (struct wl_surface *surface, void *data, uint32_t time); +static void redraw (void *data, struct wl_callback *callback, uint32_t time); static struct window *create_window (GstWaylandSink * sink, struct display *display, int width, int height); @@ -199,11 +196,9 @@ static void gst_wayland_sink_class_init (GstWaylandSinkClass * klass) { GObjectClass *gobject_class; - GstElementClass *gstelement_class; GstBaseSinkClass *gstbasesink_class; gobject_class = (GObjectClass *) klass; - gstelement_class = (GstElementClass *) klass; gstbasesink_class = (GstBaseSinkClass *) klass; gobject_class->set_property = gst_wayland_sink_set_property; @@ -322,18 +317,6 @@ event_mask_update (uint32_t mask, void *data) return 0; } -static void -sync_callback (void *data) -{ - int *done = data; - - *done = 1; -} - -static const struct wl_compositor_listener compositor_listener = { - compositor_handle_visual, -}; - static void display_handle_global (struct wl_display *display, uint32_t id, const char *interface, uint32_t version, void *data) @@ -341,12 +324,11 @@ display_handle_global (struct wl_display *display, uint32_t id, struct display *d = data; if (strcmp (interface, "wl_compositor") == 0) { - d->compositor = wl_compositor_create (display, id, 1); - wl_compositor_add_listener (d->compositor, &compositor_listener, d); + d->compositor = wl_display_bind (display, id, &wl_compositor_interface); } else if (strcmp (interface, "wl_shell") == 0) { - d->shell = wl_shell_create (display, id, 1); + d->shell = wl_display_bind (display, id, &wl_shell_interface); } else if (strcmp (interface, "wl_shm") == 0) { - d->shm = wl_shm_create (display, id, 1); + d->shm = wl_display_bind (display, id, &wl_shm_interface); } } @@ -355,10 +337,10 @@ static struct display * create_display (void) { struct display *display; - int done; display = malloc (sizeof *display); display->display = wl_display_connect (NULL); + assert (display->display); wl_display_add_global_listener (display->display, display_handle_global, display); @@ -367,12 +349,6 @@ create_display (void) wl_display_get_fd (display->display, event_mask_update, display); - wl_display_sync_callback (display->display, sync_callback, &done); - - while (!display->xrgb_visual) { - wl_display_iterate (display->display, display->mask); - } - return display; } @@ -421,8 +397,7 @@ wayland_buffer_create (GstWaylandSink * sink) } wbuffer->wbuffer = wl_shm_create_buffer (sink->display->shm, fd, - sink->video_width, sink->video_height, stride, - sink->display->xrgb_visual); + sink->video_width, sink->video_height, stride, WL_SHM_FORMAT_XRGB32); close (fd); @@ -547,21 +522,10 @@ gst_wayland_sink_set_caps (GstBaseSink * bsink, GstCaps * caps) return TRUE; } -static void -compositor_handle_visual (void *data, - struct wl_compositor *compositor, uint32_t id, uint32_t token) -{ - struct display *d = data; - - switch (token) { - case WL_COMPOSITOR_VISUAL_XRGB32: - d->xrgb_visual = wl_visual_create (d->display, id, 1); - break; - } -} +static const struct wl_callback_listener frame_listener; static void -redraw (struct wl_surface *surface, void *data, uint32_t time) +redraw (void *data, struct wl_callback *callback, uint32_t time) { GstWaylandSink *sink = (GstWaylandSink *) data; @@ -627,6 +591,7 @@ gst_wayland_sink_preroll (GstBaseSink * bsink, GstBuffer * buffer) return gst_wayland_sink_render (bsink, buffer); } + static GstFlowReturn gst_wayland_sink_render (GstBaseSink * bsink, GstBuffer * buffer) { @@ -692,20 +657,25 @@ gst_wayland_sink_render (GstBaseSink * bsink, GstBuffer * buffer) wl_surface_damage (sink->window->surface, 0, 0, res.w, res.h); - wl_display_frame_callback (sink->display->display, - sink->window->surface, redraw, sink); + if (sink->callback) + wl_callback_destroy (sink->callback); + sink->callback = wl_surface_frame (sink->window->surface); + wl_callback_add_listener (sink->callback, &frame_listener, sink); wl_display_iterate (sink->display->display, sink->display->mask); } else { GST_LOG_OBJECT (sink, "Waiting to get the signal from compositor to render the next frame.."); - g_usleep (50000); sink->render_finish = TRUE; } return GST_FLOW_OK; } +static const struct wl_callback_listener frame_listener = { + redraw +}; + static gboolean plugin_init (GstPlugin * plugin) { diff --git a/ext/wayland/gstwaylandsink.h b/ext/wayland/gstwaylandsink.h index 75c5a9ac8..678b8cfa2 100755 --- a/ext/wayland/gstwaylandsink.h +++ b/ext/wayland/gstwaylandsink.h @@ -43,7 +43,6 @@ struct display { struct wl_display *display; - struct wl_visual *xrgb_visual; struct wl_compositor *compositor; struct wl_shell *shell; struct wl_shm *shm; @@ -84,6 +83,7 @@ struct _GstWaylandSink struct display *display; struct window *window; + struct wl_callback *callback; GMutex *pool_lock; GSList *buffer_pool; -- cgit v1.2.3 From 2747aefaf7607fe2dbac0c858077405b533ca7c8 Mon Sep 17 00:00:00 2001 From: Sreerenj Balachandran Date: Thu, 16 Feb 2012 22:27:23 +0200 Subject: waylandsink: More fixes -- update to Wayland 0.85 protocol -- Added shell surface -- Added format query for shm format -- Create the window based on width and height of video extracted from upstream caps. --- ext/wayland/gstwaylandsink.c | 85 +++++++++++++++++++++++++++++++++----------- ext/wayland/gstwaylandsink.h | 2 ++ 2 files changed, 67 insertions(+), 20 deletions(-) mode change 100755 => 100644 ext/wayland/gstwaylandsink.c mode change 100755 => 100644 ext/wayland/gstwaylandsink.h (limited to 'ext') diff --git a/ext/wayland/gstwaylandsink.c b/ext/wayland/gstwaylandsink.c old mode 100755 new mode 100644 index 6a7218ae4..a073bf035 --- a/ext/wayland/gstwaylandsink.c +++ b/ext/wayland/gstwaylandsink.c @@ -107,7 +107,7 @@ static struct display *create_display (void); static void display_handle_global (struct wl_display *display, uint32_t id, const char *interface, uint32_t version, void *data); static void redraw (void *data, struct wl_callback *callback, uint32_t time); -static struct window *create_window (GstWaylandSink * sink, +static void create_window (GstWaylandSink * sink, struct display *display, int width, int height); static void @@ -229,12 +229,14 @@ gst_wayland_sink_init (GstWaylandSink * sink, { sink->caps = NULL; + sink->render_finish = TRUE; + sink->display = NULL; + sink->window = NULL; sink->pool_lock = g_mutex_new (); sink->buffer_pool = NULL; sink->wayland_lock = g_mutex_new (); - } static void @@ -269,6 +271,31 @@ gst_wayland_sink_set_property (GObject * object, } } +static void +destroy_display (struct display *display) +{ + if (display->shm) + wl_shm_destroy (display->shm); + + if (display->shell) + wl_shell_destroy (display->shell); + + if (display->compositor) + wl_compositor_destroy (display->compositor); + + wl_display_flush (display->display); + wl_display_destroy (display->display); + free (display); +} + +static void +destroy_window (struct window *window) +{ + wl_shell_surface_destroy (window->shell_surface); + wl_surface_destroy (window->surface); + free (window); +} + static void gst_wayland_sink_dispose (GObject * object) { @@ -317,6 +344,18 @@ event_mask_update (uint32_t mask, void *data) return 0; } +static void +shm_format (void *data, struct wl_shm *wl_shm, uint32_t format) +{ + struct display *d = data; + + d->formats |= (1 << format); +} + +struct wl_shm_listener shm_listenter = { + shm_format +}; + static void display_handle_global (struct wl_display *display, uint32_t id, const char *interface, uint32_t version, void *data) @@ -329,6 +368,7 @@ display_handle_global (struct wl_display *display, uint32_t id, d->shell = wl_display_bind (display, id, &wl_shell_interface); } else if (strcmp (interface, "wl_shm") == 0) { d->shm = wl_display_bind (display, id, &wl_shm_interface); + wl_shm_add_listener (d->shm, &shm_listenter, d); } } @@ -346,6 +386,12 @@ create_display (void) display_handle_global, display); wl_display_iterate (display->display, WL_DISPLAY_READABLE); + wl_display_roundtrip (display->display); + + if (!(display->formats & (1 << WL_SHM_FORMAT_XRGB8888))) { + GST_ERROR ("WL_SHM_FORMAT_XRGB32 not available"); + return NULL; + } wl_display_get_fd (display->display, event_mask_update, display); @@ -366,12 +412,7 @@ wayland_buffer_create (GstWaylandSink * sink) wbuffer = (GstWlBuffer *) gst_mini_object_new (GST_TYPE_WLBUFFER); wbuffer->wlsink = gst_object_ref (sink); - if (!init) { - wl_display_iterate (sink->display->display, sink->display->mask); - init++; - } - - snprintf (filename, 256, "%s-%d-%s", "/tmp/wayland-shm", init, "XXXXXX"); + snprintf (filename, 256, "%s-%d-%s", "/tmp/wayland-shm", init++, "XXXXXX"); fd = mkstemp (filename); if (fd < 0) { @@ -397,7 +438,7 @@ wayland_buffer_create (GstWaylandSink * sink) } wbuffer->wbuffer = wl_shm_create_buffer (sink->display->shm, fd, - sink->video_width, sink->video_height, stride, WL_SHM_FORMAT_XRGB32); + sink->video_width, sink->video_height, stride, WL_SHM_FORMAT_XRGB8888); close (fd); @@ -529,19 +570,19 @@ redraw (void *data, struct wl_callback *callback, uint32_t time) { GstWaylandSink *sink = (GstWaylandSink *) data; - g_mutex_lock (sink->wayland_lock); sink->render_finish = TRUE; - - g_mutex_unlock (sink->wayland_lock); } -static struct window * +static void create_window (GstWaylandSink * sink, struct display *display, int width, int height) { struct window *window; + if (sink->window) + return; + g_mutex_lock (sink->wayland_lock); window = malloc (sizeof *window); @@ -550,10 +591,14 @@ create_window (GstWaylandSink * sink, struct display *display, int width, window->height = height; window->surface = wl_compositor_create_surface (display->compositor); - //wl_shell_set_toplevel (display->shell, window->surface); + window->shell_surface = wl_shell_get_shell_surface (display->shell, + window->surface); +// wl_shell_surface_set_toplevel (window->shell_surface); + wl_shell_surface_set_fullscreen (window->shell_surface); + + sink->window = window; g_mutex_unlock (sink->wayland_lock); - return window; } @@ -567,8 +612,6 @@ gst_wayland_sink_start (GstBaseSink * bsink) if (!sink->display) sink->display = create_display (); - if (!sink->window) - sink->window = create_window (sink, sink->display, 1280, 720); return result; } @@ -603,6 +646,9 @@ gst_wayland_sink_render (GstBaseSink * bsink, GstBuffer * buffer) "render buffer %p, data = %p, timestamp = %" GST_TIME_FORMAT, buffer, GST_BUFFER_DATA (buffer), GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (buffer))); + if (!sink->window) + create_window (sink, sink->display, sink->video_width, sink->video_height); + if (sink->render_finish) { if (GST_IS_WLBUFFER (buffer)) { GstWlBuffer *tmp_buffer = (GstWlBuffer *) buffer; @@ -664,11 +710,10 @@ gst_wayland_sink_render (GstBaseSink * bsink, GstBuffer * buffer) wl_callback_add_listener (sink->callback, &frame_listener, sink); wl_display_iterate (sink->display->display, sink->display->mask); - } else { + } else GST_LOG_OBJECT (sink, "Waiting to get the signal from compositor to render the next frame.."); - sink->render_finish = TRUE; - } + return GST_FLOW_OK; } diff --git a/ext/wayland/gstwaylandsink.h b/ext/wayland/gstwaylandsink.h old mode 100755 new mode 100644 index 678b8cfa2..56fffd823 --- a/ext/wayland/gstwaylandsink.h +++ b/ext/wayland/gstwaylandsink.h @@ -46,6 +46,7 @@ struct display struct wl_compositor *compositor; struct wl_shell *shell; struct wl_shm *shm; + uint32_t formats; uint32_t mask; }; @@ -54,6 +55,7 @@ struct window struct display *display; int width, height; struct wl_surface *surface; + struct wl_shell_surface *shell_surface; struct wl_buffer *buffer; }; -- cgit v1.2.3 From e012ea80ffae23ec0781625fe57662c66bd9ac86 Mon Sep 17 00:00:00 2001 From: Sreerenj Balachandran Date: Tue, 28 Feb 2012 21:00:24 +0200 Subject: waylandsink: Fix in shell_surface_set_fullscreen --- ext/wayland/gstwaylandsink.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'ext') diff --git a/ext/wayland/gstwaylandsink.c b/ext/wayland/gstwaylandsink.c index a073bf035..614e5dbce 100644 --- a/ext/wayland/gstwaylandsink.c +++ b/ext/wayland/gstwaylandsink.c @@ -594,7 +594,8 @@ create_window (GstWaylandSink * sink, struct display *display, int width, window->shell_surface = wl_shell_get_shell_surface (display->shell, window->surface); // wl_shell_surface_set_toplevel (window->shell_surface); - wl_shell_surface_set_fullscreen (window->shell_surface); + wl_shell_surface_set_fullscreen (window->shell_surface, + WL_SHELL_SURFACE_FULLSCREEN_METHOD_DEFAULT, 0, NULL); sink->window = window; -- cgit v1.2.3 From 83ffd07e4416c00ac00e95d08449746a8227a6be Mon Sep 17 00:00:00 2001 From: Sebastian Dröge Date: Tue, 6 Mar 2012 14:51:26 +0100 Subject: cogcolorspace: Use correct enum type for return value --- ext/cog/gstcogcolorspace.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'ext') diff --git a/ext/cog/gstcogcolorspace.c b/ext/cog/gstcogcolorspace.c index 3c84c32a5..d849f36a0 100644 --- a/ext/cog/gstcogcolorspace.c +++ b/ext/cog/gstcogcolorspace.c @@ -372,7 +372,7 @@ gst_cogcolorspace_caps_get_chroma_site (GstCaps * caps) s = gst_video_parse_caps_chroma_site (caps); if (s == NULL) - return COG_COLOR_MATRIX_SDTV; + return COG_CHROMA_SITE_MPEG2; if (strcmp (s, "jpeg") == 0) { return COG_CHROMA_SITE_JPEG; -- cgit v1.2.3 From 4b42d5c5c686262427b0492f4b52e2bbbbb70c12 Mon Sep 17 00:00:00 2001 From: Sebastian Dröge Date: Tue, 6 Mar 2012 14:51:57 +0100 Subject: curl: Fix 'equality comparison with extraneous parentheses' compiler warning --- ext/curl/gstcurlsink.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'ext') diff --git a/ext/curl/gstcurlsink.c b/ext/curl/gstcurlsink.c index 4306de43b..7bf9b43b2 100644 --- a/ext/curl/gstcurlsink.c +++ b/ext/curl/gstcurlsink.c @@ -849,7 +849,7 @@ gst_curl_sink_handle_transfer (GstCurlSink * sink) if (!proxy_conn_established && (resp_proxy != RESPONSE_CONNECT_PROXY) && proxy_auth) { curl_easy_getinfo (sink->curl, CURLINFO_HTTP_CONNECTCODE, &resp_proxy); - if ((resp_proxy == RESPONSE_CONNECT_PROXY)) { + if (resp_proxy == RESPONSE_CONNECT_PROXY) { GST_LOG ("received HTTP/1.0 200 Connection Established"); /* Workaround: redefine HTTP headers before connecting to HTTP server. * When talking to proxy, the Content-Length: 0 is send with the request. -- cgit v1.2.3 From 3482b7b219b588cc4fd52a72a8ee98f149fd277e Mon Sep 17 00:00:00 2001 From: Sebastian Dröge Date: Tue, 6 Mar 2012 14:56:20 +0100 Subject: dfbvideosink: Fix 'implicit conversion from enumeration type 'DirectResult' to different enumeration type 'DFBResult'' compiler warning We're not checking the return value of that function anyway. --- ext/directfb/dfbvideosink.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'ext') diff --git a/ext/directfb/dfbvideosink.c b/ext/directfb/dfbvideosink.c index c3417a5e1..737096b98 100644 --- a/ext/directfb/dfbvideosink.c +++ b/ext/directfb/dfbvideosink.c @@ -1613,7 +1613,7 @@ gst_dfbvideosink_show_frame (GstBaseSink * bsink, GstBuffer * buf) res = dest->Unlock (dest); - res = dest->Release (dest); + dest->Release (dest); if (dfbvideosink->backbuffer) { if (dfbvideosink->vsync) { -- cgit v1.2.3 From 5a6b7fba4db92687d763e807a5c7f71b999d093e Mon Sep 17 00:00:00 2001 From: Sebastian Dröge Date: Tue, 6 Mar 2012 14:57:45 +0100 Subject: gsettings: Fix 'if statement has empty body' compiler warning --- ext/gsettings/gstgsettingsaudiosink.c | 5 +++-- ext/gsettings/gstgsettingsaudiosrc.c | 4 ++-- ext/gsettings/gstgsettingsvideosink.c | 4 ++-- ext/gsettings/gstgsettingsvideosrc.c | 4 ++-- 4 files changed, 9 insertions(+), 8 deletions(-) (limited to 'ext') diff --git a/ext/gsettings/gstgsettingsaudiosink.c b/ext/gsettings/gstgsettingsaudiosink.c index f4155b3bc..12d848938 100644 --- a/ext/gsettings/gstgsettingsaudiosink.c +++ b/ext/gsettings/gstgsettingsaudiosink.c @@ -160,8 +160,9 @@ static void on_changed (GSettings * settings, gchar * key, GstGSettingsAudioSink * sink) { gboolean changed = FALSE; - if (!g_str_has_suffix (key, "audiosink")); - return; + + if (!g_str_has_suffix (key, "audiosink")) + return; GST_OBJECT_LOCK (sink); if ((sink->profile == GST_GSETTINGS_AUDIOSINK_PROFILE_SOUNDS && diff --git a/ext/gsettings/gstgsettingsaudiosrc.c b/ext/gsettings/gstgsettingsaudiosrc.c index 7b9bd1f18..c30f12271 100644 --- a/ext/gsettings/gstgsettingsaudiosrc.c +++ b/ext/gsettings/gstgsettingsaudiosrc.c @@ -104,8 +104,8 @@ fail: static void on_changed (GSettings * settings, gchar * key, GstGSettingsAudioSrc * src) { - if (!g_str_equal (key, "audiosrc")); - return; + if (!g_str_equal (key, "audiosrc")) + return; gst_gsettings_audio_src_change_child (src); } diff --git a/ext/gsettings/gstgsettingsvideosink.c b/ext/gsettings/gstgsettingsvideosink.c index f04e8054c..e225ec14e 100644 --- a/ext/gsettings/gstgsettingsvideosink.c +++ b/ext/gsettings/gstgsettingsvideosink.c @@ -104,8 +104,8 @@ fail: static void on_changed (GSettings * settings, gchar * key, GstGSettingsVideoSink * sink) { - if (!g_str_has_suffix (key, "videosink")); - return; + if (!g_str_has_suffix (key, "videosink")) + return; gst_gsettings_video_sink_change_child (sink); } diff --git a/ext/gsettings/gstgsettingsvideosrc.c b/ext/gsettings/gstgsettingsvideosrc.c index 877656814..6c2a5b03e 100644 --- a/ext/gsettings/gstgsettingsvideosrc.c +++ b/ext/gsettings/gstgsettingsvideosrc.c @@ -104,8 +104,8 @@ fail: static void on_changed (GSettings * settings, gchar * key, GstGSettingsVideoSrc * src) { - if (!g_str_equal (key, "videosrc")); - return; + if (!g_str_equal (key, "videosrc")) + return; gst_gsettings_video_src_change_child (src); } -- cgit v1.2.3 From 837763fee8b13d4f964e89b1de8bf4b7f3571836 Mon Sep 17 00:00:00 2001 From: Sebastian Dröge Date: Tue, 6 Mar 2012 15:21:17 +0100 Subject: vp8enc: Fix 'argument to 'sizeof' in 'memset' call is the same expression as the destination' compiler warning --- ext/vp8/gstvp8enc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'ext') diff --git a/ext/vp8/gstvp8enc.c b/ext/vp8/gstvp8enc.c index b1f06e056..9dadd51bd 100644 --- a/ext/vp8/gstvp8enc.c +++ b/ext/vp8/gstvp8enc.c @@ -843,7 +843,7 @@ gst_vp8_enc_set_format (GstBaseVideoEncoder * base_video_encoder, /* prepare cached image buffer setup */ image = &encoder->image; - memset (image, 0, sizeof (image)); + memset (image, 0, sizeof (*image)); image->fmt = VPX_IMG_FMT_I420; image->bps = 12; -- cgit v1.2.3 From 8aa50a29de6af081129926cfab15293bd560c538 Mon Sep 17 00:00:00 2001 From: Mark Nauwelaerts Date: Tue, 6 Mar 2012 16:11:30 +0100 Subject: dtsdec: use base class tag handling helper ... so as to ensure these to be handled and sent at proper time. --- ext/dts/gstdtsdec.c | 30 ++---------------------------- ext/dts/gstdtsdec.h | 2 -- 2 files changed, 2 insertions(+), 30 deletions(-) (limited to 'ext') diff --git a/ext/dts/gstdtsdec.c b/ext/dts/gstdtsdec.c index 4a304f8e8..d589901c2 100644 --- a/ext/dts/gstdtsdec.c +++ b/ext/dts/gstdtsdec.c @@ -137,8 +137,6 @@ static gboolean gst_dtsdec_parse (GstAudioDecoder * dec, GstAdapter * adapter, gint * offset, gint * length); static GstFlowReturn gst_dtsdec_handle_frame (GstAudioDecoder * dec, GstBuffer * buffer); -static GstFlowReturn gst_dtsdec_pre_push (GstAudioDecoder * bdec, - GstBuffer ** buffer); static GstFlowReturn gst_dtsdec_chain (GstPad * pad, GstBuffer * buf); @@ -182,7 +180,6 @@ gst_dtsdec_class_init (GstDtsDecClass * klass) gstbase_class->set_format = GST_DEBUG_FUNCPTR (gst_dtsdec_set_format); gstbase_class->parse = GST_DEBUG_FUNCPTR (gst_dtsdec_parse); gstbase_class->handle_frame = GST_DEBUG_FUNCPTR (gst_dtsdec_handle_frame); - gstbase_class->pre_push = GST_DEBUG_FUNCPTR (gst_dtsdec_pre_push); /** * GstDtsDec::drc @@ -266,10 +263,6 @@ gst_dtsdec_stop (GstAudioDecoder * dec) dca_free (dts->state); dts->state = NULL; } - if (dts->pending_tags) { - gst_tag_list_free (dts->pending_tags); - dts->pending_tags = NULL; - } return TRUE; } @@ -459,28 +452,9 @@ gst_dtsdec_update_streaminfo (GstDtsDec * dts) /* 1 => open bitrate, 2 => variable bitrate, 3 => lossless */ gst_tag_list_add (taglist, GST_TAG_MERGE_APPEND, GST_TAG_BITRATE, (guint) dts->bit_rate, NULL); - - if (dts->pending_tags) { - gst_tag_list_free (dts->pending_tags); - dts->pending_tags = NULL; - } - - dts->pending_tags = taglist; - } -} - -static GstFlowReturn -gst_dtsdec_pre_push (GstAudioDecoder * bdec, GstBuffer ** buffer) -{ - GstDtsDec *dts = GST_DTSDEC (bdec); - - if (G_UNLIKELY (dts->pending_tags)) { - gst_element_found_tags_for_pad (GST_ELEMENT (dts), - GST_AUDIO_DECODER_SRC_PAD (dts), dts->pending_tags); - dts->pending_tags = NULL; + gst_audio_decoder_merge_tags (GST_AUDIO_DECODER (dts), taglist, + GST_TAG_MERGE_REPLACE); } - - return GST_FLOW_OK; } static GstFlowReturn diff --git a/ext/dts/gstdtsdec.h b/ext/dts/gstdtsdec.h index be6005a0a..172473aca 100644 --- a/ext/dts/gstdtsdec.h +++ b/ext/dts/gstdtsdec.h @@ -66,8 +66,6 @@ struct _GstDtsDec { #else dts_state_t *state; #endif - - GstTagList *pending_tags; }; struct _GstDtsDecClass { -- cgit v1.2.3 From bc7442faa350e496b2a0cc225fe4ead3c883cf54 Mon Sep 17 00:00:00 2001 From: Mark Nauwelaerts Date: Tue, 6 Mar 2012 16:11:52 +0100 Subject: celtdec: use base class tag handling helper ... so as to ensure these to be handled and sent at proper time. --- ext/celt/gstceltdec.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'ext') diff --git a/ext/celt/gstceltdec.c b/ext/celt/gstceltdec.c index 84b2d203f..e8899c488 100644 --- a/ext/celt/gstceltdec.c +++ b/ext/celt/gstceltdec.c @@ -298,8 +298,8 @@ gst_celt_dec_parse_comments (GstCeltDec * dec, GstBuffer * buf) GST_INFO_OBJECT (dec, "tags: %" GST_PTR_FORMAT, list); - gst_element_found_tags_for_pad (GST_ELEMENT (dec), - GST_AUDIO_DECODER_SRC_PAD (dec), list); + gst_audio_decoder_merge_tags (GST_AUDIO_DECODER (dec), list, + GST_TAG_MERGE_REPLACE); g_free (encoder); g_free (ver); -- cgit v1.2.3 From a1b7f84794da2219b604b8410472b4a6d29227cb Mon Sep 17 00:00:00 2001 From: Edward Hervey Date: Tue, 6 Mar 2012 18:11:35 +0100 Subject: Add missing GLIB_DISABLE_DEPRECATION_WARNINGS Suppress warnings about deprecated threading and GValueArray API, so git compiles with -Werror. --- ext/assrender/gstassrender.c | 3 +++ ext/gme/gstgme.c | 4 ++++ ext/musepack/gstmusepackdec.c | 4 ++++ ext/openal/gstopenalsink.c | 4 ++++ ext/timidity/gstwildmidi.c | 4 ++++ sys/vdpau/gstvdp/gstvdpbufferpool.c | 3 +++ sys/vdpau/gstvdp/gstvdpdevice.c | 4 ++++ sys/vdpau/gstvdpsink.c | 4 ++++ 8 files changed, 30 insertions(+) (limited to 'ext') diff --git a/ext/assrender/gstassrender.c b/ext/assrender/gstassrender.c index b71e8e4d1..a184a33f5 100644 --- a/ext/assrender/gstassrender.c +++ b/ext/assrender/gstassrender.c @@ -31,6 +31,9 @@ * */ +/* FIXME 0.11: suppress warnings for deprecated API such as GStaticRecMutex + * with newer GLib versions (>= 2.31.0) */ +#define GLIB_DISABLE_DEPRECATION_WARNINGS #ifdef HAVE_CONFIG_H # include diff --git a/ext/gme/gstgme.c b/ext/gme/gstgme.c index f8a387d43..00ad589b1 100644 --- a/ext/gme/gstgme.c +++ b/ext/gme/gstgme.c @@ -18,6 +18,10 @@ * Boston, MA 02111-1307, USA. */ +/* FIXME 0.11: suppress warnings for deprecated API such as GStaticRecMutex + * with newer GLib versions (>= 2.31.0) */ +#define GLIB_DISABLE_DEPRECATION_WARNINGS + #ifdef HAVE_CONFIG_H #include "config.h" #endif diff --git a/ext/musepack/gstmusepackdec.c b/ext/musepack/gstmusepackdec.c index 1d6380c75..899a4c25a 100644 --- a/ext/musepack/gstmusepackdec.c +++ b/ext/musepack/gstmusepackdec.c @@ -19,6 +19,10 @@ * Boston, MA 02111-1307, USA. */ +/* FIXME 0.11: suppress warnings for deprecated API such as GStaticRecMutex + * with newer GLib versions (>= 2.31.0) */ +#define GLIB_DISABLE_DEPRECATION_WARNINGS + #ifdef HAVE_CONFIG_H #include "config.h" #endif diff --git a/ext/openal/gstopenalsink.c b/ext/openal/gstopenalsink.c index a169d9e57..9e6bf9a70 100644 --- a/ext/openal/gstopenalsink.c +++ b/ext/openal/gstopenalsink.c @@ -20,6 +20,10 @@ * Boston, MA 02111-1307, USA. */ +/* FIXME 0.11: suppress warnings for deprecated API such as GStaticRecMutex + * with newer GLib versions (>= 2.31.0) */ +#define GLIB_DISABLE_DEPRECATION_WARNINGS + /** * SECTION:element-openalsink * diff --git a/ext/timidity/gstwildmidi.c b/ext/timidity/gstwildmidi.c index e78ecc11c..287ff5470 100644 --- a/ext/timidity/gstwildmidi.c +++ b/ext/timidity/gstwildmidi.c @@ -38,6 +38,10 @@ * */ +/* FIXME 0.11: suppress warnings for deprecated API such as GStaticRecMutex + * with newer GLib versions (>= 2.31.0) */ +#define GLIB_DISABLE_DEPRECATION_WARNINGS + #ifdef HAVE_CONFIG_H # include #endif diff --git a/sys/vdpau/gstvdp/gstvdpbufferpool.c b/sys/vdpau/gstvdp/gstvdpbufferpool.c index fea8aea4f..61c706b23 100644 --- a/sys/vdpau/gstvdp/gstvdpbufferpool.c +++ b/sys/vdpau/gstvdp/gstvdpbufferpool.c @@ -18,6 +18,9 @@ * Boston, MA 02111-1307, USA. */ +/* FIXME 0.11: suppress warnings for deprecated API such as GStaticRecMutex + * with newer GLib versions (>= 2.31.0) */ +#define GLIB_DISABLE_DEPRECATION_WARNINGS #include "gstvdpbufferpool.h" diff --git a/sys/vdpau/gstvdp/gstvdpdevice.c b/sys/vdpau/gstvdp/gstvdpdevice.c index 359874b16..eb5451800 100644 --- a/sys/vdpau/gstvdp/gstvdpdevice.c +++ b/sys/vdpau/gstvdp/gstvdpdevice.c @@ -18,6 +18,10 @@ * Boston, MA 02111-1307, USA. */ +/* FIXME 0.11: suppress warnings for deprecated API such as GStaticRecMutex + * with newer GLib versions (>= 2.31.0) */ +#define GLIB_DISABLE_DEPRECATION_WARNINGS + #include "gstvdpdevice.h" GST_DEBUG_CATEGORY_STATIC (gst_vdp_device_debug); diff --git a/sys/vdpau/gstvdpsink.c b/sys/vdpau/gstvdpsink.c index 7b9fa2e6c..27847bd18 100644 --- a/sys/vdpau/gstvdpsink.c +++ b/sys/vdpau/gstvdpsink.c @@ -18,6 +18,10 @@ * Boston, MA 02111-1307, USA. */ +/* FIXME 0.11: suppress warnings for deprecated API such as GStaticRecMutex + * with newer GLib versions (>= 2.31.0) */ +#define GLIB_DISABLE_DEPRECATION_WARNINGS + #ifdef HAVE_CONFIG_H #include "config.h" #endif -- cgit v1.2.3 From db0aa7f0567435b14011750c02b0dcfd12cceb65 Mon Sep 17 00:00:00 2001 From: Mark Nauwelaerts Date: Wed, 7 Mar 2012 12:55:43 +0100 Subject: opusenc: configure baseclass requested samples really in samples ... as opposed to bytes. --- ext/opus/gstopusenc.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'ext') diff --git a/ext/opus/gstopusenc.c b/ext/opus/gstopusenc.c index 29b254ee2..a87e08b3f 100644 --- a/ext/opus/gstopusenc.c +++ b/ext/opus/gstopusenc.c @@ -382,10 +382,8 @@ gst_opus_enc_setup_base_class (GstOpusEnc * enc, GstAudioEncoder * benc) { gst_audio_encoder_set_latency (benc, gst_opus_enc_get_latency (enc), gst_opus_enc_get_latency (enc)); - gst_audio_encoder_set_frame_samples_min (benc, - enc->frame_samples * enc->n_channels * 2); - gst_audio_encoder_set_frame_samples_max (benc, - enc->frame_samples * enc->n_channels * 2); + gst_audio_encoder_set_frame_samples_min (benc, enc->frame_samples); + gst_audio_encoder_set_frame_samples_max (benc, enc->frame_samples); gst_audio_encoder_set_frame_max (benc, 0); } -- cgit v1.2.3 From 228d8808fe6f8aa7390b73d2b248b3a8f092eb9e Mon Sep 17 00:00:00 2001 From: Mark Nauwelaerts Date: Wed, 7 Mar 2012 12:59:28 +0100 Subject: opusenc: only request and process 1 frame at a time ... since it is specified in _finish_frame that input buffer may be invalidated after calling it, and is as such not reliably available for further encoding. Also, requesting or allowing several frames is only useful if subclass intends to process these "in 1 run" (as in, 1 output buffer), not for having another (inner) loop in subclass where the baseclass one will do just fine. --- ext/opus/gstopusenc.c | 70 +++++++++++++++++++++++---------------------------- 1 file changed, 31 insertions(+), 39 deletions(-) (limited to 'ext') diff --git a/ext/opus/gstopusenc.c b/ext/opus/gstopusenc.c index a87e08b3f..6a19ffd89 100644 --- a/ext/opus/gstopusenc.c +++ b/ext/opus/gstopusenc.c @@ -384,7 +384,7 @@ gst_opus_enc_setup_base_class (GstOpusEnc * enc, GstAudioEncoder * benc) gst_opus_enc_get_latency (enc), gst_opus_enc_get_latency (enc)); gst_audio_encoder_set_frame_samples_min (benc, enc->frame_samples); gst_audio_encoder_set_frame_samples_max (benc, enc->frame_samples); - gst_audio_encoder_set_frame_max (benc, 0); + gst_audio_encoder_set_frame_max (benc, 1); } static gint @@ -792,6 +792,8 @@ gst_opus_enc_encode (GstOpusEnc * enc, GstBuffer * buf) gsize bsize, size; gsize bytes; gint ret = GST_FLOW_OK; + gint outsize; + GstBuffer *outbuf; g_mutex_lock (enc->property_lock); @@ -816,51 +818,41 @@ gst_opus_enc_encode (GstOpusEnc * enc, GstBuffer * buf) goto done; } + g_assert (size == bytes); - while (size) { - gint outsize; - GstBuffer *outbuf; + ret = gst_pad_alloc_buffer_and_set_caps (GST_AUDIO_ENCODER_SRC_PAD (enc), + GST_BUFFER_OFFSET_NONE, enc->max_payload_size * enc->n_channels, + GST_PAD_CAPS (GST_AUDIO_ENCODER_SRC_PAD (enc)), &outbuf); - ret = gst_pad_alloc_buffer_and_set_caps (GST_AUDIO_ENCODER_SRC_PAD (enc), - GST_BUFFER_OFFSET_NONE, enc->max_payload_size * enc->n_channels, - GST_PAD_CAPS (GST_AUDIO_ENCODER_SRC_PAD (enc)), &outbuf); - - if (GST_FLOW_OK != ret) - goto done; - - GST_DEBUG_OBJECT (enc, "encoding %d samples (%d bytes)", - enc->frame_samples, (int) bytes); - - outsize = - opus_multistream_encode (enc->state, (const gint16 *) data, - enc->frame_samples, GST_BUFFER_DATA (outbuf), - enc->max_payload_size * enc->n_channels); + if (GST_FLOW_OK != ret) + goto done; - if (outsize < 0) { - GST_ERROR_OBJECT (enc, "Encoding failed: %d", outsize); - ret = GST_FLOW_ERROR; - goto done; - } else if (outsize > enc->max_payload_size) { - GST_WARNING_OBJECT (enc, - "Encoded size %d is higher than max payload size (%d bytes)", - outsize, enc->max_payload_size); - ret = GST_FLOW_ERROR; - goto done; - } + GST_DEBUG_OBJECT (enc, "encoding %d samples (%d bytes)", + enc->frame_samples, (int) bytes); - GST_DEBUG_OBJECT (enc, "Output packet is %u bytes", outsize); - GST_BUFFER_SIZE (outbuf) = outsize; + outsize = + opus_multistream_encode (enc->state, (const gint16 *) data, + enc->frame_samples, GST_BUFFER_DATA (outbuf), + enc->max_payload_size * enc->n_channels); - ret = - gst_audio_encoder_finish_frame (GST_AUDIO_ENCODER (enc), outbuf, - enc->frame_samples); + if (outsize < 0) { + GST_ERROR_OBJECT (enc, "Encoding failed: %d", outsize); + ret = GST_FLOW_ERROR; + goto done; + } else if (outsize > enc->max_payload_size) { + GST_WARNING_OBJECT (enc, + "Encoded size %d is higher than max payload size (%d bytes)", + outsize, enc->max_payload_size); + ret = GST_FLOW_ERROR; + goto done; + } - if ((GST_FLOW_OK != ret) && (GST_FLOW_NOT_LINKED != ret)) - goto done; + GST_DEBUG_OBJECT (enc, "Output packet is %u bytes", outsize); + GST_BUFFER_SIZE (outbuf) = outsize; - data += bytes; - size -= bytes; - } + ret = + gst_audio_encoder_finish_frame (GST_AUDIO_ENCODER (enc), outbuf, + enc->frame_samples); done: -- cgit v1.2.3 From a7eda9ed4942e24f0a3971c3591af54cc4cd9a5b Mon Sep 17 00:00:00 2001 From: Mark Nauwelaerts Date: Sat, 10 Mar 2012 11:36:25 +0100 Subject: dtsdec: avoid runaway loop when resyncing during parse ... by checking for the correct (decremented) size variable. Fixes #671756. --- ext/dts/gstdtsdec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'ext') diff --git a/ext/dts/gstdtsdec.c b/ext/dts/gstdtsdec.c index d589901c2..0455ab0ca 100644 --- a/ext/dts/gstdtsdec.c +++ b/ext/dts/gstdtsdec.c @@ -286,7 +286,7 @@ gst_dtsdec_parse (GstAudioDecoder * bdec, GstAdapter * adapter, bit_rate = dts->bit_rate; sample_rate = dts->sample_rate; flags = 0; - while (av >= 7) { + while (size >= 7) { length = dca_syncinfo (dts->state, data, &flags, &sample_rate, &bit_rate, &frame_length); -- cgit v1.2.3 From 689bf4d392855fff7544a80313297a2091054851 Mon Sep 17 00:00:00 2001 From: Sreerenj Balachandran Date: Thu, 8 Mar 2012 01:48:56 +0200 Subject: waylandsink: Fix warnings, proper structuring, dead code removal, adding doc section. --- ext/wayland/gstwaylandsink.c | 145 +++++++++++++------------------------------ ext/wayland/gstwaylandsink.h | 22 ++++++- 2 files changed, 64 insertions(+), 103 deletions(-) (limited to 'ext') diff --git a/ext/wayland/gstwaylandsink.c b/ext/wayland/gstwaylandsink.c index 614e5dbce..ecc026dc4 100644 --- a/ext/wayland/gstwaylandsink.c +++ b/ext/wayland/gstwaylandsink.c @@ -1,8 +1,8 @@ /* * GStreamer Wayland video sink * - * Copyright: Intel Corporation - * Copyright: Sreerenj Balachandran + * Copyright (C) 2011 Intel Corporation + * Copyright (C) 2011 Sreerenj Balachandran * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public @@ -19,30 +19,28 @@ * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ - -/* The waylandsink is creating its own window and render the decoded video frames to that.*/ +/** + * SECTION:element-waylandsink + * + * The waylandsink is creating its own window and render the decoded video frames to that. + * Setup the Wayland environment as described in + * Wayland home page. + * The current implementaion is based on weston compositor. + * + * + * Example pipelines + * |[ + * gst-launch -v videotestsrc ! waylandsink + * ]| test the video rendering in wayland + * + */ #ifdef HAVE_CONFIG_H #include #endif -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - #include "gstwaylandsink.h" -#include - /* signals */ enum { @@ -52,7 +50,6 @@ enum }; /* Properties */ -/*Fixme: Not yet implemented */ enum { PROP_0, @@ -72,28 +69,27 @@ static GstStaticPadTemplate sink_template = GST_STATIC_PAD_TEMPLATE ("sink", "green_mask = (int) 16711680, " "blue_mask = (int) -16777216," "width = (int) [ 1, MAX ], " "height = (int) [ 1, MAX ] ")); -GType gst_wlbuffer_get_type (void); + +G_DEFINE_TYPE (GstWlBuffer, gst_wlbuffer, GST_TYPE_BUFFER); /*Fixme: Add more interfaces */ GST_BOILERPLATE (GstWaylandSink, gst_wayland_sink, GstVideoSink, GST_TYPE_VIDEO_SINK); static void gst_wlbuffer_finalize (GstWlBuffer * wbuffer); -static GstBufferClass *wlbuffer_parent_class = NULL; static void gst_wayland_sink_get_property (GObject * object, guint prop_id, GValue * value, GParamSpec * pspec); static void gst_wayland_sink_set_property (GObject * object, guint prop_id, const GValue * value, GParamSpec * pspec); -static void gst_wayland_sink_dispose (GObject * object); static void gst_wayland_sink_finalize (GObject * object); static GstCaps *gst_wayland_sink_get_caps (GstBaseSink * bsink); static gboolean gst_wayland_sink_set_caps (GstBaseSink * bsink, GstCaps * caps); static gboolean gst_wayland_sink_start (GstBaseSink * bsink); static gboolean gst_wayland_sink_stop (GstBaseSink * bsink); static GstFlowReturn -gst_wayland_sink_buffer_alloc (GstBaseSink * bsink, guint64 offset, guint size, - GstCaps * caps, GstBuffer ** buf); +gst_wayland_sink_buffer_alloc (GstBaseSink * bsink, guint64 offset, + guint size, GstCaps * caps, GstBuffer ** buf); static gboolean gst_wayland_sink_preroll (GstBaseSink * bsink, GstBuffer * buffer); static gboolean gst_wayland_sink_render (GstBaseSink * bsink, @@ -107,51 +103,25 @@ static struct display *create_display (void); static void display_handle_global (struct wl_display *display, uint32_t id, const char *interface, uint32_t version, void *data); static void redraw (void *data, struct wl_callback *callback, uint32_t time); -static void create_window (GstWaylandSink * sink, - struct display *display, int width, int height); +static void create_window (GstWaylandSink * sink, struct display *display, + int width, int height); static void -gst_wlbuffer_init (GstWlBuffer * buffer, gpointer g_class) +gst_wlbuffer_init (GstWlBuffer * buffer) { buffer->wbuffer = NULL; buffer->wlsink = NULL; } static void -gst_wlbuffer_class_init (gpointer g_class, gpointer class_data) +gst_wlbuffer_class_init (GstWlBufferClass * klass) { - GstMiniObjectClass *mini_object_class = GST_MINI_OBJECT_CLASS (g_class); - - wlbuffer_parent_class = g_type_class_peek_parent (g_class); + GstMiniObjectClass *mini_object_class = GST_MINI_OBJECT_CLASS (klass); mini_object_class->finalize = (GstMiniObjectFinalizeFunction) gst_wlbuffer_finalize; } -GType -gst_wlbuffer_get_type (void) -{ - static GType _gst_wlbuffer_type; - - if (G_UNLIKELY (_gst_wlbuffer_type == 0)) { - static const GTypeInfo wlbuffer_info = { - sizeof (GstBufferClass), - NULL, - NULL, - gst_wlbuffer_class_init, - NULL, - NULL, - sizeof (GstWlBuffer), - 0, - (GInstanceInitFunc) gst_wlbuffer_init, - NULL - }; - _gst_wlbuffer_type = g_type_register_static (GST_TYPE_BUFFER, - "GstWlBuffer", &wlbuffer_info, 0); - } - return _gst_wlbuffer_type; -} - static void gst_wlbuffer_finalize (GstWlBuffer * wbuffer) { @@ -189,7 +159,7 @@ gst_wayland_sink_base_init (gpointer gclass) gst_element_class_set_details_simple (element_class, "wayland video sink", "Sink/Video", "Output to wayland surface", - "Sreerenj Balachandran ,"); + "Sreerenj Balachandran "); } static void @@ -203,7 +173,6 @@ gst_wayland_sink_class_init (GstWaylandSinkClass * klass) gobject_class->set_property = gst_wayland_sink_set_property; gobject_class->get_property = gst_wayland_sink_get_property; - gobject_class->dispose = GST_DEBUG_FUNCPTR (gst_wayland_sink_dispose); gobject_class->finalize = GST_DEBUG_FUNCPTR (gst_wayland_sink_finalize); gstbasesink_class->get_caps = GST_DEBUG_FUNCPTR (gst_wayland_sink_get_caps); @@ -217,8 +186,8 @@ gst_wayland_sink_class_init (GstWaylandSinkClass * klass) g_object_class_install_property (gobject_class, PROP_WAYLAND_DISPLAY, g_param_spec_pointer ("wayland-display", "Wayland Display", - "Wayland Display id created by the application ", - G_PARAM_READWRITE)); + "Wayland Display handle created by the application ", + G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); parent_class = g_type_class_peek_parent (klass); } @@ -291,27 +260,24 @@ destroy_display (struct display *display) static void destroy_window (struct window *window) { - wl_shell_surface_destroy (window->shell_surface); - wl_surface_destroy (window->surface); + if (window->shell_surface) + wl_shell_surface_destroy (window->shell_surface); + if (window->surface) + wl_surface_destroy (window->surface); free (window); } -static void -gst_wayland_sink_dispose (GObject * object) -{ - G_OBJECT_CLASS (parent_class)->dispose (object); -} - static void gst_wayland_sink_finalize (GObject * object) { GstWaylandSink *sink = GST_WAYLAND_SINK (object); GST_DEBUG_OBJECT (sink, "Finalizing the sink.."); - gst_caps_replace (&sink->caps, NULL); - free (sink->display); - free (sink->window); + if (sink->window) + destroy_window (sink->window); + if (sink->display) + destroy_display (sink->display); if (sink->pool_lock) { g_mutex_free (sink->pool_lock); @@ -327,7 +293,6 @@ gst_wayland_sink_finalize (GObject * object) G_OBJECT_CLASS (parent_class)->finalize (object); } - static GstCaps * gst_wayland_sink_get_caps (GstBaseSink * bsink) { @@ -432,7 +397,8 @@ wayland_buffer_create (GstWaylandSink * sink) data = mmap (NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); unlink (filename); if (data == MAP_FAILED) { - fprintf (stderr, "mmap failed: %m\n"); + GST_ELEMENT_ERROR (sink, LIBRARY, SHUTDOWN, (NULL), + ("mmap() failed: %s", strerror (errno))); close (fd); exit (0); } @@ -446,7 +412,6 @@ wayland_buffer_create (GstWaylandSink * sink) GST_BUFFER_SIZE (wbuffer) = size; return wbuffer; - } static void @@ -457,7 +422,7 @@ gst_wayland_buffer_destroy (GstWaylandSink * sink, GstWlBuffer * buffer) gst_object_unref (sink); } - GST_MINI_OBJECT_CLASS (wlbuffer_parent_class)->finalize (GST_MINI_OBJECT + GST_MINI_OBJECT_CLASS (gst_wlbuffer_parent_class)->finalize (GST_MINI_OBJECT (buffer)); } @@ -521,7 +486,6 @@ gst_wayland_sink_buffer_alloc (GstBaseSink * bsink, guint64 offset, guint size, gst_caps_unref (desired_caps); return ret; - } static gboolean @@ -531,22 +495,13 @@ gst_wayland_sink_set_caps (GstBaseSink * bsink, GstCaps * caps) const GstStructure *structure; GstCaps *allowed_caps; gboolean ret = TRUE; - GstCaps *intersection; GST_LOG_OBJECT (sink, "set caps %" GST_PTR_FORMAT, caps); - structure = gst_caps_get_structure (caps, 0); - allowed_caps = gst_pad_get_caps (GST_BASE_SINK_PAD (bsink)); - /* We intersect those caps with our template to make sure they are correct */ - intersection = gst_caps_intersect (allowed_caps, caps); - gst_caps_unref (allowed_caps); - - if (gst_caps_is_empty (intersection)) { - gst_caps_unref (intersection); + if (!gst_caps_can_intersect (allowed_caps, caps)) return FALSE; - } structure = gst_caps_get_structure (caps, 0); @@ -558,8 +513,6 @@ gst_wayland_sink_set_caps (GstBaseSink * bsink, GstCaps * caps) gst_caps_replace (&sink->caps, caps); - gst_caps_unref (intersection); - return TRUE; } @@ -593,7 +546,7 @@ create_window (GstWaylandSink * sink, struct display *display, int width, window->shell_surface = wl_shell_get_shell_surface (display->shell, window->surface); -// wl_shell_surface_set_toplevel (window->shell_surface); + /* wl_shell_surface_set_toplevel (window->shell_surface); */ wl_shell_surface_set_fullscreen (window->shell_surface, WL_SHELL_SURFACE_FULLSCREEN_METHOD_DEFAULT, 0, NULL); @@ -602,7 +555,6 @@ create_window (GstWaylandSink * sink, struct display *display, int width, g_mutex_unlock (sink->wayland_lock); } - static gboolean gst_wayland_sink_start (GstBaseSink * bsink) { @@ -635,7 +587,6 @@ gst_wayland_sink_preroll (GstBaseSink * bsink, GstBuffer * buffer) return gst_wayland_sink_render (bsink, buffer); } - static GstFlowReturn gst_wayland_sink_render (GstBaseSink * bsink, GstBuffer * buffer) { @@ -674,15 +625,6 @@ gst_wayland_sink_render (GstBaseSink * bsink, GstBuffer * buffer) if (mem_cpy) { GstWlBuffer *wlbuf = wayland_buffer_create (sink); - /*Fixme: remove the memcpy and add memory allocation stuffs to buff_alloc */ - /*guint8 *src = GST_BUFFER_DATA (buffer); - guint len = GST_BUFFER_SIZE (buffer) / sink->height; - - for (i = 0; i < sink->height; i++) { - memcpy (data, src, len); - src += len; - data += len; - } */ memcpy (GST_BUFFER_DATA (wlbuf), GST_BUFFER_DATA (buffer), GST_BUFFER_SIZE (buffer)); @@ -735,4 +677,5 @@ plugin_init (GstPlugin * plugin) GST_PLUGIN_DEFINE (GST_VERSION_MAJOR, GST_VERSION_MINOR, "waylandsink", - "Wayland Video Sink", plugin_init, VERSION, "LGPL", "gst-wayland", "") + "Wayland Video Sink", plugin_init, VERSION, "LGPL", GST_PACKAGE_NAME, + GST_PACKAGE_ORIGIN) diff --git a/ext/wayland/gstwaylandsink.h b/ext/wayland/gstwaylandsink.h index 56fffd823..f9c1ca87c 100644 --- a/ext/wayland/gstwaylandsink.h +++ b/ext/wayland/gstwaylandsink.h @@ -21,6 +21,19 @@ #ifndef __GST_WAYLAND_VIDEO_SINK_H__ #define __GST_WAYLAND_VIDEO_SINK_H__ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + #include #include #include @@ -67,6 +80,7 @@ typedef struct _GstWaylandSinkClass GstWaylandSinkClass; #define GST_WLBUFFER (obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_WLBUFFER, GstWlBuffer)) typedef struct _GstWlBuffer GstWlBuffer; +typedef struct _GstWlBufferClass GstWlBufferClass; struct _GstWlBuffer { GstBuffer buffer; /* Extending GstBuffer */ @@ -76,6 +90,11 @@ struct _GstWlBuffer { GstWaylandSink *wlsink; }; +struct _GstWlBufferClass +{ + GstBufferClass parent_class; +}; + struct _GstWaylandSink { @@ -103,11 +122,10 @@ struct _GstWaylandSink struct _GstWaylandSinkClass { GstVideoSinkClass parent; - }; GType gst_wayland_sink_get_type (void) G_GNUC_CONST; -GType gst_dfbsurface_get_type (void); +GType gst_wlbuffer_get_type (void); G_END_DECLS #endif /* __GST_WAYLAND_VIDEO_SINK_H__ */ -- cgit v1.2.3 From 61ca28696f78738e972336d1d65026527cef5795 Mon Sep 17 00:00:00 2001 From: Tim-Philipp Müller Date: Thu, 15 Mar 2012 00:05:41 +0000 Subject: opencv: make build with opencv 2.3.1 as in debian sid Where highgui.h doesn't exist any more, but only opencv2/highgui/highgui.hpp. Also, not quite sure why we're checking for cvaux.h, it's not used anywhere. --- configure.ac | 6 +----- ext/opencv/MotionCells.h | 4 ++++ ext/opencv/gsttemplatematch.h | 6 +++++- 3 files changed, 10 insertions(+), 6 deletions(-) (limited to 'ext') diff --git a/configure.ac b/configure.ac index 37d7859d4..3630a3ab4 100644 --- a/configure.ac +++ b/configure.ac @@ -1432,16 +1432,12 @@ AG_GST_CHECK_FEATURE(OPENCV, [opencv plugins], opencv, [ AC_LANG_CPLUSPLUS OLD_CPPFLAGS=$CPPFLAGS CPPFLAGS=$OPENCV_CFLAGS - AC_CHECK_HEADER(highgui.h, HAVE_HIGHGUI="yes", HAVE_HIGHGUI="no") - AC_CHECK_HEADER(cvaux.h, HAVE_CVAUX="yes", HAVE_CVAUX="no") + AC_CHECK_HEADERS(highgui.h opencv2/highgui/highgui.hpp, HAVE_HIGHGUI="yes", HAVE_HIGHGUI="no") CPPFLAGS=$OLD_CPPFLAGS AC_LANG_C if test "x$HAVE_HIGHGUI" = "xno"; then AC_MSG_RESULT(highgui.h could not be found.) HAVE_OPENCV="no" - elif test "x$HAVE_CVAUX" = "xno"; then - AC_MSG_RESULT(cvaux.h could not be found.) - HAVE_OPENCV="no" else HAVE_OPENCV="yes" fi diff --git a/ext/opencv/MotionCells.h b/ext/opencv/MotionCells.h index ee84fd6b5..c5d4b17a5 100644 --- a/ext/opencv/MotionCells.h +++ b/ext/opencv/MotionCells.h @@ -46,7 +46,11 @@ #define MOTIONCELLS_H_ #include // includes OpenCV definitions +#ifndef __OPENCV_OLD_CV_H__ #include // includes highGUI definitions +#else +#include // includes highGUI definitions +#endif #include #include #include diff --git a/ext/opencv/gsttemplatematch.h b/ext/opencv/gsttemplatematch.h index 7b4b38852..7e55ac6cf 100644 --- a/ext/opencv/gsttemplatematch.h +++ b/ext/opencv/gsttemplatematch.h @@ -48,7 +48,11 @@ #include #include -#include +#ifndef __OPENCV_OLD_CV_H__ +#include // includes highGUI definitions +#else +#include // includes highGUI definitions +#endif G_BEGIN_DECLS /* #defines don't like whitespacey bits */ -- cgit v1.2.3 From e1e827d364942ceb6f6fd61c6ae4bb5ff3db6fdc Mon Sep 17 00:00:00 2001 From: Tim-Philipp Müller Date: Thu, 15 Mar 2012 17:26:14 +0000 Subject: rsvgoverlay: fix crash due to double adapter unref --- ext/rsvg/gstrsvgoverlay.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'ext') diff --git a/ext/rsvg/gstrsvgoverlay.c b/ext/rsvg/gstrsvgoverlay.c index 42de199f7..7f12f8f11 100644 --- a/ext/rsvg/gstrsvgoverlay.c +++ b/ext/rsvg/gstrsvgoverlay.c @@ -336,7 +336,7 @@ gst_rsvg_overlay_data_sink_event (GstPad * pad, GstEvent * event) GST_RSVG_UNLOCK (overlay); } - case GST_EVENT_FLUSH_START: + case GST_EVENT_FLUSH_STOP: gst_adapter_clear (overlay->adapter); break; @@ -436,10 +436,11 @@ gst_rsvg_overlay_stop (GstBaseTransform * btrans) if (overlay->handle) { g_object_unref (overlay->handle); - g_object_unref (overlay->adapter); overlay->handle = NULL; } + gst_adapter_clear (overlay->adapter); + return TRUE; } -- cgit v1.2.3 From e6c9b608517c3d54c1eed08ce36c1363788d8570 Mon Sep 17 00:00:00 2001 From: Tim-Philipp Müller Date: Thu, 15 Mar 2012 18:28:01 +0000 Subject: rsvgoverlay: cosmetic change Rename PROP_FILENAME to PROP_LOCATION to match the name of the property. Add some debug logging. --- ext/rsvg/gstrsvgoverlay.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'ext') diff --git a/ext/rsvg/gstrsvgoverlay.c b/ext/rsvg/gstrsvgoverlay.c index 7f12f8f11..1673829c2 100644 --- a/ext/rsvg/gstrsvgoverlay.c +++ b/ext/rsvg/gstrsvgoverlay.c @@ -72,7 +72,7 @@ enum { PROP_0, PROP_DATA, - PROP_FILENAME, + PROP_LOCATION, PROP_FIT_TO_FRAME, PROP_X, PROP_Y, @@ -164,6 +164,8 @@ gst_rsvg_overlay_set_svg_data (GstRsvgOverlay * overlay, const gchar * data, overlay->svg_width = svg_dimension.width; overlay->svg_height = svg_dimension.height; gst_base_transform_set_passthrough (btrans, FALSE); + GST_INFO_OBJECT (overlay, "updated SVG, %d x %d", overlay->svg_width, + overlay->svg_height); } } } @@ -184,7 +186,7 @@ gst_rsvg_overlay_set_property (GObject * object, guint prop_id, FALSE); break; } - case PROP_FILENAME: + case PROP_LOCATION: { gst_rsvg_overlay_set_svg_data (overlay, g_value_get_string (value), TRUE); break; @@ -474,7 +476,7 @@ gst_rsvg_overlay_class_init (GstRsvgOverlayClass * klass) g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_DATA, g_param_spec_string ("data", "data", "SVG data.", "", G_PARAM_WRITABLE | G_PARAM_STATIC_STRINGS)); - g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_FILENAME, + g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_LOCATION, g_param_spec_string ("location", "location", "SVG file location.", "", G_PARAM_WRITABLE | G_PARAM_STATIC_STRINGS)); g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_FIT_TO_FRAME, -- cgit v1.2.3 From 3d7c8aad7024014fd9e48f5c52d42bcc5564c2d6 Mon Sep 17 00:00:00 2001 From: Stefan Sauer Date: Thu, 15 Mar 2012 22:22:12 +0100 Subject: facedetect: don't skip faces Skipping faces at this point makes us lie about the num-ber of faces and also causes leaks. --- ext/opencv/gstfacedetect.c | 89 +++++++++++++++++++++++----------------------- 1 file changed, 44 insertions(+), 45 deletions(-) (limited to 'ext') diff --git a/ext/opencv/gstfacedetect.c b/ext/opencv/gstfacedetect.c index 01126710e..cff13e795 100644 --- a/ext/opencv/gstfacedetect.c +++ b/ext/opencv/gstfacedetect.c @@ -514,8 +514,6 @@ gst_face_detect_transform_ip (GstOpencvVideoFilter * base, GstBuffer * buf, for (i = 0; i < (faces ? faces->total : 0); i++) { CvRect *r = (CvRect *) cvGetSeqElem (faces, i); - GValue value = { 0 }; - GstStructure *s; guint mw = filter->min_size_width / 8; guint mh = filter->min_size_height / 8; guint rnx, rny, rnw, rnh; @@ -578,50 +576,51 @@ gst_face_detect_transform_ip (GstOpencvVideoFilter * base, GstBuffer * buf, i, faces->total, r->x, r->y, r->width, r->height, have_eyes, have_nose, have_mouth); - /* ignore 'face' where we don't fix mount/nose/eyes ? */ - if (!(have_eyes && have_nose && have_mouth)) - continue; - - s = gst_structure_new ("face", - "x", G_TYPE_UINT, r->x, - "y", G_TYPE_UINT, r->y, - "width", G_TYPE_UINT, r->width, - "height", G_TYPE_UINT, r->height, NULL); - if (nose && nose->total) { - CvRect *sr = (CvRect *) cvGetSeqElem (nose, 0); - GST_LOG_OBJECT (filter, "nose/%d: x,y = %4u,%4u: w.h = %4u,%4u", - nose->total, rnx + sr->x, rny + sr->y, sr->width, sr->height); - gst_structure_set (s, - "nose->x", G_TYPE_UINT, rnx + sr->x, - "nose->y", G_TYPE_UINT, rny + sr->y, - "nose->width", G_TYPE_UINT, sr->width, - "nose->height", G_TYPE_UINT, sr->height, NULL); - } - if (mouth && mouth->total) { - CvRect *sr = (CvRect *) cvGetSeqElem (mouth, 0); - GST_LOG_OBJECT (filter, "mouth/%d: x,y = %4u,%4u: w.h = %4u,%4u", - mouth->total, rmx + sr->x, rmy + sr->y, sr->width, sr->height); - gst_structure_set (s, - "mouth->x", G_TYPE_UINT, rmx + sr->x, - "mouth->y", G_TYPE_UINT, rmy + sr->y, - "mouth->width", G_TYPE_UINT, sr->width, - "mouth->height", G_TYPE_UINT, sr->height, NULL); - } - if (eyes && eyes->total) { - CvRect *sr = (CvRect *) cvGetSeqElem (eyes, 0); - GST_LOG_OBJECT (filter, "eyes/%d: x,y = %4u,%4u: w.h = %4u,%4u", - eyes->total, rex + sr->x, rey + sr->y, sr->width, sr->height); - gst_structure_set (s, - "eyes->x", G_TYPE_UINT, rex + sr->x, - "eyes->y", G_TYPE_UINT, rey + sr->y, - "eyes->width", G_TYPE_UINT, sr->width, - "eyes->height", G_TYPE_UINT, sr->height, NULL); - } + if (msg) { + GValue value = { 0 }; + GstStructure *s; + + s = gst_structure_new ("face", + "x", G_TYPE_UINT, r->x, + "y", G_TYPE_UINT, r->y, + "width", G_TYPE_UINT, r->width, + "height", G_TYPE_UINT, r->height, NULL); + if (nose && nose->total) { + CvRect *sr = (CvRect *) cvGetSeqElem (nose, 0); + GST_LOG_OBJECT (filter, "nose/%d: x,y = %4u,%4u: w.h = %4u,%4u", + nose->total, rnx + sr->x, rny + sr->y, sr->width, sr->height); + gst_structure_set (s, + "nose->x", G_TYPE_UINT, rnx + sr->x, + "nose->y", G_TYPE_UINT, rny + sr->y, + "nose->width", G_TYPE_UINT, sr->width, + "nose->height", G_TYPE_UINT, sr->height, NULL); + } + if (mouth && mouth->total) { + CvRect *sr = (CvRect *) cvGetSeqElem (mouth, 0); + GST_LOG_OBJECT (filter, "mouth/%d: x,y = %4u,%4u: w.h = %4u,%4u", + mouth->total, rmx + sr->x, rmy + sr->y, sr->width, sr->height); + gst_structure_set (s, + "mouth->x", G_TYPE_UINT, rmx + sr->x, + "mouth->y", G_TYPE_UINT, rmy + sr->y, + "mouth->width", G_TYPE_UINT, sr->width, + "mouth->height", G_TYPE_UINT, sr->height, NULL); + } + if (eyes && eyes->total) { + CvRect *sr = (CvRect *) cvGetSeqElem (eyes, 0); + GST_LOG_OBJECT (filter, "eyes/%d: x,y = %4u,%4u: w.h = %4u,%4u", + eyes->total, rex + sr->x, rey + sr->y, sr->width, sr->height); + gst_structure_set (s, + "eyes->x", G_TYPE_UINT, rex + sr->x, + "eyes->y", G_TYPE_UINT, rey + sr->y, + "eyes->width", G_TYPE_UINT, sr->width, + "eyes->height", G_TYPE_UINT, sr->height, NULL); + } - g_value_init (&value, GST_TYPE_STRUCTURE); - gst_value_set_structure (&value, s); - gst_value_list_append_value (&facelist, &value); - g_value_unset (&value); + g_value_init (&value, GST_TYPE_STRUCTURE); + gst_value_set_structure (&value, s); + gst_value_list_append_value (&facelist, &value); + g_value_unset (&value); + } if (do_display) { CvPoint center; -- cgit v1.2.3 From fbcee587f456dfca7c8dd2fbf163d12804ffd81c Mon Sep 17 00:00:00 2001 From: Stefan Sauer Date: Thu, 15 Mar 2012 23:08:02 +0100 Subject: facedetect: always send facedetect message The application might like to know, when we don't see the face anymore. --- ext/opencv/gstfacedetect.c | 99 +++++++++++++++++++++------------------------- 1 file changed, 46 insertions(+), 53 deletions(-) (limited to 'ext') diff --git a/ext/opencv/gstfacedetect.c b/ext/opencv/gstfacedetect.c index cff13e795..71bdee6e1 100644 --- a/ext/opencv/gstfacedetect.c +++ b/ext/opencv/gstfacedetect.c @@ -481,7 +481,9 @@ gst_face_detect_transform_ip (GstOpencvVideoFilter * base, GstBuffer * buf, if (filter->cvFaceDetect) { GstMessage *msg = NULL; + GstStructure *s; GValue facelist = { 0 }; + GValue facedata = { 0 }; CvSeq *faces; CvSeq *mouth, *nose, *eyes; gint i; @@ -507,10 +509,8 @@ gst_face_detect_transform_ip (GstOpencvVideoFilter * base, GstBuffer * buf, #endif ); - if (faces && faces->total > 0) { - msg = gst_face_detect_message_new (filter, buf); - g_value_init (&facelist, GST_TYPE_LIST); - } + msg = gst_face_detect_message_new (filter, buf); + g_value_init (&facelist, GST_TYPE_LIST); for (i = 0; i < (faces ? faces->total : 0); i++) { CvRect *r = (CvRect *) cvGetSeqElem (faces, i); @@ -576,52 +576,47 @@ gst_face_detect_transform_ip (GstOpencvVideoFilter * base, GstBuffer * buf, i, faces->total, r->x, r->y, r->width, r->height, have_eyes, have_nose, have_mouth); - if (msg) { - GValue value = { 0 }; - GstStructure *s; - - s = gst_structure_new ("face", - "x", G_TYPE_UINT, r->x, - "y", G_TYPE_UINT, r->y, - "width", G_TYPE_UINT, r->width, - "height", G_TYPE_UINT, r->height, NULL); - if (nose && nose->total) { - CvRect *sr = (CvRect *) cvGetSeqElem (nose, 0); - GST_LOG_OBJECT (filter, "nose/%d: x,y = %4u,%4u: w.h = %4u,%4u", - nose->total, rnx + sr->x, rny + sr->y, sr->width, sr->height); - gst_structure_set (s, - "nose->x", G_TYPE_UINT, rnx + sr->x, - "nose->y", G_TYPE_UINT, rny + sr->y, - "nose->width", G_TYPE_UINT, sr->width, - "nose->height", G_TYPE_UINT, sr->height, NULL); - } - if (mouth && mouth->total) { - CvRect *sr = (CvRect *) cvGetSeqElem (mouth, 0); - GST_LOG_OBJECT (filter, "mouth/%d: x,y = %4u,%4u: w.h = %4u,%4u", - mouth->total, rmx + sr->x, rmy + sr->y, sr->width, sr->height); - gst_structure_set (s, - "mouth->x", G_TYPE_UINT, rmx + sr->x, - "mouth->y", G_TYPE_UINT, rmy + sr->y, - "mouth->width", G_TYPE_UINT, sr->width, - "mouth->height", G_TYPE_UINT, sr->height, NULL); - } - if (eyes && eyes->total) { - CvRect *sr = (CvRect *) cvGetSeqElem (eyes, 0); - GST_LOG_OBJECT (filter, "eyes/%d: x,y = %4u,%4u: w.h = %4u,%4u", - eyes->total, rex + sr->x, rey + sr->y, sr->width, sr->height); - gst_structure_set (s, - "eyes->x", G_TYPE_UINT, rex + sr->x, - "eyes->y", G_TYPE_UINT, rey + sr->y, - "eyes->width", G_TYPE_UINT, sr->width, - "eyes->height", G_TYPE_UINT, sr->height, NULL); - } - - g_value_init (&value, GST_TYPE_STRUCTURE); - gst_value_set_structure (&value, s); - gst_value_list_append_value (&facelist, &value); - g_value_unset (&value); + s = gst_structure_new ("face", + "x", G_TYPE_UINT, r->x, + "y", G_TYPE_UINT, r->y, + "width", G_TYPE_UINT, r->width, + "height", G_TYPE_UINT, r->height, NULL); + if (nose && nose->total) { + CvRect *sr = (CvRect *) cvGetSeqElem (nose, 0); + GST_LOG_OBJECT (filter, "nose/%d: x,y = %4u,%4u: w.h = %4u,%4u", + nose->total, rnx + sr->x, rny + sr->y, sr->width, sr->height); + gst_structure_set (s, + "nose->x", G_TYPE_UINT, rnx + sr->x, + "nose->y", G_TYPE_UINT, rny + sr->y, + "nose->width", G_TYPE_UINT, sr->width, + "nose->height", G_TYPE_UINT, sr->height, NULL); + } + if (mouth && mouth->total) { + CvRect *sr = (CvRect *) cvGetSeqElem (mouth, 0); + GST_LOG_OBJECT (filter, "mouth/%d: x,y = %4u,%4u: w.h = %4u,%4u", + mouth->total, rmx + sr->x, rmy + sr->y, sr->width, sr->height); + gst_structure_set (s, + "mouth->x", G_TYPE_UINT, rmx + sr->x, + "mouth->y", G_TYPE_UINT, rmy + sr->y, + "mouth->width", G_TYPE_UINT, sr->width, + "mouth->height", G_TYPE_UINT, sr->height, NULL); + } + if (eyes && eyes->total) { + CvRect *sr = (CvRect *) cvGetSeqElem (eyes, 0); + GST_LOG_OBJECT (filter, "eyes/%d: x,y = %4u,%4u: w.h = %4u,%4u", + eyes->total, rex + sr->x, rey + sr->y, sr->width, sr->height); + gst_structure_set (s, + "eyes->x", G_TYPE_UINT, rex + sr->x, + "eyes->y", G_TYPE_UINT, rey + sr->y, + "eyes->width", G_TYPE_UINT, sr->width, + "eyes->height", G_TYPE_UINT, sr->height, NULL); } + g_value_init (&facedata, GST_TYPE_STRUCTURE); + gst_value_set_structure (&facedata, s); + gst_value_list_append_value (&facelist, &facedata); + g_value_unset (&facedata); + if (do_display) { CvPoint center; CvSize axes; @@ -678,11 +673,9 @@ gst_face_detect_transform_ip (GstOpencvVideoFilter * base, GstBuffer * buf, } } - if (msg) { - gst_structure_set_value (msg->structure, "faces", &facelist); - g_value_unset (&facelist); - gst_element_post_message (GST_ELEMENT (filter), msg); - } + gst_structure_set_value (msg->structure, "faces", &facelist); + g_value_unset (&facelist); + gst_element_post_message (GST_ELEMENT (filter), msg); } return GST_FLOW_OK; -- cgit v1.2.3 From 6fde848ada3a4abd91e345dff179e238ec771bd9 Mon Sep 17 00:00:00 2001 From: Stefan Sauer Date: Thu, 15 Mar 2012 23:17:55 +0100 Subject: facedetect: move the detector to an own method to hide the ugly ifdefs This improves the readability in the actual processing function. --- ext/opencv/gstfacedetect.c | 47 ++++++++++++++++++---------------------------- 1 file changed, 18 insertions(+), 29 deletions(-) (limited to 'ext') diff --git a/ext/opencv/gstfacedetect.c b/ext/opencv/gstfacedetect.c index 71bdee6e1..6883e2c64 100644 --- a/ext/opencv/gstfacedetect.c +++ b/ext/opencv/gstfacedetect.c @@ -469,6 +469,19 @@ gst_face_detect_message_new (GstFaceDetect * filter, GstBuffer * buf) return gst_message_new_element (GST_OBJECT (filter), s); } +static CvSeq * +gst_face_detect_run_detector (GstFaceDetect * filter, + CvHaarClassifierCascade * detector, gint min_size_width, + gint min_size_height) +{ + return cvHaarDetectObjects (filter->cvGray, detector, + filter->cvStorage, filter->scale_factor, filter->min_neighbors, + filter->flags, cvSize (min_size_width, min_size_height) +#if (CV_MAJOR_VERSION >= 2) && (CV_MINOR_VERSION >= 2) + , cvSize (min_size_width + 2, min_size_height + 2) +#endif + ); +} /* * Performs the face detection @@ -500,14 +513,8 @@ gst_face_detect_transform_ip (GstOpencvVideoFilter * base, GstBuffer * buf, cvCvtColor (img, filter->cvGray, CV_RGB2GRAY); cvClearMemStorage (filter->cvStorage); - faces = - cvHaarDetectObjects (filter->cvGray, filter->cvFaceDetect, - filter->cvStorage, filter->scale_factor, filter->min_neighbors, - filter->flags, cvSize (filter->min_size_width, filter->min_size_height) -#if (CV_MAJOR_VERSION >= 2) && (CV_MINOR_VERSION >= 2) - , cvSize (filter->min_size_width + 2, filter->min_size_height + 2) -#endif - ); + faces = gst_face_detect_run_detector (filter, filter->cvFaceDetect, + filter->min_size_width, filter->min_size_height); msg = gst_face_detect_message_new (filter, buf); g_value_init (&facelist, GST_TYPE_LIST); @@ -529,13 +536,7 @@ gst_face_detect_transform_ip (GstOpencvVideoFilter * base, GstBuffer * buf, rnh = r->height / 2; cvSetImageROI (filter->cvGray, cvRect (rnx, rny, rnw, rnh)); nose = - cvHaarDetectObjects (filter->cvGray, filter->cvNoseDetect, - filter->cvStorage, filter->scale_factor, filter->min_neighbors, - filter->flags, cvSize (mw, mh) -#if (CV_MAJOR_VERSION >= 2) && (CV_MINOR_VERSION >= 2) - , cvSize (mw + 2, mh + 2) -#endif - ); + gst_face_detect_run_detector (filter, filter->cvNoseDetect, mw, mh); have_nose = (nose && nose->total); cvResetImageROI (filter->cvGray); @@ -545,13 +546,7 @@ gst_face_detect_transform_ip (GstOpencvVideoFilter * base, GstBuffer * buf, rmh = r->height / 2; cvSetImageROI (filter->cvGray, cvRect (rmx, rmy, rmw, rmh)); mouth = - cvHaarDetectObjects (filter->cvGray, filter->cvMouthDetect, - filter->cvStorage, filter->scale_factor, filter->min_neighbors, - filter->flags, cvSize (mw, mh) -#if (CV_MAJOR_VERSION >= 2) && (CV_MINOR_VERSION >= 2) - , cvSize (mw + 2, mh + 2) -#endif - ); + gst_face_detect_run_detector (filter, filter->cvMouthDetect, mw, mh); have_mouth = (mouth && mouth->total); cvResetImageROI (filter->cvGray); @@ -561,13 +556,7 @@ gst_face_detect_transform_ip (GstOpencvVideoFilter * base, GstBuffer * buf, reh = r->height / 2; cvSetImageROI (filter->cvGray, cvRect (rex, rey, rew, reh)); eyes = - cvHaarDetectObjects (filter->cvGray, filter->cvEyesDetect, - filter->cvStorage, filter->scale_factor, filter->min_neighbors, - filter->flags, cvSize (mw, mh) -#if (CV_MAJOR_VERSION >= 2) && (CV_MINOR_VERSION >= 2) - , cvSize (mw + 2, mh + 2) -#endif - ); + gst_face_detect_run_detector (filter, filter->cvEyesDetect, mw, mh); have_eyes = (eyes && eyes->total); cvResetImageROI (filter->cvGray); -- cgit v1.2.3 From 2311a0ac0efa3da8306f2aa776a9dbc3e3134062 Mon Sep 17 00:00:00 2001 From: Stefan Sauer Date: Fri, 16 Mar 2012 12:04:11 +0100 Subject: facedetect: skip detection for unavailable detectors --- ext/opencv/gstfacedetect.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'ext') diff --git a/ext/opencv/gstfacedetect.c b/ext/opencv/gstfacedetect.c index 6883e2c64..a52158b23 100644 --- a/ext/opencv/gstfacedetect.c +++ b/ext/opencv/gstfacedetect.c @@ -474,6 +474,9 @@ gst_face_detect_run_detector (GstFaceDetect * filter, CvHaarClassifierCascade * detector, gint min_size_width, gint min_size_height) { + if (!detector) + return NULL; + return cvHaarDetectObjects (filter->cvGray, detector, filter->cvStorage, filter->scale_factor, filter->min_neighbors, filter->flags, cvSize (min_size_width, min_size_height) -- cgit v1.2.3 From 9ebacafc6ad8deb3be29f1972bd209fbb0c4c4ce Mon Sep 17 00:00:00 2001 From: Vincent Penquerc'h Date: Thu, 15 Mar 2012 17:10:18 +0000 Subject: rsndvdsrc: post a message with title number and durations https://bugzilla.gnome.org/show_bug.cgi?id=672165 --- ext/resindvd/resindvdsrc.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) (limited to 'ext') diff --git a/ext/resindvd/resindvdsrc.c b/ext/resindvd/resindvdsrc.c index 76139aa52..98473694b 100644 --- a/ext/resindvd/resindvdsrc.c +++ b/ext/resindvd/resindvdsrc.c @@ -2427,6 +2427,53 @@ rsn_dvdsrc_src_event (GstBaseSrc * basesrc, GstEvent * event) return res; } +static void +rsn_dvdsrc_post_title_info (GstElement * element) +{ + resinDvdSrc *src = RESINDVDSRC (element); + GstMessage *message; + GstStructure *s; + int32_t n, ntitles; + int res; + GValue array = { 0 }; + + res = dvdnav_get_number_of_titles (src->dvdnav, &ntitles); + if (res != DVDNAV_STATUS_OK) { + GST_WARNING_OBJECT (src, "Failed to get number of titles: %d", res); + return; + } + + g_value_init (&array, GST_TYPE_ARRAY); + + s = gst_structure_new ("application/x-gst-dvd", "event", + G_TYPE_STRING, "dvd-title-info", NULL); + + for (n = 0; n < ntitles; ++n) { + uint64_t *times, duration; + uint32_t nchapters; + GValue item = { 0 }; + + g_value_init (&item, G_TYPE_UINT64); + + nchapters = + dvdnav_describe_title_chapters (src->dvdnav, n, ×, &duration); + if (nchapters == 0) { + GST_WARNING_OBJECT (src, "Failed to get title %d info", n); + g_value_set_uint64 (&item, GST_CLOCK_TIME_NONE); + } else { + g_value_set_uint64 (&item, gst_util_uint64_scale (duration, GST_SECOND, + 90000)); + } + gst_value_array_append_value (&array, &item); + g_value_unset (&item); + } + gst_structure_set_value (s, "title-durations", &array); + g_value_unset (&array); + + message = gst_message_new_element (GST_OBJECT (src), s); + gst_element_post_message (GST_ELEMENT_CAST (src), message); +} + static GstStateChangeReturn rsn_dvdsrc_change_state (GstElement * element, GstStateChange transition) { @@ -2463,6 +2510,9 @@ rsn_dvdsrc_change_state (GstElement * element, GstStateChange transition) rsn_dvdsrc_check_nav_blocks (src); g_mutex_unlock (src->dvd_lock); break; + case GST_STATE_CHANGE_READY_TO_PAUSED: + rsn_dvdsrc_post_title_info (element); + break; default: break; } -- cgit v1.2.3 From d4509a2fda5bff72201e393f774ebfed8f0137cd Mon Sep 17 00:00:00 2001 From: Stefan Sauer Date: Fri, 16 Mar 2012 12:57:05 +0100 Subject: opencv: use opencv prefix from pkgconfig to lookup datafiles Don't hardconde /usr to lookup datafiles (such as haar cascades). --- configure.ac | 3 +++ ext/opencv/gstfaceblur.c | 3 ++- ext/opencv/gstfacedetect.c | 9 +++++---- 3 files changed, 10 insertions(+), 5 deletions(-) (limited to 'ext') diff --git a/configure.ac b/configure.ac index 3630a3ab4..9cf3de2fc 100644 --- a/configure.ac +++ b/configure.ac @@ -1444,6 +1444,9 @@ AG_GST_CHECK_FEATURE(OPENCV, [opencv plugins], opencv, [ ], [ HAVE_OPENCV="no" ]) + OPENCV_PREFIX="`$PKG_CONFIG --variable=prefix opencv`" + AC_DEFINE_UNQUOTED(OPENCV_PREFIX, "$OPENCV_PREFIX", [opencv install prefix]) + AC_SUBST(OPENCV_PREFIX) AC_SUBST(OPENCV_CFLAGS) AC_SUBST(OPENCV_LIBS) ]) diff --git a/ext/opencv/gstfaceblur.c b/ext/opencv/gstfaceblur.c index 2f9dcf544..7b801c1cc 100644 --- a/ext/opencv/gstfaceblur.c +++ b/ext/opencv/gstfaceblur.c @@ -68,7 +68,8 @@ GST_DEBUG_CATEGORY_STATIC (gst_face_blur_debug); #define GST_CAT_DEFAULT gst_face_blur_debug -#define DEFAULT_PROFILE "/usr/share/opencv/haarcascades/haarcascade_frontalface_default.xml" +#define HAAR_CASCADES_DIR OPENCV_PREFIX "/share/opencv/haarcascades/" +#define DEFAULT_PROFILE HAAR_CASCADES_DIR "haarcascade_frontalface_default.xml" /* Filter signals and args */ enum diff --git a/ext/opencv/gstfacedetect.c b/ext/opencv/gstfacedetect.c index a52158b23..89079f07f 100644 --- a/ext/opencv/gstfacedetect.c +++ b/ext/opencv/gstfacedetect.c @@ -82,10 +82,11 @@ GST_DEBUG_CATEGORY_STATIC (gst_face_detect_debug); #define GST_CAT_DEFAULT gst_face_detect_debug -#define DEFAULT_FACE_PROFILE "/usr/share/opencv/haarcascades/haarcascade_frontalface_default.xml" -#define DEFAULT_NOSE_PROFILE "/usr/share/opencv/haarcascades/haarcascade_mcs_nose.xml" -#define DEFAULT_MOUTH_PROFILE "/usr/share/opencv/haarcascades/haarcascade_mcs_mouth.xml" -#define DEFAULT_EYES_PROFILE "/usr/share/opencv/haarcascades/haarcascade_mcs_eyepair_small.xml" +#define HAAR_CASCADES_DIR OPENCV_PREFIX "/share/opencv/haarcascades/" +#define DEFAULT_FACE_PROFILE HAAR_CASCADES_DIR "haarcascade_frontalface_default.xml" +#define DEFAULT_NOSE_PROFILE HAAR_CASCADES_DIR "haarcascade_mcs_nose.xml" +#define DEFAULT_MOUTH_PROFILE HAAR_CASCADES_DIR "haarcascade_mcs_mouth.xml" +#define DEFAULT_EYES_PROFILE HAAR_CASCADES_DIR "haarcascade_mcs_eyepair_small.xml" #define DEFAULT_SCALE_FACTOR 1.1 #define DEFAULT_FLAGS 0 #define DEFAULT_MIN_NEIGHBORS 3 -- cgit v1.2.3 From 99fb8e941a003e3565aa1a1943e296680c253735 Mon Sep 17 00:00:00 2001 From: Stefan Sauer Date: Fri, 16 Mar 2012 13:14:48 +0100 Subject: opencv: cosmetic code changes Check for the availability of the detectors in the processing function to avoid setting up the ROIs. Use the booleans for have_xxx more. --- ext/opencv/gstfacedetect.c | 86 ++++++++++++++++++++++++++-------------------- 1 file changed, 48 insertions(+), 38 deletions(-) (limited to 'ext') diff --git a/ext/opencv/gstfacedetect.c b/ext/opencv/gstfacedetect.c index 89079f07f..f53b6eab7 100644 --- a/ext/opencv/gstfacedetect.c +++ b/ext/opencv/gstfacedetect.c @@ -475,9 +475,6 @@ gst_face_detect_run_detector (GstFaceDetect * filter, CvHaarClassifierCascade * detector, gint min_size_width, gint min_size_height) { - if (!detector) - return NULL; - return cvHaarDetectObjects (filter->cvGray, detector, filter->cvStorage, filter->scale_factor, filter->min_neighbors, filter->flags, cvSize (min_size_width, min_size_height) @@ -534,35 +531,48 @@ gst_face_detect_transform_ip (GstOpencvVideoFilter * base, GstBuffer * buf, /* detect face features */ - rnx = r->x + r->width / 4; - rny = r->y + r->height / 4; - rnw = r->width / 2; - rnh = r->height / 2; - cvSetImageROI (filter->cvGray, cvRect (rnx, rny, rnw, rnh)); - nose = - gst_face_detect_run_detector (filter, filter->cvNoseDetect, mw, mh); - have_nose = (nose && nose->total); - cvResetImageROI (filter->cvGray); - - rmx = r->x; - rmy = r->y + r->height / 2; - rmw = r->width; - rmh = r->height / 2; - cvSetImageROI (filter->cvGray, cvRect (rmx, rmy, rmw, rmh)); - mouth = - gst_face_detect_run_detector (filter, filter->cvMouthDetect, mw, mh); - have_mouth = (mouth && mouth->total); - cvResetImageROI (filter->cvGray); - - rex = r->x; - rey = r->y; - rew = r->width; - reh = r->height / 2; - cvSetImageROI (filter->cvGray, cvRect (rex, rey, rew, reh)); - eyes = - gst_face_detect_run_detector (filter, filter->cvEyesDetect, mw, mh); - have_eyes = (eyes && eyes->total); - cvResetImageROI (filter->cvGray); + if (filter->cvNoseDetect) { + rnx = r->x + r->width / 4; + rny = r->y + r->height / 4; + rnw = r->width / 2; + rnh = r->height / 2; + cvSetImageROI (filter->cvGray, cvRect (rnx, rny, rnw, rnh)); + nose = + gst_face_detect_run_detector (filter, filter->cvNoseDetect, mw, mh); + have_nose = (nose && nose->total); + cvResetImageROI (filter->cvGray); + } else { + have_nose = FALSE; + } + + if (filter->cvMouthDetect) { + rmx = r->x; + rmy = r->y + r->height / 2; + rmw = r->width; + rmh = r->height / 2; + cvSetImageROI (filter->cvGray, cvRect (rmx, rmy, rmw, rmh)); + mouth = + gst_face_detect_run_detector (filter, filter->cvMouthDetect, mw, + mh); + have_mouth = (mouth && mouth->total); + cvResetImageROI (filter->cvGray); + } else { + have_mouth = FALSE; + } + + if (filter->cvEyesDetect) { + rex = r->x; + rey = r->y; + rew = r->width; + reh = r->height / 2; + cvSetImageROI (filter->cvGray, cvRect (rex, rey, rew, reh)); + eyes = + gst_face_detect_run_detector (filter, filter->cvEyesDetect, mw, mh); + have_eyes = (eyes && eyes->total); + cvResetImageROI (filter->cvGray); + } else { + have_eyes = FALSE; + } GST_LOG_OBJECT (filter, "%2d/%2d: x,y = %4u,%4u: w.h = %4u,%4u : features(e,n,m) = %d,%d,%d", @@ -574,7 +584,7 @@ gst_face_detect_transform_ip (GstOpencvVideoFilter * base, GstBuffer * buf, "y", G_TYPE_UINT, r->y, "width", G_TYPE_UINT, r->width, "height", G_TYPE_UINT, r->height, NULL); - if (nose && nose->total) { + if (have_nose) { CvRect *sr = (CvRect *) cvGetSeqElem (nose, 0); GST_LOG_OBJECT (filter, "nose/%d: x,y = %4u,%4u: w.h = %4u,%4u", nose->total, rnx + sr->x, rny + sr->y, sr->width, sr->height); @@ -584,7 +594,7 @@ gst_face_detect_transform_ip (GstOpencvVideoFilter * base, GstBuffer * buf, "nose->width", G_TYPE_UINT, sr->width, "nose->height", G_TYPE_UINT, sr->height, NULL); } - if (mouth && mouth->total) { + if (have_mouth) { CvRect *sr = (CvRect *) cvGetSeqElem (mouth, 0); GST_LOG_OBJECT (filter, "mouth/%d: x,y = %4u,%4u: w.h = %4u,%4u", mouth->total, rmx + sr->x, rmy + sr->y, sr->width, sr->height); @@ -594,7 +604,7 @@ gst_face_detect_transform_ip (GstOpencvVideoFilter * base, GstBuffer * buf, "mouth->width", G_TYPE_UINT, sr->width, "mouth->height", G_TYPE_UINT, sr->height, NULL); } - if (eyes && eyes->total) { + if (have_eyes) { CvRect *sr = (CvRect *) cvGetSeqElem (eyes, 0); GST_LOG_OBJECT (filter, "eyes/%d: x,y = %4u,%4u: w.h = %4u,%4u", eyes->total, rex + sr->x, rey + sr->y, sr->width, sr->height); @@ -627,7 +637,7 @@ gst_face_detect_transform_ip (GstOpencvVideoFilter * base, GstBuffer * buf, cvEllipse (img, center, axes, 0.0, 0.0, 360.0, CV_RGB (cr, cg, cb), 3, 8, 0); - if (nose && nose->total) { + if (have_nose) { CvRect *sr = (CvRect *) cvGetSeqElem (nose, 0); w = sr->width / 2; @@ -639,7 +649,7 @@ gst_face_detect_transform_ip (GstOpencvVideoFilter * base, GstBuffer * buf, cvEllipse (img, center, axes, 0.0, 0.0, 360.0, CV_RGB (cr, cg, cb), 1, 8, 0); } - if (mouth && mouth->total) { + if (have_mouth) { CvRect *sr = (CvRect *) cvGetSeqElem (mouth, 0); w = sr->width / 2; @@ -651,7 +661,7 @@ gst_face_detect_transform_ip (GstOpencvVideoFilter * base, GstBuffer * buf, cvEllipse (img, center, axes, 0.0, 0.0, 360.0, CV_RGB (cr, cg, cb), 1, 8, 0); } - if (eyes && eyes->total) { + if (have_eyes) { CvRect *sr = (CvRect *) cvGetSeqElem (eyes, 0); w = sr->width / 2; -- cgit v1.2.3 From 486ddd38cf872099048f05b5f7739d6205e8d979 Mon Sep 17 00:00:00 2001 From: Stefan Sauer Date: Fri, 16 Mar 2012 17:07:46 +0100 Subject: facedetect: initialize some arbitrary variable that gcc-4.6 can track properly The access to them is clearly guarded by the booleans though. --- ext/opencv/gstfacedetect.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'ext') diff --git a/ext/opencv/gstfacedetect.c b/ext/opencv/gstfacedetect.c index f53b6eab7..485e42424 100644 --- a/ext/opencv/gstfacedetect.c +++ b/ext/opencv/gstfacedetect.c @@ -499,7 +499,7 @@ gst_face_detect_transform_ip (GstOpencvVideoFilter * base, GstBuffer * buf, GValue facelist = { 0 }; GValue facedata = { 0 }; CvSeq *faces; - CvSeq *mouth, *nose, *eyes; + CvSeq *mouth = NULL, *nose = NULL, *eyes = NULL; gint i; gboolean do_display = FALSE; @@ -524,9 +524,9 @@ gst_face_detect_transform_ip (GstOpencvVideoFilter * base, GstBuffer * buf, CvRect *r = (CvRect *) cvGetSeqElem (faces, i); guint mw = filter->min_size_width / 8; guint mh = filter->min_size_height / 8; - guint rnx, rny, rnw, rnh; - guint rmx, rmy, rmw, rmh; - guint rex, rey, rew, reh; + guint rnx = 0, rny = 0, rnw, rnh; + guint rmx = 0, rmy = 0, rmw, rmh; + guint rex = 0, rey = 0, rew, reh; gboolean have_nose, have_mouth, have_eyes; /* detect face features */ -- cgit v1.2.3 From 692bf9ba633c909efd313259598202d30ce0bb08 Mon Sep 17 00:00:00 2001 From: Tim-Philipp Müller Date: Sat, 17 Mar 2012 12:47:52 +0000 Subject: opencv: fix configure check and build with opencv 2.1 AC_CHECK_HEADERS() calls action-if-not-found also if just one of the headers checked for is missing, which is not what we wanted. Also, check for highgui_c.h instead of highgui.hpp. https://bugzilla.gnome.org/show_bug.cgi?id=672226 --- configure.ac | 11 ++++++----- ext/opencv/MotionCells.cpp | 7 +++++++ ext/opencv/MotionCells.h | 7 ++++--- ext/opencv/gstopencvutils.c | 4 ++++ ext/opencv/gsttemplatematch.h | 7 ++++--- ext/opencv/motioncells_wrapper.cpp | 7 +++++++ 6 files changed, 32 insertions(+), 11 deletions(-) (limited to 'ext') diff --git a/configure.ac b/configure.ac index 9cf3de2fc..ec821e224 100644 --- a/configure.ac +++ b/configure.ac @@ -1432,14 +1432,15 @@ AG_GST_CHECK_FEATURE(OPENCV, [opencv plugins], opencv, [ AC_LANG_CPLUSPLUS OLD_CPPFLAGS=$CPPFLAGS CPPFLAGS=$OPENCV_CFLAGS - AC_CHECK_HEADERS(highgui.h opencv2/highgui/highgui.hpp, HAVE_HIGHGUI="yes", HAVE_HIGHGUI="no") + AC_CHECK_HEADERS([highgui.h opencv2/highgui/highgui_c.h]) CPPFLAGS=$OLD_CPPFLAGS AC_LANG_C - if test "x$HAVE_HIGHGUI" = "xno"; then - AC_MSG_RESULT(highgui.h could not be found.) - HAVE_OPENCV="no" - else + + if test $ac_cv_header_highgui_h = "yes" -o $ac_cv_header_opencv2_highgui_highgui_c_h = "yes" ; then HAVE_OPENCV="yes" + else + AC_MSG_RESULT([neither highgui.h nor opencv2/highgui/highgui_c.h could not be found]) + HAVE_OPENCV="no" fi ], [ HAVE_OPENCV="no" diff --git a/ext/opencv/MotionCells.cpp b/ext/opencv/MotionCells.cpp index 5223bc7f7..6d18a9993 100644 --- a/ext/opencv/MotionCells.cpp +++ b/ext/opencv/MotionCells.cpp @@ -42,6 +42,13 @@ * Boston, MA 02111-1307, USA. */ +/* This breaks the build for reasons that aren't entirely clear to me yet */ +#if 0 +//#ifdef HAVE_CONFIG_H +//#include "config.h" +//#endif +#endif + #include #include #include diff --git a/ext/opencv/MotionCells.h b/ext/opencv/MotionCells.h index c5d4b17a5..68a2fec57 100644 --- a/ext/opencv/MotionCells.h +++ b/ext/opencv/MotionCells.h @@ -46,10 +46,11 @@ #define MOTIONCELLS_H_ #include // includes OpenCV definitions -#ifndef __OPENCV_OLD_CV_H__ +#ifdef HAVE_HIGHGUI_H #include // includes highGUI definitions -#else -#include // includes highGUI definitions +#endif +#ifdef HAVE_OPENCV2_HIGHGUI_HIGHGUI_C_H +#include // includes highGUI definitions #endif #include #include diff --git a/ext/opencv/gstopencvutils.c b/ext/opencv/gstopencvutils.c index dc42f90d5..8c72257cc 100644 --- a/ext/opencv/gstopencvutils.c +++ b/ext/opencv/gstopencvutils.c @@ -19,6 +19,10 @@ * Boston, MA 02111-1307, USA. */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include "gstopencvutils.h" static gboolean diff --git a/ext/opencv/gsttemplatematch.h b/ext/opencv/gsttemplatematch.h index 7e55ac6cf..8d99f982e 100644 --- a/ext/opencv/gsttemplatematch.h +++ b/ext/opencv/gsttemplatematch.h @@ -48,10 +48,11 @@ #include #include -#ifndef __OPENCV_OLD_CV_H__ +#ifdef HAVE_HIGHGUI_H #include // includes highGUI definitions -#else -#include // includes highGUI definitions +#endif +#ifdef HAVE_OPENCV2_HIGHGUI_HIGHGUI_C_H +#include // includes highGUI definitions #endif G_BEGIN_DECLS diff --git a/ext/opencv/motioncells_wrapper.cpp b/ext/opencv/motioncells_wrapper.cpp index d50968677..f55802bb4 100644 --- a/ext/opencv/motioncells_wrapper.cpp +++ b/ext/opencv/motioncells_wrapper.cpp @@ -42,6 +42,13 @@ * Boston, MA 02111-1307, USA. */ +/* This breaks the build for reasons that aren't entirely clear to me yet */ +#if 0 +//#ifdef HAVE_CONFIG_H +//#include "config.h" +//#endif +#endif + #include #include #include "motioncells_wrapper.h" -- cgit v1.2.3 From 0fad58c1231064964229551d555ff000f4702491 Mon Sep 17 00:00:00 2001 From: Nicola Murino Date: Sat, 17 Mar 2012 15:09:21 +0100 Subject: opencv: fix memory leak https://bugzilla.gnome.org/show_bug.cgi?id=672295 --- ext/opencv/gstopencvvideofilter.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'ext') diff --git a/ext/opencv/gstopencvvideofilter.c b/ext/opencv/gstopencvvideofilter.c index 7c42b1956..dcb98c01a 100644 --- a/ext/opencv/gstopencvvideofilter.c +++ b/ext/opencv/gstopencvvideofilter.c @@ -122,6 +122,8 @@ gst_opencv_video_filter_finalize (GObject * obj) if (transform->cvImage) cvReleaseImage (&transform->cvImage); + if (transform->out_cvImage) + cvReleaseImage (&transform->out_cvImage); G_OBJECT_CLASS (parent_class)->finalize (obj); } -- cgit v1.2.3 From 362727b9f4970233040fe1e72282db26bc0d91d6 Mon Sep 17 00:00:00 2001 From: Nicola Murino Date: Sun, 18 Mar 2012 00:51:32 +0000 Subject: facedetect: fix structure leak https://bugzilla.gnome.org/show_bug.cgi?id=672294 --- ext/opencv/gstfacedetect.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'ext') diff --git a/ext/opencv/gstfacedetect.c b/ext/opencv/gstfacedetect.c index 485e42424..e51eb52c7 100644 --- a/ext/opencv/gstfacedetect.c +++ b/ext/opencv/gstfacedetect.c @@ -616,9 +616,10 @@ gst_face_detect_transform_ip (GstOpencvVideoFilter * base, GstBuffer * buf, } g_value_init (&facedata, GST_TYPE_STRUCTURE); - gst_value_set_structure (&facedata, s); + g_value_take_boxed (&facedata, s); gst_value_list_append_value (&facelist, &facedata); g_value_unset (&facedata); + s = NULL; if (do_display) { CvPoint center; -- cgit v1.2.3 From bece1c97f2ad1e7e132af1eb3dffdad52d8cbed7 Mon Sep 17 00:00:00 2001 From: Stefan Sauer Date: Fri, 23 Mar 2012 18:16:08 +0100 Subject: modplug: work around memory trashing in libmodplug (0.8.7) Allocate double sized buffers. Also add more debug logging. --- ext/modplug/gstmodplug.cc | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'ext') diff --git a/ext/modplug/gstmodplug.cc b/ext/modplug/gstmodplug.cc index 9344cf9c0..8b42a52bd 100644 --- a/ext/modplug/gstmodplug.cc +++ b/ext/modplug/gstmodplug.cc @@ -467,6 +467,8 @@ static void gst_modplug_fixate (GstPad * pad, GstCaps * caps) { GstStructure *structure; + + GST_DEBUG_OBJECT (pad, "Fixating caps: %"GST_PTR_FORMAT, caps); structure = gst_caps_get_structure (caps, 0); if (!gst_structure_fixate_field_nearest_int (structure, "rate", 44100)) @@ -500,6 +502,10 @@ gst_modplug_load_song (GstModPlug * modplug) gst_structure_get_int (structure, "depth", &modplug->bits); gst_structure_get_int (structure, "channels", &modplug->channel); gst_structure_get_int (structure, "rate", &modplug->frequency); + + GST_DEBUG_OBJECT (modplug, + "Audio settings: %d bits, %d channel(s), %d Hz sampling rate", + modplug->bits, modplug->channel, modplug->frequency); gst_pad_set_caps (modplug->srcpad, newcaps); gst_caps_unref (newcaps); @@ -667,7 +673,6 @@ gst_modplug_loop (GstModPlug * modplug) GST_TAG_COMMENT, comment, NULL); } - gst_element_found_tags (GST_ELEMENT (modplug), tags); } else { /* not fully loaded yet */ @@ -682,7 +687,7 @@ gst_modplug_loop (GstModPlug * modplug) gfloat temp; temp = (gfloat) modplug->song_length / modplug->seek_at; - seek_to_pos = (int) (modplug->mSoundFile->GetMaxPosition () / temp); + seek_to_pos = (gint) (modplug->mSoundFile->GetMaxPosition () / temp); GST_DEBUG_OBJECT (modplug, "Seeking to row %d", seek_to_pos); @@ -691,9 +696,12 @@ gst_modplug_loop (GstModPlug * modplug) } /* read and output a buffer */ + GST_LOG_OBJECT (modplug, "Read %d bytes", (gint)modplug->read_bytes); + /* libmodplug 0.8.7 trashes memory */ flow = gst_pad_alloc_buffer_and_set_caps (modplug->srcpad, - GST_BUFFER_OFFSET_NONE, modplug->read_bytes, + GST_BUFFER_OFFSET_NONE, modplug->read_bytes * 2, GST_PAD_CAPS (modplug->srcpad), &out); + GST_BUFFER_SIZE (out) = modplug->read_bytes; if (flow != GST_FLOW_OK) { GST_LOG_OBJECT (modplug, "pad alloc flow: %s", gst_flow_get_name (flow)); -- cgit v1.2.3 From 4f1bcb55a40603f2d6bc94c16befd8fa9989cb3b Mon Sep 17 00:00:00 2001 From: Stefan Sauer Date: Fri, 23 Mar 2012 18:18:06 +0100 Subject: flte: comment cleanup Remove commented out code for a flitesynth that we don't have in git anyway. Add a comment regarding the flite voices. --- ext/flite/gstflite.c | 3 --- ext/flite/gstflitetestsrc.c | 3 +-- 2 files changed, 1 insertion(+), 5 deletions(-) (limited to 'ext') diff --git a/ext/flite/gstflite.c b/ext/flite/gstflite.c index 2995d9f3e..d75bd2ffe 100644 --- a/ext/flite/gstflite.c +++ b/ext/flite/gstflite.c @@ -24,7 +24,6 @@ #include #include -GType gst_flite_synth_get_type (void); GType gst_flite_test_src_get_type (void); @@ -33,8 +32,6 @@ plugin_init (GstPlugin * plugin) { flite_init (); -// gst_element_register (plugin, "flitesynth", GST_RANK_NONE, -// gst_flite_synth_get_type ()); gst_element_register (plugin, "flitetestsrc", GST_RANK_NONE, gst_flite_test_src_get_type ()); diff --git a/ext/flite/gstflitetestsrc.c b/ext/flite/gstflitetestsrc.c index a8e595c03..97c2acf96 100644 --- a/ext/flite/gstflitetestsrc.c +++ b/ext/flite/gstflitetestsrc.c @@ -298,10 +298,9 @@ gst_flite_test_src_get_times (GstBaseSrc * basesrc, GstBuffer * buffer, } #endif +/* there is no header for libflite_cmu_us_kal */ cst_voice *register_cmu_us_kal (); - - static gboolean gst_flite_test_src_start (GstBaseSrc * basesrc) { -- cgit v1.2.3 From d84d98943af42ce645ee022207bcf04e747d2d4a Mon Sep 17 00:00:00 2001 From: Stefan Sauer Date: Fri, 23 Mar 2012 18:36:21 +0100 Subject: modplug: memory handling cleanup Don't leak the CSoundFile. Use define for comment buffer size and ensure it is 0 terminated. --- ext/modplug/gstmodplug.cc | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'ext') diff --git a/ext/modplug/gstmodplug.cc b/ext/modplug/gstmodplug.cc index 8b42a52bd..346809971 100644 --- a/ext/modplug/gstmodplug.cc +++ b/ext/modplug/gstmodplug.cc @@ -646,7 +646,8 @@ gst_modplug_loop (GstModPlug * modplug) GstEvent *newsegment; GstTagList *tags; gboolean ok; - gchar comment[16384]; + #define COMMENT_SIZE 16384 + gchar comment[COMMENT_SIZE]; ok = gst_modplug_load_song (modplug); gst_buffer_unref (modplug->buffer); @@ -668,7 +669,9 @@ gst_modplug_loop (GstModPlug * modplug) GST_TAG_BEATS_PER_MINUTE, (gdouble) modplug->mSoundFile->GetMusicTempo (), NULL); - if (modplug->mSoundFile->GetSongComments ((gchar *) & comment, 16384, 32)) { + if (modplug->mSoundFile->GetSongComments ((gchar *) & comment, + COMMENT_SIZE, 32)) { + comment[COMMENT_SIZE - 1] = '\0'; gst_tag_list_add (tags, GST_TAG_MERGE_APPEND, GST_TAG_COMMENT, comment, NULL); } @@ -777,6 +780,7 @@ gst_modplug_change_state (GstElement * element, GstStateChange transition) } if (modplug->mSoundFile) { modplug->mSoundFile->Destroy (); + delete modplug->mSoundFile; modplug->mSoundFile = NULL; } break; -- cgit v1.2.3