+2008-02-14 Wim Taymans <wim.taymans@collabora.co.uk>
+
+ * gst/playback/gstplaybin2.c: (gst_play_bin_class_init),
+ (gst_play_bin_set_property), (gst_play_bin_get_property),
+ (pad_added_cb), (pad_removed_cb), (no_more_pads_cb):
+ * gst/playback/gstplaysink.c: (gst_play_sink_set_mute),
+ (gst_play_sink_get_mute), (gen_audio_chain):
+ * gst/playback/gstplaysink.h:
+ Add mute property.
+
+ * gst/playback/gststreamselector.c: (gst_selector_pad_event),
+ (gst_selector_pad_chain):
+ * gst/playback/gststreamselector.h:
+ Make sure we forward the event only once.
+
+ * tests/examples/seek/seek.c: (stop_cb), (mute_toggle_cb), (main):
+ Add and implement the mute button for playbin2.
+
2008-02-13 Wim Taymans <wim.taymans@collabora.co.uk>
Patch by: Tommi Myöhänen <ext-tommi dot myohanen at nokia dot com>
#define DEFAULT_VIDEO_SINK NULL
#define DEFAULT_VIS_PLUGIN NULL
#define DEFAULT_VOLUME 1.0
+#define DEFAULT_MUTE FALSE
#define DEFAULT_FRAME NULL
#define DEFAULT_FONT_DESC NULL
#define DEFAULT_CONNECTION_SPEED 0
PROP_VIDEO_SINK,
PROP_VIS_PLUGIN,
PROP_VOLUME,
+ PROP_MUTE,
PROP_FRAME,
PROP_FONT_DESC,
PROP_CONNECTION_SPEED
GST_TYPE_ELEMENT, G_PARAM_READWRITE));
g_object_class_install_property (gobject_klass, PROP_VOLUME,
- g_param_spec_double ("volume", "volume", "volume",
+ g_param_spec_double ("volume", "Volume", "The audio volume",
0.0, VOLUME_MAX_DOUBLE, 1.0, G_PARAM_READWRITE));
+ g_object_class_install_property (gobject_klass, PROP_MUTE,
+ g_param_spec_boolean ("mute", "Mute",
+ "Mute the audio channel without changing the volume", FALSE,
+ G_PARAM_READWRITE));
+
g_object_class_install_property (gobject_klass, PROP_FRAME,
gst_param_spec_mini_object ("frame", "Frame",
"The last frame (NULL = no video available)",
case PROP_VOLUME:
gst_play_sink_set_volume (playbin->playsink, g_value_get_double (value));
break;
+ case PROP_MUTE:
+ gst_play_sink_set_mute (playbin->playsink, g_value_get_boolean (value));
+ break;
case PROP_FONT_DESC:
break;
case PROP_CONNECTION_SPEED:
case PROP_VOLUME:
g_value_set_double (value, gst_play_sink_get_volume (playbin->playsink));
break;
+ case PROP_MUTE:
+ g_value_set_boolean (value, gst_play_sink_get_mute (playbin->playsink));
+ break;
case PROP_FRAME:
break;
case PROP_FONT_DESC:
if (select == NULL)
goto unknown_type;
- /* store the selector for the pad */
- g_object_set_data (G_OBJECT (pad), "playbin2.select", select);
-
if (select->selector == NULL) {
/* no selector, create one */
GST_DEBUG_OBJECT (playbin, "creating new selector");
GST_DEBUG_OBJECT (playbin, "got pad %s:%s from selector",
GST_DEBUG_PAD_NAME (sinkpad));
+ /* store the selector for the pad */
+ g_object_set_data (G_OBJECT (sinkpad), "playbin2.select", select);
+
/* store the pad in the array */
g_ptr_array_add (select->channels, sinkpad);
if ((select = g_object_get_data (G_OBJECT (pad), "playbin2.select"))) {
/* remove the pad from the array */
g_ptr_array_remove (select->channels, pad);
+ GST_DEBUG_OBJECT (playbin, "pad removed from array");
}
/* get the selector sinkpad */
select->sinkpad =
gst_play_sink_request_pad (playbin->playsink, select->type);
res = gst_pad_link (select->srcpad, select->sinkpad);
- GST_DEBUG_OBJECT (playbin, "linked type %s: %d", select->media, res);
+ GST_DEBUG_OBJECT (playbin, "linked type %s, result: %d", select->media,
+ res);
}
}
/* configure the modes now */
GstPad *teesrc;
GstElement *conv;
GstElement *resample;
- GstElement *volume;
+ GstElement *volume; /* element with the volume property */
+ GstElement *mute; /* element with the mute property */
GstElement *sink;
} GstPlayAudioChain;
GstElement *video_sink;
GstElement *visualisation;
gfloat volume;
+ gboolean mute;
gchar *font_desc; /* font description */
guint connection_speed; /* connection speed in bits/sec (0 = unknown) */
return result;
}
+void
+gst_play_sink_set_mute (GstPlaySink * playsink, gboolean mute)
+{
+ GstPlayAudioChain *chain;
+
+ GST_PLAY_SINK_LOCK (playsink);
+ playsink->mute = mute;
+ chain = (GstPlayAudioChain *) playsink->audiochain;
+ if (chain && chain->mute) {
+ g_object_set (chain->mute, "mute", mute, NULL);
+ }
+ GST_PLAY_SINK_UNLOCK (playsink);
+}
+
+gboolean
+gst_play_sink_get_mute (GstPlaySink * playsink)
+{
+ gboolean result;
+ GstPlayAudioChain *chain;
+
+ GST_PLAY_SINK_LOCK (playsink);
+ chain = (GstPlayAudioChain *) playsink->audiochain;
+ if (chain && chain->mute) {
+ g_object_get (chain->mute, "mute", &result, NULL);
+ playsink->mute = result;
+ } else {
+ result = playsink->mute;
+ }
+ GST_PLAY_SINK_UNLOCK (playsink);
+
+ return result;
+}
+
static void
gst_play_sink_set_property (GObject * object, guint prop_id,
const GValue * value, GParamSpec * pspec)
chain->volume = gst_element_factory_make ("volume", "volume");
if (chain->volume == NULL)
goto no_volume;
+
+ /* volume also has the mute property */
+ chain->mute = gst_object_ref (chain->volume);
+
/* configure with the latest volume */
g_object_set (G_OBJECT (chain->volume), "volume", playsink->volume, NULL);
gst_bin_add (bin, chain->volume);
void gst_play_sink_set_volume (GstPlaySink *playsink, gdouble volume);
gdouble gst_play_sink_get_volume (GstPlaySink *playsink);
+void gst_play_sink_set_mute (GstPlaySink *playsink, gboolean mute);
+gboolean gst_play_sink_get_mute (GstPlaySink *playsink);
+
gboolean gst_play_sink_set_flags (GstPlaySink * playsink, GstPlayFlags flags);
GstPlayFlags gst_play_sink_get_flags (GstPlaySink * playsink);
gst_event_parse_new_segment_full (event, &update, &rate, &arate, &format,
&start, &stop, &time);
- GST_DEBUG_OBJECT (sel,
+ GST_DEBUG_OBJECT (selpad,
"configured NEWSEGMENT update %d, rate %lf, applied rate %lf, "
"format %d, "
"%" G_GINT64_FORMAT " -- %" G_GINT64_FORMAT ", time %"
gst_segment_set_newsegment_full (&selpad->segment, update,
rate, arate, format, start, stop, time);
- /* if we are not going to forward the segment, mark the segment as
- * pending */
+ /* mark pending segment if we are not forwarding, we assume all pads share
+ * the same segment so we only forward once. */
if (!forward)
- selpad->segment_pending = TRUE;
+ sel->segment_pending = TRUE;
break;
}
case GST_EVENT_TAG:
goto ignore;
/* if we have a pending segment, push it out now */
- if (selpad->segment_pending) {
+ if (sel->segment_pending) {
gst_pad_push_event (sel->srcpad, gst_event_new_new_segment_full (FALSE,
seg->rate, seg->applied_rate, seg->format, seg->start, seg->stop,
seg->time));
- selpad->segment_pending = FALSE;
+ sel->segment_pending = FALSE;
}
/* forward */
guint padcount;
GstSegment segment;
+ gboolean segment_pending;
};
struct _GstStreamSelectorClass {
static gint n_video = 0, n_audio = 0, n_text = 0;
static GtkWidget *video_combo, *audio_combo, *text_combo;
static GtkWidget *vis_checkbox, *video_checkbox, *audio_checkbox;
-static GtkWidget *text_checkbox, *volume_spinbutton;
+static GtkWidget *text_checkbox, *mute_checkbox, *volume_spinbutton;
static void clear_streams (GstElement * pipeline);
set_update_scale (FALSE);
set_scale (0.0);
+
if (pipeline_type == 16)
clear_streams (pipeline);
update_flag (pipeline, 2, gtk_toggle_button_get_active (button));
}
+static void
+mute_toggle_cb (GtkToggleButton * button, GstPipeline * pipeline)
+{
+ gboolean mute;
+
+ mute = gtk_toggle_button_get_active (button);
+ g_object_set (pipeline, "mute", mute, NULL);
+}
+
static void
clear_streams (GstElement * pipeline)
{
video_checkbox = gtk_check_button_new_with_label ("Video");
audio_checkbox = gtk_check_button_new_with_label ("Audio");
text_checkbox = gtk_check_button_new_with_label ("Text");
+ mute_checkbox = gtk_check_button_new_with_label ("Mute");
volume_spinbutton = gtk_spin_button_new_with_range (0, 2.0, 0.1);
gtk_spin_button_set_value (GTK_SPIN_BUTTON (volume_spinbutton), 1.0);
gtk_box_pack_start (GTK_BOX (boxes), vis_checkbox, TRUE, TRUE, 2);
gtk_box_pack_start (GTK_BOX (boxes), audio_checkbox, TRUE, TRUE, 2);
gtk_box_pack_start (GTK_BOX (boxes), video_checkbox, TRUE, TRUE, 2);
gtk_box_pack_start (GTK_BOX (boxes), text_checkbox, TRUE, TRUE, 2);
+ gtk_box_pack_start (GTK_BOX (boxes), mute_checkbox, TRUE, TRUE, 2);
gtk_box_pack_start (GTK_BOX (boxes), volume_spinbutton, TRUE, TRUE, 2);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (vis_checkbox), TRUE);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (audio_checkbox), TRUE);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (video_checkbox), TRUE);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (text_checkbox), TRUE);
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (mute_checkbox), FALSE);
g_signal_connect (G_OBJECT (vis_checkbox), "toggled",
G_CALLBACK (vis_toggle_cb), pipeline);
g_signal_connect (G_OBJECT (audio_checkbox), "toggled",
G_CALLBACK (video_toggle_cb), pipeline);
g_signal_connect (G_OBJECT (text_checkbox), "toggled",
G_CALLBACK (text_toggle_cb), pipeline);
+ g_signal_connect (G_OBJECT (mute_checkbox), "toggled",
+ G_CALLBACK (mute_toggle_cb), pipeline);
g_signal_connect (G_OBJECT (volume_spinbutton), "value_changed",
G_CALLBACK (volume_spinbutton_changed_cb), pipeline);
} else {