|
|
|
@ -109,6 +109,42 @@ class LinphoneCommunicationSocket():
@@ -109,6 +109,42 @@ class LinphoneCommunicationSocket():
|
|
|
|
|
else: |
|
|
|
|
raise RuntimeError(answer["error"]) |
|
|
|
|
|
|
|
|
|
def call_stats(self, call_id): |
|
|
|
|
self.socket.send("call-stats {call_id}".format(call_id=call_id).encode("ascii")) |
|
|
|
|
answer = self._await_answer() |
|
|
|
|
|
|
|
|
|
if answer["status"]: |
|
|
|
|
stats_offsets = [i for i, x in enumerate(answer["data"]) if "Id:" in x] |
|
|
|
|
stats = { |
|
|
|
|
"audio": {}, |
|
|
|
|
"video": {} |
|
|
|
|
} |
|
|
|
|
stat_type = answer["data"][stats_offsets[0]+1].split(":", 1)[1].strip().lower() |
|
|
|
|
for stat in answer["data"][:stats_offsets[1]]: |
|
|
|
|
k, v = stat.split(":", 1) |
|
|
|
|
key = k.strip().lower().replace(" ", "_") |
|
|
|
|
value = v.strip().lower().replace(" ", "_") |
|
|
|
|
try: |
|
|
|
|
value = int(value) |
|
|
|
|
except Exception: |
|
|
|
|
pass |
|
|
|
|
stats[stat_type].update({key: value}) |
|
|
|
|
|
|
|
|
|
stat_type = answer["data"][stats_offsets[1]+1].split(":", 1)[1].strip().lower() |
|
|
|
|
for stat in answer["data"][stats_offsets[1]:]: |
|
|
|
|
k, v = stat.split(":", 1) |
|
|
|
|
key = k.strip().lower().replace(" ", "_") |
|
|
|
|
value = v.strip().lower().replace(" ", "_") |
|
|
|
|
try: |
|
|
|
|
value = int(value) |
|
|
|
|
except Exception: |
|
|
|
|
pass |
|
|
|
|
stats[stat_type].update({key: value}) |
|
|
|
|
|
|
|
|
|
return status |
|
|
|
|
else: |
|
|
|
|
raise RuntimeError(answer["error"]) |
|
|
|
|
|
|
|
|
|
def call_resume(self, call_id): |
|
|
|
|
self.socket.send("call-resume {call_id}".format(call_id=call_id).encode("ascii")) |
|
|
|
|
answer = self._await_answer() |
|
|
|
|