#include <libempathy-gtk/empathy-sound-manager.h>
#include <libempathy-gtk/empathy-geometry.h>
#include <libempathy-gtk/empathy-images.h>
+#include <libempathy-gtk/empathy-call-utils.h>
#define DEBUG_FLAG EMPATHY_DEBUG_VOIP
#include <libempathy/empathy-debug.h>
GtkWidget *audio_call_button;
GtkWidget *video_call_button;
GtkWidget *mic_button;
+ GtkWidget *volume_button;
GtkWidget *camera_button;
GtkWidget *dialpad_button;
GtkWidget *toolbar;
/* These are used to accept or reject an incoming call when the status
is RINGING. */
GtkWidget *incoming_call_dialog;
- TpyCallChannel *pending_channel;
+ TpCallChannel *pending_channel;
TpChannelDispatchOperation *pending_cdo;
TpAddDispatchOperationContext *pending_context;
gulong video_output_motion_handler_id;
guint bus_message_source_id;
- gdouble volume;
-
/* String that contains the queued tones to send after the current ones
are sent */
GString *tones;
GstElement *video_output_sink;
GstElement *audio_input;
GstElement *audio_output;
+ gboolean audio_output_added;
GstElement *pipeline;
GstElement *video_tee;
static void empathy_call_window_set_send_video (EmpathyCallWindow *window,
CameraState state);
-static void empathy_call_window_mic_toggled_cb (
- GtkToggleToolButton *toggle, EmpathyCallWindow *window);
-
static void empathy_call_window_hangup_cb (gpointer object,
EmpathyCallWindow *window);
static gboolean empathy_call_window_bus_message (GstBus *bus,
GstMessage *message, gpointer user_data);
-static void
-empathy_call_window_volume_changed_cb (GtkScaleButton *button,
- gdouble value, EmpathyCallWindow *window);
-
static void
empathy_call_window_show_hangup_button (EmpathyCallWindow *self,
gboolean show)
empathy_call_window_maybe_emit_tones (self);
}
-static void
-empathy_call_window_mic_volume_changed (EmpathyCallWindow *self)
-{
- EmpathyCallWindowPriv *priv = GET_PRIV (self);
- gdouble volume;
-
- volume = g_settings_get_double (priv->settings,
- EMPATHY_PREFS_CALL_SOUND_VOLUME) / 100.0;
-
- /* Don't store the volume because of muting */
- if (volume > 0 || gtk_toggle_tool_button_get_active (
- GTK_TOGGLE_TOOL_BUTTON (priv->mic_button)))
- priv->volume = volume;
-
- /* Ensure that the toggle button is active if the volume is > 0 and inactive
- * if it's smaller than 0 */
- if ((volume > 0) != gtk_toggle_tool_button_get_active (
- GTK_TOGGLE_TOOL_BUTTON (priv->mic_button)))
- gtk_toggle_tool_button_set_active (
- GTK_TOGGLE_TOOL_BUTTON (priv->mic_button), volume > 0);
-
- empathy_audio_src_set_volume (EMPATHY_GST_AUDIO_SRC (priv->audio_input),
- volume);
-}
-
-static void
-empathy_call_window_prefs_volume_changed_cb (GSettings *settings,
- gchar *key,
- EmpathyCallWindow *self)
-{
- empathy_call_window_mic_volume_changed (self);
-}
-
static void
empathy_call_window_raise_actors (EmpathyCallWindow *self)
{
priv->audio_input = empathy_audio_src_new ();
gst_object_ref (priv->audio_input);
gst_object_sink (priv->audio_input);
+
+ g_object_bind_property (priv->mic_button, "active",
+ priv->audio_input, "mute",
+ G_BINDING_BIDIRECTIONAL |
+ G_BINDING_INVERT_BOOLEAN | G_BINDING_SYNC_CREATE);
}
static void
g_assert (self->priv->call_state != CONNECTED);
- video = tpy_call_channel_has_initial_video (self->priv->pending_channel);
+ video = tp_call_channel_has_initial_video (self->priv->pending_channel, NULL);
empathy_call_window_status_message (self, _("Incoming call"));
self->priv->call_state = RINGING;
void
empathy_call_window_start_ringing (EmpathyCallWindow *self,
- TpyCallChannel *channel,
+ TpCallChannel *channel,
TpChannelDispatchOperation *dispatch_operation,
TpAddDispatchOperationContext *context)
{
"audiocall", &priv->audio_call_button,
"videocall", &priv->video_call_button,
"microphone", &priv->mic_button,
+ "volume", &priv->volume_button,
"camera", &priv->camera_button,
"hangup", &priv->hangup_button,
"dialpad", &priv->dialpad_button,
"hangup", "clicked", empathy_call_window_hangup_cb,
"audiocall", "clicked", empathy_call_window_audio_call_cb,
"videocall", "clicked", empathy_call_window_video_call_cb,
- "volume", "value-changed", empathy_call_window_volume_changed_cb,
- "microphone", "toggled", empathy_call_window_mic_toggled_cb,
"camera", "toggled", empathy_call_window_camera_toggled_cb,
"dialpad", "toggled", empathy_call_window_dialpad_cb,
"menufullscreen", "activate", empathy_call_window_fullscreen_cb,
gtk_container_add (GTK_CONTAINER (self), top_vbox);
- priv->content_hbox = gtk_hbox_new (FALSE, CONTENT_HBOX_SPACING);
+ priv->content_hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL,
+ CONTENT_HBOX_SPACING);
gtk_container_set_border_width (GTK_CONTAINER (priv->content_hbox),
CONTENT_HBOX_BORDER_WIDTH);
gtk_box_pack_start (GTK_BOX (priv->pane), priv->content_hbox,
priv->video_container = gtk_clutter_embed_new ();
+ gtk_widget_set_size_request (priv->video_container,
+ EMPATHY_VIDEO_WIDGET_DEFAULT_WIDTH, EMPATHY_VIDEO_WIDGET_DEFAULT_HEIGHT);
+
/* Set the background color to that of the rest of the window */
context = gtk_widget_get_style_context (priv->content_hbox);
gtk_style_context_get_background_color (context,
empathy_call_window_show_hangup_button (self, TRUE);
- /* Retrieve initial volume */
- priv->volume = g_settings_get_double (priv->settings,
- EMPATHY_PREFS_CALL_SOUND_VOLUME) / 100.0;
-
- g_signal_connect (priv->settings, "changed::"EMPATHY_PREFS_CALL_SOUND_VOLUME,
- G_CALLBACK (empathy_call_window_prefs_volume_changed_cb), self);
-
empathy_geometry_bind (GTK_WINDOW (self), "call-window");
/* These signals are used to track the window position and save it
* when the window is destroyed. We need to do this as we don't want
{
EmpathyCallWindow *self = EMPATHY_CALL_WINDOW (object);
EmpathyCallWindowPriv *priv = GET_PRIV (self);
- TpyCallChannel *call;
- TpyCallState state;
+ TpCallChannel *call;
+ TpCallState state;
g_assert (priv->handler != NULL);
g_object_get (priv->handler, "call-channel", &call, NULL);
- state = tpy_call_channel_get_state (call, NULL, NULL);
- priv->outgoing = (state == TPY_CALL_STATE_PENDING_INITIATOR);
+ state = tp_call_channel_get_state (call, NULL, NULL, NULL);
+ priv->outgoing = (state == TP_CALL_STATE_PENDING_INITIATOR);
tp_clear_object (&call);
g_object_get (priv->handler, "target-contact", &priv->contact, NULL);
if (priv->audio_output != NULL)
g_object_unref (priv->audio_output);
priv->audio_output = NULL;
+ priv->audio_output_added = FALSE;
if (priv->video_tee != NULL)
g_object_unref (priv->video_tee);
{
gst_element_set_state (priv->audio_output, GST_STATE_NULL);
- gst_bin_remove (GST_BIN (priv->pipeline), priv->audio_output);
+ if (priv->audio_output_added)
+ gst_bin_remove (GST_BIN (priv->pipeline), priv->audio_output);
priv->audio_output = NULL;
+ priv->audio_output_added = FALSE;
}
}
else
GstPad *pad;
GstPadTemplate *template;
- if (priv->audio_output == NULL)
+ if (!priv->audio_output_added)
{
- priv->audio_output = empathy_audio_sink_new ();
- g_object_ref_sink (priv->audio_output);
-
if (!gst_bin_add (GST_BIN (priv->pipeline), priv->audio_output))
{
g_warning ("Could not add audio sink to pipeline");
}
}
- /* For raw audio conferences assume that the producer of the raw data
- * has already processed it, so turn off any echo cancellation and any
- * other audio improvements that come with it */
- empathy_audio_sink_set_echo_cancel (
- EMPATHY_GST_AUDIO_SINK (priv->audio_output),
- !empathy_call_window_content_is_raw (content));
-
template = gst_element_class_get_pad_template (
GST_ELEMENT_GET_CLASS (priv->audio_output), "sink%d");
content_area = gtk_info_bar_get_content_area (GTK_INFO_BAR (info_bar));
/* hbox containing the image and the messages vbox */
- hbox = gtk_hbox_new (FALSE, 3);
+ hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 3);
gtk_container_add (GTK_CONTAINER (content_area), hbox);
/* Add image */
gtk_box_pack_start (GTK_BOX (hbox), image, FALSE, FALSE, 0);
/* vbox containing the main message and the details expander */
- vbox = gtk_vbox_new (FALSE, 3);
+ vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 3);
gtk_box_pack_start (GTK_BOX (hbox), vbox, TRUE, TRUE, 0);
/* Add text */
#if 0
static gchar *
media_stream_error_to_txt (EmpathyCallWindow *self,
- TpyCallChannel *call,
+ TpCallChannel *call,
gboolean audio,
TpMediaStreamError error)
{
static void
empathy_call_window_stream_error (EmpathyCallWindow *self,
- TpyCallChannel *call,
+ TpCallChannel *call,
gboolean audio,
guint code,
const gchar *msg,
}
static void
-empathy_call_window_audio_stream_error (TpyCallChannel *call,
+empathy_call_window_audio_stream_error (TpCallChannel *call,
guint code,
const gchar *msg,
EmpathyCallWindow *self)
}
static void
-empathy_call_window_video_stream_error (TpyCallChannel *call,
+empathy_call_window_video_stream_error (TpCallChannel *call,
guint code,
const gchar *msg,
EmpathyCallWindow *self)
static void
empathy_call_window_state_changed_cb (EmpathyCallHandler *handler,
- TpyCallState state,
+ TpCallState state,
gchar *reason,
EmpathyCallWindow *self)
{
EmpathyCallWindowPriv *priv = GET_PRIV (self);
- TpyCallChannel *call;
+ TpCallChannel *call;
gboolean can_send_video;
- if (state == TPY_CALL_STATE_ENDED &&
+ if (state == TP_CALL_STATE_ENDED &&
!tp_strdiff (reason, TP_ERROR_STR_INSUFFICIENT_BALANCE))
{
show_balance_error (self);
return;
}
- if (state != TPY_CALL_STATE_ACCEPTED)
+ if (state != TP_CALL_STATE_ACCEPTED)
return;
if (priv->call_state == CONNECTED)
g_object_get (priv->handler, "call-channel", &call, NULL);
- if (tpy_call_channel_has_dtmf (call))
+ if (tp_call_channel_has_dtmf (call))
gtk_widget_set_sensitive (priv->dtmf_panel, TRUE);
if (priv->video_input == NULL)
G_CALLBACK (empathy_call_window_video_probe_cb), self);
if (priv->got_video_src > 0)
g_source_remove (priv->got_video_src);
- priv->got_video_src = g_timeout_add_seconds (5,
+ priv->got_video_src = g_timeout_add_seconds (1,
empathy_call_window_check_video_cb, self);
break;
default:
return TRUE;
}
+static void
+empathy_call_window_prepare_audio_output (EmpathyCallWindow *self,
+ TfContent *content)
+{
+ EmpathyCallWindowPriv *priv = self->priv;
+
+ g_assert (priv->audio_output_added == FALSE);
+ g_assert (priv->audio_output == FALSE);
+
+ priv->audio_output = empathy_audio_sink_new ();
+ g_object_ref_sink (priv->audio_output);
+
+ /* volume button to output volume linking */
+ g_object_bind_property (priv->audio_output, "volume",
+ priv->volume_button, "value",
+ G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE);
+
+ g_object_bind_property_full (content, "requested-output-volume",
+ priv->audio_output, "volume",
+ G_BINDING_DEFAULT,
+ audio_control_volume_to_element,
+ element_volume_to_audio_control,
+ NULL, NULL);
+
+ /* Link volumes together, sync the current audio input volume property
+ * back to farstream first */
+ g_object_bind_property_full (priv->audio_output, "volume",
+ content, "reported-output-volume",
+ G_BINDING_SYNC_CREATE,
+ element_volume_to_audio_control,
+ audio_control_volume_to_element,
+ NULL, NULL);
+
+ /* For raw audio conferences assume that the producer of the raw data
+ * has already processed it, so turn off any echo cancellation and any
+ * other audio improvements that come with it */
+ empathy_audio_sink_set_echo_cancel (
+ EMPATHY_GST_AUDIO_SINK (priv->audio_output),
+ !empathy_call_window_content_is_raw (content));
+}
+
+
static gboolean
empathy_call_window_content_added_cb (EmpathyCallHandler *handler,
TfContent *content, gpointer user_data)
break;
}
+ /* Prepare our audio output, not added yet though */
+ empathy_call_window_prepare_audio_output (self, content);
+
retval = TRUE;
break;
case FS_MEDIA_TYPE_VIDEO:
if (empathy_call_handler_has_initial_video (priv->handler))
{
- TpyCallChannel *call;
- TpySendingState s;
+ TpCallChannel *call;
+ TpSendingState s;
g_object_get (priv->handler, "call-channel", &call, NULL);
/* If the call channel isn't set yet we're requesting it, if we're
* requesting it with initial video it should be PENDING_SEND when we get
* it */
if (call == NULL)
- s = TPY_SENDING_STATE_PENDING_SEND;
+ s = TP_SENDING_STATE_PENDING_SEND;
else
- s = tpy_call_channel_get_video_state (call);
+ s = empathy_call_channel_get_video_state (call);
- if (s == TPY_SENDING_STATE_PENDING_SEND ||
- s == TPY_SENDING_STATE_SENDING)
+ if (s == TP_SENDING_STATE_PENDING_SEND ||
+ s == TP_SENDING_STATE_SENDING)
{
/* Enable 'send video' buttons and display the preview */
gtk_toggle_tool_button_set_active (
}
static void
-empathy_call_window_members_changed_cb (TpyCallChannel *call,
- GHashTable *members,
+empathy_call_window_members_changed_cb (TpCallChannel *call,
+ GHashTable *updates,
+ GPtrArray *removed,
+ TpCallStateReason *reason,
EmpathyCallWindow *self)
{
EmpathyCallWindowPriv *priv = GET_PRIV (self);
gpointer key, value;
gboolean held = FALSE;
- g_hash_table_iter_init (&iter, members);
+ g_hash_table_iter_init (&iter, updates);
while (g_hash_table_iter_next (&iter, &key, &value))
{
- if (GPOINTER_TO_INT (value) & TPY_CALL_MEMBER_FLAG_HELD)
+ if (GPOINTER_TO_INT (value) & TP_CALL_MEMBER_FLAG_HELD)
{
/* This assumes this is a 1-1 call, otherwise one participant
* putting the call on hold wouldn't mean the call is on hold
EmpathyCallWindow *self)
{
EmpathyCallWindowPriv *priv = GET_PRIV (self);
- TpyCallChannel *call;
+ TpCallChannel *call;
g_object_get (priv->handler, "call-channel", &call, NULL);
if (call == NULL)
empathy_call_window_connect_handler (EmpathyCallWindow *self)
{
EmpathyCallWindowPriv *priv = GET_PRIV (self);
- TpyCallChannel *call;
+ TpCallChannel *call;
g_signal_connect (priv->handler, "state-changed",
G_CALLBACK (empathy_call_window_state_changed_cb), self);
CameraState state)
{
EmpathyCallWindowPriv *priv = GET_PRIV (window);
- TpyCallChannel *call;
+ TpCallChannel *call;
priv->sending_video = (state == CAMERA_STATE_ON);
g_object_get (priv->handler, "call-channel", &call, NULL);
DEBUG ("%s sending video", priv->sending_video ? "start": "stop");
- tpy_call_channel_send_video (call, priv->sending_video);
+ empathy_call_channel_send_video (call, priv->sending_video);
g_object_unref (call);
}
-static void
-empathy_call_window_mic_toggled_cb (GtkToggleToolButton *toggle,
- EmpathyCallWindow *self)
-{
- EmpathyCallWindowPriv *priv = GET_PRIV (self);
- gboolean active;
-
- active = (gtk_toggle_tool_button_get_active (toggle));
-
- /* We don't want the settings callback to react to this change to avoid
- * a loop. */
- g_signal_handlers_block_by_func (priv->settings,
- empathy_call_window_prefs_volume_changed_cb, self);
-
- if (active)
- {
- g_settings_set_double (priv->settings, EMPATHY_PREFS_CALL_SOUND_VOLUME,
- priv->volume * 100);
- }
- else
- {
- /* TODO, Instead of setting the input volume to 0 we should probably
- * stop sending but this would cause the audio call to drop if both
- * sides mute at the same time on certain CMs AFAIK. Need to revisit this
- * in the future. GNOME #574574
- */
- g_settings_set_double (priv->settings, EMPATHY_PREFS_CALL_SOUND_VOLUME,
- 0);
- }
-
- g_signal_handlers_unblock_by_func (priv->settings,
- empathy_call_window_prefs_volume_changed_cb, self);
-}
-
static void
empathy_call_window_hangup_cb (gpointer object,
EmpathyCallWindow *self)
(GtkCallback) gtk_widget_destroy, NULL);
create_video_output_widget (window);
-
- /* While the call was disconnected, the input volume might have changed.
- * However, since the audio_input source was destroyed, its volume has not
- * been updated during that time. That's why we manually update it here */
- empathy_call_window_mic_volume_changed (window);
-
priv->outgoing = TRUE;
empathy_call_window_set_state_connecting (window);
gtk_label_set_label (GTK_LABEL (self->priv->status_label), message);
}
-static void
-empathy_call_window_volume_changed_cb (GtkScaleButton *button,
- gdouble value, EmpathyCallWindow *window)
-{
- EmpathyCallWindowPriv *priv = GET_PRIV (window);
-
- if (priv->audio_output == NULL)
- return;
-
- empathy_audio_sink_set_volume (EMPATHY_GST_AUDIO_SINK (priv->audio_output),
- value);
-}
-
GtkUIManager *
empathy_call_window_get_ui_manager (EmpathyCallWindow *window)
{
{
return EMPATHY_GST_VIDEO_SRC (self->priv->video_input);
}
+
+void
+empathy_call_window_change_webcam (EmpathyCallWindow *self,
+ const gchar *device)
+{
+ EmpathyGstVideoSrc *video;
+ gboolean running;
+
+ /* Restart the camera only if it's already running */
+ running = (self->priv->video_preview != NULL);
+ video = empathy_call_window_get_video_src (self);
+
+ if (running)
+ empathy_call_window_play_camera (self, FALSE);
+
+ empathy_video_src_change_device (video, device);
+
+ if (running)
+ empathy_call_window_play_camera (self, TRUE);
+}