]> www.infradead.org Git - pidgin-chime.git/commitdiff
Fix up some muted/silent confusion
authorDavid Woodhouse <dwmw@amazon.co.uk>
Wed, 7 Mar 2018 15:15:21 +0000 (15:15 +0000)
committerDavid Woodhouse <dwmw@amazon.co.uk>
Wed, 7 Mar 2018 15:15:21 +0000 (15:15 +0000)
chat.c
chime-call-audio.c
chime-call-audio.h
chime-call-transport.c
chime-call.c
chime-call.h

diff --git a/chat.c b/chat.c
index 4a67039338b19b44d658b03cf827f419a2bb1f3e..0f1cfcae85bc57ffd1120b8511fc437e45eb8776 100644 (file)
--- a/chat.c
+++ b/chat.c
@@ -261,7 +261,7 @@ static void call_media_changed(PurpleMedia *media, PurpleMediaState state, const
        if (state == PURPLE_MEDIA_STATE_END && !id && !participant) {
                if (chat->media) {
                        chat->media = NULL;
-                       chime_call_set_mute(chat->call, TRUE);
+                       chime_call_set_silent(chat->call, TRUE);
                }
        }
 }
@@ -285,7 +285,7 @@ static void on_audio_state(ChimeCall *call, ChimeAudioState audio_state, struct
                                                                TRUE);
                if (!chat->media) {
                        /* XX: Report error, but not with purple_media_error()! */
-                       chime_call_set_mute(chat->call, TRUE);
+                       chime_call_set_silent(chat->call, TRUE);
                        return;
                }
 
@@ -296,7 +296,7 @@ static void on_audio_state(ChimeCall *call, ChimeAudioState audio_state, struct
                        purple_media_error(chat->media, _("Error adding media stream\n"));
                        purple_media_end(chat->media, NULL, NULL);
                        chat->media = NULL;
-                       chime_call_set_mute(chat->call, TRUE);
+                       chime_call_set_silent(chat->call, TRUE);
                        return;
                }
 
@@ -327,7 +327,7 @@ static void on_audio_state(ChimeCall *call, ChimeAudioState audio_state, struct
                        purple_media_error(chat->media, _("Error setting Chime OPUS codec\n"));
                        purple_media_end(chat->media, NULL, NULL);
                        chat->media = NULL;
-                       chime_call_set_mute(chat->call, TRUE);
+                       chime_call_set_silent(chat->call, TRUE);
                        return;
                }
                purple_media_codec_list_free(codecs);
@@ -775,7 +775,7 @@ static void join_audio(PurpleBuddy *buddy, gpointer _chat)
 {
        struct chime_chat *chat = _chat;
        if (chat->call)
-               chime_call_set_mute(chat->call, FALSE);
+               chime_call_set_silent(chat->call, FALSE);
 }
 
 GList *chime_purple_chat_menu(PurpleChat *pchat)
index aa404722221de517255cf3d6f9db327ce7c3c7f7..dedfc25ba7b8fc0785fc8e8f25830d999ed6d3f9 100644 (file)
@@ -213,7 +213,7 @@ static gboolean audio_receive_auth_msg(ChimeCallAudio *audio, gconstpointer pkt,
        chime_debug("Got AuthMessage authorised %d %d\n", msg->has_authorized, msg->authorized);
        if (msg->has_authorized && msg->authorized) {
                do_send_rt_packet(audio, NULL);
-               chime_call_audio_set_state(audio, audio->muted ? CHIME_AUDIO_STATE_AUDIOLESS :
+               chime_call_audio_set_state(audio, audio->silent ? CHIME_AUDIO_STATE_AUDIOLESS :
                                           (audio->local_mute ? CHIME_AUDIO_STATE_AUDIO_MUTED : CHIME_AUDIO_STATE_AUDIO));
        }
 
@@ -534,7 +534,7 @@ void chime_call_audio_install_gst_app_callbacks(ChimeCallAudio *audio, GstAppSrc
        gst_app_sink_set_callbacks(appsink, &chime_appsink_callbacks, audio, chime_appsink_destroy);
 }
 
-ChimeCallAudio *chime_call_audio_open(ChimeConnection *cxn, ChimeCall *call, gboolean muted)
+ChimeCallAudio *chime_call_audio_open(ChimeConnection *cxn, ChimeCall *call, gboolean silent)
 {
        ChimeCallAudio *audio = g_new0(ChimeCallAudio, 1);
        audio->call = call;
@@ -551,27 +551,32 @@ ChimeCallAudio *chime_call_audio_open(ChimeConnection *cxn, ChimeCall *call, gbo
        audio->audio_msg.has_sample_time = 1;
        audio->audio_msg.sample_time = g_random_int();
 
-       chime_call_transport_connect(audio, muted);
+       chime_call_transport_connect(audio, silent);
        chime_call_audio_set_state(audio, CHIME_AUDIO_STATE_CONNECTING);
 
        return audio;
 }
 
 /* Reopen the transport with/without audio enabled at all. */
-void chime_call_audio_reopen(ChimeCallAudio *audio, gboolean muted)
+void chime_call_audio_reopen(ChimeCallAudio *audio, gboolean silent)
 {
-       chime_call_audio_local_mute(audio, muted);
-       if (muted != audio->muted) {
+       chime_call_audio_local_mute(audio, silent);
+       if (silent != audio->silent) {
                if (audio->send_rt_source)
                        g_source_remove(audio->send_rt_source);
                if (audio->data_ack_source)
                        g_source_remove(audio->data_ack_source);
                chime_call_transport_disconnect(audio, TRUE);
-               chime_call_transport_connect(audio, muted);
+               chime_call_transport_connect(audio, silent);
                chime_call_audio_set_state(audio, CHIME_AUDIO_STATE_CONNECTING);
        }
 }
 
+gboolean chime_call_audio_get_silent(ChimeCallAudio *audio)
+{
+       return audio->silent;
+}
+
 /* Set client-side muting, when the audio is actually connected */
 void chime_call_audio_local_mute(ChimeCallAudio *audio, gboolean muted)
 {
index 0aa2583534f49428e92fa257c0bfb6c4e20d47fe..cae498a8979b6727ad01f3fc618caad7a4d9fe1d 100644 (file)
@@ -33,8 +33,8 @@
 struct _ChimeCallAudio {
        ChimeCall *call;
        ChimeAudioState state;
-       gboolean local_mute;
-       gboolean muted;
+       gboolean local_mute; /* Listening but not sending from mic */
+       gboolean silent; /* No audio; only participant data */
        GMutex transport_lock;
        SoupWebsocketConnection *ws;
        guint data_ack_source;
@@ -71,14 +71,15 @@ enum xrp_pkt_type {
 };
 
 /* Called from ChimeMeeting */
-ChimeCallAudio *chime_call_audio_open(ChimeConnection *cxn, ChimeCall *call, gboolean muted);
+ChimeCallAudio *chime_call_audio_open(ChimeConnection *cxn, ChimeCall *call, gboolean silent);
 void chime_call_audio_close(ChimeCallAudio *audio, gboolean hangup);
-void chime_call_audio_reopen(ChimeCallAudio *audio, gboolean muted);
+void chime_call_audio_reopen(ChimeCallAudio *audio, gboolean silent);
+gboolean chime_call_audio_get_silent(ChimeCallAudio *audio);
 void chime_call_audio_set_state(ChimeCallAudio *audio, ChimeAudioState state);
 void chime_call_audio_local_mute(ChimeCallAudio *audio, gboolean muted);
 
 /* Called from audio code */
-void chime_call_transport_connect(ChimeCallAudio *audio, gboolean muted);
+void chime_call_transport_connect(ChimeCallAudio *audio, gboolean silent);
 void chime_call_transport_disconnect(ChimeCallAudio *audio, gboolean hangup);
 void chime_call_transport_send_packet(ChimeCallAudio *audio, enum xrp_pkt_type type, const ProtobufCMessage *message);
 
index e3d20f96c4411a88ab6cb4e4947418d2190a20ff..b4b7fe203097a17a98ac41416a3158c9992a7eec 100644 (file)
@@ -97,7 +97,7 @@ static void audio_send_auth_packet(ChimeCallAudio *audio)
        msg.has_codec = TRUE;
 
        msg.flags = FLAGS__FLAG_HAS_PROFILE_TABLE | FLAGS__FLAG_HAS_CLIENT_STATUS;
-       if (audio->muted)
+       if (audio->silent)
                msg.flags |= FLAGS__FLAG_MUTE;
        msg.has_flags = TRUE;
 
@@ -136,7 +136,7 @@ static void audio_send_hangup_packet(ChimeCallAudio *audio)
        msg.has_codec = TRUE;
 
        msg.flags = FLAGS__FLAG_HAS_PROFILE_TABLE;
-       if (audio->muted)
+       if (audio->silent)
                msg.flags |= FLAGS__FLAG_MUTE;
        msg.has_flags = TRUE;
 
@@ -165,14 +165,14 @@ static void audio_ws_connect_cb(GObject *obj, GAsyncResult *res, gpointer _audio
 }
 
 
-void chime_call_transport_connect(ChimeCallAudio *audio, gboolean muted)
+void chime_call_transport_connect(ChimeCallAudio *audio, gboolean silent)
 {
        /* Grrr, GDtlsClientConnection doesn't actually exist yet. Let's stick
           with the WebSocket for now... */
        SoupURI *uri = soup_uri_new_printf(chime_call_get_audio_ws_url(audio->call), "/audio");
        SoupMessage *msg = soup_message_new_from_uri("GET", uri);
 
-       audio->muted = muted;
+       audio->silent = silent;
 
        char *protocols[] = { (char *)"opus-med", NULL };
        gchar *origin = g_strdup_printf("http://%s", soup_uri_get_host(uri));
index f01afbcb4eaf3493f9bd35eff1159d8611e346f9..c1cb57716cf6b21e9f5b9d6b10da2154783285f3 100644 (file)
@@ -505,10 +505,18 @@ void chime_connection_open_call(ChimeConnection *cxn, ChimeCall *call, gboolean
        }
 }
 
-void chime_call_set_mute(ChimeCall *call, gboolean muted)
+void chime_call_set_silent(ChimeCall *call, gboolean silent)
 {
        if (call->audio)
-               chime_call_audio_reopen(call->audio, muted);
+               chime_call_audio_reopen(call->audio, silent);
+}
+
+gboolean chime_call_get_silent(ChimeCall *call)
+{
+       if (call->audio)
+               return chime_call_audio_get_silent(call->audio);
+       else
+               return TRUE;
 }
 
 void chime_call_set_local_mute(ChimeCall *call, gboolean muted)
index 7f22a77575ad1049ad864cbc9bf0ba7243268a80..697c4807293911016c24a5643a4a4dda83547d46 100644 (file)
@@ -68,7 +68,8 @@ const gchar *chime_call_get_mobile_bithub_url(ChimeCall *self);
 const gchar *chime_call_get_stun_server_url(ChimeCall *self);
 
 /* Is this an audio-less call, where we are just "checked in"? */
-void chime_call_set_mute(ChimeCall *call, gboolean muted);
+void chime_call_set_silent(ChimeCall *call, gboolean muted);
+gboolean chime_call_get_silent(ChimeCall *call);
 
 /* Audio call, but we want to be quiet now. */
 void chime_call_set_local_mute(ChimeCall *call, gboolean muted);