From 18e7091238e1a692f7a1d5b4cadc5089f04e1e2c Mon Sep 17 00:00:00 2001 From: Lasse Laukkanen Date: Tue, 23 Jun 2009 13:01:13 +0300 Subject: camerabin: fix setting mute when video bin elements haven't been created --- gst/camerabin/camerabinvideo.c | 20 ++++++++++++++------ gst/camerabin/camerabinvideo.h | 8 ++------ 2 files changed, 16 insertions(+), 12 deletions(-) (limited to 'gst') diff --git a/gst/camerabin/camerabinvideo.c b/gst/camerabin/camerabinvideo.c index d3de662e..2569772a 100644 --- a/gst/camerabin/camerabinvideo.c +++ b/gst/camerabin/camerabinvideo.c @@ -184,6 +184,8 @@ gst_camerabin_video_init (GstCameraBinVideo * vid, vid->pending_eos = NULL; + vid->mute = ARG_DEFAULT_MUTE; + /* Create src and sink ghost pads */ vid->sinkpad = gst_ghost_pad_new_no_target ("sink", GST_PAD_SINK); gst_element_add_pad (GST_ELEMENT (vid), vid->sinkpad); @@ -629,6 +631,8 @@ gst_camerabin_video_create_elements (GstCameraBinVideo * vid) GST_WARNING_OBJECT (vid, "unable to add volume element"); /* gst_camerabin_try_add_element() destroyed the element */ vid->volume = NULL; + } else { + g_object_set (vid->volume, "mute", vid->mute, NULL); } /* Add user set or default audio encoder element */ @@ -732,8 +736,11 @@ gst_camerabin_video_destroy_elements (GstCameraBinVideo * vid) void gst_camerabin_video_set_mute (GstCameraBinVideo * vid, gboolean mute) { - if (vid && vid->volume) { - GST_DEBUG_OBJECT (vid, "setting mute %s", mute ? "on" : "off"); + g_return_if_fail (vid != NULL); + + GST_DEBUG_OBJECT (vid, "setting mute %s", mute ? "on" : "off"); + vid->mute = mute; + if (vid->volume) { g_object_set (vid->volume, "mute", mute, NULL); } } @@ -800,12 +807,13 @@ gst_camerabin_video_set_audio_src (GstCameraBinVideo * vid, gboolean gst_camerabin_video_get_mute (GstCameraBinVideo * vid) { - gboolean mute = ARG_DEFAULT_MUTE; + g_return_val_if_fail (vid != NULL, FALSE); - if (vid && vid->volume) { - g_object_get (vid->volume, "mute", &mute, NULL); + if (vid->volume) { + g_object_get (vid->volume, "mute", &vid->mute, NULL); } - return mute; + + return vid->mute; } GstElement * diff --git a/gst/camerabin/camerabinvideo.h b/gst/camerabin/camerabinvideo.h index 9f4f5152..dd094d52 100644 --- a/gst/camerabin/camerabinvideo.h +++ b/gst/camerabin/camerabinvideo.h @@ -24,24 +24,19 @@ #include G_BEGIN_DECLS - //#define USE_TIMEOVERLAY 1 - #define ARG_DEFAULT_MUTE FALSE - #define GST_TYPE_CAMERABIN_VIDEO (gst_camerabin_video_get_type()) #define GST_CAMERABIN_VIDEO_CAST(obj) ((GstCameraBinVideo*)(obj)) #define GST_CAMERABIN_VIDEO(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_CAMERABIN_VIDEO,GstCameraBinVideo)) #define GST_CAMERABIN_VIDEO_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_CAMERABIN_VIDEO,GstCameraBinVideoClass)) #define GST_IS_CAMERABIN_VIDEO(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_CAMERABIN_VIDEO)) #define GST_IS_CAMERABIN_VIDEO_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_CAMERABIN_VIDEO)) - /** * GstCameraBinVideo: * * The opaque #GstCameraBinVideo structure. */ - typedef struct _GstCameraBinVideo GstCameraBinVideo; typedef struct _GstCameraBinVideoClass GstCameraBinVideoClass; @@ -86,6 +81,8 @@ struct _GstCameraBinVideo GstElement *muxer; /* Muxer */ GstEvent *pending_eos; + + gboolean mute; }; struct _GstCameraBinVideoClass @@ -132,5 +129,4 @@ GstElement *gst_camerabin_video_get_muxer (GstCameraBinVideo * vid); GstElement *gst_camerabin_video_get_audio_src (GstCameraBinVideo * vid); G_END_DECLS - #endif /* #ifndef __CAMERABIN_VIDEO_H__ */ -- cgit v1.2.1