42
42
SipDialError ,
43
43
SetStreamClassError ,
44
44
BroadcastError ,
45
+ DTMFError
45
46
)
46
47
47
48
@@ -1009,6 +1010,11 @@ def dial(self, session_id, token, sip_uri, options=[]):
1009
1010
honor the force mute action. Defaults to False if moderator does not want to observe force
1010
1011
mute a stream and set to True if the moderator wants to observe force mute a stream.
1011
1012
1013
+ Boolean 'video': A Boolean flag that indicates whether the SIP call will include video(true)
1014
+ or not(false, which is the default). With video included, the SIP client's video is included
1015
+ in the OpenTok stream that is sent to the OpenTok session. The SIP client will receive a single
1016
+ composed video of the published streams in the OpenTok session.
1017
+
1012
1018
This is an example of what the payload POST data body could look like:
1013
1019
1014
1020
{
@@ -1025,10 +1031,12 @@ def dial(self, session_id, token, sip_uri, options=[]):
1025
1031
"password": "password"
1026
1032
},
1027
1033
"secure": true|false,
1028
- "observeForceMute": true|false
1034
+ "observeForceMute": true|false,
1035
+ "video": true|false
1029
1036
}
1030
1037
}
1031
1038
1039
+
1032
1040
:rtype: A SipCall object, which contains data of the SIP call: id, connectionId and streamId.
1033
1041
This is what the response body should look like after returning with a status code of 200:
1034
1042
@@ -1042,6 +1050,7 @@ def dial(self, session_id, token, sip_uri, options=[]):
1042
1050
"""
1043
1051
payload = {"sessionId" : session_id , "token" : token , "sip" : {"uri" : sip_uri }}
1044
1052
observeForceMute = False
1053
+ video = False
1045
1054
1046
1055
if "from" in options :
1047
1056
payload ["sip" ]["from" ] = options ["from" ]
@@ -1058,6 +1067,10 @@ def dial(self, session_id, token, sip_uri, options=[]):
1058
1067
if "observeForceMute" in options :
1059
1068
observeForceMute = True
1060
1069
payload ["sip" ]["observeForceMute" ] = options ["observeForceMute" ]
1070
+
1071
+ if "video" in options :
1072
+ video = True
1073
+ payload ["sip" ]["video" ] = options ["video" ]
1061
1074
1062
1075
endpoint = self .endpoints .dial_url ()
1063
1076
@@ -1447,3 +1460,41 @@ def mute(self, session_id: str, stream_id: str= "", options: dict = {}) -> reque
1447
1460
("There was an error thrown by the OpenTok SDK, please check that your session_id {0} and stream_id (if exists) {1} are valid" ).format (
1448
1461
session_id , stream_id ))
1449
1462
1463
+ def play_dtmf (self , session_id : str , connection_id : str , digits : str , options : dict = {}) -> requests .Response :
1464
+ """
1465
+ Plays a DTMF string into a session or to a specific connection
1466
+
1467
+ :param session_id The ID of the OpenTok session that the participant being called
1468
+ will join
1469
+
1470
+ :param connection_id An optional parameter used to send the DTMF tones to a specific
1471
+ connectoiin in a session.
1472
+
1473
+ :param digits DTMF digits to play
1474
+ Valid DTMF digits are 0-9, p, #, and * digits. 'p' represents a 500ms pause if a delay is
1475
+ needed during the input process.
1476
+
1477
+ """
1478
+
1479
+ try :
1480
+ if not connection_id :
1481
+ url = self .endpoints .get_dtmf_all_url (session_id )
1482
+ payload = {"digits" : digits }
1483
+ else :
1484
+ url = self .endpoints .get_dtmf_specific_url (session_id , connection_id )
1485
+ payload = {"digits" : digits }
1486
+
1487
+ response = requests .post (url , headers = self .get_json_headers (), data = json .dumps (payload ))
1488
+
1489
+ if response .status_code == 200 :
1490
+ return response
1491
+ elif response .status_code == 400 :
1492
+ raise DTMFError ("One of the properties digits, sessionId or connectionId is invalid." )
1493
+ elif response .status_code == 403 :
1494
+ raise AuthError ("Failed to create session, invalid credentials. Please check your OpenTok API Key or JSON web token" )
1495
+ elif response .status_code == 404 :
1496
+ raise NotFoundError ("The session does not exists or the client specified by the connection_id is not connected to the session" )
1497
+ except Exception as e :
1498
+ raise OpenTokException (
1499
+ (f"There was an error thrown by the OpenTok SDK, please check that your session_id: { session_id } , connection_id (if exists): { connection_id } and digits: { digits } are valid" ))
1500
+
0 commit comments