|
| 1 | +""" |
| 2 | +start_stream.py |
| 3 | +
|
| 4 | +Bandwidth's StartStream BXML verb |
| 5 | +
|
| 6 | +@copyright Bandwidth INC |
| 7 | +""" |
| 8 | +from typing import List |
| 9 | + |
| 10 | +from ..verb import Verb |
| 11 | +from ..verbs.stream_param import StreamParam |
| 12 | + |
| 13 | + |
| 14 | +class StartStream(Verb): |
| 15 | + |
| 16 | + def __init__( |
| 17 | + self, destination: str, stream_params: List[StreamParam] = [], |
| 18 | + name: str=None, tracks: str=None, |
| 19 | + stream_event_url: str=None, |
| 20 | + stream_event_method: str=None, |
| 21 | + username: str=None, password: str=None, |
| 22 | + ): |
| 23 | + """Initialize a <Transfer> verb |
| 24 | +
|
| 25 | + Args: |
| 26 | + name (str, optional): A name to refer to this stream by. Used when sending <StopStream>. If not provided, it will default to the generated stream id as sent in the Media Stream Started webhook. |
| 27 | + tracks (str, optional): The part of the call to send a stream from. inbound, outbound or both. Default is inbound. |
| 28 | + destination (str, optional): A websocket URI to send the stream to. The audio from the specified tracks will be sent via websocket to this URL as base64-encoded PCMU/G711 audio. See below for more details on the websocket packet format. |
| 29 | + stream_event_url (str, optional): URL to send the associated Webhook events to during this stream's lifetime. Does not accept BXML. May be a relative URL. |
| 30 | + stream_event_method (str, optional): The HTTP method to use for the request to streamEventUrl. GET or POST. Default value is POST. |
| 31 | + username (str, optional): The username to send in the HTTP request to streamEventUrl. If specified, the URLs must be TLS-encrypted (i.e., https). |
| 32 | + password (str, optional): The password to send in the HTTP request to streamEventUrl. If specified, the URLs must be TLS-encrypted (i.e., https). |
| 33 | + |
| 34 | + Nested Verbs: |
| 35 | + StreamParam: (optional) You may specify up to 12 <StreamParam/> elements nested within a <StartStream> tag. These elements define optional user specified parameters that will be sent to the destination URL when the stream is first started. |
| 36 | +
|
| 37 | + """ |
| 38 | + self.destination = destination |
| 39 | + self.stream_params = stream_params |
| 40 | + self.name = name |
| 41 | + self.tracks = tracks |
| 42 | + self.stream_event_url = stream_event_url |
| 43 | + self.stream_event_method = stream_event_method |
| 44 | + self.username = username |
| 45 | + self.password = password |
| 46 | + super().__init__( |
| 47 | + tag="StartStream", |
| 48 | + nested_verbs=self.stream_params |
| 49 | + ) |
| 50 | + |
| 51 | + @property |
| 52 | + def _attributes(self): |
| 53 | + return { |
| 54 | + "destination": self.destination, |
| 55 | + "name": self.name, |
| 56 | + "tracks": self.tracks, |
| 57 | + "streamEventUrl": self.stream_event_url, |
| 58 | + "streamEventMethod": self.stream_event_method, |
| 59 | + "username": self.username, |
| 60 | + "password": self.password, |
| 61 | + } |
0 commit comments