7
7
8
8
from fishjam import (
9
9
FishjamClient ,
10
+ Peer ,
10
11
PeerOptions ,
12
+ Room ,
11
13
RoomOptions ,
12
14
)
13
- from fishjam ._openapi_client .models import (
15
+ from fishjam .errors import (
16
+ BadRequestError ,
17
+ NotFoundError ,
18
+ ServiceUnavailableError ,
19
+ UnauthorizedError ,
20
+ )
21
+ from fishjam .peer import (
14
22
PeerMetadata ,
15
23
PeerStatus ,
16
24
PeerType ,
25
+ SubscribeOptions ,
26
+ SubscribeOptionsAudioFormat ,
27
+ SubscribeOptionsAudioSampleRate ,
28
+ )
29
+ from fishjam .room import (
17
30
RoomConfig ,
18
31
RoomConfigRoomType ,
19
32
RoomConfigVideoCodec ,
20
33
)
21
- from fishjam .api ._fishjam_client import Peer , Room
22
- from fishjam .errors import (
23
- BadRequestError ,
24
- NotFoundError ,
25
- ServiceUnavailableError ,
26
- UnauthorizedError ,
27
- )
28
34
29
35
HOST = "fishjam" if os .getenv ("DOCKER_TEST" ) == "TRUE" else "localhost"
30
36
FISHJAM_URL = f"http://{ HOST } :5002"
@@ -179,7 +185,12 @@ def test_id_not_found(self, room_api):
179
185
180
186
class TestCreatePeer :
181
187
def _assert_peer_created (
182
- self , room_api , webrtc_peer , room_id , server_metadata = None
188
+ self ,
189
+ room_api ,
190
+ webrtc_peer ,
191
+ room_id ,
192
+ server_metadata = None ,
193
+ subscribe = None ,
183
194
):
184
195
server_metadata = server_metadata or {}
185
196
@@ -189,19 +200,26 @@ def _assert_peer_created(
189
200
status = PeerStatus ("disconnected" ),
190
201
tracks = [],
191
202
metadata = PeerMetadata .from_dict ({"peer" : {}, "server" : server_metadata }),
192
- subscribe = None ,
203
+ subscribe = subscribe ,
193
204
)
194
205
195
206
room = room_api .get_room (room_id )
196
207
assert peer in room .peers
197
208
198
209
def test_with_specified_options (self , room_api : FishjamClient ):
199
- options = PeerOptions (enable_simulcast = True )
210
+ subscribe = SubscribeOptions (
211
+ audio_format = SubscribeOptionsAudioFormat .PCM16 ,
212
+ audio_sample_rate = SubscribeOptionsAudioSampleRate .VALUE_16000 ,
213
+ )
214
+ options = PeerOptions (
215
+ enable_simulcast = True ,
216
+ subscribe = subscribe ,
217
+ )
200
218
201
219
room = room_api .create_room ()
202
220
peer , _token = room_api .create_peer (room .id , options = options )
203
221
204
- self ._assert_peer_created (room_api , peer , room .id )
222
+ self ._assert_peer_created (room_api , peer , room .id , subscribe = subscribe )
205
223
206
224
def test_with_metadata (self , room_api : FishjamClient ):
207
225
options = PeerOptions (metadata = {"is_test" : True })
0 commit comments