Philipp Hörist pushed to branch master at gajim / gajim
Commits: b5e9c8e3 by emil at 2021-12-24T00:13:16+01:00 Calls: Add DSP
- - - - - 4fdf993e by emil at 2021-12-24T00:27:35+01:00 Calls: Add ringing/dialing sound
- - - - -
9 changed files:
- gajim/common/helpers.py - gajim/common/jingle_rtp.py - gajim/common/setting_values.py - + gajim/data/sounds/CREDITS - + gajim/data/sounds/call_incoming.wav - + gajim/data/sounds/call_outgoing.wav - gajim/gtk/call_widget.py - gajim/gtk/conversation/rows/call.py - gajim/gtk/manage_sounds.py
Changes:
===================================== gajim/common/helpers.py ===================================== @@ -467,13 +467,16 @@ def get_contact_dict_for_account(account): return contacts_dict
-def play_sound(sound_event: str, account: str, - force: bool = False) -> None: +def play_sound(sound_event: str, + account: str, + force: bool = False, + loop: bool = False) -> None: + if sound_event is None: return if force or allow_sound_notification(account, sound_event): play_sound_file( - app.settings.get_soundevent_settings(sound_event)['path']) + app.settings.get_soundevent_settings(sound_event)['path'], loop)
def check_soundfile_path(file_, dirs=None): @@ -530,13 +533,13 @@ def strip_soundfile_path(file_, dirs=None, abs_=True): return name return file_
-def play_sound_file(path_to_soundfile): +def play_sound_file(path_to_soundfile: str, loop: bool = False): path_to_soundfile = check_soundfile_path(path_to_soundfile) if path_to_soundfile is None: return
from gajim.common import sound - sound.play(path_to_soundfile) + sound.play(path_to_soundfile, loop)
def get_connection_status(account: str) -> str: if not app.account_is_available(account):
===================================== gajim/common/jingle_rtp.py ===================================== @@ -413,12 +413,19 @@ def setup_stream(self): # TODO: Add queues? self.src_bin = self.make_bin_from_config( 'audio_input_device', - '%s ! audioconvert', + '''%s + ! webrtcdsp + echo-suppression-level=high + noise-suppression-level=very-high + voice-detection=true + ! audioconvert ''', _('audio input'))
+ # setting name=webrtcechoprobe0 is needed because lingering probes + # cause a bug in subsequent calls self.sink = self.make_bin_from_config( 'audio_output_device', - 'audioconvert ! volume name=gajim_out_vol ! %s', + 'audioconvert ! volume name=gajim_out_vol ! webrtcechoprobe name=webrtcechoprobe0 ! %s', _('audio output'))
self.mic_volume = self.src_bin.get_by_name('gajim_vol')
===================================== gajim/common/setting_values.py ===================================== @@ -538,6 +538,14 @@ class _ACCOUNT_DEFAULT: 'muc_message_received': { 'enabled': True, 'path': 'message2.wav' + }, + 'incoming-call-sound': { + 'enabled': True, + 'path': 'call_incoming.wav' + }, + 'outgoing-call-sound': { + 'enabled': True, + 'path': 'call_outgoing.wav' } }
===================================== gajim/data/sounds/CREDITS ===================================== @@ -0,0 +1,5 @@ +incoming-call.wav +outgoing-call.wav + Copyright: Damien Sandras + URL: http://git.gnome.org/cgit/ekiga/tree/sounds + License: GPLv2+
===================================== gajim/data/sounds/call_incoming.wav ===================================== Binary files /dev/null and b/gajim/data/sounds/call_incoming.wav differ
===================================== gajim/data/sounds/call_outgoing.wav ===================================== Binary files /dev/null and b/gajim/data/sounds/call_outgoing.wav differ
===================================== gajim/gtk/call_widget.py ===================================== @@ -35,6 +35,8 @@ from gajim.common.i18n import _ from gajim.common.jingle_rtp import JingleAudio from gajim.common.nec import NetworkEvent +from gajim.common.helpers import play_sound +from gajim.common import sound
from .gstreamer import create_gtk_widget from .builder import get_builder @@ -109,10 +111,12 @@ def get_jingle_available(self, content_type: str) -> bool: return self._jingle[content_type].available
def _on_call_with_mic(self, _button: Gtk.Button) -> None: + play_sound('outgoing-call-sound', self._account, force=True, loop=True) self._on_jingle_button_toggled(['audio']) self._ui.av_start_box.hide()
def _on_call_with_mic_and_cam(self, _button: Gtk.Button) -> None: + play_sound('outgoing-call-sound', self._account, force=True, loop=True) self._on_jingle_button_toggled(['audio', 'video']) self._ui.av_start_box.hide()
@@ -237,8 +241,9 @@ def _on_jingle_request(self, event): self._incoming_video_event = event else: # There is no voice call running running yet - self.emit('incoming-call', event) + play_sound('incoming-call-sound', self._account, loop=True)
+ self.emit('incoming-call', event) app.nec.push_incoming_event( NetworkEvent('notification', account=self._account, @@ -268,6 +273,7 @@ def _on_jingle_connected(self, event): session.approve_session() for content in event.media: session.approve_content(content) + sound.stop() # dialing/ringing
def _on_jingle_disconnected(self, event): if event.media is None: @@ -284,6 +290,7 @@ def _on_jingle_disconnected(self, event): JingleState.NULL, sid=event.sid, reason=event.reason) + sound.stop() # dialing/ringing
def _on_jingle_error(self, event): if event.sid == self._jingle['audio'].sid: @@ -291,6 +298,7 @@ def _on_jingle_error(self, event): 'audio', JingleState.ERROR, reason=event.reason) + sound.stop() # dialing/ringing
def start_call(self) -> None: audio_state = self._jingle['audio'].state @@ -305,6 +313,8 @@ def start_call(self) -> None: self._ui.av_cam_button.set_sensitive(False)
def accept_call(self, session): + sound.stop() # dialing/ringing + if not session: return
@@ -328,6 +338,8 @@ def accept_call(self, session):
@staticmethod def decline_call(session): + sound.stop() # dialing/ringing + if not session: return
===================================== gajim/gtk/conversation/rows/call.py ===================================== @@ -24,6 +24,7 @@ from gajim.common.const import KindConstant from gajim.common.i18n import _ from gajim.common.jingle_session import JingleSession +from gajim.common import sound
from .widgets import SimpleLabel from .base import BaseRow @@ -95,6 +96,7 @@ def _on_accept(self, button): self.get_parent().accept_call(self._session)
def _on_decline(self, _button): + sound.stop() # dialing/ringing if self._event is not None: session = self._client.get_module('Jingle').get_jingle_session( self._event.fjid, self._event.sid)
===================================== gajim/gtk/manage_sounds.py ===================================== @@ -39,6 +39,8 @@ 'message_sent': _('Message Sent'), 'muc_message_highlight': _('Group Chat Message Highlight'), 'muc_message_received': _('Group Chat Message Received'), + 'incoming-call-sound': _('Call Incoming'), + 'outgoing-call-sound': _('Call Outgoing'), }
View it on GitLab: https://dev.gajim.org/gajim/gajim/-/compare/4b76de1bf3982b869ce048c06bcfbac3...