From e3f16c63713fd74f2b7e09c5c994fc6413e4f3e8 Mon Sep 17 00:00:00 2001 From: Thibaut GIRKA Date: Sun, 10 Jan 2010 16:31:00 +0100 Subject: [PATCH] [Jingle] Volume levels are saved, audio UI shows up even if there are errors, until the session ends --- src/chat_control.py | 20 ++++++++++++++++++-- src/common/config.py | 2 ++ src/common/jingle_rtp.py | 10 ++++++++-- src/common/jingle_session.py | 2 +- 4 files changed, 29 insertions(+), 5 deletions(-) diff --git a/src/chat_control.py b/src/chat_control.py index bd0f1e89d..ca5ce6e58 100644 --- a/src/chat_control.py +++ b/src/chat_control.py @@ -1550,9 +1550,17 @@ class ChatControl(ChatControlBase): self._update_jingle('audio') vbox = self.xml.get_widget('audio_vbox') if self.audio_state == self.JINGLE_STATE_CONNECTED: + # Set volume from config + input_vol = gajim.config.get('audio_input_volume') + output_vol = gajim.config.get('audio_output_volume') + input_vol = max(min(input_vol, 100), 0) + output_vol = max(min(output_vol, 100), 0) + self.xml.get_widget('mic_hscale').set_value(input_vol) + self.xml.get_widget('sound_hscale').set_value(output_vol) + # Show vbox vbox.set_no_show_all(False) vbox.show_all() - else: + elif not self.audio_sid: vbox.set_no_show_all(True) vbox.hide() @@ -1632,9 +1640,17 @@ class ChatControl(ChatControlBase): def on_mic_hscale_value_changed(self, widget): value = widget.get_value() self._get_audio_content().set_mic_volume(value / 100) + # Save volume to config + # FIXME: Putting it here is maybe not the right thing to do? + gajim.config.set('audio_input_volume', value) + def on_sound_hscale_value_changed(self, widget): - pass + value = widget.get_value() + self._get_audio_content().set_out_volume(value / 100) + # Save volume to config + # FIXME: Putting it here is maybe not the right thing to do? + gajim.config.set('audio_output_volume', value) def on_avatar_eventbox_enter_notify_event(self, widget, event): """ diff --git a/src/common/config.py b/src/common/config.py index afe3cca47..475200912 100644 --- a/src/common/config.py +++ b/src/common/config.py @@ -277,6 +277,8 @@ class Config: 'audio_output_device': [opt_str, 'autoaudiosink'], 'video_input_device': [opt_str, 'autovideosrc ! videoscale ! ffmpegcolorspace'], 'video_output_device': [opt_str, 'autovideosink'], + 'audio_input_volume': [opt_int, 50], + 'audio_output_volume': [opt_int, 50], 'use_stun_server': [opt_bool, True, _('If True, Gajim will try to use a STUN server when using jingle. The one in "stun_server" option, or the one given by the jabber server.')], 'stun_server': [opt_str, '', _('STUN server to use when using jingle')], 'show_affiliation_in_groupchat': [opt_bool, True, _('If True, Gajim will show affiliation of groupchat occupants by adding a colored square to the status icon')], diff --git a/src/common/jingle_rtp.py b/src/common/jingle_rtp.py index 8a57bde97..fe5d3fc9d 100644 --- a/src/common/jingle_rtp.py +++ b/src/common/jingle_rtp.py @@ -268,6 +268,12 @@ class JingleAudio(JingleRTPContent): """ self.mic_volume.set_property('volume', vol) + def set_out_volume(self, vol): + """ + vol must be between 0 ans 1 + """ + self.out_volume.set_property('volume', vol) + def setup_stream(self): JingleRTPContent.setup_stream(self) @@ -289,10 +295,10 @@ class JingleAudio(JingleRTPContent): '%s ! audioconvert', _("audio input")) self.sink = self.make_bin_from_config('audio_output_device', - 'audioconvert ! %s', _("audio output")) + 'audioconvert ! volume name=gajim_out_vol ! %s', _("audio output")) self.mic_volume = src_bin.get_by_name('gajim_vol') - self.set_mic_volume(0) + self.out_volume = self.sink.get_by_name('gajim_out_vol') # link gst elements self.pipeline.add(self.sink, src_bin) diff --git a/src/common/jingle_session.py b/src/common/jingle_session.py index 7002e12b7..25eebd2a1 100644 --- a/src/common/jingle_session.py +++ b/src/common/jingle_session.py @@ -100,7 +100,7 @@ class JingleSession(object): 'security-info': [self.__ack], #TODO 'session-accept': [self.__on_session_accept, self.__on_content_accept, self.__broadcast, self.__ack], - 'session-info': [self.__on_session_info, self.__broadcast, self.__ack], + 'session-info': [self.__broadcast, self.__on_session_info, self.__ack], 'session-initiate': [self.__on_session_initiate, self.__broadcast, self.__ack], 'session-terminate': [self.__on_session_terminate, self.__broadcast_all,