Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Recording API #12

Merged
merged 2 commits into from
Nov 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 73 additions & 0 deletions client/src/dolbyio_rest_apis/communications/recording.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
"""
dolbyio_rest_apis.communications.recording
~~~~~~~~~~~~~~~

This module contains the functions to work with the recording API.
"""

from dolbyio_rest_apis.communications.internal.http_context import CommunicationsHttpContext
from dolbyio_rest_apis.communications.internal.urls import get_comms_url_v2
from dolbyio_rest_apis.core.helpers import add_if_not_none

async def start(
access_token: str,
conference_id: str,
layout_url: str=None,
) -> None:
r"""
Starts recording for the specified conference.
You can specify a custom layout URL per recording request.
The `layoutURL` parameter overrides the layout URL configured in the dashboard.

See: https://docs.dolby.io/communications-apis/reference/api-recording-start

Args:
access_token: Access token to use for authentication.
conference_id: Identifier of the conference.
layout_url: Overwrites the layout URL configuration.
This field is ignored if it is not relevant regarding recording configuration,
for example if live_recording set to false or if the recording is MP3 only.
- `null`: uses the layout URL configured in the dashboard (if no URL is set in the dashboard, then uses the Dolby.io default);
- `default`: uses the Dolby.io default layout;
- URL string: uses this layout URL

Raises:
HttpRequestError: If a client error one occurred.
HTTPError: If one occurred.
"""
url = f'{get_comms_url_v2()}/conferences/mix/{conference_id}/recording/start'

payload = {}
add_if_not_none(payload, 'layoutUrl', layout_url)

async with CommunicationsHttpContext() as http_context:
await http_context.requests_post(
access_token=access_token,
url=url,
payload=payload,
)

async def stop(
access_token: str,
conference_id: str,
) -> None:
r"""
Stops the recording of the specified conference.

See: https://docs.dolby.io/communications-apis/reference/api-recording-stop

Args:
access_token: Access token to use for authentication.
conference_id: Identifier of the conference.

Raises:
HttpRequestError: If a client error one occurred.
HTTPError: If one occurred.
"""
url = f'{get_comms_url_v2()}/conferences/mix/{conference_id}/recording/stop'

async with CommunicationsHttpContext() as http_context:
await http_context.requests_post(
access_token=access_token,
url=url,
)
8 changes: 8 additions & 0 deletions client/src/dolbyio_rest_apis/communications/streaming.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ async def start_rtmp(
access_token: str,
conference_id: str,
rtmp_url: str,
layout_url: str=None,
) -> None:
r"""
Starts the RTMP live stream for the specified conference. Once the Dolby.io Communications APIs service starts
Expand All @@ -24,6 +25,12 @@ async def start_rtmp(
access_token: Access token to use for authentication.
conference_id: Identifier of the conference.
rtmp_url: The destination URI provided by the RTMP service.
layout_url: Overwrites the layout URL configuration.
This field is ignored if it is not relevant regarding recording configuration,
for example if live_recording set to false or if the recording is MP3 only.
- `null`: uses the layout URL configured in the dashboard (if no URL is set in the dashboard, then uses the Dolby.io default);
- `default`: uses the Dolby.io default layout;
- URL string: uses this layout URL

Raises:
HttpRequestError: If a client error one occurred.
Expand All @@ -33,6 +40,7 @@ async def start_rtmp(
payload = {
'uri': rtmp_url,
}
add_if_not_none(payload, 'layoutUrl', layout_url)

async with CommunicationsHttpContext() as http_context:
await http_context.requests_post(
Expand Down