-
Notifications
You must be signed in to change notification settings - Fork 118
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
118 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,39 @@ | ||
from .enums import ArchiveMode, MediaMode, TokenRole | ||
from .audio_connector import ( | ||
AudioConnectorData, | ||
AudioConnectorOptions, | ||
AudioConnectorWebSocket, | ||
) | ||
from .captions import CaptionsData, CaptionsOptions | ||
from .enums import ( | ||
ArchiveMode, | ||
AudioSampleRate, | ||
LanguageCode, | ||
MediaMode, | ||
P2pPreference, | ||
TokenRole, | ||
) | ||
from .session import SessionOptions, VideoSession | ||
from .signal import SignalData | ||
from .stream import StreamInfo, StreamLayout, StreamLayoutOptions | ||
from .token import TokenOptions | ||
|
||
__all__ = [ | ||
'MediaMode', | ||
'AudioConnectorData', | ||
'AudioConnectorOptions', | ||
'AudioConnectorWebSocket', | ||
'CaptionsData', | ||
'CaptionsOptions', | ||
'ArchiveMode', | ||
'MediaMode', | ||
'TokenRole', | ||
'TokenOptions', | ||
'P2pPreference', | ||
'LanguageCode', | ||
'AudioSampleRate', | ||
'SessionOptions', | ||
'VideoSession', | ||
'SignalData', | ||
'StreamInfo', | ||
'StreamLayoutOptions', | ||
'StreamLayout', | ||
'TokenOptions', | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"id": "b3cd31f4-020e-4ba3-9a2a-12d98b8a184f", | ||
"connectionId": "1bf530df-97f4-4437-b6c9-2a66200200c8" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
from os.path import abspath | ||
|
||
import responses | ||
from vonage_http_client import HttpClient | ||
from vonage_video.models.audio_connector import ( | ||
AudioConnectorOptions, | ||
AudioConnectorWebSocket, | ||
) | ||
from vonage_video.models.enums import AudioSampleRate, TokenRole | ||
from vonage_video.models.token import TokenOptions | ||
from vonage_video.video import Video | ||
|
||
from testutils import build_response, get_mock_jwt_auth | ||
|
||
path = abspath(__file__) | ||
|
||
|
||
video = Video(HttpClient(get_mock_jwt_auth())) | ||
|
||
|
||
def test_audio_connector_options_model(): | ||
options = AudioConnectorOptions( | ||
session_id='test_session_id', | ||
token='test_token', | ||
websocket=AudioConnectorWebSocket( | ||
uri='test_uri', | ||
streams=['test_stream_id'], | ||
headers={'test_header': 'test_value'}, | ||
audio_rate=AudioSampleRate.KHZ_16, | ||
), | ||
) | ||
|
||
assert options.model_dump(by_alias=True) == { | ||
'sessionId': 'test_session_id', | ||
'token': 'test_token', | ||
'websocket': { | ||
'uri': 'test_uri', | ||
'streams': ['test_stream_id'], | ||
'headers': {'test_header': 'test_value'}, | ||
'audioRate': 16000, | ||
}, | ||
} | ||
|
||
|
||
@responses.activate | ||
def test_start_audio_connector(): | ||
build_response( | ||
path, | ||
'POST', | ||
'https://video.api.vonage.com/v2/project/test_application_id/connect', | ||
'audio_connector.json', | ||
200, | ||
) | ||
|
||
session_id = 'test_session_id' | ||
options = AudioConnectorOptions( | ||
session_id=session_id, | ||
token=video.generate_client_token( | ||
TokenOptions(session_id=session_id, role=TokenRole.MODERATOR) | ||
), | ||
websocket=AudioConnectorWebSocket( | ||
uri='wss://example.com/ws', | ||
audio_rate=AudioSampleRate.KHZ_16, | ||
), | ||
) | ||
|
||
audio_connector = video.start_audio_connector(options) | ||
|
||
assert audio_connector.id == 'b3cd31f4-020e-4ba3-9a2a-12d98b8a184f' | ||
assert audio_connector.connection_id == '1bf530df-97f4-4437-b6c9-2a66200200c8' |