Mercurial > pidgin.yaz
changeset 26129:f09107a80608
merge of '1c8357244603e0d86b5df08b5df711f916c01347'
and '38031eda38655d87862feafe0580344c910908b1'
author | Marcus Lundblad <ml@update.uu.se> |
---|---|
date | Tue, 13 Jan 2009 13:46:06 +0000 |
parents | 5d9a97a23d6e (diff) fc921eb8b220 (current diff) |
children | 525aa65805b9 |
files | libpurple/media.c |
diffstat | 7 files changed, 55 insertions(+), 268 deletions(-) [+] |
line wrap: on
line diff
--- a/finch/gntmedia.c Tue Jan 13 12:24:39 2009 +0000 +++ b/finch/gntmedia.c Tue Jan 13 13:46:06 2009 +0000 @@ -47,8 +47,6 @@ struct _FinchMediaPrivate { PurpleMedia *media; - GstElement *send_level; - GstElement *recv_level; GntWidget *accept; GntWidget *reject; @@ -77,8 +75,6 @@ enum { PROP_0, PROP_MEDIA, - PROP_SEND_LEVEL, - PROP_RECV_LEVEL }; GType @@ -121,18 +117,6 @@ "The PurpleMedia associated with this media.", PURPLE_TYPE_MEDIA, G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE)); - g_object_class_install_property(gobject_class, PROP_SEND_LEVEL, - g_param_spec_object("send-level", - "Send level", - "The GstElement of this media's send 'level'", - GST_TYPE_ELEMENT, - G_PARAM_READWRITE)); - g_object_class_install_property(gobject_class, PROP_RECV_LEVEL, - g_param_spec_object("recv-level", - "Receive level", - "The GstElement of this media's recv 'level'", - GST_TYPE_ELEMENT, - G_PARAM_READWRITE)); finch_media_signals[MESSAGE] = g_signal_new("message", G_TYPE_FROM_CLASS(klass), G_SIGNAL_RUN_LAST, 0, NULL, NULL, @@ -187,16 +171,13 @@ purple_media_set_src(media, sessions->data, sendbin); } g_list_free(sessions); - - g_object_set(gntmedia, "send-level", sendlevel, - NULL); } static void finch_media_accept_cb(PurpleMedia *media, FinchMedia *gntmedia) { GntWidget *parent; - GstElement *sendbin = NULL, *recvbin = NULL; + GstElement *sendbin = NULL; finch_media_emit_message(gntmedia, _("Call in progress.")); @@ -220,9 +201,8 @@ gnt_box_readjust(GNT_BOX(parent)); gnt_widget_draw(parent); - purple_media_get_elements(media, &sendbin, &recvbin, NULL, NULL); + purple_media_get_elements(media, &sendbin, NULL, NULL, NULL); gst_element_set_state(GST_ELEMENT(sendbin), GST_STATE_PLAYING); - gst_element_set_state(GST_ELEMENT(recvbin), GST_STATE_PLAYING); } static void @@ -246,33 +226,34 @@ } static void -finch_media_hangup_cb(PurpleMedia *media, FinchMedia *gntmedia) -{ - finch_media_emit_message(gntmedia, _("You have ended the call.")); - finch_conversation_set_info_widget(gntmedia->priv->conv, NULL); - gnt_widget_destroy(GNT_WIDGET(gntmedia)); - /* XXX: This shouldn't have to be here to free the FinchMedia widget */ - g_object_unref(gntmedia); -} - -static void -finch_media_got_hangup_cb(PurpleMedia *media, FinchMedia *gntmedia) +finch_media_state_changed_cb(PurpleMedia *media, + PurpleMediaStateChangedType type, + gchar *sid, gchar *name, FinchMedia *gntmedia) { - finch_media_emit_message(gntmedia, _("The call has been terminated.")); - finch_conversation_set_info_widget(gntmedia->priv->conv, NULL); - gnt_widget_destroy(GNT_WIDGET(gntmedia)); - /* XXX: This shouldn't have to be here to free the FinchMedia widget */ - g_object_unref(gntmedia); -} - -static void -finch_media_reject_cb(PurpleMedia *media, FinchMedia *gntmedia) -{ - finch_media_emit_message(gntmedia, _("You have rejected the call.")); - finch_conversation_set_info_widget(gntmedia->priv->conv, NULL); - gnt_widget_destroy(GNT_WIDGET(gntmedia)); - /* XXX: This shouldn't have to be here to free the FinchMedia widget */ - g_object_unref(gntmedia); + purple_debug_info("gntmedia", "type: %d sid: %s name: %s\n", + type, sid, name); + if (sid == NULL && name == NULL) { + if (type == PURPLE_MEDIA_STATE_CHANGED_END) { + finch_media_emit_message(gntmedia, + _("The call has been terminated.")); + finch_conversation_set_info_widget( + gntmedia->priv->conv, NULL); + gnt_widget_destroy(GNT_WIDGET(gntmedia)); + /* + * XXX: This shouldn't have to be here + * to free the FinchMedia widget. + */ + g_object_unref(gntmedia); + } else if (type == PURPLE_MEDIA_STATE_CHANGED_REJECTED) { + finch_media_emit_message(gntmedia, + _("You have rejected the call.")); + } + } else if (type == PURPLE_MEDIA_STATE_CHANGED_NEW + && sid != NULL && name != NULL) { + finch_media_ready_cb(media, gntmedia); + } else if (type == PURPLE_MEDIA_STATE_CHANGED_CONNECTED) { + finch_media_accept_cb(media, gntmedia); + } } static void @@ -284,6 +265,8 @@ media = FINCH_MEDIA(object); switch (prop_id) { case PROP_MEDIA: + { + gboolean is_initiator; if (media->priv->media) g_object_unref(media->priv->media); media->priv->media = g_value_get_object(value); @@ -295,33 +278,15 @@ g_signal_connect_swapped(G_OBJECT(media->priv->hangup), "activate", G_CALLBACK(purple_media_hangup), media->priv->media); - g_signal_connect(G_OBJECT(media->priv->media), "accepted", - G_CALLBACK(finch_media_accept_cb), media); - g_signal_connect(G_OBJECT(media->priv->media) ,"ready", - G_CALLBACK(finch_media_ready_cb), media); - g_signal_connect(G_OBJECT(media->priv->media), "wait", - G_CALLBACK(finch_media_wait_cb), media); - g_signal_connect(G_OBJECT(media->priv->media), "hangup", - G_CALLBACK(finch_media_hangup_cb), media); - g_signal_connect(G_OBJECT(media->priv->media), "reject", - G_CALLBACK(finch_media_reject_cb), media); - g_signal_connect(G_OBJECT(media->priv->media), "got-hangup", - G_CALLBACK(finch_media_got_hangup_cb), media); - g_signal_connect(G_OBJECT(media->priv->media), "got-accept", - G_CALLBACK(finch_media_accept_cb), media); + g_object_get(G_OBJECT(media->priv->media), "initiator", + &is_initiator, NULL); + if (is_initiator == TRUE) { + finch_media_wait_cb(media->priv->media, media); + } + g_signal_connect(G_OBJECT(media->priv->media), "state-changed", + G_CALLBACK(finch_media_state_changed_cb), media); break; - case PROP_SEND_LEVEL: - if (media->priv->send_level) - gst_object_unref(media->priv->send_level); - media->priv->send_level = g_value_get_object(value); - g_object_ref(media->priv->send_level); - break; - case PROP_RECV_LEVEL: - if (media->priv->recv_level) - gst_object_unref(media->priv->recv_level); - media->priv->recv_level = g_value_get_object(value); - g_object_ref(media->priv->recv_level); - break; + } default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -340,12 +305,6 @@ case PROP_MEDIA: g_value_set_object(value, media->priv->media); break; - case PROP_SEND_LEVEL: - g_value_set_object(value, media->priv->send_level); - break; - case PROP_RECV_LEVEL: - g_value_set_object(value, media->priv->recv_level); - break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -400,7 +359,6 @@ if (!media) return PURPLE_CMD_STATUS_FAILED; - purple_media_wait(media); return PURPLE_CMD_STATUS_OK; }
--- a/libpurple/media.c Tue Jan 13 12:24:39 2009 +0000 +++ b/libpurple/media.c Tue Jan 13 13:46:06 2009 +0000 @@ -111,18 +111,7 @@ enum { ERROR, - READY, - WAIT, - ACCEPTED, - HANGUP, - REJECT, - GOT_REQUEST, - GOT_HANGUP, - GOT_ACCEPT, NEW_CANDIDATE, - CANDIDATES_PREPARED, - CANDIDATE_PAIR, - CODECS_READY, READY_NEW, STATE_CHANGED, LAST_SIGNAL @@ -203,56 +192,11 @@ G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__STRING, G_TYPE_NONE, 1, G_TYPE_STRING); - purple_media_signals[READY] = g_signal_new("ready", G_TYPE_FROM_CLASS(klass), - G_SIGNAL_RUN_LAST, 0, NULL, NULL, - g_cclosure_marshal_VOID__VOID, - G_TYPE_NONE, 0); - purple_media_signals[WAIT] = g_signal_new("wait", G_TYPE_FROM_CLASS(klass), - G_SIGNAL_RUN_LAST, 0, NULL, NULL, - g_cclosure_marshal_VOID__VOID, - G_TYPE_NONE, 0); - purple_media_signals[ACCEPTED] = g_signal_new("accepted", G_TYPE_FROM_CLASS(klass), - G_SIGNAL_RUN_LAST, 0, NULL, NULL, - g_cclosure_marshal_VOID__VOID, - G_TYPE_NONE, 0); - purple_media_signals[HANGUP] = g_signal_new("hangup", G_TYPE_FROM_CLASS(klass), - G_SIGNAL_RUN_LAST, 0, NULL, NULL, - g_cclosure_marshal_VOID__VOID, - G_TYPE_NONE, 0); - purple_media_signals[REJECT] = g_signal_new("reject", G_TYPE_FROM_CLASS(klass), - G_SIGNAL_RUN_LAST, 0, NULL, NULL, - g_cclosure_marshal_VOID__VOID, - G_TYPE_NONE, 0); - purple_media_signals[GOT_REQUEST] = g_signal_new("got-request", G_TYPE_FROM_CLASS(klass), - G_SIGNAL_RUN_LAST, 0, NULL, NULL, - g_cclosure_marshal_VOID__VOID, - G_TYPE_NONE, 0); - purple_media_signals[GOT_HANGUP] = g_signal_new("got-hangup", G_TYPE_FROM_CLASS(klass), - G_SIGNAL_RUN_LAST, 0, NULL, NULL, - g_cclosure_marshal_VOID__VOID, - G_TYPE_NONE, 0); - purple_media_signals[GOT_ACCEPT] = g_signal_new("got-accept", G_TYPE_FROM_CLASS(klass), - G_SIGNAL_RUN_LAST, 0, NULL, NULL, - g_cclosure_marshal_VOID__VOID, - G_TYPE_NONE, 0); purple_media_signals[NEW_CANDIDATE] = g_signal_new("new-candidate", G_TYPE_FROM_CLASS(klass), G_SIGNAL_RUN_LAST, 0, NULL, NULL, purple_smarshal_VOID__POINTER_POINTER_OBJECT, G_TYPE_NONE, 3, G_TYPE_POINTER, G_TYPE_POINTER, PURPLE_TYPE_MEDIA_CANDIDATE); - purple_media_signals[CANDIDATES_PREPARED] = g_signal_new("candidates-prepared", G_TYPE_FROM_CLASS(klass), - G_SIGNAL_RUN_LAST, 0, NULL, NULL, - purple_smarshal_VOID__STRING_STRING, - G_TYPE_NONE, 2, G_TYPE_STRING, G_TYPE_STRING); - purple_media_signals[CANDIDATE_PAIR] = g_signal_new("candidate-pair", G_TYPE_FROM_CLASS(klass), - G_SIGNAL_RUN_LAST, 0, NULL, NULL, - purple_smarshal_VOID__BOXED_BOXED, - G_TYPE_NONE, 2, PURPLE_TYPE_MEDIA_CANDIDATE, - PURPLE_TYPE_MEDIA_CANDIDATE); - purple_media_signals[CODECS_READY] = g_signal_new("codecs-ready", G_TYPE_FROM_CLASS(klass), - G_SIGNAL_RUN_LAST, 0, NULL, NULL, - g_cclosure_marshal_VOID__STRING, - G_TYPE_NONE, 1, G_TYPE_STRING); purple_media_signals[READY_NEW] = g_signal_new("ready-new", G_TYPE_FROM_CLASS(klass), G_SIGNAL_RUN_LAST, 0, NULL, NULL, purple_smarshal_VOID__STRING_STRING, @@ -1203,9 +1147,6 @@ g_object_get(session->session, "codecs-ready", &ready, NULL); if (session->codecs_ready == FALSE && ready == TRUE) { session->codecs_ready = ready; - g_signal_emit(session->media, - purple_media_signals[CODECS_READY], - 0, session->id); purple_media_emit_ready(media, session, NULL); } @@ -1274,32 +1215,19 @@ } void -purple_media_ready(PurpleMedia *media) -{ - g_signal_emit(media, purple_media_signals[READY], 0); -} - -void -purple_media_wait(PurpleMedia *media) -{ - g_signal_emit(media, purple_media_signals[WAIT], 0); -} - -void purple_media_accept(PurpleMedia *media) { GList *sessions; GList *streams; - g_signal_emit(media, purple_media_signals[ACCEPTED], 0); - sessions = g_hash_table_get_values(media->priv->sessions); for (; sessions; sessions = g_list_delete_link(sessions, sessions)) { PurpleMediaSession *session = sessions->data; session->accepted = TRUE; - purple_media_emit_ready(media, session, NULL); + if (media->priv->initiator == FALSE) + purple_media_emit_ready(media, session, NULL); } streams = media->priv->streams; @@ -1332,12 +1260,6 @@ } void -purple_media_got_request(PurpleMedia *media) -{ - g_signal_emit(media, purple_media_signals[GOT_REQUEST], 0); -} - -void purple_media_got_hangup(PurpleMedia *media) { g_signal_emit(media, purple_media_signals[STATE_CHANGED], @@ -1345,28 +1267,6 @@ NULL, NULL); } -void -purple_media_got_accept(PurpleMedia *media) -{ - GList *sessions; - GList *streams; - - g_signal_emit(media, purple_media_signals[GOT_ACCEPT], 0); - - sessions = g_hash_table_get_values(media->priv->sessions); - - for (; sessions; sessions = g_list_delete_link(sessions, sessions)) { - PurpleMediaSession *session = sessions->data; - session->accepted = TRUE; - } - - streams = media->priv->streams; - - for (; streams; streams = g_list_next(streams)) { - purple_media_set_remote_candidates(streams->data); - } -} - GList* purple_media_get_devices(const gchar *plugin) { @@ -1592,9 +1492,6 @@ stream_data = purple_media_get_stream(session->media, session->id, name); stream_data->candidates_prepared = TRUE; - g_signal_emit(session->media, purple_media_signals[CANDIDATES_PREPARED], - 0, session->id, name); - purple_media_emit_ready(session->media, session, name); g_free(name); } @@ -1609,10 +1506,6 @@ { gchar *name; FsParticipant *participant; - PurpleMediaCandidate *local = - purple_media_candidate_from_fs(native_candidate); - PurpleMediaCandidate *remote = - purple_media_candidate_from_fs(remote_candidate); PurpleMediaStream *stream; g_object_get(fsstream, "participant", &participant, NULL); @@ -1625,11 +1518,6 @@ stream->remote_candidate = fs_candidate_copy(remote_candidate); purple_debug_info("media", "candidate pair established\n"); - g_signal_emit(session->media, purple_media_signals[CANDIDATE_PAIR], 0, - local, remote); - - purple_media_candidate_free(local); - purple_media_candidate_free(remote); } static gboolean
--- a/libpurple/media.h Tue Jan 13 12:24:39 2009 +0000 +++ b/libpurple/media.h Tue Jan 13 13:46:06 2009 +0000 @@ -380,20 +380,6 @@ void purple_media_error(PurpleMedia *media, const gchar *error, ...); /** - * Set the media session to the ready state. - * - * @param media The media object to set the state on. - */ -void purple_media_ready(PurpleMedia *media); - -/** - * Set the media session to the wait state. - * - * @param media The media object to set the state on. - */ -void purple_media_wait(PurpleMedia *media); - -/** * Set the media session to the accepted state. * * @param media The media object to set the state on. @@ -415,13 +401,6 @@ void purple_media_hangup(PurpleMedia *media); /** - * Set the media session to the got_request state. - * - * @param media The media object to set the state on. - */ -void purple_media_got_request(PurpleMedia *media); - -/** * Set the media session to the got_hangup state. * * @param media The media object to set the state on. @@ -429,13 +408,6 @@ void purple_media_got_hangup(PurpleMedia *media); /** - * Set the media session to the got_accept state. - * - * @param media The media object to set the state on. - */ -void purple_media_got_accept(PurpleMedia *media); - -/** * Enumerates a list of devices. * * @param plugin The name of the GStreamer plugin from which to enumerate devices.
--- a/libpurple/protocols/jabber/google.c Tue Jan 13 12:24:39 2009 +0000 +++ b/libpurple/protocols/jabber/google.c Tue Jan 13 13:46:06 2009 +0000 @@ -305,7 +305,6 @@ G_CALLBACK(google_session_ready), session); g_signal_connect(G_OBJECT(session->media), "state-changed", G_CALLBACK(google_session_state_changed_cb), session); - purple_media_ready(session->media); if (sessions == NULL) sessions = g_hash_table_new(google_session_id_hash, @@ -367,7 +366,6 @@ G_CALLBACK(google_session_ready), session); g_signal_connect(G_OBJECT(session->media), "state-changed", G_CALLBACK(google_session_state_changed_cb), session); - purple_media_ready(session->media); purple_media_codec_list_free(codecs); @@ -442,7 +440,7 @@ purple_media_set_remote_codecs(session->media, "google-voice", session->remote_jid, codecs); - purple_media_got_accept(session->media); + purple_media_accept(session->media); } static void
--- a/libpurple/protocols/jabber/jingle/rtp.c Tue Jan 13 12:24:39 2009 +0000 +++ b/libpurple/protocols/jabber/jingle/rtp.c Tue Jan 13 13:46:06 2009 +0000 @@ -553,7 +553,7 @@ /* This needs to be for the entire session, not a single content */ /* very hacky */ if (xmlnode_get_next_twin(xmlcontent) == NULL) - purple_media_got_accept(jingle_rtp_get_media(session)); + purple_media_accept(jingle_rtp_get_media(session)); g_object_unref(session); break; @@ -585,10 +585,6 @@ candidates); } - /* very hacky */ - if (xmlnode_get_next_twin(xmlcontent) == NULL) - purple_media_ready(jingle_rtp_get_media(session)); - g_object_unref(session); break; } @@ -696,9 +692,6 @@ return NULL; } - purple_media_ready(media); - purple_media_wait(media); - g_free(jid); g_free(me);
--- a/pidgin/gtkblist.c Tue Jan 13 12:24:39 2009 +0000 +++ b/pidgin/gtkblist.c Tue Jan 13 13:46:06 2009 +0000 @@ -340,32 +340,22 @@ #ifdef USE_VV static void gtk_blist_menu_audio_call_cb(GtkWidget *w, PurpleBuddy *b) { - PurpleMedia *media = purple_prpl_initiate_media(purple_buddy_get_account(b), + purple_prpl_initiate_media(purple_buddy_get_account(b), purple_buddy_get_name(b), PURPLE_MEDIA_AUDIO); - - if (media) { - purple_media_wait(media); - } } static void gtk_blist_menu_video_call_cb(GtkWidget *w, PurpleBuddy *b) { - PurpleMedia *media = NULL; - /* if the buddy supports both audio and video, start a combined call, otherwise start a pure video session */ if (purple_prpl_can_do_media(purple_buddy_get_account(b), purple_buddy_get_name(b), PURPLE_MEDIA_AUDIO)) { - media = purple_prpl_initiate_media(purple_buddy_get_account(b), + purple_prpl_initiate_media(purple_buddy_get_account(b), purple_buddy_get_name(b), PURPLE_MEDIA_AUDIO | PURPLE_MEDIA_VIDEO); } else { - media = purple_prpl_initiate_media(purple_buddy_get_account(b), + purple_prpl_initiate_media(purple_buddy_get_account(b), purple_buddy_get_name(b), PURPLE_MEDIA_VIDEO); } - - if (media) { - purple_media_wait(media); - } } #endif
--- a/pidgin/gtkconv.c Tue Jan 13 12:24:39 2009 +0000 +++ b/pidgin/gtkconv.c Tue Jan 13 13:46:06 2009 +0000 @@ -7765,13 +7765,9 @@ PurpleConversation *conv = pidgin_conv_window_get_active_conversation(win); PurpleAccount *account = purple_conversation_get_account(conv); - PurpleMedia *media = - purple_prpl_initiate_media(account, - purple_conversation_get_name(conv), - PURPLE_MEDIA_AUDIO); - - if (media) - purple_media_wait(media); + purple_prpl_initiate_media(account, + purple_conversation_get_name(conv), + PURPLE_MEDIA_AUDIO); } static void @@ -7781,13 +7777,9 @@ PurpleConversation *conv = pidgin_conv_window_get_active_conversation(win); PurpleAccount *account = purple_conversation_get_account(conv); - PurpleMedia *media = - purple_prpl_initiate_media(account, - purple_conversation_get_name(conv), - PURPLE_MEDIA_VIDEO); - - if (media) - purple_media_wait(media); + purple_prpl_initiate_media(account, + purple_conversation_get_name(conv), + PURPLE_MEDIA_VIDEO); } static void @@ -7797,13 +7789,9 @@ PurpleConversation *conv = pidgin_conv_window_get_active_conversation(win); PurpleAccount *account = purple_conversation_get_account(conv); - PurpleMedia *media = - purple_prpl_initiate_media(account, - purple_conversation_get_name(conv), - PURPLE_MEDIA_AUDIO | PURPLE_MEDIA_VIDEO); - - if (media) - purple_media_wait(media); + purple_prpl_initiate_media(account, + purple_conversation_get_name(conv), + PURPLE_MEDIA_AUDIO | PURPLE_MEDIA_VIDEO); } static void