From b6e745d2d3690883b1d9c0e9e5f31d38a4fd967a Mon Sep 17 00:00:00 2001 From: Sebastian Dröge Date: Sun, 22 Feb 2009 12:41:53 +0100 Subject: hdv1394src: Don't use void * pointer arithmetic --- ext/raw1394/gsthdv1394src.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'ext') diff --git a/ext/raw1394/gsthdv1394src.c b/ext/raw1394/gsthdv1394src.c index cbb02136..30f59d59 100644 --- a/ext/raw1394/gsthdv1394src.c +++ b/ext/raw1394/gsthdv1394src.c @@ -317,7 +317,7 @@ gst_hdv1394src_iec61883_receive (unsigned char *data, int len, return -1; if (len == IEC61883_MPEG2_TSP_SIZE) { - memcpy (dv1394src->outdata + dv1394src->outoffset, data, len); + memcpy ((guint8 *) dv1394src->outdata + dv1394src->outoffset, data, len); dv1394src->outoffset += len; } dv1394src->frame_sequence++; -- cgit From dfa627da30dd44e170f3249ff3bdda333ea1edf1 Mon Sep 17 00:00:00 2001 From: Sebastian Dröge Date: Sun, 22 Feb 2009 18:08:59 +0100 Subject: pulsemixer: Don't use g_atomic_int_(get|set) for accessing the mixer track flags g_atomic_int_(get|set) only work on ints and the flags are an enum (which on most architectures is stored as an int). Also the way the flags were accessed atomically would still leave a possible race condition and we don't do it in any other mixer track implementation, let alone at any other place where an integer could be changed from different threads. Removing the g_atomic_int_(get|set) will only introduce a new race condition on architectures where integers could be half-written while reading them which shouldn't be the case for any modern architecture and if we really care about this we need to use g_atomic_int_(get|set) at many other places too. Apart from that g_atomic_int_(set|get) will result in aliasing warnings if their argument is explicitely casted to an int *. Fixes bug #571153. --- ext/pulse/pulsemixerctrl.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) (limited to 'ext') diff --git a/ext/pulse/pulsemixerctrl.c b/ext/pulse/pulsemixerctrl.c index 41b68cfc..ae807c66 100644 --- a/ext/pulse/pulsemixerctrl.c +++ b/ext/pulse/pulsemixerctrl.c @@ -93,10 +93,11 @@ gst_pulsemixer_ctrl_sink_info_cb (pa_context * context, const pa_sink_info * i, c->type = GST_PULSEMIXER_SINK; if (c->track) { - int i = g_atomic_int_get ((gint *) & c->track->flags); + GstMixerTrackFlags flags = c->track->flags; - i = (i & ~GST_MIXER_TRACK_MUTE) | (c->muted ? GST_MIXER_TRACK_MUTE : 0); - g_atomic_int_set ((gint *) & c->track->flags, i); + flags = + (flags & ~GST_MIXER_TRACK_MUTE) | (c->muted ? GST_MIXER_TRACK_MUTE : 0); + c->track->flags = flags; } c->operation_success = 1; @@ -142,10 +143,11 @@ gst_pulsemixer_ctrl_source_info_cb (pa_context * context, c->type = GST_PULSEMIXER_SOURCE; if (c->track) { - int i = g_atomic_int_get ((gint *) & c->track->flags); + GstMixerTrackFlags flags = c->track->flags; - i = (i & ~GST_MIXER_TRACK_MUTE) | (c->muted ? GST_MIXER_TRACK_MUTE : 0); - g_atomic_int_set ((gint *) & c->track->flags, i); + flags = + (flags & ~GST_MIXER_TRACK_MUTE) | (c->muted ? GST_MIXER_TRACK_MUTE : 0); + c->track->flags = flags; } c->operation_success = 1; @@ -572,10 +574,11 @@ gst_pulsemixer_ctrl_set_mute (GstPulseMixerCtrl * c, GstMixerTrack * track, c->update_mute = TRUE; if (c->track) { - int i = g_atomic_int_get ((gint *) & c->track->flags); + GstMixerTrackFlags flags = c->track->flags; - i = (i & ~GST_MIXER_TRACK_MUTE) | (c->muted ? GST_MIXER_TRACK_MUTE : 0); - g_atomic_int_set ((gint *) & c->track->flags, i); + flags = + (flags & ~GST_MIXER_TRACK_MUTE) | (c->muted ? GST_MIXER_TRACK_MUTE : 0); + c->track->flags = flags; } restart_time_event (c); -- cgit From ef33cf891f7a9f97f178169adb87aa3695bf9b2b Mon Sep 17 00:00:00 2001 From: Sjoerd Simons Date: Sun, 22 Feb 2009 19:30:32 +0100 Subject: gconfvideo(src|sink): Disconnect GConf notifications Fixes bug #571321. --- ext/gconf/gstgconfvideosink.c | 5 ++++- ext/gconf/gstgconfvideosink.h | 3 +++ ext/gconf/gstgconfvideosrc.c | 5 ++++- ext/gconf/gstgconfvideosrc.h | 3 +++ 4 files changed, 14 insertions(+), 2 deletions(-) (limited to 'ext') diff --git a/ext/gconf/gstgconfvideosink.c b/ext/gconf/gstgconfvideosink.c index 4090cc91..1b05fd37 100644 --- a/ext/gconf/gstgconfvideosink.c +++ b/ext/gconf/gstgconfvideosink.c @@ -122,7 +122,7 @@ gst_gconf_video_sink_init (GstGConfVideoSink * sink, sink->client = gconf_client_get_default (); gconf_client_add_dir (sink->client, GST_GCONF_DIR, GCONF_CLIENT_PRELOAD_RECURSIVE, NULL); - gconf_client_notify_add (sink->client, + sink->notify_id = gconf_client_notify_add (sink->client, GST_GCONF_DIR "/" GST_GCONF_VIDEOSINK_KEY, cb_toggle_element, sink, NULL, NULL); } @@ -133,6 +133,9 @@ gst_gconf_video_sink_dispose (GObject * object) GstGConfVideoSink *sink = GST_GCONF_VIDEO_SINK (object); if (sink->client) { + if (sink->notify_id != 0) + gconf_client_notify_remove (sink->client, sink->notify_id); + g_object_unref (G_OBJECT (sink->client)); sink->client = NULL; } diff --git a/ext/gconf/gstgconfvideosink.h b/ext/gconf/gstgconfvideosink.h index 8f69c81a..2461e652 100644 --- a/ext/gconf/gstgconfvideosink.h +++ b/ext/gconf/gstgconfvideosink.h @@ -46,6 +46,9 @@ typedef struct _GstGConfVideoSink { GstElement *kid; GstPad *pad; + /* gconf notify id */ + guint notify_id; + /* Current gconf string */ gchar *gconf_str; } GstGConfVideoSink; diff --git a/ext/gconf/gstgconfvideosrc.c b/ext/gconf/gstgconfvideosrc.c index fe177d86..6192d73d 100644 --- a/ext/gconf/gstgconfvideosrc.c +++ b/ext/gconf/gstgconfvideosrc.c @@ -124,7 +124,7 @@ gst_gconf_video_src_init (GstGConfVideoSrc * src, src->client = gconf_client_get_default (); gconf_client_add_dir (src->client, GST_GCONF_DIR, GCONF_CLIENT_PRELOAD_RECURSIVE, NULL); - gconf_client_notify_add (src->client, + src->notify_id = gconf_client_notify_add (src->client, GST_GCONF_DIR "/" GST_GCONF_VIDEOSRC_KEY, cb_toggle_element, src, NULL, NULL); } @@ -135,6 +135,9 @@ gst_gconf_video_src_dispose (GObject * object) GstGConfVideoSrc *src = GST_GCONF_VIDEO_SRC (object); if (src->client) { + if (src->notify_id != 0) + gconf_client_notify_remove (src->client, src->notify_id); + g_object_unref (G_OBJECT (src->client)); src->client = NULL; } diff --git a/ext/gconf/gstgconfvideosrc.h b/ext/gconf/gstgconfvideosrc.h index 6f64e6d1..4a2c8cdd 100644 --- a/ext/gconf/gstgconfvideosrc.h +++ b/ext/gconf/gstgconfvideosrc.h @@ -40,6 +40,9 @@ typedef struct _GstGConfVideoSrc { GstElement *kid; GstPad *pad; + /* gconf key notification id */ + guint notify_id; + /* Current gconf string */ gchar *gconf_str; } GstGConfVideoSrc; -- cgit From 7e64f1d1069179f5b5f067595ed27cf9c1d8f6ab Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Mon, 23 Feb 2009 15:48:41 +0100 Subject: Some cleanups Remove some unused variables. Avoid a useless _resync call. Correctly use a gboolean. --- ext/jpeg/gstjpegenc.c | 5 +---- ext/jpeg/gstjpegenc.h | 1 - 2 files changed, 1 insertion(+), 5 deletions(-) (limited to 'ext') diff --git a/ext/jpeg/gstjpegenc.c b/ext/jpeg/gstjpegenc.c index 908c7e00..df4b416f 100644 --- a/ext/jpeg/gstjpegenc.c +++ b/ext/jpeg/gstjpegenc.c @@ -339,9 +339,8 @@ gst_jpegenc_setcaps (GstPad * pad, GstCaps * caps) ret = gst_pad_set_caps (jpegenc->srcpad, othercaps); gst_caps_unref (othercaps); - if (GST_PAD_LINK_SUCCESSFUL (ret)) { + if (ret) gst_jpegenc_resync (jpegenc); - } gst_object_unref (jpegenc); @@ -411,7 +410,6 @@ gst_jpegenc_resync (GstJpegEnc * jpegenc) jpeg_suppress_tables (&jpegenc->cinfo, TRUE); //jpeg_suppress_tables(&jpegenc->cinfo, FALSE); - jpegenc->buffer = NULL; GST_DEBUG_OBJECT (jpegenc, "resync done"); } @@ -557,7 +555,6 @@ gst_jpegenc_change_state (GstElement * element, GstStateChange transition) filter->line[0] = NULL; filter->line[1] = NULL; filter->line[2] = NULL; - gst_jpegenc_resync (filter); break; default: break; diff --git a/ext/jpeg/gstjpegenc.h b/ext/jpeg/gstjpegenc.h index 719b88b0..99341569 100644 --- a/ext/jpeg/gstjpegenc.h +++ b/ext/jpeg/gstjpegenc.h @@ -57,7 +57,6 @@ struct _GstJpegEnc { gint height; /* the video buffer */ gint bufsize; - GstBuffer *buffer; guint row_stride; /* the jpeg line buffer */ guchar **line[3]; -- cgit From 5da35b1ee243f25c17dc9a5350ce6b56ed174031 Mon Sep 17 00:00:00 2001 From: Sebastian Dröge Date: Tue, 24 Feb 2009 14:55:28 +0100 Subject: gconf: Rename gconf.[ch] to gstgconf.[ch] to prevent name conflicts --- ext/gconf/Makefile.am | 4 +- ext/gconf/gconf.c | 304 ------------------------------------------- ext/gconf/gconf.h | 66 ---------- ext/gconf/gstgconf.c | 304 +++++++++++++++++++++++++++++++++++++++++++ ext/gconf/gstgconf.h | 66 ++++++++++ ext/gconf/gstgconfelements.h | 2 +- 6 files changed, 373 insertions(+), 373 deletions(-) delete mode 100644 ext/gconf/gconf.c delete mode 100644 ext/gconf/gconf.h create mode 100644 ext/gconf/gstgconf.c create mode 100644 ext/gconf/gstgconf.h (limited to 'ext') diff --git a/ext/gconf/Makefile.am b/ext/gconf/Makefile.am index 4f6f63ad..330cf29f 100644 --- a/ext/gconf/Makefile.am +++ b/ext/gconf/Makefile.am @@ -7,7 +7,7 @@ libgstgconfelements_la_SOURCES = \ gstgconfvideosink.c \ gstgconfvideosrc.c \ gstswitchsink.c \ - gconf.c + gstgconf.c DIR_CFLAGS = -DGST_GCONF_DIR=\"/system/gstreamer/@GST_MAJORMINOR@\" libgstgconfelements_la_CFLAGS = $(GST_CFLAGS) $(GCONF_CFLAGS) $(DIR_CFLAGS) @@ -22,4 +22,4 @@ noinst_HEADERS = \ gstgconfvideosink.h \ gstgconfvideosrc.h \ gstswitchsink.h \ - gconf.h + gstgconf.h diff --git a/ext/gconf/gconf.c b/ext/gconf/gconf.c deleted file mode 100644 index e7214e2d..00000000 --- a/ext/gconf/gconf.c +++ /dev/null @@ -1,304 +0,0 @@ -/* GStreamer - * nf_get_default_audio_sink - * Copyright (C) <2002> Thomas Vander Stichele - * Copyright (C) <2006> Jürg Billeter - * - * 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., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -/* - * this library handles interaction with GConf - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include - -#include "gconf.h" -#include "gstgconfelements.h" /* for debug category */ - -#ifndef GST_GCONF_DIR -#error "GST_GCONF_DIR is not defined !" -#endif - -static GConfClient *_gst_gconf_client = NULL; /* GConf connection */ - - -/* internal functions */ - -static GConfClient * -gst_gconf_get_client (void) -{ - if (!_gst_gconf_client) - _gst_gconf_client = gconf_client_get_default (); - - return _gst_gconf_client; -} - -/* external functions */ - -/** - * gst_gconf_get_string: - * @key: a #gchar corresponding to the key you want to get. - * - * Get GConf key @key's string value. - * - * Returns: a newly allocated #gchar string containing @key's value, - * or NULL in the case of an error.. - */ -gchar * -gst_gconf_get_string (const gchar * key) -{ - GError *error = NULL; - gchar *value = NULL; - gchar *full_key; - - if (!g_str_has_prefix (key, GST_GCONF_DIR)) - full_key = g_strdup_printf ("%s/%s", GST_GCONF_DIR, key); - else - full_key = g_strdup (key); - - value = gconf_client_get_string (gst_gconf_get_client (), full_key, &error); - g_free (full_key); - - if (error) { - g_warning ("gst_gconf_get_string: error: %s\n", error->message); - g_error_free (error); - return NULL; - } - - return value; -} - -const gchar * -gst_gconf_get_key_for_sink_profile (GstGConfProfile profile) -{ - switch (profile) { - case GCONF_PROFILE_SOUNDS: - return GST_GCONF_DIR "/" GST_GCONF_AUDIOSINK_KEY; - case GCONF_PROFILE_MUSIC: - return GST_GCONF_DIR "/" GST_GCONF_MUSIC_AUDIOSINK_KEY; - case GCONF_PROFILE_CHAT: - return GST_GCONF_DIR "/" GST_GCONF_CHAT_AUDIOSINK_KEY; - default: - break; - } - - g_return_val_if_reached (GST_GCONF_DIR "/" GST_GCONF_AUDIOSINK_KEY); -} - -/** - * gst_gconf_set_string: - * @key: a #gchar corresponding to the key you want to set. - * @value: a #gchar containing key value. - * - * Set GConf key @key to string value @value. - */ -void -gst_gconf_set_string (const gchar * key, const gchar * value) -{ - GError *error = NULL; - gchar *full_key; - - if (!g_str_has_prefix (key, GST_GCONF_DIR)) - full_key = g_strdup_printf ("%s/%s", GST_GCONF_DIR, key); - else - full_key = g_strdup (key); - - gconf_client_set_string (gst_gconf_get_client (), full_key, value, &error); - if (error) { - GST_ERROR ("gst_gconf_set_string: error: %s\n", error->message); - g_error_free (error); - } - g_free (full_key); -} - -/** - * gst_gconf_render_bin_from_key: - * @key: a #gchar string corresponding to a GConf key. - * - * Render bin from GConf key @key. - * - * Returns: a #GstElement containing the rendered bin. - */ -GstElement * -gst_gconf_render_bin_from_key (const gchar * key) -{ - GstElement *bin = NULL; - gchar *value; - - value = gst_gconf_get_string (key); - - GST_LOG ("%s = %s", GST_STR_NULL (key), GST_STR_NULL (value)); - - if (value) { - GError *err = NULL; - - bin = gst_parse_bin_from_description (value, TRUE, &err); - if (err) { - GST_ERROR ("gconf: error creating bin '%s': %s", value, err->message); - g_error_free (err); - } - - g_free (value); - } - return bin; -} - -/** - * gst_gconf_render_bin_with_default: - * @bin: a #gchar string describing the pipeline to construct. - * @default_sink: an element to use as default if the given pipeline fails to construct. - * - * Render bin from description @bin using @default_sink element as a fallback. - * - * Returns: a #GstElement containing the rendered bin. - */ -GstElement * -gst_gconf_render_bin_with_default (const gchar * bin, - const gchar * default_sink) -{ - GstElement *ret = NULL; - GError *err = NULL; - - if (bin != NULL) - ret = gst_parse_bin_from_description (bin, TRUE, &err); - - if (ret == NULL || err != NULL) { - if (err) { - GST_DEBUG ("Could not create audio sink from GConf settings: %s", - err->message); - g_error_free (err); - } else { - GST_DEBUG ("Could not create audio sink from GConf settings"); - } - - ret = gst_element_factory_make (default_sink, NULL); - - if (!ret) - g_warning - ("Could not build GConf audio sink and the replacement %s doesn't work", - DEFAULT_AUDIOSINK); - } - - return ret; -} - -/** - * gst_gconf_get_default_video_sink: - * - * Render video output bin from GStreamer GConf key : "default/videosink". - * If key is invalid, the default video sink for the platform is used - * (typically xvimagesink or ximagesink). - * - * Returns: a #GstElement containing the video output bin, or NULL if - * everything failed. - */ -GstElement * -gst_gconf_get_default_video_sink (void) -{ - GstElement *ret = gst_gconf_render_bin_from_key (GST_GCONF_VIDEOSINK_KEY); - - if (!ret) { - ret = gst_element_factory_make (DEFAULT_VIDEOSINK, NULL); - - if (!ret) - g_warning ("No GConf default video sink key and %s doesn't work", - DEFAULT_VIDEOSINK); - } - - return ret; -} - -/** - * gst_gconf_get_default_audio_src: - * - * Render audio acquisition bin from GStreamer GConf key : "default/audiosrc". - * If key is invalid, the default audio source for the plaform is used. - * (typically osssrc or sunaudiosrc). - * - * Returns: a #GstElement containing the audio source bin, or NULL if - * everything failed. - */ -GstElement * -gst_gconf_get_default_audio_src (void) -{ - GstElement *ret = gst_gconf_render_bin_from_key (GST_GCONF_AUDIOSRC_KEY); - - if (!ret) { - ret = gst_element_factory_make (DEFAULT_AUDIOSRC, NULL); - - if (!ret) - g_warning ("No GConf default audio src key and %s doesn't work", - DEFAULT_AUDIOSRC); - } - - return ret; -} - -/** - * gst_gconf_get_default_video_src: - * - * Render video acquisition bin from GStreamer GConf key : - * "default/videosrc". If key is invalid, the default video source - * for the platform is used (typically videotestsrc). - * - * Returns: a #GstElement containing the video source bin, or NULL if - * everything failed. - */ -GstElement * -gst_gconf_get_default_video_src (void) -{ - GstElement *ret = gst_gconf_render_bin_from_key (GST_GCONF_VIDEOSRC_KEY); - - if (!ret) { - ret = gst_element_factory_make (DEFAULT_VIDEOSRC, NULL); - - if (!ret) - g_warning ("No GConf default video src key and %s doesn't work", - DEFAULT_VIDEOSRC); - } - - return ret; -} - -/** - * gst_gconf_get_default_visualization_element: - * - * Render visualization bin from GStreamer GConf key : "default/visualization". - * If key is invalid, the default visualization element is used. - * - * Returns: a #GstElement containing the visualization bin, or NULL if - * everything failed. - */ -GstElement * -gst_gconf_get_default_visualization_element (void) -{ - GstElement *ret = gst_gconf_render_bin_from_key ("default/visualization"); - - if (!ret) { - ret = gst_element_factory_make (DEFAULT_VISUALIZER, NULL); - - if (!ret) - g_warning - ("No GConf default visualization plugin key and %s doesn't work", - DEFAULT_VISUALIZER); - } - - return ret; -} diff --git a/ext/gconf/gconf.h b/ext/gconf/gconf.h deleted file mode 100644 index b1153e93..00000000 --- a/ext/gconf/gconf.h +++ /dev/null @@ -1,66 +0,0 @@ -/* GStreamer - * Copyright (C) <2002> Thomas Vander Stichele - * Copyright (C) <2006> Jürg Billeter - * - * 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., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#ifndef GST_GCONF_H -#define GST_GCONF_H - -/* - * this library handles interaction with GConf - */ - -#include -#include - -G_BEGIN_DECLS - -#define GST_GCONF_AUDIOSRC_KEY "default/audiosrc" -#define GST_GCONF_AUDIOSINK_KEY "default/audiosink" -#define GST_GCONF_MUSIC_AUDIOSINK_KEY "default/musicaudiosink" -#define GST_GCONF_CHAT_AUDIOSINK_KEY "default/chataudiosink" -#define GST_GCONF_VIDEOSRC_KEY "default/videosrc" -#define GST_GCONF_VIDEOSINK_KEY "default/videosink" - -typedef enum -{ - GCONF_PROFILE_SOUNDS, - GCONF_PROFILE_MUSIC, - GCONF_PROFILE_CHAT, - GCONF_PROFILE_NONE /* Internal value only */ -} GstGConfProfile; - -gchar * gst_gconf_get_string (const gchar *key); -void gst_gconf_set_string (const gchar *key, - const gchar *value); - -const gchar * gst_gconf_get_key_for_sink_profile (GstGConfProfile profile); - -GstElement * gst_gconf_render_bin_from_key (const gchar *key); -GstElement * gst_gconf_render_bin_with_default (const gchar *bin, - const gchar *default_sink); - -GstElement * gst_gconf_get_default_video_sink (void); -GstElement * gst_gconf_get_default_audio_sink (int profile); -GstElement * gst_gconf_get_default_video_src (void); -GstElement * gst_gconf_get_default_audio_src (void); -GstElement * gst_gconf_get_default_visualization_element (void); - -G_END_DECLS - -#endif /* GST_GCONF_H */ diff --git a/ext/gconf/gstgconf.c b/ext/gconf/gstgconf.c new file mode 100644 index 00000000..eee80c9d --- /dev/null +++ b/ext/gconf/gstgconf.c @@ -0,0 +1,304 @@ +/* GStreamer + * nf_get_default_audio_sink + * Copyright (C) <2002> Thomas Vander Stichele + * Copyright (C) <2006> Jürg Billeter + * + * 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., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +/* + * this library handles interaction with GConf + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include + +#include "gstgconf.h" +#include "gstgconfelements.h" /* for debug category */ + +#ifndef GST_GCONF_DIR +#error "GST_GCONF_DIR is not defined !" +#endif + +static GConfClient *_gst_gconf_client = NULL; /* GConf connection */ + + +/* internal functions */ + +static GConfClient * +gst_gconf_get_client (void) +{ + if (!_gst_gconf_client) + _gst_gconf_client = gconf_client_get_default (); + + return _gst_gconf_client; +} + +/* external functions */ + +/** + * gst_gconf_get_string: + * @key: a #gchar corresponding to the key you want to get. + * + * Get GConf key @key's string value. + * + * Returns: a newly allocated #gchar string containing @key's value, + * or NULL in the case of an error.. + */ +gchar * +gst_gconf_get_string (const gchar * key) +{ + GError *error = NULL; + gchar *value = NULL; + gchar *full_key; + + if (!g_str_has_prefix (key, GST_GCONF_DIR)) + full_key = g_strdup_printf ("%s/%s", GST_GCONF_DIR, key); + else + full_key = g_strdup (key); + + value = gconf_client_get_string (gst_gconf_get_client (), full_key, &error); + g_free (full_key); + + if (error) { + g_warning ("gst_gconf_get_string: error: %s\n", error->message); + g_error_free (error); + return NULL; + } + + return value; +} + +const gchar * +gst_gconf_get_key_for_sink_profile (GstGConfProfile profile) +{ + switch (profile) { + case GCONF_PROFILE_SOUNDS: + return GST_GCONF_DIR "/" GST_GCONF_AUDIOSINK_KEY; + case GCONF_PROFILE_MUSIC: + return GST_GCONF_DIR "/" GST_GCONF_MUSIC_AUDIOSINK_KEY; + case GCONF_PROFILE_CHAT: + return GST_GCONF_DIR "/" GST_GCONF_CHAT_AUDIOSINK_KEY; + default: + break; + } + + g_return_val_if_reached (GST_GCONF_DIR "/" GST_GCONF_AUDIOSINK_KEY); +} + +/** + * gst_gconf_set_string: + * @key: a #gchar corresponding to the key you want to set. + * @value: a #gchar containing key value. + * + * Set GConf key @key to string value @value. + */ +void +gst_gconf_set_string (const gchar * key, const gchar * value) +{ + GError *error = NULL; + gchar *full_key; + + if (!g_str_has_prefix (key, GST_GCONF_DIR)) + full_key = g_strdup_printf ("%s/%s", GST_GCONF_DIR, key); + else + full_key = g_strdup (key); + + gconf_client_set_string (gst_gconf_get_client (), full_key, value, &error); + if (error) { + GST_ERROR ("gst_gconf_set_string: error: %s\n", error->message); + g_error_free (error); + } + g_free (full_key); +} + +/** + * gst_gconf_render_bin_from_key: + * @key: a #gchar string corresponding to a GConf key. + * + * Render bin from GConf key @key. + * + * Returns: a #GstElement containing the rendered bin. + */ +GstElement * +gst_gconf_render_bin_from_key (const gchar * key) +{ + GstElement *bin = NULL; + gchar *value; + + value = gst_gconf_get_string (key); + + GST_LOG ("%s = %s", GST_STR_NULL (key), GST_STR_NULL (value)); + + if (value) { + GError *err = NULL; + + bin = gst_parse_bin_from_description (value, TRUE, &err); + if (err) { + GST_ERROR ("gconf: error creating bin '%s': %s", value, err->message); + g_error_free (err); + } + + g_free (value); + } + return bin; +} + +/** + * gst_gconf_render_bin_with_default: + * @bin: a #gchar string describing the pipeline to construct. + * @default_sink: an element to use as default if the given pipeline fails to construct. + * + * Render bin from description @bin using @default_sink element as a fallback. + * + * Returns: a #GstElement containing the rendered bin. + */ +GstElement * +gst_gconf_render_bin_with_default (const gchar * bin, + const gchar * default_sink) +{ + GstElement *ret = NULL; + GError *err = NULL; + + if (bin != NULL) + ret = gst_parse_bin_from_description (bin, TRUE, &err); + + if (ret == NULL || err != NULL) { + if (err) { + GST_DEBUG ("Could not create audio sink from GConf settings: %s", + err->message); + g_error_free (err); + } else { + GST_DEBUG ("Could not create audio sink from GConf settings"); + } + + ret = gst_element_factory_make (default_sink, NULL); + + if (!ret) + g_warning + ("Could not build GConf audio sink and the replacement %s doesn't work", + DEFAULT_AUDIOSINK); + } + + return ret; +} + +/** + * gst_gconf_get_default_video_sink: + * + * Render video output bin from GStreamer GConf key : "default/videosink". + * If key is invalid, the default video sink for the platform is used + * (typically xvimagesink or ximagesink). + * + * Returns: a #GstElement containing the video output bin, or NULL if + * everything failed. + */ +GstElement * +gst_gconf_get_default_video_sink (void) +{ + GstElement *ret = gst_gconf_render_bin_from_key (GST_GCONF_VIDEOSINK_KEY); + + if (!ret) { + ret = gst_element_factory_make (DEFAULT_VIDEOSINK, NULL); + + if (!ret) + g_warning ("No GConf default video sink key and %s doesn't work", + DEFAULT_VIDEOSINK); + } + + return ret; +} + +/** + * gst_gconf_get_default_audio_src: + * + * Render audio acquisition bin from GStreamer GConf key : "default/audiosrc". + * If key is invalid, the default audio source for the plaform is used. + * (typically osssrc or sunaudiosrc). + * + * Returns: a #GstElement containing the audio source bin, or NULL if + * everything failed. + */ +GstElement * +gst_gconf_get_default_audio_src (void) +{ + GstElement *ret = gst_gconf_render_bin_from_key (GST_GCONF_AUDIOSRC_KEY); + + if (!ret) { + ret = gst_element_factory_make (DEFAULT_AUDIOSRC, NULL); + + if (!ret) + g_warning ("No GConf default audio src key and %s doesn't work", + DEFAULT_AUDIOSRC); + } + + return ret; +} + +/** + * gst_gconf_get_default_video_src: + * + * Render video acquisition bin from GStreamer GConf key : + * "default/videosrc". If key is invalid, the default video source + * for the platform is used (typically videotestsrc). + * + * Returns: a #GstElement containing the video source bin, or NULL if + * everything failed. + */ +GstElement * +gst_gconf_get_default_video_src (void) +{ + GstElement *ret = gst_gconf_render_bin_from_key (GST_GCONF_VIDEOSRC_KEY); + + if (!ret) { + ret = gst_element_factory_make (DEFAULT_VIDEOSRC, NULL); + + if (!ret) + g_warning ("No GConf default video src key and %s doesn't work", + DEFAULT_VIDEOSRC); + } + + return ret; +} + +/** + * gst_gconf_get_default_visualization_element: + * + * Render visualization bin from GStreamer GConf key : "default/visualization". + * If key is invalid, the default visualization element is used. + * + * Returns: a #GstElement containing the visualization bin, or NULL if + * everything failed. + */ +GstElement * +gst_gconf_get_default_visualization_element (void) +{ + GstElement *ret = gst_gconf_render_bin_from_key ("default/visualization"); + + if (!ret) { + ret = gst_element_factory_make (DEFAULT_VISUALIZER, NULL); + + if (!ret) + g_warning + ("No GConf default visualization plugin key and %s doesn't work", + DEFAULT_VISUALIZER); + } + + return ret; +} diff --git a/ext/gconf/gstgconf.h b/ext/gconf/gstgconf.h new file mode 100644 index 00000000..b1153e93 --- /dev/null +++ b/ext/gconf/gstgconf.h @@ -0,0 +1,66 @@ +/* GStreamer + * Copyright (C) <2002> Thomas Vander Stichele + * Copyright (C) <2006> Jürg Billeter + * + * 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., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#ifndef GST_GCONF_H +#define GST_GCONF_H + +/* + * this library handles interaction with GConf + */ + +#include +#include + +G_BEGIN_DECLS + +#define GST_GCONF_AUDIOSRC_KEY "default/audiosrc" +#define GST_GCONF_AUDIOSINK_KEY "default/audiosink" +#define GST_GCONF_MUSIC_AUDIOSINK_KEY "default/musicaudiosink" +#define GST_GCONF_CHAT_AUDIOSINK_KEY "default/chataudiosink" +#define GST_GCONF_VIDEOSRC_KEY "default/videosrc" +#define GST_GCONF_VIDEOSINK_KEY "default/videosink" + +typedef enum +{ + GCONF_PROFILE_SOUNDS, + GCONF_PROFILE_MUSIC, + GCONF_PROFILE_CHAT, + GCONF_PROFILE_NONE /* Internal value only */ +} GstGConfProfile; + +gchar * gst_gconf_get_string (const gchar *key); +void gst_gconf_set_string (const gchar *key, + const gchar *value); + +const gchar * gst_gconf_get_key_for_sink_profile (GstGConfProfile profile); + +GstElement * gst_gconf_render_bin_from_key (const gchar *key); +GstElement * gst_gconf_render_bin_with_default (const gchar *bin, + const gchar *default_sink); + +GstElement * gst_gconf_get_default_video_sink (void); +GstElement * gst_gconf_get_default_audio_sink (int profile); +GstElement * gst_gconf_get_default_video_src (void); +GstElement * gst_gconf_get_default_audio_src (void); +GstElement * gst_gconf_get_default_visualization_element (void); + +G_END_DECLS + +#endif /* GST_GCONF_H */ diff --git a/ext/gconf/gstgconfelements.h b/ext/gconf/gstgconfelements.h index 1b3efe3c..872b2f2d 100644 --- a/ext/gconf/gstgconfelements.h +++ b/ext/gconf/gstgconfelements.h @@ -20,7 +20,7 @@ #ifndef __GST_GCONF_ELEMENTS_H__ #define __GST_GCONF_ELEMENTS_H__ -#include +#include "gstgconf.h" GST_DEBUG_CATEGORY_EXTERN (gconf_debug); #define GST_CAT_DEFAULT gconf_debug -- cgit From 1a2bd6c617dff728a93801d98aeb81d1c8bd5c07 Mon Sep 17 00:00:00 2001 From: Tim-Philipp Müller Date: Thu, 19 Feb 2009 20:14:10 +0000 Subject: jpegenc: error out instead of crashing if no caps have been set Don't crash if we receive a buffer without caps. Fixes #572413. --- ext/jpeg/gstjpegenc.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'ext') diff --git a/ext/jpeg/gstjpegenc.c b/ext/jpeg/gstjpegenc.c index df4b416f..5edb11f1 100644 --- a/ext/jpeg/gstjpegenc.c +++ b/ext/jpeg/gstjpegenc.c @@ -427,6 +427,9 @@ gst_jpegenc_chain (GstPad * pad, GstBuffer * buf) jpegenc = GST_JPEGENC (GST_OBJECT_PARENT (pad)); + if (G_UNLIKELY (jpegenc->width <= 0 || jpegenc->height <= 0)) + goto not_negotiated; + data = GST_BUFFER_DATA (buf); size = GST_BUFFER_SIZE (buf); @@ -495,6 +498,14 @@ done: gst_buffer_unref (buf); return ret; + +/* ERRORS */ +not_negotiated: + { + GST_WARNING_OBJECT (jpegenc, "no input format set (no caps on buffer)"); + ret = GST_FLOW_NOT_NEGOTIATED; + goto done; + } } static void @@ -572,6 +583,8 @@ gst_jpegenc_change_state (GstElement * element, GstStateChange transition) filter->line[0] = NULL; filter->line[1] = NULL; filter->line[2] = NULL; + filter->width = -1; + filter->height = -1; break; default: break; -- cgit From b264c990747bbe837caf89bad1b6c4924750e9fd Mon Sep 17 00:00:00 2001 From: David Schleef Date: Wed, 25 Feb 2009 19:58:29 -0800 Subject: dvdec: Add interlacing info to caps and buffers --- ext/dv/gstdvdec.c | 10 +++++++++- ext/dv/gstdvdec.h | 1 + 2 files changed, 10 insertions(+), 1 deletion(-) (limited to 'ext') diff --git a/ext/dv/gstdvdec.c b/ext/dv/gstdvdec.c index ade97966..fad43be2 100644 --- a/ext/dv/gstdvdec.c +++ b/ext/dv/gstdvdec.c @@ -43,6 +43,7 @@ #endif #include #include +#include #include "gstdvdec.h" @@ -328,7 +329,7 @@ gst_dvdec_src_negotiate (GstDVDec * dvdec) "framerate", GST_TYPE_FRACTION, dvdec->framerate_numerator, dvdec->framerate_denominator, "pixel-aspect-ratio", GST_TYPE_FRACTION, dvdec->par_x, - dvdec->par_y, NULL); + dvdec->par_y, "interlaced", G_TYPE_BOOLEAN, dvdec->interlaced, NULL); gst_pad_set_caps (dvdec->srcpad, othercaps); gst_caps_unref (othercaps); @@ -434,6 +435,7 @@ gst_dvdec_chain (GstPad * pad, GstBuffer * buf) dvdec->height = (dvdec->PAL ? PAL_HEIGHT : NTSC_HEIGHT); + dvdec->interlaced = !dv_is_progressive (dvdec->decoder); /* negotiate if not done yet */ if (!dvdec->src_negotiated) { @@ -466,6 +468,12 @@ gst_dvdec_chain (GstPad * pad, GstBuffer * buf) dv_decode_full_frame (dvdec->decoder, inframe, e_dv_color_yuv, outframe_ptrs, outframe_pitches); + if (dvdec->PAL) { + GST_BUFFER_FLAG_UNSET (outbuf, GST_VIDEO_BUFFER_TFF); + } else { + GST_BUFFER_FLAG_SET (outbuf, GST_VIDEO_BUFFER_TFF); + } + GST_BUFFER_OFFSET (outbuf) = GST_BUFFER_OFFSET (buf); GST_BUFFER_OFFSET_END (outbuf) = GST_BUFFER_OFFSET_END (buf); GST_BUFFER_TIMESTAMP (outbuf) = cstart; diff --git a/ext/dv/gstdvdec.h b/ext/dv/gstdvdec.h index 5f166a14..de8481d9 100644 --- a/ext/dv/gstdvdec.h +++ b/ext/dv/gstdvdec.h @@ -57,6 +57,7 @@ struct _GstDVDec { gint quality; gboolean PAL; + gboolean interlaced; gboolean wide; gint frame_len; -- cgit From 9f3ad53ca868ce4e33efac104d77391a3a0cf57b Mon Sep 17 00:00:00 2001 From: David Schleef Date: Fri, 27 Feb 2009 23:25:32 -0800 Subject: Fix the field dominance PAL is TFF, NTSC is BFF. Some day I will learn to keep this straight. --- ext/dv/gstdvdec.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'ext') diff --git a/ext/dv/gstdvdec.c b/ext/dv/gstdvdec.c index fad43be2..550b99d1 100644 --- a/ext/dv/gstdvdec.c +++ b/ext/dv/gstdvdec.c @@ -469,9 +469,9 @@ gst_dvdec_chain (GstPad * pad, GstBuffer * buf) e_dv_color_yuv, outframe_ptrs, outframe_pitches); if (dvdec->PAL) { - GST_BUFFER_FLAG_UNSET (outbuf, GST_VIDEO_BUFFER_TFF); - } else { GST_BUFFER_FLAG_SET (outbuf, GST_VIDEO_BUFFER_TFF); + } else { + GST_BUFFER_FLAG_UNSET (outbuf, GST_VIDEO_BUFFER_TFF); } GST_BUFFER_OFFSET (outbuf) = GST_BUFFER_OFFSET (buf); -- cgit