aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2010-02-17 19:35:39 +0800
committerGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2010-04-01 16:15:39 +0800
commit93fdc771e51c327cad047b39a9be05f66d58fa21 (patch)
treeaa62d9e58cf4e916b70d862cee0056c7b33611b5
parentef79ba8294dbb740f38c3d15d732b7a8933264a7 (diff)
downloadgsoc2013-empathy-93fdc771e51c327cad047b39a9be05f66d58fa21.tar
gsoc2013-empathy-93fdc771e51c327cad047b39a9be05f66d58fa21.tar.gz
gsoc2013-empathy-93fdc771e51c327cad047b39a9be05f66d58fa21.tar.bz2
gsoc2013-empathy-93fdc771e51c327cad047b39a9be05f66d58fa21.tar.lz
gsoc2013-empathy-93fdc771e51c327cad047b39a9be05f66d58fa21.tar.xz
gsoc2013-empathy-93fdc771e51c327cad047b39a9be05f66d58fa21.tar.zst
gsoc2013-empathy-93fdc771e51c327cad047b39a9be05f66d58fa21.zip
Actually turn off the camera when preview/sending is disabled
There is no point to let the camera on if we are not using it. Also split empathy_call_window_setup_video_preview() to create_video_preview() and add_video_preview_to_pipeline().
-rw-r--r--src/empathy-call-window.c80
1 files changed, 54 insertions, 26 deletions
diff --git a/src/empathy-call-window.c b/src/empathy-call-window.c
index 7f2b4d043..a1ada3eff 100644
--- a/src/empathy-call-window.c
+++ b/src/empathy-call-window.c
@@ -651,46 +651,74 @@ create_audio_input (EmpathyCallWindow *self)
}
static void
-empathy_call_window_setup_video_preview (EmpathyCallWindow *window)
+add_video_preview_to_pipeline (EmpathyCallWindow *self)
{
- EmpathyCallWindowPriv *priv = GET_PRIV (window);
+ EmpathyCallWindowPriv *priv = GET_PRIV (self);
GstElement *preview;
- GstBus *bus = gst_pipeline_get_bus (GST_PIPELINE (priv->pipeline));
- if (priv->video_preview != NULL)
- {
- /* Since the video preview and the video tee are initialized and freed
- at the same time, if one is initialized, then the other one should
- be too. */
- g_assert (priv->video_tee != NULL);
- return;
- }
+ g_assert (priv->video_preview != NULL);
+ g_assert (priv->pipeline != NULL);
+ g_assert (priv->video_input != NULL);
+ g_assert (priv->video_tee != NULL);
+
+ preview = empathy_video_widget_get_element (
+ EMPATHY_VIDEO_WIDGET (priv->video_preview));
+ gst_bin_add_many (GST_BIN (priv->pipeline), priv->video_input,
+ priv->video_tee, preview, NULL);
+ gst_element_link_many (priv->video_input, priv->video_tee,
+ preview, NULL);
+}
+
+static void
+create_video_preview (EmpathyCallWindow *self)
+{
+ EmpathyCallWindowPriv *priv = GET_PRIV (self);
+ GstBus *bus;
- DEBUG ("Create video preview");
+ g_assert (priv->video_preview == NULL);
g_assert (priv->video_tee == NULL);
- priv->video_tee = gst_element_factory_make ("tee", NULL);
- gst_object_ref (priv->video_tee);
- gst_object_sink (priv->video_tee);
+ bus = gst_pipeline_get_bus (GST_PIPELINE (priv->pipeline));
priv->video_preview = empathy_video_widget_new_with_size (bus,
SELF_VIDEO_SECTION_WIDTH, SELF_VIDEO_SECTION_HEIGTH);
g_object_set (priv->video_preview, "sync", FALSE, "async", TRUE, NULL);
+
gtk_box_pack_start (GTK_BOX (priv->self_user_output_hbox),
priv->video_preview, TRUE, TRUE, 0);
- preview = empathy_video_widget_get_element (
- EMPATHY_VIDEO_WIDGET (priv->video_preview));
- gst_bin_add_many (GST_BIN (priv->pipeline), priv->video_input,
- priv->video_tee, preview, NULL);
- gst_element_link_many (priv->video_input, priv->video_tee,
- preview, NULL);
+ priv->video_tee = gst_element_factory_make ("tee", NULL);
+ gst_object_ref (priv->video_tee);
+ gst_object_sink (priv->video_tee);
g_object_unref (bus);
+}
+
+static void
+play_camera (EmpathyCallWindow *window,
+ gboolean play)
+{
+ EmpathyCallWindowPriv *priv = GET_PRIV (window);
+ GstElement *preview;
+ GstState state;
+
+ if (priv->video_preview == NULL)
+ {
+ create_video_preview (window);
+ add_video_preview_to_pipeline (window);
+ }
+
+ if (play)
+ state = GST_STATE_PLAYING;
+ else
+ state = GST_STATE_NULL;
+
+ preview = empathy_video_widget_get_element (
+ EMPATHY_VIDEO_WIDGET (priv->video_preview));
- gst_element_set_state (preview, GST_STATE_PLAYING);
- gst_element_set_state (priv->video_input, GST_STATE_PLAYING);
- gst_element_set_state (priv->video_tee, GST_STATE_PLAYING);
+ gst_element_set_state (preview, state);
+ gst_element_set_state (priv->video_input, state);
+ gst_element_set_state (priv->video_tee, state);
}
static void
@@ -704,8 +732,7 @@ display_video_preview (EmpathyCallWindow *self,
/* Display the preview and hide the self avatar */
DEBUG ("Show video preview");
- if (priv->video_preview == NULL)
- empathy_call_window_setup_video_preview (self);
+ play_camera (self, TRUE);
gtk_widget_show (priv->video_preview);
gtk_widget_hide (priv->self_user_avatar_widget);
}
@@ -716,6 +743,7 @@ display_video_preview (EmpathyCallWindow *self,
if (priv->video_preview != NULL)
gtk_widget_hide (priv->video_preview);
+ play_camera (self, FALSE);
gtk_widget_show (priv->self_user_avatar_widget);
}
}