@@ -407,7 +407,7 @@ def create_session(
407
407
proxies = self .proxies ,
408
408
timeout = self .timeout ,
409
409
)
410
-
410
+
411
411
response .encoding = "utf-8"
412
412
413
413
if response .status_code == 403 :
@@ -754,13 +754,13 @@ def list_archives(self, offset=None, count=None, session_id=None):
754
754
return self .get_archives (offset , count , session_id )
755
755
756
756
def add_archive_stream (
757
- self ,
757
+ self ,
758
758
archive_id : str ,
759
759
stream_id : str ,
760
760
has_audio : bool = True ,
761
- has_video : bool = True
761
+ has_video : bool = True
762
762
) -> requests .Response :
763
-
763
+
764
764
"""
765
765
This method will add streams to the archive with addStream for new participant(choosing audio, video or both).
766
766
@@ -1120,16 +1120,15 @@ def dial(self, session_id, token, sip_uri, options=[]):
1120
1120
}
1121
1121
1122
1122
Boolean 'secure': A Boolean flag that indicates whether the media must be transmitted
1123
- encrypted (true) or not (false , the default)
1123
+ encrypted (true) or not (False , the default)
1124
1124
1125
- Boolean 'observeForceMute': A Boolean flag that determines whether the SIP endpoint should
1126
- honor the force mute action. The force mute action allows a moderator to force clients to
1127
- mute audio in streams they publish. It defaults to False if moderator does not want to observe
1128
- force mute a stream and set to True if the moderator wants to observe force mute a stream.
1125
+ Boolean 'observeForceMute': Whether the SIP endpoint should honor a force mute action
1126
+ (True) or not (False, the default). A force mute action allows a moderator to force clients to
1127
+ mute audio in streams they publish.
1129
1128
1130
- Boolean 'video': A Boolean flag that indicates whether the SIP call will include video(true)
1131
- or not(false, which is the default). With video included, the SIP client's video is included
1132
- in the OpenTok stream that is sent to the OpenTok session. The SIP client will receive a single
1129
+ Boolean 'video': Whether the SIP call will include video (true)
1130
+ or not (False, the default). With video included, the SIP client's video is included
1131
+ in the OpenTok stream that is sent to the OpenTok session. The SIP client will receive a single
1133
1132
composed video of the published streams in the OpenTok session.
1134
1133
1135
1134
This is an example of what the payload POST data body could look like:
@@ -1154,7 +1153,7 @@ def dial(self, session_id, token, sip_uri, options=[]):
1154
1153
}
1155
1154
1156
1155
1157
- :rtype: A SipCall object, which contains data of the SIP call: id, connectionId and streamId.
1156
+ :rtype: A SipCall object, which contains data of the SIP call: id, connectionId and streamId.
1158
1157
This is what the response body should look like after returning with a status code of 200:
1159
1158
1160
1159
{
@@ -1184,7 +1183,7 @@ def dial(self, session_id, token, sip_uri, options=[]):
1184
1183
if "observeForceMute" in options :
1185
1184
observeForceMute = True
1186
1185
payload ["sip" ]["observeForceMute" ] = options ["observeForceMute" ]
1187
-
1186
+
1188
1187
if "video" in options :
1189
1188
video = True
1190
1189
payload ["sip" ]["video" ] = options ["video" ]
@@ -1382,7 +1381,7 @@ def stop_broadcast(self, broadcast_id):
1382
1381
self .json_headers (),
1383
1382
self .proxies ,
1384
1383
)
1385
-
1384
+
1386
1385
response = requests .post (
1387
1386
endpoint ,
1388
1387
headers = self .get_json_headers (),
@@ -1408,13 +1407,13 @@ def stop_broadcast(self, broadcast_id):
1408
1407
raise RequestError ("OpenTok server error." , response .status_code )
1409
1408
1410
1409
def add_broadcast_stream (
1411
- self ,
1410
+ self ,
1412
1411
broadcast_id : str ,
1413
1412
stream_id : str ,
1414
1413
has_audio : bool = True ,
1415
- has_video : bool = True
1414
+ has_video : bool = True
1416
1415
) -> requests .Response :
1417
-
1416
+
1418
1417
"""
1419
1418
This method will add streams to the broadcast with addStream for new participant(choosing audio, video or both).
1420
1419
@@ -1462,7 +1461,7 @@ def add_broadcast_stream(
1462
1461
else :
1463
1462
raise RequestError ("OpenTok server error." , response .status_code )
1464
1463
1465
-
1464
+
1466
1465
def remove_broadcast_stream (self , broadcast_id : str , stream_id : str ) -> requests .Response :
1467
1466
"""
1468
1467
This method will remove streams from the broadcast with removeStream.
@@ -1616,8 +1615,8 @@ def _create_jwt_auth_header(self):
1616
1615
}
1617
1616
1618
1617
return jwt .encode (payload , self .api_secret , algorithm = "HS256" )
1619
-
1620
-
1618
+
1619
+
1621
1620
1622
1621
class OpenTok (Client ):
1623
1622
def __init__ (
@@ -1641,36 +1640,34 @@ def __init__(
1641
1640
app_version = app_version
1642
1641
)
1643
1642
1644
- def mute_all (self ,
1645
- session_id : str ,
1646
- excludedStreamIds : Optional [List [str ]],
1647
- active : bool = True ) -> requests .Response :
1643
+ def mute_all (self ,
1644
+ session_id : str ,
1645
+ excludedStreamIds : Optional [List [str ]]) -> requests .Response :
1648
1646
1649
1647
"""
1650
1648
Mutes all streams in an OpenTok session.
1651
1649
1652
- You can include an optional list of streams IDs to exclude from being muted.
1650
+ You can include an optional list of streams IDs to exclude from being muted.
1651
+
1652
+ In addition to existing streams, any streams that are published after the call to
1653
+ this method are published with audio muted. You can remove the mute state of a session
1654
+ by calling the OpenTok.disableForceMute() method.
1653
1655
1654
1656
:param session_id The session ID
1655
1657
1656
- :param excludedStreamIds A list of stream IDs for streams that should not be muted.
1658
+ :param excludedStreamIds A list of stream IDs for streams that should not be muted.
1657
1659
This is an optional property. If you omit this property, all streams in the session will be muted.
1658
-
1659
- :param active Whether streams published after the call, in addition to the current streams
1660
- in the session, should be muted (True) or not (False).
1661
1660
"""
1662
1661
1663
1662
options = {}
1664
1663
url = self .endpoints .get_mute_all_url (session_id )
1665
1664
1666
1665
try :
1667
1666
if excludedStreamIds :
1668
- if active :
1669
- options = {'active' : active , 'excludedStreams' : excludedStreamIds }
1667
+ options = {'active' : True , 'excludedStreams' : excludedStreamIds }
1670
1668
else :
1671
- active = False
1672
- options = {'active' : active , 'excludedStreams' : []}
1673
-
1669
+ options = {'active' : True , 'excludedStreams' : []}
1670
+
1674
1671
response = requests .post (url , headers = self .get_headers (), data = json .dumps (options ))
1675
1672
1676
1673
if response :
@@ -1686,15 +1683,48 @@ def mute_all(self,
1686
1683
("There was an error thrown by the OpenTok SDK, please check that your session_id {0} and excludedStreamIds (if exists) {1} are valid" ).format (
1687
1684
session_id , excludedStreamIds ))
1688
1685
1689
-
1686
+
1687
+ def disable_force_mute (self , session_id : str ) -> requests .Response :
1688
+ """
1689
+ Disables the active mute state of the session. After you call this method, new streams
1690
+ published to the session will no longer have audio muted.
1691
+
1692
+ After you call the mute_all() method, any streams published after
1693
+ the call are published with audio muted. Call the OpenTok.disable_force_mute() method
1694
+ to remove the mute state of a session, so that new published streams are not
1695
+ automatically muted.
1696
+
1697
+ :param session_id The session ID.
1698
+ """
1699
+
1700
+ options = {'active' : False }
1701
+ url = self .endpoints .get_mute_all_url (session_id )
1702
+
1703
+ response = requests .post (url , headers = self .get_headers (), data = json .dumps (options ))
1704
+
1705
+
1706
+ try :
1707
+ if response :
1708
+ return response
1709
+ elif response .status_code == 400 :
1710
+ raise GetStreamError ("Invalid request. This response may indicate that data in your request data is invalid JSON. Or it may indicate that you do not pass in a session ID or you passed in an invalid stream ID." )
1711
+ elif response .status_code == 403 :
1712
+ raise AuthError ("Failed to mute, invalid credentials." )
1713
+ elif response .status_code == 404 :
1714
+ raise NotFoundError ("The session or a stream is not found." )
1715
+ except Exception as e :
1716
+ raise OpenTokException (
1717
+ ("There was an error thrown by the OpenTok SDK, please check that your session_id {0} is valid" ).format (
1718
+ session_id ))
1719
+
1690
1720
1691
1721
def mute_stream (self , session_id : str , stream_id : str ) -> requests .Response :
1692
1722
"""
1693
1723
Mutes a single stream in an OpenTok session.
1694
1724
1695
1725
:param session_id The session ID.
1696
1726
1697
- :param stream_id The stream iD .
1727
+ :param stream_id The stream ID .
1698
1728
"""
1699
1729
1700
1730
try :
@@ -1754,4 +1784,3 @@ def play_dtmf(self, session_id: str, connection_id: str, digits: str, options: d
1754
1784
except Exception as e :
1755
1785
raise OpenTokException (
1756
1786
(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" ))
1757
-
0 commit comments