Commit f217bfe5 authored by Dan Pascu's avatar Dan Pascu

Simplified update_ringtone logic and made it more readable

parent 21c9deb2
...@@ -5263,12 +5263,6 @@ class SessionManager(object): ...@@ -5263,12 +5263,6 @@ class SessionManager(object):
else: else:
outbound_ringtone = Null outbound_ringtone = Null
if outbound_ringtone.type is self.PrimaryRingtone and self.inbound_ringtone.type is self.PrimaryRingtone:
self.inbound_ringtone = Null
if outbound_ringtone is not Null and self.hold_tone is not Null:
self.hold_tone = Null
self.outbound_ringtone = outbound_ringtone
# Incoming ringtone # Incoming ringtone
if self.incoming_requests: if self.incoming_requests:
try: try:
...@@ -5278,7 +5272,7 @@ class SessionManager(object): ...@@ -5278,7 +5272,7 @@ class SessionManager(object):
request = self.incoming_requests[0] request = self.incoming_requests[0]
ringtone_type = self.SecondaryRingtone ringtone_type = self.SecondaryRingtone
if self.active_session is not None and self.active_session.state in ('connecting/ringing', 'connected/*'): if outbound_ringtone.type is self.PrimaryRingtone or self.active_session is not None and self.active_session.state == 'connected/*':
ringtone_type = self.SecondaryRingtone ringtone_type = self.SecondaryRingtone
initial_delay = 1 # have a small delay to avoid sounds overlapping initial_delay = 1 # have a small delay to avoid sounds overlapping
else: else:
...@@ -5299,14 +5293,10 @@ class SessionManager(object): ...@@ -5299,14 +5293,10 @@ class SessionManager(object):
else: else:
inbound_ringtone = Null inbound_ringtone = Null
if inbound_ringtone is not Null and self.hold_tone is not Null:
self.hold_tone = Null
self.inbound_ringtone = inbound_ringtone
# Hold tone # Hold tone
connected_sessions = [session for session in self.sessions if session.state=='connected/*'] connected_sessions = [session for session in self.sessions if session.state=='connected/*']
connected_on_hold_sessions = [session for session in connected_sessions if session.on_hold] connected_on_hold_sessions = [session for session in connected_sessions if session.on_hold]
if self.outbound_ringtone is Null and self.inbound_ringtone is Null and connected_sessions: if outbound_ringtone is Null and inbound_ringtone is Null and connected_sessions:
if len(connected_sessions) == len(connected_on_hold_sessions): if len(connected_sessions) == len(connected_on_hold_sessions):
hold_tone = WavePlayer(SIPApplication.alert_audio_mixer, Resources.get('sounds/hold_tone.wav'), loop_count=0, volume=30, initial_delay=45, pause_time=45) hold_tone = WavePlayer(SIPApplication.alert_audio_mixer, Resources.get('sounds/hold_tone.wav'), loop_count=0, volume=30, initial_delay=45, pause_time=45)
hold_tone.bridge = SIPApplication.alert_audio_bridge hold_tone.bridge = SIPApplication.alert_audio_bridge
...@@ -5319,6 +5309,9 @@ class SessionManager(object): ...@@ -5319,6 +5309,9 @@ class SessionManager(object):
hold_tone = Null hold_tone = Null
else: else:
hold_tone = Null hold_tone = Null
self.outbound_ringtone = outbound_ringtone
self.inbound_ringtone = inbound_ringtone
self.hold_tone = hold_tone self.hold_tone = hold_tone
def _process_remote_proposal(self, blink_session): def _process_remote_proposal(self, blink_session):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment