Skip to content
Snippets Groups Projects
Commit f58647ea authored by Reese Wilson's avatar Reese Wilson
Browse files

expose a few more functions for python

other updates
* fix config test
* remove bad import (allows dringctrl.py to run, where
  previously it would result in an import error)

Change-Id: I401629956b64d2c8d51c499113f1e03b96ae3338
parent 6da70d8a
No related branches found
No related tags found
No related merge requests found
...@@ -508,11 +508,21 @@ class DRingCtrl(Thread): ...@@ -508,11 +508,21 @@ class DRingCtrl(Thread):
return [str(x) for x in self.callmanager.getCallList()] return [str(x) for x in self.callmanager.getCallList()]
def getAllConferences(self):
"""Return all conferences handled by the daemon"""
return [str(x) for x in self.callmanager.getConferenceList()]
def getCallDetails(self, callid): def getCallDetails(self, callid):
"""Return informations on this call if exists""" """Return informations on this call if exists"""
return self.callmanager.getCallDetails(callid) return self.callmanager.getCallDetails(callid)
def getConferenceDetails(self, confid):
"""Return informations on this conference if exists"""
return self.callmanager.getConferenceDetails(confid)
def printClientCallList(self): def printClientCallList(self):
print("Client active call list:") print("Client active call list:")
print("------------------------") print("------------------------")
...@@ -611,6 +621,22 @@ class DRingCtrl(Thread): ...@@ -611,6 +621,22 @@ class DRingCtrl(Thread):
self.callmanager.unhold(callid) self.callmanager.unhold(callid)
def SetAudioOutputDevice(self, index):
self.configurationmanager.setAudioOutputDevice(int (index ))
def SetAudioInputDevice(self, index):
self.configurationmanager.setAudioInputDevice(int (index ))
def ListAudioDevices(self):
outs = self.configurationmanager.getAudioOutputDeviceList()
ins = self.configurationmanager.getAudioInputDeviceList()
return {
"outputDevices": list(outs),
"inputDevices": list(ins)
}
def Dtmf(self, key): def Dtmf(self, key):
"""Send a DTMF""" """Send a DTMF"""
...@@ -633,7 +659,7 @@ class DRingCtrl(Thread): ...@@ -633,7 +659,7 @@ class DRingCtrl(Thread):
""" Create a conference given the two call ids """ """ Create a conference given the two call ids """
self.callmanager.joinParticipant(call1Id, call2Id) self.callmanager.joinParticipant(call1Id, call2Id)
return self.callmanager.getConferenceId(call1Id)
def hangupConference(self, confId): def hangupConference(self, confId):
""" Hang up each call for this conference """ """ Hang up each call for this conference """
......
...@@ -76,6 +76,10 @@ if __name__ == "__main__": ...@@ -76,6 +76,10 @@ if __name__ == "__main__":
metavar='<codec list>', type=str) metavar='<codec list>', type=str)
parser.add_argument('--get-call-list', help='Get call list', action='store_true') parser.add_argument('--get-call-list', help='Get call list', action='store_true')
parser.add_argument('--get-call-details', help='Get call details', metavar='<call-id>')
parser.add_argument('--get-conference-list', help='Get conference list', action='store_true')
parser.add_argument('--get-conference-details', help='Get conference details', metavar='<conference-id>')
group = parser.add_mutually_exclusive_group() group = parser.add_mutually_exclusive_group()
group.add_argument('--call', help='Call to number', metavar='<destination>') group.add_argument('--call', help='Call to number', metavar='<destination>')
#group.add_argument('--transfer', help='Transfer active call', metavar='<destination>') #group.add_argument('--transfer', help='Transfer active call', metavar='<destination>')
...@@ -89,6 +93,12 @@ if __name__ == "__main__": ...@@ -89,6 +93,12 @@ if __name__ == "__main__":
group.add_argument('--hold', help='Hold the call', metavar='<call>') group.add_argument('--hold', help='Hold the call', metavar='<call>')
group.add_argument('--unhold', help='Unhold the call', metavar='<call>') group.add_argument('--unhold', help='Unhold the call', metavar='<call>')
parser.add_argument('--list-audio-devices', help='List audio input and output devices', action='store_true')
parser.add_argument('--set-input', help='Set active input audio device',
metavar='<device-index>', type=int)
parser.add_argument('--set-output', help='Set active output audio device',
metavar='<device-index>', type=int)
parser.add_argument('--dtmf', help='Send DTMF', metavar='<key>') parser.add_argument('--dtmf', help='Send DTMF', metavar='<key>')
parser.add_argument('--toggle-video', help='Launch toggle video tests', action='store_true') parser.add_argument('--toggle-video', help='Launch toggle video tests', action='store_true')
...@@ -159,6 +169,24 @@ if __name__ == "__main__": ...@@ -159,6 +169,24 @@ if __name__ == "__main__":
for call in ctrl.getAllCalls(): for call in ctrl.getAllCalls():
print(call) print(call)
if args.get_call_details:
details = ctrl.getCallDetails(args.get_call_details)
for k,detail in details.items():
print(k + ": " + detail)
if args.get_conference_list:
for conference in ctrl.getAllConferences():
print(conference)
if args.get_conference_details:
details = ctrl.getConferenceDetails(args.get_conference_details)
if details is None:
print("Something went wrong, is conference still active?")
sys.exit(1)
for k,detail in details.items():
print(k + ": " + detail)
if args.call: if args.call:
ctrl.Call(args.call) ctrl.Call(args.call)
...@@ -177,6 +205,21 @@ if __name__ == "__main__": ...@@ -177,6 +205,21 @@ if __name__ == "__main__":
if args.unhold: if args.unhold:
ctrl.UnHold(args.unhold) ctrl.UnHold(args.unhold)
if args.list_audio_devices:
allDevices = ctrl.ListAudioDevices()
print("Output Devices")
for index,device in enumerate(allDevices["outputDevices"]):
print(f"{index}: {device}")
print("Input Devices")
for index,device in enumerate(allDevices["inputDevices"]):
print(f"{index}: {device}")
if args.set_input is not None:
print(ctrl.SetAudioInputDevice(args.set_input))
if args.set_output:
print(ctrl.SetAudioOutputDevice(args.set_output))
if args.dtmf: if args.dtmf:
ctrl.Dtmf(args.dtmf) ctrl.Dtmf(args.dtmf)
......
...@@ -25,7 +25,7 @@ import logging ...@@ -25,7 +25,7 @@ import logging
import multiprocessing import multiprocessing
from sippwrap import SippWrapper from sippwrap import SippWrapper
from sippwrap import SippScreenStatParser from sippwrap import SippScreenStatParser
from sflphonectrl import SflPhoneCtrl from dringctrl import DRingCtrl as SflPhoneCtrl
from nose.tools import nottest from nose.tools import nottest
...@@ -93,7 +93,7 @@ class TestSFLPhoneAccountConfig(SflPhoneCtrl): ...@@ -93,7 +93,7 @@ class TestSFLPhoneAccountConfig(SflPhoneCtrl):
""" The test suite for account configuration """ """ The test suite for account configuration """
def __init__(self): def __init__(self):
SflPhoneCtrl.__init__(self) SflPhoneCtrl.__init__(self, "test", False)
self.logger = logging.getLogger("TestSFLPhoneAccountConfig") self.logger = logging.getLogger("TestSFLPhoneAccountConfig")
filehdlr = logging.FileHandler("/tmp/sflphonedbustest.log") filehdlr = logging.FileHandler("/tmp/sflphonedbustest.log")
...@@ -203,7 +203,7 @@ class TestSFLPhoneRegisteredCalls(SflPhoneCtrl, SippCtrl): ...@@ -203,7 +203,7 @@ class TestSFLPhoneRegisteredCalls(SflPhoneCtrl, SippCtrl):
""" The test suite for call interaction """ """ The test suite for call interaction """
def __init__(self): def __init__(self):
SflPhoneCtrl.__init__(self) SflPhoneCtrl.__init__(self, "test", False)
SippCtrl.__init__(self) SippCtrl.__init__(self)
self.logger = logging.getLogger("TestSFLPhoneRegisteredCalls") self.logger = logging.getLogger("TestSFLPhoneRegisteredCalls")
...@@ -284,7 +284,7 @@ class TestSFLPhoneConferenceCalls(SflPhoneCtrl, SippCtrl): ...@@ -284,7 +284,7 @@ class TestSFLPhoneConferenceCalls(SflPhoneCtrl, SippCtrl):
""" Test Conference calls """ """ Test Conference calls """
def __init__(self): def __init__(self):
SflPhoneCtrl.__init__(self) SflPhoneCtrl.__init__(self, "test", False)
SippCtrl.__init__(self) SippCtrl.__init__(self)
self.logger = logging.getLogger("TestSFLPhoneRegisteredCalls") self.logger = logging.getLogger("TestSFLPhoneRegisteredCalls")
......
...@@ -32,7 +32,6 @@ except Exception as e: ...@@ -32,7 +32,6 @@ except Exception as e:
from threading import Thread from threading import Thread
from random import shuffle from random import shuffle
from errors import *
ALL_TEST_NAME = { ALL_TEST_NAME = {
'TestConfig': 'testConfig', 'TestConfig': 'testConfig',
...@@ -56,7 +55,7 @@ class DRingTester(): ...@@ -56,7 +55,7 @@ class DRingTester():
codecAudio = '' codecAudio = ''
codecVideo = '' codecVideo = ''
def testConfig(self, ctrl): def testConfig(self, ctrl, nbIteration, delay):
print("**[BEGIN] test config") print("**[BEGIN] test config")
allCodecs = ctrl.getAllCodecs() allCodecs = ctrl.getAllCodecs()
if len(allCodecs) == 0: if len(allCodecs) == 0:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment