From 3f642f3635ac475f2b5a4c9d682a413c93f0ca0b Mon Sep 17 00:00:00 2001 From: Stefan Kost Date: Wed, 25 May 2011 12:29:21 +0300 Subject: [PATCH 01/28] xvimagesink: remove unneded !=NULL checks We check for matching_attr!=NULL right before already. --- sys/xvimage/xvimagesink.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sys/xvimage/xvimagesink.c b/sys/xvimage/xvimagesink.c index 3e0b457cb2..7d3482ed83 100644 --- a/sys/xvimage/xvimagesink.c +++ b/sys/xvimage/xvimagesink.c @@ -1894,8 +1894,8 @@ gst_xvimagesink_xcontext_get (GstXvImageSink * xvimagesink) channel = g_object_new (GST_TYPE_COLOR_BALANCE_CHANNEL, NULL); channel->label = g_strdup (channels[i]); - channel->min_value = matching_attr ? matching_attr->min_value : -1000; - channel->max_value = matching_attr ? matching_attr->max_value : 1000; + channel->min_value = matching_attr->min_value; + channel->max_value = matching_attr->max_value; xcontext->channels_list = g_list_append (xcontext->channels_list, channel); From b229b8f3f98f1cb2eca52cc1e802b2a3c5d4b002 Mon Sep 17 00:00:00 2001 From: Stefan Kost Date: Wed, 25 May 2011 12:30:51 +0300 Subject: [PATCH 02/28] xvimagesink: run gst-indent --- sys/xvimage/xvimagesink.c | 80 +++++++++++++++++++-------------------- 1 file changed, 39 insertions(+), 41 deletions(-) diff --git a/sys/xvimage/xvimagesink.c b/sys/xvimage/xvimagesink.c index 7d3482ed83..29bb96a32e 100644 --- a/sys/xvimage/xvimagesink.c +++ b/sys/xvimage/xvimagesink.c @@ -191,8 +191,7 @@ enum PROP_WINDOW_HEIGHT }; -static void -gst_xvimagesink_init_interfaces (GType type); +static void gst_xvimagesink_init_interfaces (GType type); GST_BOILERPLATE_FULL (GstXvImageSink, gst_xvimagesink, GstVideoSink, GST_TYPE_VIDEO_SINK, gst_xvimagesink_init_interfaces); @@ -3476,7 +3475,8 @@ gst_xvimagesink_finalize (GObject * object) } static void -gst_xvimagesink_init (GstXvImageSink * xvimagesink, GstXvImageSinkClass *xvimagesinkclass) +gst_xvimagesink_init (GstXvImageSink * xvimagesink, + GstXvImageSinkClass * xvimagesinkclass) { xvimagesink->display_name = NULL; xvimagesink->adaptor_no = 0; @@ -3702,47 +3702,45 @@ gst_xvimagesink_class_init (GstXvImageSinkClass * klass) static void gst_xvimagesink_init_interfaces (GType type) { - static const GInterfaceInfo iface_info = { - (GInterfaceInitFunc) gst_xvimagesink_interface_init, - NULL, - NULL, - }; - static const GInterfaceInfo navigation_info = { - (GInterfaceInitFunc) gst_xvimagesink_navigation_init, - NULL, - NULL, - }; - static const GInterfaceInfo overlay_info = { - (GInterfaceInitFunc) gst_xvimagesink_xoverlay_init, - NULL, - NULL, - }; - static const GInterfaceInfo colorbalance_info = { - (GInterfaceInitFunc) gst_xvimagesink_colorbalance_init, - NULL, - NULL, - }; - static const GInterfaceInfo propertyprobe_info = { - (GInterfaceInitFunc) gst_xvimagesink_property_probe_interface_init, - NULL, - NULL, + static const GInterfaceInfo iface_info = { + (GInterfaceInitFunc) gst_xvimagesink_interface_init, + NULL, + NULL, + }; + static const GInterfaceInfo navigation_info = { + (GInterfaceInitFunc) gst_xvimagesink_navigation_init, + NULL, + NULL, + }; + static const GInterfaceInfo overlay_info = { + (GInterfaceInitFunc) gst_xvimagesink_xoverlay_init, + NULL, + NULL, + }; + static const GInterfaceInfo colorbalance_info = { + (GInterfaceInitFunc) gst_xvimagesink_colorbalance_init, + NULL, + NULL, + }; + static const GInterfaceInfo propertyprobe_info = { + (GInterfaceInitFunc) gst_xvimagesink_property_probe_interface_init, + NULL, + NULL, }; - g_type_add_interface_static (type, - GST_TYPE_IMPLEMENTS_INTERFACE, &iface_info); - g_type_add_interface_static (type, GST_TYPE_NAVIGATION, - &navigation_info); - g_type_add_interface_static (type, GST_TYPE_X_OVERLAY, - &overlay_info); - g_type_add_interface_static (type, GST_TYPE_COLOR_BALANCE, - &colorbalance_info); - g_type_add_interface_static (type, GST_TYPE_PROPERTY_PROBE, - &propertyprobe_info); + g_type_add_interface_static (type, + GST_TYPE_IMPLEMENTS_INTERFACE, &iface_info); + g_type_add_interface_static (type, GST_TYPE_NAVIGATION, &navigation_info); + g_type_add_interface_static (type, GST_TYPE_X_OVERLAY, &overlay_info); + g_type_add_interface_static (type, GST_TYPE_COLOR_BALANCE, + &colorbalance_info); + g_type_add_interface_static (type, GST_TYPE_PROPERTY_PROBE, + &propertyprobe_info); - /* register type and create class in a more safe place instead of at - * runtime since the type registration and class creation is not - * threadsafe. */ - g_type_class_ref (gst_xvimage_buffer_get_type ()); + /* register type and create class in a more safe place instead of at + * runtime since the type registration and class creation is not + * threadsafe. */ + g_type_class_ref (gst_xvimage_buffer_get_type ()); } static gboolean From 8ffe4445f6e01623dc8c972f5e01b7677b8446f2 Mon Sep 17 00:00:00 2001 From: Stefan Kost Date: Wed, 25 May 2011 13:59:57 +0300 Subject: [PATCH 03/28] exiftag: set value=1 if we found the token Otherwise we never write the tag. This would also be consistent with the code in deserialize_scene_type(). --- gst-libs/gst/tag/gstexiftag.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gst-libs/gst/tag/gstexiftag.c b/gst-libs/gst/tag/gstexiftag.c index c97901c6b0..9d941da909 100644 --- a/gst-libs/gst/tag/gstexiftag.c +++ b/gst-libs/gst/tag/gstexiftag.c @@ -2608,7 +2608,7 @@ serialize_scene_type (GstExifWriter * writer, const GstTagList * taglist, if (gst_tag_list_peek_string_index (taglist, GST_TAG_CAPTURING_SOURCE, 0, &str)) { if (strcmp (str, "dsc") == 0) { - value = 0; + value = 1; } } From 5e3f448afb33322f3518252b46ff5d3845b2fa8d Mon Sep 17 00:00:00 2001 From: Stefan Kost Date: Wed, 25 May 2011 14:12:50 +0300 Subject: [PATCH 04/28] exiftag: reflow the code Move the warning on unsupported units to the swicth-case. Move fetching the pending tags down to where we use them. --- gst-libs/gst/tag/gstexiftag.c | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/gst-libs/gst/tag/gstexiftag.c b/gst-libs/gst/tag/gstexiftag.c index 9d941da909..2527e99dbf 100644 --- a/gst-libs/gst/tag/gstexiftag.c +++ b/gst-libs/gst/tag/gstexiftag.c @@ -2565,14 +2565,6 @@ deserialize_resolution (GstExifReader * exif_reader, unit = GST_READ_UINT16_BE (tagdata->offset_as_data); } - if (unit != 2 && unit != 3) { - GST_WARNING ("Invalid resolution unit, ignoring PPI tags"); - return 0; - } - - xres = gst_exif_reader_get_pending_tag (exif_reader, EXIF_TAG_XRESOLUTION); - yres = gst_exif_reader_get_pending_tag (exif_reader, EXIF_TAG_YRESOLUTION); - switch (unit) { case 2: /* inch */ multiplier = 1; @@ -2581,15 +2573,16 @@ deserialize_resolution (GstExifReader * exif_reader, multiplier = 1 / 2.54; break; default: - multiplier = 1; - g_assert_not_reached (); - break; + GST_WARNING ("Invalid resolution unit, ignoring PPI tags"); + return 0; } + xres = gst_exif_reader_get_pending_tag (exif_reader, EXIF_TAG_XRESOLUTION); if (xres) { parse_exif_rational_tag (exif_reader, GST_TAG_IMAGE_HORIZONTAL_PPI, xres->count, xres->offset, multiplier, FALSE); } + yres = gst_exif_reader_get_pending_tag (exif_reader, EXIF_TAG_YRESOLUTION); if (yres) { parse_exif_rational_tag (exif_reader, GST_TAG_IMAGE_VERTICAL_PPI, yres->count, yres->offset, multiplier, FALSE); From 1916eecc3059476897a42d9a614f52d595e0b3ca Mon Sep 17 00:00:00 2001 From: Stefan Kost Date: Wed, 25 May 2011 14:28:18 +0300 Subject: [PATCH 05/28] volume: use a flag for 'mute' using the controller Previously we checked mute_csource to determine wheter we need to premultiply volumes and mute values. That fails as we unrefs mute_csource and set it to NULL after. Use an extra flag instead. --- gst/volume/gstvolume.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/gst/volume/gstvolume.c b/gst/volume/gstvolume.c index a5927073df..03145bfe03 100644 --- a/gst/volume/gstvolume.c +++ b/gst/volume/gstvolume.c @@ -897,6 +897,7 @@ volume_transform_ip (GstBaseTransform * base, GstBuffer * outbuf) guint nsamples = size / (width * channels); GstClockTime interval = gst_util_uint64_scale_int (1, GST_SECOND, rate); GstClockTime ts = GST_BUFFER_TIMESTAMP (outbuf); + gboolean use_mutes = FALSE; ts = gst_segment_to_stream_time (&base->segment, GST_FORMAT_TIME, ts); @@ -918,6 +919,7 @@ volume_transform_ip (GstBaseTransform * base, GstBuffer * outbuf) gst_object_unref (mute_csource); mute_csource = NULL; + use_mutes = TRUE; } else { g_free (self->mutes); self->mutes = NULL; @@ -937,7 +939,7 @@ volume_transform_ip (GstBaseTransform * base, GstBuffer * outbuf) orc_memset_f64 (self->volumes, self->current_volume, nsamples); } - if (mute_csource) { + if (use_mutes) { orc_prepare_volumes (self->volumes, self->mutes, nsamples); } From a11f6d4a738f08851bbc75ea3fdb4a52a50cf46a Mon Sep 17 00:00:00 2001 From: Stefan Kost Date: Wed, 25 May 2011 15:04:20 +0300 Subject: [PATCH 06/28] riff: remove the g_return_if_fail as we test it below We don't want to return without setting taglist=NULL if asserts are on and with setting taglist=NULL otherwise. --- gst-libs/gst/riff/riff-read.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/gst-libs/gst/riff/riff-read.c b/gst-libs/gst/riff/riff-read.c index e5983be5b9..314c19fe66 100644 --- a/gst-libs/gst/riff/riff-read.c +++ b/gst-libs/gst/riff/riff-read.c @@ -527,7 +527,7 @@ too_small: * codec initialization data). * * Parses a interleaved (also known as "complex") stream“s strf - * structure plus optionally some extradata from input data. This + * structure plus optionally some extradata from input data. This * function takes ownership of @buf. * * Returns: TRUE if parsing succeeded, otherwise FALSE. @@ -608,7 +608,6 @@ gst_riff_parse_info (GstElement * element, GstTagList *taglist; g_return_if_fail (_taglist != NULL); - g_return_if_fail (buf != NULL); if (!buf) { *_taglist = NULL; From af29082e9417864fe46b73276fc94dc1c1d7691f Mon Sep 17 00:00:00 2001 From: Stefan Kost Date: Wed, 25 May 2011 15:23:13 +0300 Subject: [PATCH 07/28] theoraenc: fix variable type for bytes_consumed th_encode_ctl() returns an int. Using a gsize result in bogus <0 checks. --- ext/theora/gsttheoraenc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ext/theora/gsttheoraenc.c b/ext/theora/gsttheoraenc.c index c580675146..45c9afb88c 100644 --- a/ext/theora/gsttheoraenc.c +++ b/ext/theora/gsttheoraenc.c @@ -1008,7 +1008,8 @@ theora_enc_read_multipass_cache (GstTheoraEnc * enc) { GstBuffer *cache_buf; const guint8 *cache_data; - gsize bytes_read = 0, bytes_consumed = 0; + gsize bytes_read = 0; + gint bytes_consumed = 0; GIOStatus stat = G_IO_STATUS_NORMAL; gboolean done = FALSE; From 41b60ca83acad826b0e9685913976aa94885abf5 Mon Sep 17 00:00:00 2001 From: Stefan Kost Date: Wed, 25 May 2011 15:24:33 +0300 Subject: [PATCH 08/28] theoraenc: remove bogus <0 check for unsigned var bytes_written is a gsize which is unsigned and thus never < 0. --- ext/theora/gsttheoraenc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/theora/gsttheoraenc.c b/ext/theora/gsttheoraenc.c index 45c9afb88c..e77f8e6d39 100644 --- a/ext/theora/gsttheoraenc.c +++ b/ext/theora/gsttheoraenc.c @@ -1078,7 +1078,7 @@ theora_enc_write_multipass_cache (GstTheoraEnc * enc, gboolean begin, } - if (stat == G_IO_STATUS_ERROR || bytes_read < 0 || bytes_written < 0) { + if (stat == G_IO_STATUS_ERROR || bytes_read < 0) { if (begin) { if (eos) GST_ELEMENT_WARNING (enc, RESOURCE, WRITE, (NULL), From 56717f5954c3321801e0c380821d540cd8f56bc3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim-Philipp=20M=C3=BCller?= Date: Wed, 25 May 2011 16:08:54 +0100 Subject: [PATCH 09/28] configure: update GLib requirement to >= 2.24 Same as core (make implicit requirement explicit). http://gstreamer.freedesktop.org/wiki/ReleasePlanning/GLibRequirement --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 9614618e5c..3ad974a664 100644 --- a/configure.ac +++ b/configure.ac @@ -259,7 +259,7 @@ AC_CHECK_FUNC(gethostbyname,,[AC_CHECK_LIB(nsl,gethostbyname)]) dnl *** checks for dependency libraries *** dnl GLib is required -AG_GST_GLIB_CHECK([2.22]) +AG_GST_GLIB_CHECK([2.24]) ORC_CHECK([0.4.11]) From 882ffb3b5b1dd88c9f2e1ac1b0e4ec9af91303a6 Mon Sep 17 00:00:00 2001 From: Vladimir Eremeev Date: Mon, 27 Sep 2010 12:46:54 +0400 Subject: [PATCH 10/28] seek: make seek example work in win32 https://bugzilla.gnome.org/show_bug.cgi?id=630322 --- tests/examples/seek/seek.c | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/tests/examples/seek/seek.c b/tests/examples/seek/seek.c index 8bf0818984..34d8a3b00a 100644 --- a/tests/examples/seek/seek.c +++ b/tests/examples/seek/seek.c @@ -35,6 +35,10 @@ #ifdef HAVE_X #include #endif +#ifdef G_OS_WIN32 +#include +#endif + #include #if (!GTK_CHECK_VERSION(2, 23, 0) || GTK_CHECK_VERSION(2, 90, 0)) && !GTK_CHECK_VERSION(2, 91, 1) @@ -57,17 +61,26 @@ gtk_widget_get_allocation (GtkWidget * w, GtkAllocation * a) /* configuration */ -//#define SOURCE "filesrc" -#define SOURCE "gnomevfssrc" +#define SOURCE "filesrc" -#define ASINK "alsasink" +#define ASINK DEFAULT_AUDIOSINK +//#define ASINK "pulsesink" +//#define ASINK "alsasink" //#define ASINK "osssink" +//#define ASINK "directsoundsink" +#ifdef G_OS_WIN32 +#define VSINK "directdrawsink" +#else #define VSINK "xvimagesink" +#endif //#define VSINK "sdlvideosink" //#define VSINK "ximagesink" //#define VSINK "aasink" //#define VSINK "cacasink" +//#define VSINK "dshowvideosink" +//#define VSINK "sdlvideosink" +//#define VSINK "glimagesink" #define FILL_INTERVAL 100 //#define UPDATE_INTERVAL 500 @@ -2424,7 +2437,7 @@ msg_clock_lost (GstBus * bus, GstMessage * message, GstPipeline * data) } } -#ifdef HAVE_X +#if defined (HAVE_X) || defined (G_OS_WIN32) static gulong embed_xid = 0; @@ -2492,11 +2505,15 @@ realize_cb (GtkWidget * widget, gpointer data) } #endif -#ifdef HAVE_X +#if defined (HAVE_X) || defined (G_OS_WIN32) { GdkWindow *window = gtk_widget_get_window (video_window); +#ifdef G_OS_WIN32 + embed_xid = GDK_WINDOW_HWND (window); +#else embed_xid = GDK_WINDOW_XID (window); +#endif g_print ("Window realize: video window XID = %lu\n", embed_xid); } #endif From 2ff8c8777f16643a66f8480275c6d581d7c2f8ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim-Philipp=20M=C3=BCller?= Date: Wed, 25 May 2011 18:45:33 +0100 Subject: [PATCH 11/28] seek: use gst_filename_to_uri() to convert a filename to a uri --- tests/examples/seek/seek.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/examples/seek/seek.c b/tests/examples/seek/seek.c index 34d8a3b00a..ef3fce4a74 100644 --- a/tests/examples/seek/seek.c +++ b/tests/examples/seek/seek.c @@ -931,11 +931,13 @@ playerbin_set_uri (GstElement * player, const gchar * location) gchar *uri; /* Add "file://" prefix for convenience */ - if (g_str_has_prefix (location, "/")) { - uri = g_strconcat ("file://", location, NULL); + if (g_str_has_prefix (location, "/") || !gst_uri_is_valid (location)) { + uri = gst_filename_to_uri (location, NULL); + g_print ("Setting URI: %s\n", uri); g_object_set (G_OBJECT (player), "uri", uri, NULL); g_free (uri); } else { + g_print ("Setting URI: %s\n", location); g_object_set (G_OBJECT (player), "uri", location, NULL); } } From ee6fbc2874ce7ddf887cf8f2efa7197e6014dc9f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim-Philipp=20M=C3=BCller?= Date: Wed, 25 May 2011 18:50:34 +0100 Subject: [PATCH 12/28] seek: use the right GDK defines to differentiate between the backends --- tests/examples/seek/seek.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/tests/examples/seek/seek.c b/tests/examples/seek/seek.c index ef3fce4a74..2a2a9d18c8 100644 --- a/tests/examples/seek/seek.c +++ b/tests/examples/seek/seek.c @@ -32,10 +32,10 @@ #include #include -#ifdef HAVE_X +#include +#if defined (GDK_WINDOWING_X11) #include -#endif -#ifdef G_OS_WIN32 +#elif defined (GDK_WINDOWING_WIN32) #include #endif @@ -2439,7 +2439,7 @@ msg_clock_lost (GstBus * bus, GstMessage * message, GstPipeline * data) } } -#if defined (HAVE_X) || defined (G_OS_WIN32) +#if defined (GDK_WINDOWING_X11) || defined (GDK_WINDOWING_WIN32) static gulong embed_xid = 0; @@ -2507,11 +2507,11 @@ realize_cb (GtkWidget * widget, gpointer data) } #endif -#if defined (HAVE_X) || defined (G_OS_WIN32) +#if defined (GDK_WINDOWING_X11) || defined (GDK_WINDOWING_WIN32) { GdkWindow *window = gtk_widget_get_window (video_window); -#ifdef G_OS_WIN32 +#if defined (GDK_WINDOWING_WIN32) embed_xid = GDK_WINDOW_HWND (window); #else embed_xid = GDK_WINDOW_XID (window); @@ -2549,7 +2549,7 @@ connect_bus_signals (GstElement * pipeline) { GstBus *bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline)); -#ifdef HAVE_X +#if defined (GDK_WINDOWING_X11) || defined (GDK_WINDOWING_WIN32) /* handle prepare-xwindow-id element message synchronously */ gst_bus_set_sync_handler (bus, (GstBusSyncHandler) bus_sync_handler, pipeline); @@ -2989,7 +2989,7 @@ main (int argc, char **argv) * asks for the XID of the window to render onto */ gtk_widget_realize (window); -#ifdef HAVE_X +#if defined (GDK_WINDOWING_X11) || defined (GDK_WINDOWING_WIN32) /* we should have the XID now */ g_assert (embed_xid != 0); #endif From 2b12546e024ea2044230bdb4b8f15c91885fb277 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim-Philipp=20M=C3=BCller?= Date: Wed, 25 May 2011 19:03:44 +0100 Subject: [PATCH 13/28] seek: add --audiosink and --videosink command line options --- tests/examples/seek/seek.c | 66 +++++++++++++++++--------------------- 1 file changed, 30 insertions(+), 36 deletions(-) diff --git a/tests/examples/seek/seek.c b/tests/examples/seek/seek.c index 2a2a9d18c8..459ea30739 100644 --- a/tests/examples/seek/seek.c +++ b/tests/examples/seek/seek.c @@ -63,24 +63,8 @@ gtk_widget_get_allocation (GtkWidget * w, GtkAllocation * a) #define SOURCE "filesrc" -#define ASINK DEFAULT_AUDIOSINK -//#define ASINK "pulsesink" -//#define ASINK "alsasink" -//#define ASINK "osssink" -//#define ASINK "directsoundsink" - -#ifdef G_OS_WIN32 -#define VSINK "directdrawsink" -#else -#define VSINK "xvimagesink" -#endif -//#define VSINK "sdlvideosink" -//#define VSINK "ximagesink" -//#define VSINK "aasink" -//#define VSINK "cacasink" -//#define VSINK "dshowvideosink" -//#define VSINK "sdlvideosink" -//#define VSINK "glimagesink" +static gchar *opt_audiosink_str; /* NULL */ +static gchar *opt_videosink_str; /* NULL */ #define FILL_INTERVAL 100 //#define UPDATE_INTERVAL 500 @@ -232,7 +216,7 @@ make_mod_pipeline (const gchar * location) src = gst_element_factory_make_or_warn (SOURCE, "src"); decoder = gst_element_factory_make_or_warn ("modplug", "decoder"); - audiosink = gst_element_factory_make_or_warn (ASINK, "sink"); + audiosink = gst_element_factory_make_or_warn (opt_audiosink_str, "sink"); //g_object_set (G_OBJECT (audiosink), "sync", FALSE, NULL); g_object_set (G_OBJECT (src), "location", location, NULL); @@ -267,7 +251,7 @@ make_dv_pipeline (const gchar * location) demux = gst_element_factory_make_or_warn ("dvdemux", "demuxer"); v_queue = gst_element_factory_make_or_warn ("queue", "v_queue"); decoder = gst_element_factory_make_or_warn ("ffdec_dvvideo", "decoder"); - videosink = gst_element_factory_make_or_warn (VSINK, "v_sink"); + videosink = gst_element_factory_make_or_warn (opt_videosink_str, "v_sink"); a_queue = gst_element_factory_make_or_warn ("queue", "a_queue"); audiosink = gst_element_factory_make_or_warn ("alsasink", "a_sink"); @@ -308,7 +292,7 @@ make_wav_pipeline (const gchar * location) src = gst_element_factory_make_or_warn (SOURCE, "src"); decoder = gst_element_factory_make_or_warn ("wavparse", "decoder"); - audiosink = gst_element_factory_make_or_warn (ASINK, "sink"); + audiosink = gst_element_factory_make_or_warn (opt_audiosink_str, "sink"); g_object_set (G_OBJECT (src), "location", location, NULL); @@ -340,7 +324,7 @@ make_flac_pipeline (const gchar * location) src = gst_element_factory_make_or_warn (SOURCE, "src"); decoder = gst_element_factory_make_or_warn ("flacdec", "decoder"); - audiosink = gst_element_factory_make_or_warn (ASINK, "sink"); + audiosink = gst_element_factory_make_or_warn (opt_audiosink_str, "sink"); g_object_set (G_OBJECT (audiosink), "sync", FALSE, NULL); g_object_set (G_OBJECT (src), "location", location, NULL); @@ -372,7 +356,7 @@ make_sid_pipeline (const gchar * location) src = gst_element_factory_make_or_warn (SOURCE, "src"); decoder = gst_element_factory_make_or_warn ("siddec", "decoder"); - audiosink = gst_element_factory_make_or_warn (ASINK, "sink"); + audiosink = gst_element_factory_make_or_warn (opt_audiosink_str, "sink"); //g_object_set (G_OBJECT (audiosink), "sync", FALSE, NULL); g_object_set (G_OBJECT (src), "location", location, NULL); @@ -439,7 +423,7 @@ make_vorbis_pipeline (const gchar * location) demux = gst_element_factory_make_or_warn ("oggdemux", "demux"); decoder = gst_element_factory_make_or_warn ("vorbisdec", "decoder"); convert = gst_element_factory_make_or_warn ("audioconvert", "convert"); - audiosink = gst_element_factory_make_or_warn (ASINK, "sink"); + audiosink = gst_element_factory_make_or_warn (opt_audiosink_str, "sink"); g_object_set (G_OBJECT (audiosink), "sync", TRUE, NULL); g_object_set (G_OBJECT (src), "location", location, NULL); @@ -486,7 +470,7 @@ make_theora_pipeline (const gchar * location) demux = gst_element_factory_make_or_warn ("oggdemux", "demux"); decoder = gst_element_factory_make_or_warn ("theoradec", "decoder"); convert = gst_element_factory_make_or_warn ("ffmpegcolorspace", "convert"); - videosink = gst_element_factory_make_or_warn (VSINK, "sink"); + videosink = gst_element_factory_make_or_warn (opt_videosink_str, "sink"); g_object_set (G_OBJECT (src), "location", location, NULL); @@ -544,7 +528,7 @@ make_vorbis_theora_pipeline (const gchar * location) a_queue = gst_element_factory_make_or_warn ("queue", "a_queue"); a_decoder = gst_element_factory_make_or_warn ("vorbisdec", "a_dec"); a_convert = gst_element_factory_make_or_warn ("audioconvert", "a_convert"); - audiosink = gst_element_factory_make_or_warn (ASINK, "a_sink"); + audiosink = gst_element_factory_make_or_warn (opt_audiosink_str, "a_sink"); gst_bin_add (GST_BIN (pipeline), audio_bin); @@ -570,7 +554,7 @@ make_vorbis_theora_pipeline (const gchar * location) v_convert = gst_element_factory_make_or_warn ("ffmpegcolorspace", "v_convert"); v_scale = gst_element_factory_make_or_warn ("videoscale", "v_scale"); - videosink = gst_element_factory_make_or_warn (VSINK, "v_sink"); + videosink = gst_element_factory_make_or_warn (opt_videosink_str, "v_sink"); gst_bin_add (GST_BIN (pipeline), video_bin); @@ -624,7 +608,7 @@ make_avi_msmpeg4v3_mp3_pipeline (const gchar * location) a_queue = gst_element_factory_make_or_warn ("queue", "a_queue"); a_decoder = gst_element_factory_make_or_warn ("mad", "a_dec"); a_convert = gst_element_factory_make_or_warn ("audioconvert", "a_convert"); - audiosink = gst_element_factory_make_or_warn (ASINK, "a_sink"); + audiosink = gst_element_factory_make_or_warn (opt_audiosink_str, "a_sink"); gst_bin_add (GST_BIN (audio_bin), a_queue); gst_bin_add (GST_BIN (audio_bin), a_decoder); @@ -649,7 +633,7 @@ make_avi_msmpeg4v3_mp3_pipeline (const gchar * location) v_decoder = gst_element_factory_make_or_warn ("ffdec_msmpeg4", "v_dec"); v_convert = gst_element_factory_make_or_warn ("ffmpegcolorspace", "v_convert"); - videosink = gst_element_factory_make_or_warn (VSINK, "v_sink"); + videosink = gst_element_factory_make_or_warn (opt_videosink_str, "v_sink"); gst_bin_add (GST_BIN (video_bin), v_queue); gst_bin_add (GST_BIN (video_bin), v_decoder); @@ -690,7 +674,7 @@ make_mp3_pipeline (const gchar * location) parser = gst_element_factory_make_or_warn ("mp3parse", "parse"); decoder = gst_element_factory_make_or_warn ("mad", "dec"); queue = gst_element_factory_make_or_warn ("queue", "queue"); - audiosink = gst_element_factory_make_or_warn (ASINK, "sink"); + audiosink = gst_element_factory_make_or_warn (opt_audiosink_str, "sink"); seekable_elements = g_list_prepend (seekable_elements, audiosink); @@ -739,7 +723,7 @@ make_avi_pipeline (const gchar * location) audio_bin = gst_bin_new ("a_decoder_bin"); a_decoder = gst_element_factory_make_or_warn ("mad", "a_dec"); - audiosink = gst_element_factory_make_or_warn (ASINK, "a_sink"); + audiosink = gst_element_factory_make_or_warn (opt_audiosink_str, "a_sink"); a_queue = gst_element_factory_make_or_warn ("queue", "a_queue"); gst_element_link (a_decoder, a_queue); gst_element_link (a_queue, audiosink); @@ -760,7 +744,7 @@ make_avi_pipeline (const gchar * location) video_bin = gst_bin_new ("v_decoder_bin"); v_decoder = gst_element_factory_make_or_warn ("ffmpegdecall", "v_dec"); - videosink = gst_element_factory_make_or_warn (VSINK, "v_sink"); + videosink = gst_element_factory_make_or_warn (opt_videosink_str, "v_sink"); v_queue = gst_element_factory_make_or_warn ("queue", "v_queue"); gst_element_link (v_decoder, v_queue); gst_element_link (v_queue, videosink); @@ -808,7 +792,7 @@ make_mpeg_pipeline (const gchar * location) audio_bin = gst_bin_new ("a_decoder_bin"); a_decoder = gst_element_factory_make_or_warn ("mad", "a_dec"); a_queue = gst_element_factory_make_or_warn ("queue", "a_queue"); - audiosink = gst_element_factory_make_or_warn (ASINK, "a_sink"); + audiosink = gst_element_factory_make_or_warn (opt_audiosink_str, "a_sink"); gst_bin_add (GST_BIN (audio_bin), a_decoder); gst_bin_add (GST_BIN (audio_bin), a_queue); gst_bin_add (GST_BIN (audio_bin), audiosink); @@ -829,7 +813,7 @@ make_mpeg_pipeline (const gchar * location) v_decoder = gst_element_factory_make_or_warn ("mpeg2dec", "v_dec"); v_queue = gst_element_factory_make_or_warn ("queue", "v_queue"); v_filter = gst_element_factory_make_or_warn ("ffmpegcolorspace", "v_filter"); - videosink = gst_element_factory_make_or_warn (VSINK, "v_sink"); + videosink = gst_element_factory_make_or_warn (opt_videosink_str, "v_sink"); gst_bin_add (GST_BIN (video_bin), v_decoder); gst_bin_add (GST_BIN (video_bin), v_queue); @@ -885,7 +869,7 @@ make_mpegnt_pipeline (const gchar * location) audio_bin = gst_bin_new ("a_decoder_bin"); a_decoder = gst_element_factory_make_or_warn ("mad", "a_dec"); a_queue = gst_element_factory_make_or_warn ("queue", "a_queue"); - audiosink = gst_element_factory_make_or_warn (ASINK, "a_sink"); + audiosink = gst_element_factory_make_or_warn (opt_audiosink_str, "a_sink"); //g_object_set (G_OBJECT (audiosink), "fragment", 0x00180008, NULL); g_object_set (G_OBJECT (audiosink), "sync", FALSE, NULL); gst_element_link (a_decoder, a_queue); @@ -907,7 +891,7 @@ make_mpegnt_pipeline (const gchar * location) video_bin = gst_bin_new ("v_decoder_bin"); v_decoder = gst_element_factory_make_or_warn ("mpeg2dec", "v_dec"); v_filter = gst_element_factory_make_or_warn ("ffmpegcolorspace", "v_filter"); - videosink = gst_element_factory_make_or_warn (VSINK, "v_sink"); + videosink = gst_element_factory_make_or_warn (opt_videosink_str, "v_sink"); gst_element_link_many (v_decoder, v_filter, videosink, NULL); gst_bin_add_many (GST_BIN (video_bin), v_decoder, v_filter, videosink, NULL); @@ -2656,12 +2640,16 @@ main (int argc, char **argv) GtkWidget *scrub_checkbox, *play_scrub_checkbox; GtkWidget *rate_label, *volume_label; GOptionEntry options[] = { + {"audiosink", '\0', 0, G_OPTION_ARG_STRING, &opt_audiosink_str, + "audio sink to use (default: " DEFAULT_AUDIOSINK ")", NULL}, {"stats", 's', 0, G_OPTION_ARG_NONE, &stats, "Show pad stats", NULL}, {"elem", 'e', 0, G_OPTION_ARG_NONE, &elem_seek, "Seek on elements instead of pads", NULL}, {"verbose", 'v', 0, G_OPTION_ARG_NONE, &verbose, "Verbose properties", NULL}, + {"videosink", '\0', 0, G_OPTION_ARG_STRING, &opt_videosink_str, + "video sink to use (default: " DEFAULT_VIDEOSINK ")", NULL}, {NULL} }; GOptionContext *ctx; @@ -2680,6 +2668,12 @@ main (int argc, char **argv) exit (1); } + if (opt_audiosink_str == NULL) + opt_audiosink_str = g_strdup (DEFAULT_AUDIOSINK); + + if (opt_videosink_str == NULL) + opt_videosink_str = g_strdup (DEFAULT_VIDEOSINK); + GST_DEBUG_CATEGORY_INIT (seek_debug, "seek", 0, "seek example"); if (argc != 3) { From 4c8fd85e8e185f80ef51c4d8003f5ca92e7db73c Mon Sep 17 00:00:00 2001 From: Vladimir Eremeev Date: Mon, 27 Sep 2010 13:32:31 +0400 Subject: [PATCH 14/28] seek: set selected/default audio/video sinks on playbin and playbin2 https://bugzilla.gnome.org/show_bug.cgi?id=630322 --- tests/examples/seek/seek.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tests/examples/seek/seek.c b/tests/examples/seek/seek.c index 459ea30739..d79209ccbd 100644 --- a/tests/examples/seek/seek.c +++ b/tests/examples/seek/seek.c @@ -930,6 +930,7 @@ static GstElement * construct_playerbin (const gchar * name, const gchar * location) { GstElement *player; + GstElement *avsink; player = gst_element_factory_make (name, "player"); g_assert (player); @@ -941,6 +942,14 @@ construct_playerbin (const gchar * name, const gchar * location) /* force element seeking on this pipeline */ elem_seek = TRUE; + avsink = gst_element_factory_make_or_warn (opt_audiosink_str, "a_sink"); + if (avsink) + g_object_set (player, "audio-sink", avsink, NULL); + + avsink = gst_element_factory_make_or_warn (opt_videosink_str, "v_sink"); + if (avsink) + g_object_set (player, "video-sink", avsink, NULL); + return player; } From 1cf831e74ec1231137ec3cbbd8b8cab5eb0c4749 Mon Sep 17 00:00:00 2001 From: Stefan Kost Date: Wed, 25 May 2011 23:40:26 +0300 Subject: [PATCH 15/28] audiotestsrc: add red (brownian) noise generator Add another noise generator which produces a quite dark noise color. Fixes parts of #649969. --- gst/audiotestsrc/gstaudiotestsrc.c | 50 ++++++++++++++++++++++++++++++ gst/audiotestsrc/gstaudiotestsrc.h | 17 +++++++--- 2 files changed, 62 insertions(+), 5 deletions(-) diff --git a/gst/audiotestsrc/gstaudiotestsrc.c b/gst/audiotestsrc/gstaudiotestsrc.c index ecbb2fbb07..1570c59a8f 100644 --- a/gst/audiotestsrc/gstaudiotestsrc.c +++ b/gst/audiotestsrc/gstaudiotestsrc.c @@ -130,6 +130,7 @@ gst_audiostestsrc_wave_get_type (void) {GST_AUDIO_TEST_SRC_WAVE_TICKS, "Periodic Ticks", "ticks"}, {GST_AUDIO_TEST_SRC_WAVE_GAUSSIAN_WHITE_NOISE, "White Gaussian noise", "gaussian-noise"}, + {GST_AUDIO_TEST_SRC_WAVE_RED_NOISE, "Red (brownian) noise", "red-noise"}, {0, NULL, NULL}, }; @@ -837,6 +838,49 @@ static const ProcessFunc gaussian_white_noise_funcs[] = { (ProcessFunc) gst_audio_test_src_create_gaussian_white_noise_double }; +/* Brownian (Red) Noise: noise where the power density decreases by 6 dB per + * octave with increasing frequency + * + * taken from http://vellocet.com/dsp/noise/VRand.html + * by Andrew Simper of Vellocet (andy@vellocet.com) + */ + +#define DEFINE_RED_NOISE(type,scale) \ +static void \ +gst_audio_test_src_create_red_noise_##type (GstAudioTestSrc * src, g##type * samples) \ +{ \ + gint i, c; \ + gdouble amp = (src->volume * scale); \ + gdouble state = src->red.state; \ + \ + for (i = 0; i < src->generate_samples_per_buffer * src->channels; ) { \ + for (c = 0; c < src->channels; ++c) { \ + while (TRUE) { \ + gdouble r = g_rand_double_range (src->gen, -1.0, 1.0); \ + state += r; \ + if (state<-8.0f || state>8.0f) state -= r; \ + else break; \ + } \ + samples[i++] = (g##type) (amp * state * 0.0625f); /* /16.0 */ \ + } \ + } \ + src->red.state = state; \ +} + +DEFINE_RED_NOISE (int16, 32767.0); +DEFINE_RED_NOISE (int32, 2147483647.0); +DEFINE_RED_NOISE (float, 1.0); +DEFINE_RED_NOISE (double, 1.0); + +static const ProcessFunc red_noise_funcs[] = { + (ProcessFunc) gst_audio_test_src_create_red_noise_int16, + (ProcessFunc) gst_audio_test_src_create_red_noise_int32, + (ProcessFunc) gst_audio_test_src_create_red_noise_float, + (ProcessFunc) gst_audio_test_src_create_red_noise_double +}; + + + /* * gst_audio_test_src_change_wave: * Assign function pointer of wave genrator. @@ -889,6 +933,12 @@ gst_audio_test_src_change_wave (GstAudioTestSrc * src) src->gen = g_rand_new (); src->process = gaussian_white_noise_funcs[src->format]; break; + case GST_AUDIO_TEST_SRC_WAVE_RED_NOISE: + if (!(src->gen)) + src->gen = g_rand_new (); + src->red.state = 0.0; + src->process = red_noise_funcs[src->format]; + break; default: GST_ERROR ("invalid wave-form"); break; diff --git a/gst/audiotestsrc/gstaudiotestsrc.h b/gst/audiotestsrc/gstaudiotestsrc.h index 8c76594822..971fe77f60 100644 --- a/gst/audiotestsrc/gstaudiotestsrc.h +++ b/gst/audiotestsrc/gstaudiotestsrc.h @@ -50,6 +50,7 @@ G_BEGIN_DECLS * @GST_AUDIO_TEST_SRC_WAVE_SINE_TAB: sine wave using a table * @GST_AUDIO_TEST_SRC_WAVE_TICKS: periodic ticks * @GST_AUDIO_TEST_SRC_WAVE_GAUSSIAN_WHITE_NOISE: white (zero mean) Gaussian noise; volume sets the standard deviation of the noise in units of the range of values of the sample type, e.g. volume=0.1 produces noise with a standard deviation of 0.1*32767=3277 with 16-bit integer samples, or 0.1*1.0=0.1 with floating-point samples. + * @GST_AUDIO_TEST_SRC_WAVE_RED_NOISE: red (brownian) noise * * Different types of supported sound waves. */ @@ -63,8 +64,9 @@ typedef enum { GST_AUDIO_TEST_SRC_WAVE_PINK_NOISE, GST_AUDIO_TEST_SRC_WAVE_SINE_TAB, GST_AUDIO_TEST_SRC_WAVE_TICKS, - GST_AUDIO_TEST_SRC_WAVE_GAUSSIAN_WHITE_NOISE -} GstAudioTestSrcWave; + GST_AUDIO_TEST_SRC_WAVE_GAUSSIAN_WHITE_NOISE, + GST_AUDIO_TEST_SRC_WAVE_RED_NOISE +} GstAudioTestSrcWave; #define PINK_MAX_RANDOM_ROWS (30) #define PINK_RANDOM_BITS (16) @@ -78,6 +80,10 @@ typedef struct { gdouble scalar; /* Used to scale within range of -1.0 to +1.0 */ } GstPinkNoise; +typedef struct { + gdouble state; /* noise state */ +} GstRedNoise; + typedef enum { GST_AUDIO_TEST_SRC_FORMAT_NONE = -1, GST_AUDIO_TEST_SRC_FORMAT_S16 = 0, @@ -105,14 +111,14 @@ struct _GstAudioTestSrc { GstAudioTestSrcWave wave; gdouble volume; gdouble freq; - + /* audio parameters */ gint channels; gint samplerate; gint samples_per_buffer; gint sample_size; GstAudioTestSrcFormat format; - + /*< private >*/ gboolean tags_pushed; /* send tags just once ? */ GstClockTimeDiff timestamp_offset; /* base offset */ @@ -125,11 +131,12 @@ struct _GstAudioTestSrc { gint generate_samples_per_buffer; /* used to generate a partial buffer */ gboolean can_activate_pull; gboolean reverse; /* play backwards */ - + /* waveform specific context data */ GRand *gen; /* random number generator */ gdouble accumulator; /* phase angle */ GstPinkNoise pink; + GstRedNoise red; gdouble wave_table[1024]; }; From 5cd0e0f666699e9c49ee4f9646118b596cd351ed Mon Sep 17 00:00:00 2001 From: Stefan Kost Date: Thu, 26 May 2011 00:17:40 +0300 Subject: [PATCH 16/28] audiotestsrc: add blue and violet noise by using spectral inversion Add blue and violet noise by spectral inversion of pink and red noise. Fixes #649969 --- gst/audiotestsrc/gstaudiotestsrc.c | 73 ++++++++++++++++++++++++++++++ gst/audiotestsrc/gstaudiotestsrc.h | 4 +- 2 files changed, 76 insertions(+), 1 deletion(-) diff --git a/gst/audiotestsrc/gstaudiotestsrc.c b/gst/audiotestsrc/gstaudiotestsrc.c index 1570c59a8f..030322ec49 100644 --- a/gst/audiotestsrc/gstaudiotestsrc.c +++ b/gst/audiotestsrc/gstaudiotestsrc.c @@ -131,6 +131,8 @@ gst_audiostestsrc_wave_get_type (void) {GST_AUDIO_TEST_SRC_WAVE_GAUSSIAN_WHITE_NOISE, "White Gaussian noise", "gaussian-noise"}, {GST_AUDIO_TEST_SRC_WAVE_RED_NOISE, "Red (brownian) noise", "red-noise"}, + {GST_AUDIO_TEST_SRC_WAVE_BLUE_NOISE, "Blue noise", "blue-noise"}, + {GST_AUDIO_TEST_SRC_WAVE_VIOLET_NOISE, "Violet noise", "violet-noise"}, {0, NULL, NULL}, }; @@ -879,6 +881,66 @@ static const ProcessFunc red_noise_funcs[] = { (ProcessFunc) gst_audio_test_src_create_red_noise_double }; +/* Blue Noise: apply spectral inversion to pink noise */ + +#define DEFINE_BLUE_NOISE(type) \ +static void \ +gst_audio_test_src_create_blue_noise_##type (GstAudioTestSrc * src, g##type * samples) \ +{ \ + gint i, c; \ + static gdouble flip=1.0; \ + \ + gst_audio_test_src_create_pink_noise_##type (src, samples); \ + for (i = 0; i < src->generate_samples_per_buffer * src->channels; ) { \ + for (c = 0; c < src->channels; ++c) { \ + samples[i++] *= flip; \ + } \ + flip *= -1.0; \ + } \ +} + +DEFINE_BLUE_NOISE (int16); +DEFINE_BLUE_NOISE (int32); +DEFINE_BLUE_NOISE (float); +DEFINE_BLUE_NOISE (double); + +static const ProcessFunc blue_noise_funcs[] = { + (ProcessFunc) gst_audio_test_src_create_blue_noise_int16, + (ProcessFunc) gst_audio_test_src_create_blue_noise_int32, + (ProcessFunc) gst_audio_test_src_create_blue_noise_float, + (ProcessFunc) gst_audio_test_src_create_blue_noise_double +}; + + +/* Violet Noise: apply spectral inversion to red noise */ + +#define DEFINE_VIOLET_NOISE(type) \ +static void \ +gst_audio_test_src_create_violet_noise_##type (GstAudioTestSrc * src, g##type * samples) \ +{ \ + gint i, c; \ + static gdouble flip=1.0; \ + \ + gst_audio_test_src_create_red_noise_##type (src, samples); \ + for (i = 0; i < src->generate_samples_per_buffer * src->channels; ) { \ + for (c = 0; c < src->channels; ++c) { \ + samples[i++] *= flip; \ + } \ + flip *= -1.0; \ + } \ +} + +DEFINE_VIOLET_NOISE (int16); +DEFINE_VIOLET_NOISE (int32); +DEFINE_VIOLET_NOISE (float); +DEFINE_VIOLET_NOISE (double); + +static const ProcessFunc violet_noise_funcs[] = { + (ProcessFunc) gst_audio_test_src_create_violet_noise_int16, + (ProcessFunc) gst_audio_test_src_create_violet_noise_int32, + (ProcessFunc) gst_audio_test_src_create_violet_noise_float, + (ProcessFunc) gst_audio_test_src_create_violet_noise_double +}; /* @@ -939,6 +1001,17 @@ gst_audio_test_src_change_wave (GstAudioTestSrc * src) src->red.state = 0.0; src->process = red_noise_funcs[src->format]; break; + case GST_AUDIO_TEST_SRC_WAVE_BLUE_NOISE: + if (!(src->gen)) + src->gen = g_rand_new (); + gst_audio_test_src_init_pink_noise (src); + src->process = blue_noise_funcs[src->format]; + break; + case GST_AUDIO_TEST_SRC_WAVE_VIOLET_NOISE: + if (!(src->gen)) + src->gen = g_rand_new (); + src->red.state = 0.0; + src->process = violet_noise_funcs[src->format]; default: GST_ERROR ("invalid wave-form"); break; diff --git a/gst/audiotestsrc/gstaudiotestsrc.h b/gst/audiotestsrc/gstaudiotestsrc.h index 971fe77f60..529ad63c3e 100644 --- a/gst/audiotestsrc/gstaudiotestsrc.h +++ b/gst/audiotestsrc/gstaudiotestsrc.h @@ -65,7 +65,9 @@ typedef enum { GST_AUDIO_TEST_SRC_WAVE_SINE_TAB, GST_AUDIO_TEST_SRC_WAVE_TICKS, GST_AUDIO_TEST_SRC_WAVE_GAUSSIAN_WHITE_NOISE, - GST_AUDIO_TEST_SRC_WAVE_RED_NOISE + GST_AUDIO_TEST_SRC_WAVE_RED_NOISE, + GST_AUDIO_TEST_SRC_WAVE_BLUE_NOISE, + GST_AUDIO_TEST_SRC_WAVE_VIOLET_NOISE } GstAudioTestSrcWave; #define PINK_MAX_RANDOM_ROWS (30) From 2f6d9e55cc062d2bca7c965f9a187d07296beb12 Mon Sep 17 00:00:00 2001 From: Sreerenj Balachandran Date: Wed, 25 May 2011 14:08:43 +0300 Subject: [PATCH 17/28] xvimagesink: Remove the g_assert from interface query --- sys/xvimage/xvimagesink.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/sys/xvimage/xvimagesink.c b/sys/xvimage/xvimagesink.c index 29bb96a32e..b645b35392 100644 --- a/sys/xvimage/xvimagesink.c +++ b/sys/xvimage/xvimagesink.c @@ -2722,9 +2722,11 @@ no_caps: static gboolean gst_xvimagesink_interface_supported (GstImplementsInterface * iface, GType type) { - g_assert (type == GST_TYPE_NAVIGATION || type == GST_TYPE_X_OVERLAY || - type == GST_TYPE_COLOR_BALANCE || type == GST_TYPE_PROPERTY_PROBE); - return TRUE; + if (type == GST_TYPE_NAVIGATION || type == GST_TYPE_X_OVERLAY || + type == GST_TYPE_COLOR_BALANCE || type == GST_TYPE_PROPERTY_PROBE) + return TRUE; + else + return FALSE; } static void From b977d550df0bdd5c1f104d36f64f84fa23cc1764 Mon Sep 17 00:00:00 2001 From: Sreerenj Balachandran Date: Wed, 25 May 2011 14:14:46 +0300 Subject: [PATCH 18/28] ximagesink: Remove g_assert from interface query --- sys/ximage/ximagesink.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/sys/ximage/ximagesink.c b/sys/ximage/ximagesink.c index 99ad35b350..c882bece8a 100644 --- a/sys/ximage/ximagesink.c +++ b/sys/ximage/ximagesink.c @@ -1951,8 +1951,10 @@ beach: static gboolean gst_ximagesink_interface_supported (GstImplementsInterface * iface, GType type) { - g_assert (type == GST_TYPE_NAVIGATION || type == GST_TYPE_X_OVERLAY); - return TRUE; + if (type == GST_TYPE_NAVIGATION || type == GST_TYPE_X_OVERLAY) + return TRUE; + else + return FALSE; } static void From 847d274a5c4c2fb7d5f636bdf91bf65fab3db142 Mon Sep 17 00:00:00 2001 From: American Dynamics Date: Fri, 3 Sep 2010 09:11:30 -0400 Subject: [PATCH 19/28] gnomevfssrc: Add support for cancelling the read operations This allows the state change from PAUSED to READY to be faster. Fixes bug #628337. --- ext/gnomevfs/gstgnomevfssrc.c | 68 +++++++++++++++++++++++++++++++++-- ext/gnomevfs/gstgnomevfssrc.h | 2 ++ 2 files changed, 68 insertions(+), 2 deletions(-) diff --git a/ext/gnomevfs/gstgnomevfssrc.c b/ext/gnomevfs/gstgnomevfssrc.c index 4b2507c977..f144317d96 100644 --- a/ext/gnomevfs/gstgnomevfssrc.c +++ b/ext/gnomevfs/gstgnomevfssrc.c @@ -70,6 +70,7 @@ #include "gst/gst-i18n-plugin.h" #include "gstgnomevfssrc.h" +#include #include #include @@ -132,6 +133,8 @@ static gboolean gst_gnome_vfs_src_stop (GstBaseSrc * src); static gboolean gst_gnome_vfs_src_start (GstBaseSrc * src); static gboolean gst_gnome_vfs_src_is_seekable (GstBaseSrc * src); static gboolean gst_gnome_vfs_src_check_get_range (GstBaseSrc * src); +static gboolean gst_gnome_vfs_src_unlock (GstBaseSrc * basesrc); +static gboolean gst_gnome_vfs_src_unlock_stop (GstBaseSrc * basesrc); static gboolean gst_gnome_vfs_src_get_size (GstBaseSrc * src, guint64 * size); static GstFlowReturn gst_gnome_vfs_src_create (GstBaseSrc * basesrc, guint64 offset, guint size, GstBuffer ** buffer); @@ -241,6 +244,9 @@ gst_gnome_vfs_src_class_init (GstGnomeVFSSrcClass * klass) gstbasesrc_class->start = GST_DEBUG_FUNCPTR (gst_gnome_vfs_src_start); gstbasesrc_class->stop = GST_DEBUG_FUNCPTR (gst_gnome_vfs_src_stop); + gstbasesrc_class->unlock = GST_DEBUG_FUNCPTR (gst_gnome_vfs_src_unlock); + gstbasesrc_class->unlock_stop = + GST_DEBUG_FUNCPTR (gst_gnome_vfs_src_unlock_stop); gstbasesrc_class->get_size = GST_DEBUG_FUNCPTR (gst_gnome_vfs_src_get_size); gstbasesrc_class->is_seekable = GST_DEBUG_FUNCPTR (gst_gnome_vfs_src_is_seekable); @@ -255,7 +261,9 @@ gst_gnome_vfs_src_init (GstGnomeVFSSrc * gnomevfssrc) { gnomevfssrc->uri = NULL; gnomevfssrc->uri_name = NULL; + gnomevfssrc->context = NULL; gnomevfssrc->handle = NULL; + gnomevfssrc->interrupted = FALSE; gnomevfssrc->curoffset = 0; gnomevfssrc->seekable = FALSE; @@ -633,9 +641,19 @@ gst_gnome_vfs_src_create (GstBaseSrc * basesrc, guint64 offset, guint size, data = GST_BUFFER_DATA (buf); todo = size; - while (todo > 0) { + while (!src->interrupted && todo > 0) { /* this can return less that we ask for */ - res = gnome_vfs_read (src->handle, data, todo, &readbytes); + res = gnome_vfs_read_cancellable (src->handle, data, todo, &readbytes, src->context); + + if (G_UNLIKELY (res == GNOME_VFS_ERROR_CANCELLED)) { + GST_DEBUG_OBJECT (src, "interrupted"); + + /* Just take what we've so far gotten and return */ + size = size - todo; + GST_BUFFER_SIZE (buf) = size; + todo = 0; + break; + } if (G_UNLIKELY (res == GNOME_VFS_ERROR_EOF || (res == GNOME_VFS_OK && readbytes == 0))) @@ -652,6 +670,11 @@ gst_gnome_vfs_src_create (GstBaseSrc * basesrc, guint64 offset, guint size, } GST_LOG (" got size %" G_GUINT64_FORMAT, readbytes); } + + /* Handle interrupts implicitly, since the flag may have been cleared by now */ + if (size == todo) + goto interrupted; + GST_BUFFER_OFFSET (buf) = src->curoffset; src->curoffset += size; @@ -681,6 +704,11 @@ read_failed: ("Failed to read data: %s", gnome_vfs_result_to_string (res))); return GST_FLOW_ERROR; } +interrupted: + { + gst_buffer_unref (buf); + return GST_FLOW_WRONG_STATE; + } eos: { gst_buffer_unref (buf); @@ -766,6 +794,38 @@ undecided: } } +/* Interrupt a blocking request. */ +static gboolean +gst_gnome_vfs_src_unlock (GstBaseSrc * basesrc) +{ + GstGnomeVFSSrc *src; + + src = GST_GNOME_VFS_SRC (basesrc); + GST_DEBUG_OBJECT (src, "unlock()"); + src->interrupted = TRUE; + if (src->context) + { + GnomeVFSCancellation *cancel = + gnome_vfs_context_get_cancellation (src->context); + if (cancel) + gnome_vfs_cancellation_cancel (cancel); + } + return TRUE; +} + +/* Interrupt interrupt. */ +static gboolean +gst_gnome_vfs_src_unlock_stop (GstBaseSrc * basesrc) +{ + GstGnomeVFSSrc *src; + + src = GST_GNOME_VFS_SRC (basesrc); + GST_DEBUG_OBJECT (src, "unlock_stop()"); + + src->interrupted = FALSE; + return TRUE; +} + static gboolean gst_gnome_vfs_src_get_size (GstBaseSrc * basesrc, guint64 * size) { @@ -819,6 +879,7 @@ gst_gnome_vfs_src_start (GstBaseSrc * basesrc) gst_gnome_vfs_src_push_callbacks (src); + src->context = gnome_vfs_context_new(); if (src->uri != NULL) { GnomeVFSOpenMode mode = GNOME_VFS_OPEN_READ; @@ -890,6 +951,9 @@ gst_gnome_vfs_src_stop (GstBaseSrc * basesrc) src->handle = NULL; } src->curoffset = 0; + src->interrupted = FALSE; + gnome_vfs_context_free( src->context ); + src->context = NULL; return TRUE; } diff --git a/ext/gnomevfs/gstgnomevfssrc.h b/ext/gnomevfs/gstgnomevfssrc.h index 31c1f65caa..e8c228d9b7 100644 --- a/ext/gnomevfs/gstgnomevfssrc.h +++ b/ext/gnomevfs/gstgnomevfssrc.h @@ -58,8 +58,10 @@ struct _GstGnomeVFSSrc /* uri, file, ... */ GnomeVFSURI *uri; gchar *uri_name; + GnomeVFSContext *context; GnomeVFSHandle *handle; gboolean own_handle; + gboolean interrupted; GnomeVFSFileOffset curoffset; /* current offset in file */ gboolean seekable; From 99188bce77ffa9958480410e87a1b52e1b32ddab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Thu, 26 May 2011 10:31:11 +0200 Subject: [PATCH 20/28] gnomevfssrc: Keep track of interruptions during read with a flag --- ext/gnomevfs/gstgnomevfssrc.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/ext/gnomevfs/gstgnomevfssrc.c b/ext/gnomevfs/gstgnomevfssrc.c index f144317d96..ef9ab74157 100644 --- a/ext/gnomevfs/gstgnomevfssrc.c +++ b/ext/gnomevfs/gstgnomevfssrc.c @@ -246,7 +246,7 @@ gst_gnome_vfs_src_class_init (GstGnomeVFSSrcClass * klass) gstbasesrc_class->stop = GST_DEBUG_FUNCPTR (gst_gnome_vfs_src_stop); gstbasesrc_class->unlock = GST_DEBUG_FUNCPTR (gst_gnome_vfs_src_unlock); gstbasesrc_class->unlock_stop = - GST_DEBUG_FUNCPTR (gst_gnome_vfs_src_unlock_stop); + GST_DEBUG_FUNCPTR (gst_gnome_vfs_src_unlock_stop); gstbasesrc_class->get_size = GST_DEBUG_FUNCPTR (gst_gnome_vfs_src_get_size); gstbasesrc_class->is_seekable = GST_DEBUG_FUNCPTR (gst_gnome_vfs_src_is_seekable); @@ -612,6 +612,7 @@ gst_gnome_vfs_src_create (GstBaseSrc * basesrc, guint64 offset, guint size, guint8 *data; guint todo; GstGnomeVFSSrc *src; + gboolean interrupted = FALSE; src = GST_GNOME_VFS_SRC (basesrc); @@ -643,7 +644,9 @@ gst_gnome_vfs_src_create (GstBaseSrc * basesrc, guint64 offset, guint size, todo = size; while (!src->interrupted && todo > 0) { /* this can return less that we ask for */ - res = gnome_vfs_read_cancellable (src->handle, data, todo, &readbytes, src->context); + res = + gnome_vfs_read_cancellable (src->handle, data, todo, &readbytes, + src->context); if (G_UNLIKELY (res == GNOME_VFS_ERROR_CANCELLED)) { GST_DEBUG_OBJECT (src, "interrupted"); @@ -652,6 +655,7 @@ gst_gnome_vfs_src_create (GstBaseSrc * basesrc, guint64 offset, guint size, size = size - todo; GST_BUFFER_SIZE (buf) = size; todo = 0; + interrupted = TRUE; break; } @@ -671,8 +675,7 @@ gst_gnome_vfs_src_create (GstBaseSrc * basesrc, guint64 offset, guint size, GST_LOG (" got size %" G_GUINT64_FORMAT, readbytes); } - /* Handle interrupts implicitly, since the flag may have been cleared by now */ - if (size == todo) + if (interrupted) goto interrupted; GST_BUFFER_OFFSET (buf) = src->curoffset; @@ -803,10 +806,9 @@ gst_gnome_vfs_src_unlock (GstBaseSrc * basesrc) src = GST_GNOME_VFS_SRC (basesrc); GST_DEBUG_OBJECT (src, "unlock()"); src->interrupted = TRUE; - if (src->context) - { + if (src->context) { GnomeVFSCancellation *cancel = - gnome_vfs_context_get_cancellation (src->context); + gnome_vfs_context_get_cancellation (src->context); if (cancel) gnome_vfs_cancellation_cancel (cancel); } @@ -879,7 +881,7 @@ gst_gnome_vfs_src_start (GstBaseSrc * basesrc) gst_gnome_vfs_src_push_callbacks (src); - src->context = gnome_vfs_context_new(); + src->context = gnome_vfs_context_new (); if (src->uri != NULL) { GnomeVFSOpenMode mode = GNOME_VFS_OPEN_READ; @@ -952,7 +954,7 @@ gst_gnome_vfs_src_stop (GstBaseSrc * basesrc) } src->curoffset = 0; src->interrupted = FALSE; - gnome_vfs_context_free( src->context ); + gnome_vfs_context_free (src->context); src->context = NULL; return TRUE; From fe533c999531f7db4a25813c5fff7921c4a15c40 Mon Sep 17 00:00:00 2001 From: Jindrich Makovicka Date: Thu, 26 May 2011 10:42:46 +0200 Subject: [PATCH 21/28] textrender: Prevent double unref of caps if the caps can't be set on the srcpad --- ext/pango/gsttextrender.c | 1 - 1 file changed, 1 deletion(-) diff --git a/ext/pango/gsttextrender.c b/ext/pango/gsttextrender.c index c93724497f..eaa4742f76 100644 --- a/ext/pango/gsttextrender.c +++ b/ext/pango/gsttextrender.c @@ -498,7 +498,6 @@ gst_text_render_chain (GstPad * pad, GstBuffer * inbuf) } if (!gst_pad_set_caps (render->srcpad, caps)) { - gst_caps_unref (caps); GST_ELEMENT_ERROR (render, CORE, NEGOTIATION, (NULL), (NULL)); ret = GST_FLOW_ERROR; goto done; From c186d400e597ad30c5b8c0277567baa376cf48bd Mon Sep 17 00:00:00 2001 From: Jindrich Makovicka Date: Thu, 26 May 2011 10:43:51 +0200 Subject: [PATCH 22/28] textrender: Add bound checks to not write outside the image area --- ext/pango/gsttextrender.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/ext/pango/gsttextrender.c b/ext/pango/gsttextrender.c index eaa4742f76..c0129f5b36 100644 --- a/ext/pango/gsttextrender.c +++ b/ext/pango/gsttextrender.c @@ -380,8 +380,10 @@ gst_text_render_fixate_caps (GstPad * pad, GstCaps * caps) GstStructure *s = gst_caps_get_structure (caps, 0); GST_DEBUG ("Fixating caps %" GST_PTR_FORMAT, caps); - gst_structure_fixate_field_nearest_int (s, "width", render->image_width); - gst_structure_fixate_field_nearest_int (s, "height", render->image_height); + gst_structure_fixate_field_nearest_int (s, "width", MAX (render->image_width, + DEFAULT_RENDER_WIDTH)); + gst_structure_fixate_field_nearest_int (s, "height", + MAX (render->image_height + render->ypad, DEFAULT_RENDER_HEIGHT)); GST_DEBUG ("Fixated to %" GST_PTR_FORMAT, caps); gst_object_unref (render); @@ -404,12 +406,12 @@ gst_text_renderer_image_to_ayuv (GstTextRender * render, guchar * pixbuf, width = render->image_width; height = render->image_height; - bitp = render->text_image; - for (y = 0; y < height; y++) { + for (y = 0; y < height && ypos + y < render->height; y++) { int n; p = pixbuf + (ypos + y) * stride + xpos * 4; - for (n = 0; n < width; n++) { + bitp = render->text_image + y * width * 4; + for (n = 0; n < width && n < render->width; n++) { b = bitp[CAIRO_ARGB_B]; g = bitp[CAIRO_ARGB_G]; r = bitp[CAIRO_ARGB_R]; @@ -440,11 +442,11 @@ gst_text_renderer_image_to_argb (GstTextRender * render, guchar * pixbuf, width = render->image_width; height = render->image_height; - bitp = render->text_image; - for (i = 0; i < height; i++) { + for (i = 0; i < height && ypos + i < render->height; i++) { p = pixbuf + (ypos + i) * stride + xpos * 4; - for (j = 0; j < width; j++) { + bitp = render->text_image + i * width * 4; + for (j = 0; j < width && j < render->width; j++) { p[0] = bitp[CAIRO_ARGB_A]; p[1] = bitp[CAIRO_ARGB_R]; p[2] = bitp[CAIRO_ARGB_G]; From 2ba4a56d7497a26af24ed27699ff72144bc9e4dd Mon Sep 17 00:00:00 2001 From: Jindrich Makovicka Date: Thu, 26 May 2011 10:48:05 +0200 Subject: [PATCH 23/28] textrender: Correctly negotiate with downstream instead of just using random caps Fixes bug #638897. --- ext/pango/gsttextrender.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/ext/pango/gsttextrender.c b/ext/pango/gsttextrender.c index c0129f5b36..e200758802 100644 --- a/ext/pango/gsttextrender.c +++ b/ext/pango/gsttextrender.c @@ -467,7 +467,7 @@ gst_text_render_chain (GstPad * pad, GstBuffer * inbuf) GstTextRender *render; GstFlowReturn ret; GstBuffer *outbuf; - GstCaps *caps = NULL; + GstCaps *caps = NULL, *padcaps, *peercaps; guint8 *data = GST_BUFFER_DATA (inbuf); guint size = GST_BUFFER_SIZE (inbuf); gint n; @@ -489,16 +489,21 @@ gst_text_render_chain (GstPad * pad, GstBuffer * inbuf) gst_text_render_check_argb (render); - if (!render->use_ARGB) { - caps = - gst_video_format_new_caps (GST_VIDEO_FORMAT_AYUV, render->width, - render->height, 1, 1, 1, 1); - } else { - caps = - gst_video_format_new_caps (GST_VIDEO_FORMAT_ARGB, render->width, - render->height, 1, 1, 1, 1); + peercaps = gst_pad_peer_get_caps (render->srcpad); + padcaps = gst_pad_get_caps (render->srcpad); + caps = gst_caps_intersect (padcaps, peercaps); + gst_caps_unref (padcaps); + gst_caps_unref (peercaps); + + if (!caps || gst_caps_is_empty (caps)) { + GST_ELEMENT_ERROR (render, CORE, NEGOTIATION, (NULL), (NULL)); + ret = GST_FLOW_ERROR; + goto done; } + gst_caps_truncate (caps); + gst_pad_fixate_caps (render->srcpad, caps); + if (!gst_pad_set_caps (render->srcpad, caps)) { GST_ELEMENT_ERROR (render, CORE, NEGOTIATION, (NULL), (NULL)); ret = GST_FLOW_ERROR; From c8a3f6390918e1306f33a2042f4f0668f8c7e98d Mon Sep 17 00:00:00 2001 From: Lane Brooks Date: Thu, 20 Jan 2011 00:42:39 -0700 Subject: [PATCH 24/28] textoverlay: added 'shadow' option to control whether text gets a shadow --- ext/pango/gsttextoverlay.c | 32 +++++++++++++++++++++++++++----- ext/pango/gsttextoverlay.h | 1 + 2 files changed, 28 insertions(+), 5 deletions(-) diff --git a/ext/pango/gsttextoverlay.c b/ext/pango/gsttextoverlay.c index d4775ca0c9..76b53a0169 100644 --- a/ext/pango/gsttextoverlay.c +++ b/ext/pango/gsttextoverlay.c @@ -95,6 +95,7 @@ GST_DEBUG_CATEGORY (pango_debug); #define DEFAULT_PROP_TEXT "" #define DEFAULT_PROP_SHADING FALSE +#define DEFAULT_PROP_SHADOW TRUE #define DEFAULT_PROP_VALIGNMENT GST_TEXT_OVERLAY_VALIGN_BASELINE #define DEFAULT_PROP_HALIGNMENT GST_TEXT_OVERLAY_HALIGN_CENTER #define DEFAULT_PROP_VALIGN "baseline" @@ -185,6 +186,7 @@ enum PROP_AUTO_ADJUST_SIZE, PROP_VERTICAL_RENDER, PROP_COLOR, + PROP_SHADOW, PROP_LAST }; @@ -418,6 +420,17 @@ gst_text_overlay_class_init (GstTextOverlayClass * klass) g_param_spec_boolean ("shaded-background", "shaded background", "Whether to shade the background under the text area", DEFAULT_PROP_SHADING, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); + /** + * GstTextOverlay:shadow + * + * Whether to display a shadow of each letter under the text. + * + * Since: 0.10.35 + **/ + g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_SHADOW, + g_param_spec_boolean ("shadow", "create shadow of text", + "Whether to create a shadow of the letters under the text", + DEFAULT_PROP_SHADOW, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_VALIGNMENT, g_param_spec_enum ("valignment", "vertical alignment", "Vertical alignment of the text", GST_TYPE_TEXT_OVERLAY_VALIGN, @@ -655,6 +668,7 @@ gst_text_overlay_init (GstTextOverlay * overlay, GstTextOverlayClass * klass) overlay->wrap_mode = DEFAULT_PROP_WRAP_MODE; overlay->want_shading = DEFAULT_PROP_SHADING; + overlay->want_shadow = DEFAULT_PROP_SHADOW; overlay->shading_value = DEFAULT_SHADING_VALUE; overlay->silent = DEFAULT_PROP_SILENT; overlay->wait_text = DEFAULT_PROP_WAIT_TEXT; @@ -798,6 +812,9 @@ gst_text_overlay_set_property (GObject * object, guint prop_id, case PROP_SHADING: overlay->want_shading = g_value_get_boolean (value); break; + case PROP_SHADOW: + overlay->want_shadow = g_value_get_boolean (value); + break; case PROP_XPAD: overlay->xpad = g_value_get_int (value); break; @@ -926,6 +943,9 @@ gst_text_overlay_get_property (GObject * object, guint prop_id, case PROP_SHADING: g_value_set_boolean (value, overlay->want_shading); break; + case PROP_SHADOW: + g_value_set_boolean (value, overlay->want_shadow); + break; case PROP_XPAD: g_value_set_int (value, overlay->xpad); break; @@ -1374,11 +1394,13 @@ gst_text_overlay_render_pangocairo (GstTextOverlay * overlay, */ /* draw shadow text */ - cairo_save (cr); - cairo_translate (cr, overlay->shadow_offset, overlay->shadow_offset); - cairo_set_source_rgba (cr, 0.0, 0.0, 0.0, 0.5); - pango_cairo_show_layout (cr, overlay->layout); - cairo_restore (cr); + if (overlay->want_shadow) { + cairo_save (cr); + cairo_translate (cr, overlay->shadow_offset, overlay->shadow_offset); + cairo_set_source_rgba (cr, 0.0, 0.0, 0.0, 0.5); + pango_cairo_show_layout (cr, overlay->layout); + cairo_restore (cr); + } /* draw outline text */ cairo_save (cr); diff --git a/ext/pango/gsttextoverlay.h b/ext/pango/gsttextoverlay.h index 5cd42601d4..de5b7a3892 100644 --- a/ext/pango/gsttextoverlay.h +++ b/ext/pango/gsttextoverlay.h @@ -140,6 +140,7 @@ struct _GstTextOverlay { PangoLayout *layout; gdouble shadow_offset; + gboolean want_shadow; gdouble outline_offset; guchar *text_image; gint image_width; From 548887709056ea168a48d6e2de2c32ce6a1760dc Mon Sep 17 00:00:00 2001 From: Lane Brooks Date: Thu, 20 Jan 2011 00:52:50 -0700 Subject: [PATCH 25/28] textoverlay: added 'outline-color' parameter to control whether text gets a shadow --- ext/pango/gsttextoverlay.c | 28 +++++++++++++++++++++++++++- ext/pango/gsttextoverlay.h | 2 +- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/ext/pango/gsttextoverlay.c b/ext/pango/gsttextoverlay.c index 76b53a0169..590baa9eec 100644 --- a/ext/pango/gsttextoverlay.c +++ b/ext/pango/gsttextoverlay.c @@ -114,6 +114,7 @@ GST_DEBUG_CATEGORY (pango_debug); #define DEFAULT_PROP_AUTO_ADJUST_SIZE TRUE #define DEFAULT_PROP_VERTICAL_RENDER FALSE #define DEFAULT_PROP_COLOR 0xffffffff +#define DEFAULT_PROP_OUTLINE_COLOR 0xff000000 /* make a property of me */ #define DEFAULT_SHADING_VALUE -80 @@ -187,6 +188,7 @@ enum PROP_VERTICAL_RENDER, PROP_COLOR, PROP_SHADOW, + PROP_OUTLINE_COLOR, PROP_LAST }; @@ -511,6 +513,18 @@ gst_text_overlay_class_init (GstTextOverlayClass * klass) "Color to use for text (big-endian ARGB).", 0, G_MAXUINT32, DEFAULT_PROP_COLOR, G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE | G_PARAM_STATIC_STRINGS)); + /** + * GstTextOverlay:outline-color + * + * Color of the outline of the rendered text. + * + * Since: 0.10.35 + **/ + g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_OUTLINE_COLOR, + g_param_spec_uint ("outline-color", "Text Outline Color", + "Color to use for outline the text (big-endian ARGB).", 0, + G_MAXUINT32, DEFAULT_PROP_OUTLINE_COLOR, + G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE | G_PARAM_STATIC_STRINGS)); /** * GstTextOverlay:line-alignment @@ -656,6 +670,7 @@ gst_text_overlay_init (GstTextOverlay * overlay, GstTextOverlayClass * klass) gst_text_overlay_adjust_values_with_fontdesc (overlay, desc); overlay->color = DEFAULT_PROP_COLOR; + overlay->outline_color = DEFAULT_PROP_OUTLINE_COLOR; overlay->halign = DEFAULT_PROP_HALIGNMENT; overlay->valign = DEFAULT_PROP_VALIGNMENT; overlay->xpad = DEFAULT_PROP_XPAD; @@ -896,6 +911,9 @@ gst_text_overlay_set_property (GObject * object, guint prop_id, case PROP_COLOR: overlay->color = g_value_get_uint (value); break; + case PROP_OUTLINE_COLOR: + overlay->outline_color = g_value_get_uint (value); + break; case PROP_SILENT: overlay->silent = g_value_get_boolean (value); break; @@ -991,6 +1009,9 @@ gst_text_overlay_get_property (GObject * object, guint prop_id, case PROP_COLOR: g_value_set_uint (value, overlay->color); break; + case PROP_OUTLINE_COLOR: + g_value_set_uint (value, overlay->outline_color); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -1402,9 +1423,14 @@ gst_text_overlay_render_pangocairo (GstTextOverlay * overlay, cairo_restore (cr); } + a = (overlay->outline_color >> 24) & 0xff; + r = (overlay->outline_color >> 16) & 0xff; + g = (overlay->outline_color >> 8) & 0xff; + b = (overlay->outline_color >> 0) & 0xff; + /* draw outline text */ cairo_save (cr); - cairo_set_source_rgb (cr, 0.0, 0.0, 0.0); + cairo_set_source_rgba (cr, r / 255.0, g / 255.0, b / 255.0, a / 255.0); cairo_set_line_width (cr, overlay->outline_offset); pango_cairo_layout_path (cr, overlay->layout); cairo_stroke (cr); diff --git a/ext/pango/gsttextoverlay.h b/ext/pango/gsttextoverlay.h index de5b7a3892..73a26f0b0b 100644 --- a/ext/pango/gsttextoverlay.h +++ b/ext/pango/gsttextoverlay.h @@ -136,7 +136,7 @@ struct _GstTextOverlay { gboolean want_shading; gboolean silent; gboolean wait_text; - guint color; + guint color, outline_color; PangoLayout *layout; gdouble shadow_offset; From 216258fbc275c5acdec6d91028cf4f274bb5f9f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Thu, 26 May 2011 11:41:50 +0200 Subject: [PATCH 26/28] playbin2: Let the input-selectors sync all streams to the running time This is especially needed when switching between a non-sparse and sparse video stream, see bug #537382. It also lowers the time needed for switching between streams a bit. --- gst/playback/gstplaybin2.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/gst/playback/gstplaybin2.c b/gst/playback/gstplaybin2.c index c46f1108f4..93f409bff3 100644 --- a/gst/playback/gstplaybin2.c +++ b/gst/playback/gstplaybin2.c @@ -2515,6 +2515,8 @@ pad_added_cb (GstElement * decodebin, GstPad * pad, GstSourceGroup * group) (_("Missing element '%s' - check your GStreamer installation."), "input-selector"), (NULL)); } else { + g_object_set (select->selector, "sync-streams", TRUE, NULL); + g_signal_connect (select->selector, "notify::active-pad", G_CALLBACK (selector_active_pad_changed), playbin); From 34ae792075acece5b0adf7b7b8874a0255a2800d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Thu, 26 May 2011 12:30:31 +0200 Subject: [PATCH 27/28] ximagesink: Fallback to non-XShm mode if allocating the XShm image failed Fixes bug #630442. --- sys/ximage/ximagesink.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/sys/ximage/ximagesink.c b/sys/ximage/ximagesink.c index c882bece8a..d68ec68c6d 100644 --- a/sys/ximage/ximagesink.c +++ b/sys/ximage/ximagesink.c @@ -434,16 +434,23 @@ gst_ximagesink_ximage_new (GstXImageSink * ximagesink, GstCaps * caps) ZPixmap, NULL, &ximage->SHMInfo, ximage->width, ximage->height); if (!ximage->ximage || error_caught) { g_mutex_unlock (ximagesink->x_lock); - /* Reset error handler */ + + /* Reset error flag */ error_caught = FALSE; - XSetErrorHandler (handler); - /* Push an error */ - GST_ELEMENT_ERROR (ximagesink, RESOURCE, WRITE, + + /* Push a warning */ + GST_ELEMENT_WARNING (ximagesink, RESOURCE, WRITE, ("Failed to create output image buffer of %dx%d pixels", ximage->width, ximage->height), ("could not XShmCreateImage a %dx%d image", ximage->width, ximage->height)); - goto beach; + + /* Retry without XShm */ + ximagesink->xcontext->use_xshm = FALSE; + + /* Hold X mutex again to try without XShm */ + g_mutex_lock (ximagesink->x_lock); + goto no_xshm; } /* we have to use the returned bytes_per_line for our shm size */ @@ -498,6 +505,7 @@ gst_ximagesink_ximage_new (GstXImageSink * ximagesink, GstCaps * caps) shmctl (ximage->SHMInfo.shmid, IPC_RMID, NULL); } else + no_xshm: #endif /* HAVE_XSHM */ { guint allocsize; From 7716358d045d90f43aecd7136a29c31f6ce75bdf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Thu, 26 May 2011 12:33:08 +0200 Subject: [PATCH 28/28] xvimagesink: Fallback to non-XShm mode if allocating the XShm image failed Fixes bug #630442. --- sys/xvimage/xvimagesink.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/sys/xvimage/xvimagesink.c b/sys/xvimage/xvimagesink.c index b645b35392..ba10ef0717 100644 --- a/sys/xvimage/xvimagesink.c +++ b/sys/xvimage/xvimagesink.c @@ -562,16 +562,23 @@ gst_xvimagesink_xvimage_new (GstXvImageSink * xvimagesink, GstCaps * caps) xvimage->width, xvimage->height, &xvimage->SHMInfo); if (!xvimage->xvimage || error_caught) { g_mutex_unlock (xvimagesink->x_lock); - /* Reset error handler */ + + /* Reset error flag */ error_caught = FALSE; - XSetErrorHandler (handler); - /* Push an error */ - GST_ELEMENT_ERROR (xvimagesink, RESOURCE, WRITE, + + /* Push a warning */ + GST_ELEMENT_WARNING (xvimagesink, RESOURCE, WRITE, ("Failed to create output image buffer of %dx%d pixels", xvimage->width, xvimage->height), ("could not XvShmCreateImage a %dx%d image", xvimage->width, xvimage->height)); - goto beach_unlocked; + + /* Retry without XShm */ + xvimagesink->xcontext->use_xshm = FALSE; + + /* Hold X mutex again to try without XShm */ + g_mutex_lock (xvimagesink->x_lock); + goto no_xshm; } /* we have to use the returned data_size for our shm size */ @@ -680,6 +687,7 @@ gst_xvimagesink_xvimage_new (GstXvImageSink * xvimagesink, GstCaps * caps) GST_DEBUG_OBJECT (xvimagesink, "XServer ShmAttached to 0x%x, id 0x%lx", xvimage->SHMInfo.shmid, xvimage->SHMInfo.shmseg); } else + no_xshm: #endif /* HAVE_XSHM */ { xvimage->xvimage = XvCreateImage (xvimagesink->xcontext->disp,