|
@@ -129,6 +129,8 @@ def sleep(duration):
|
|
dummy_event.wait(timeout=duration)
|
|
dummy_event.wait(timeout=duration)
|
|
|
|
|
|
|
|
|
|
|
|
+
|
|
|
|
+
|
|
class SipConnection(object):
|
|
class SipConnection(object):
|
|
def say(self, core):
|
|
def say(self, core):
|
|
if self._conversation.status is not ConversationStatus.IMTALKING:
|
|
if self._conversation.status is not ConversationStatus.IMTALKING:
|
|
@@ -145,7 +147,7 @@ class SipConnection(object):
|
|
self._replies_pos = 1
|
|
self._replies_pos = 1
|
|
|
|
|
|
duration = get_wav_duration(voice_filename)
|
|
duration = get_wav_duration(voice_filename)
|
|
- log("Saying : " + voice_filename + "(duration : " + str(duration) + ")")
|
|
|
|
|
|
+ log("Saying : " + voice_filename)
|
|
|
|
|
|
core.play_file = voice_filename
|
|
core.play_file = voice_filename
|
|
|
|
|
|
@@ -156,8 +158,6 @@ class SipConnection(object):
|
|
self._conversation.status = ConversationStatus.WAITFORANSWER
|
|
self._conversation.status = ConversationStatus.WAITFORANSWER
|
|
|
|
|
|
def incoming_stream_worker(self, core, call):
|
|
def incoming_stream_worker(self, core, call):
|
|
- log("Worker is starting")
|
|
|
|
-
|
|
|
|
f = open(self._incoming_stream_file, "rb")
|
|
f = open(self._incoming_stream_file, "rb")
|
|
f.seek(0, io.SEEK_END)
|
|
f.seek(0, io.SEEK_END)
|
|
p = f.tell()
|
|
p = f.tell()
|
|
@@ -195,6 +195,10 @@ class SipConnection(object):
|
|
|
|
|
|
log("Worker is quitting")
|
|
log("Worker is quitting")
|
|
|
|
|
|
|
|
+ @staticmethod
|
|
|
|
+ def registration_state_changed(core, call, state, message):
|
|
|
|
+ log("Registration status: " + message)
|
|
|
|
+
|
|
def call_state_changed(self, core, call, state, message):
|
|
def call_state_changed(self, core, call, state, message):
|
|
log("state changed : " + message)
|
|
log("state changed : " + message)
|
|
|
|
|
|
@@ -269,7 +273,8 @@ class SipConnection(object):
|
|
def __init__(self, domain, username, password):
|
|
def __init__(self, domain, username, password):
|
|
|
|
|
|
callbacks = {
|
|
callbacks = {
|
|
- 'call_state_changed': self.call_state_changed
|
|
|
|
|
|
+ 'call_state_changed': self.call_state_changed,
|
|
|
|
+ 'registration_state_changed': self.registration_state_changed,
|
|
}
|
|
}
|
|
|
|
|
|
self._core = linphone.Core.new(callbacks, None, None)
|
|
self._core = linphone.Core.new(callbacks, None, None)
|
|
@@ -282,6 +287,7 @@ class SipConnection(object):
|
|
self._replies_pos = 0
|
|
self._replies_pos = 0
|
|
self._volume_threshold = VOLUME_THRESHOLD
|
|
self._volume_threshold = VOLUME_THRESHOLD
|
|
self._incoming_stream_file = tempfile.NamedTemporaryFile(delete=False).name
|
|
self._incoming_stream_file = tempfile.NamedTemporaryFile(delete=False).name
|
|
|
|
+ self._core.iterate()
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
if __name__ == "__main__":
|