|
| 1 | +from typing import Any, Dict, Type, TypeVar, Union |
| 2 | + |
| 3 | +from attrs import define as _attrs_define |
| 4 | + |
| 5 | +from ..models.peer_options_web_rtc_subscribe_audio_format import ( |
| 6 | + PeerOptionsWebRTCSubscribeAudioFormat, |
| 7 | +) |
| 8 | +from ..models.peer_options_web_rtc_subscribe_audio_sample_rate import ( |
| 9 | + PeerOptionsWebRTCSubscribeAudioSampleRate, |
| 10 | +) |
| 11 | +from ..types import UNSET, Unset |
| 12 | + |
| 13 | +T = TypeVar("T", bound="PeerOptionsWebRTCSubscribe") |
| 14 | + |
| 15 | + |
| 16 | +@_attrs_define |
| 17 | +class PeerOptionsWebRTCSubscribe: |
| 18 | + """Configure server-side subscriptions to the peer's tracks |
| 19 | +
|
| 20 | + Example: |
| 21 | + {'audioFormat': 'pcm16'} |
| 22 | +
|
| 23 | + """ |
| 24 | + |
| 25 | + audio_format: Union[ |
| 26 | + Unset, PeerOptionsWebRTCSubscribeAudioFormat |
| 27 | + ] = PeerOptionsWebRTCSubscribeAudioFormat.PCM16 |
| 28 | + """The format to use for the output audio""" |
| 29 | + audio_sample_rate: Union[ |
| 30 | + Unset, PeerOptionsWebRTCSubscribeAudioSampleRate |
| 31 | + ] = PeerOptionsWebRTCSubscribeAudioSampleRate.VALUE_16000 |
| 32 | + """The sample rate to use for the output audio""" |
| 33 | + |
| 34 | + def to_dict(self) -> Dict[str, Any]: |
| 35 | + """@private""" |
| 36 | + audio_format: Union[Unset, str] = UNSET |
| 37 | + if not isinstance(self.audio_format, Unset): |
| 38 | + audio_format = self.audio_format.value |
| 39 | + |
| 40 | + audio_sample_rate: Union[Unset, int] = UNSET |
| 41 | + if not isinstance(self.audio_sample_rate, Unset): |
| 42 | + audio_sample_rate = self.audio_sample_rate.value |
| 43 | + |
| 44 | + field_dict: Dict[str, Any] = {} |
| 45 | + field_dict.update({}) |
| 46 | + if audio_format is not UNSET: |
| 47 | + field_dict["audioFormat"] = audio_format |
| 48 | + if audio_sample_rate is not UNSET: |
| 49 | + field_dict["audioSampleRate"] = audio_sample_rate |
| 50 | + |
| 51 | + return field_dict |
| 52 | + |
| 53 | + @classmethod |
| 54 | + def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: |
| 55 | + """@private""" |
| 56 | + d = src_dict.copy() |
| 57 | + _audio_format = d.pop("audioFormat", UNSET) |
| 58 | + audio_format: Union[Unset, PeerOptionsWebRTCSubscribeAudioFormat] |
| 59 | + if isinstance(_audio_format, Unset): |
| 60 | + audio_format = UNSET |
| 61 | + else: |
| 62 | + audio_format = PeerOptionsWebRTCSubscribeAudioFormat(_audio_format) |
| 63 | + |
| 64 | + _audio_sample_rate = d.pop("audioSampleRate", UNSET) |
| 65 | + audio_sample_rate: Union[Unset, PeerOptionsWebRTCSubscribeAudioSampleRate] |
| 66 | + if isinstance(_audio_sample_rate, Unset): |
| 67 | + audio_sample_rate = UNSET |
| 68 | + else: |
| 69 | + audio_sample_rate = PeerOptionsWebRTCSubscribeAudioSampleRate( |
| 70 | + _audio_sample_rate |
| 71 | + ) |
| 72 | + |
| 73 | + peer_options_web_rtc_subscribe = cls( |
| 74 | + audio_format=audio_format, |
| 75 | + audio_sample_rate=audio_sample_rate, |
| 76 | + ) |
| 77 | + |
| 78 | + return peer_options_web_rtc_subscribe |
0 commit comments