|
34 | 34 | SignalingError, |
35 | 35 | GetStreamError, |
36 | 36 | ForceDisconnectError, |
37 | | - SipDialError |
| 37 | + SipDialError, |
| 38 | + SetStreamClassError |
38 | 39 | ) |
39 | 40 |
|
40 | 41 | class Roles(Enum): |
@@ -530,7 +531,7 @@ def signal(self, session_id, payload, connection_id=None): |
530 | 531 | def get_stream(self, session_id, stream_id): |
531 | 532 | """ |
532 | 533 | Returns an Stream object that contains information of an OpenTok stream: |
533 | | - |
| 534 | +
|
534 | 535 | -id: The stream ID |
535 | 536 | -videoType: "camera" or "screen" |
536 | 537 | -name: The stream name (if one was set when the client published the stream) |
@@ -638,7 +639,6 @@ def set_archive_layout(self, archive_id, layout_type, stylesheet=None): |
638 | 639 | else: |
639 | 640 | raise RequestError('OpenTok server error.', response.status_code) |
640 | 641 |
|
641 | | - |
642 | 642 | def dial(self, session_id, token, sip_uri, options=[]): |
643 | 643 | """ |
644 | 644 | Use this method to connect a SIP platform to an OpenTok session. The audio from the end |
@@ -720,6 +720,47 @@ def dial(self, session_id, token, sip_uri, options=[]): |
720 | 720 | else: |
721 | 721 | raise RequestError('OpenTok server error.', response.status_code) |
722 | 722 |
|
| 723 | + def set_stream_class_lists(self, session_id, payload): |
| 724 | + """ |
| 725 | + Use this method to change layout classes for OpenTok streams. The layout classes |
| 726 | + define how the streams are displayed in the layout of a composed OpenTok archive |
| 727 | +
|
| 728 | + :param String session_id: The ID of the session of the streams that will be updated |
| 729 | +
|
| 730 | + :param List payload: A list defining the class lists to apply to the streams. |
| 731 | + Each element in the list is a dictionary with two properties: 'id' and 'layoutClassList'. |
| 732 | + The 'id' property is the stream ID (a String), and the 'layoutClassList' is an array of |
| 733 | + class names (Strings) to apply to the stream. For example: |
| 734 | +
|
| 735 | + payload = [ |
| 736 | + {'id': '7b09ec3c-26f9-43d7-8197-f608f13d4fb6', 'layoutClassList': ['focus']}, |
| 737 | + {'id': '567bc941-6ea0-4c69-97fc-70a740b68976', 'layoutClassList': ['top']}, |
| 738 | + {'id': '307dc941-0450-4c09-975c-705740d08970', 'layoutClassList': ['bottom']} |
| 739 | + ] |
| 740 | + """ |
| 741 | + items_payload = {'items': payload} |
| 742 | + |
| 743 | + endpoint = self.endpoints.set_stream_class_lists_url(session_id) |
| 744 | + response = requests.put( |
| 745 | + endpoint, |
| 746 | + data=json.dumps(items_payload), |
| 747 | + headers=self.json_headers(), |
| 748 | + proxies=self.proxies, |
| 749 | + timeout=self.timeout |
| 750 | + ) |
| 751 | + |
| 752 | + if response.status_code == 200: |
| 753 | + pass |
| 754 | + elif response.status_code == 400: |
| 755 | + raise SetStreamClassError( |
| 756 | + 'Invalid request. This response may indicate that data in your request data ' |
| 757 | + 'is invalid JSON. It may also indicate that you passed in invalid layout options.' |
| 758 | + ) |
| 759 | + elif response.status_code == 403: |
| 760 | + raise AuthError('Authentication error.') |
| 761 | + else: |
| 762 | + raise RequestError('OpenTok server error.', response.status_code) |
| 763 | + |
723 | 764 | def _sign_string(self, string, secret): |
724 | 765 | return hmac.new(secret.encode('utf-8'), string.encode('utf-8'), hashlib.sha1).hexdigest() |
725 | 766 |
|
|
0 commit comments