Skip to main content

A Python wrapper for the Dolby.io REST APIs.

Project description

Dolby.io REST APIs

Python wrapper for the dolby.io REST Communications and Media APIs. All the functions are using the async pattern.

Install this project

Check the dolbyio-rest-apis package on PyPI. To install the latest stable python package run the following command:

python3 -m pip install dolbyio-rest-apis

Upgrade your package to the latest version:

python3 -m pip install --upgrade dolbyio-rest-apis

Logging

You can change the log level by using the Python (logging)[https://docs.python.org/3/library/logging.html] library.

import logging

logging.basicConfig(level="DEBUG")

Communications Examples

Authenticate

To get an access token that will be used by the client SDK for an end user to open a session against dolby.io, use the following code:

import asyncio
from dolbyio_rest_apis.communications import authentication

APP_KEY = "YOUR_APP_KEY"
APP_SECRET = "YOUR_APP_SECRET"

loop = asyncio.get_event_loop()
task = authentication.get_api_token(APP_KEY, APP_SECRET)
at = loop.run_until_complete(task)

print(f"Access Token: {at.access_token}")

You can write an async function like that:

from dolbyio_rest_apis.communications import authentication

APP_KEY = "YOUR_APP_KEY"
APP_SECRET = "YOUR_APP_SECRET"

async def get_client_access_token():
    at = await authentication.get_client_access_token(APP_KEY, APP_SECRET)
    print(f"Access Token: {at.access_token}")

To get an access token that will be used by your server to perform backend operations like creating a conference, use the following code.

import asyncio
from dolbyio_rest_apis.communications import authentication

APP_KEY = "YOUR_APP_KEY"
APP_SECRET = "YOUR_APP_SECRET"

loop = asyncio.get_event_loop()
task = authentication.get_api_access_token(APP_KEY, APP_SECRET)
at = loop.run_until_complete(task)

print(f"Access Token: {at.access_token}")

Create a conference

To create a Dolby Voice conference, you first must retrieve an API Access Token, then use the following code to create the conference.

import asyncio
from dolbyio_rest_apis.communications import conference
from dolbyio_rest_apis.communications.models import Participant, Permission, VideoCodec

access_token = "" # Retrieve an API Access Token
owner_id = "" # Identifier of the owner of the conference
alias = "" # Conference alias

participants = [
    Participant("hostA", [Permission.JOIN, Permission.SEND_AUDIO, Permission.SEND_VIDEO], notify=True),
    Participant("listener1", [Permission.JOIN], notify=False),
]

loop = asyncio.get_event_loop()
task = conference.create_conference(
    access_token,
    owner_id,
    alias,
    video_codec=VideoCodec.VP8,
    participants=participants
)
conf = loop.run_until_complete(task)

print(f"Conference created: {conf.id}")

Media Examples

Media Input and Output

Upload a media file to the temporary Dolby.io cloud storage for processing:

import asyncio
from dolbyio_rest_apis.media import io

ACCESS_TOKEN = "YOUR_API_TOKEN"

# Get an Upload URL
task = io.get_upload_url(
    access_token=ACCESS_TOKEN,
    dlb_url='dlb://in/file.mp4'
)
upload_url = loop.run_until_complete(task)

print(f"Upload URL: {upload_url}")

# Upload the file
task = io.upload_file(
    upload_url=upload_url,
    file_path='/path/to/file.mp4'
)
loop.run_until_complete(task)

Download a file that was processed by the API:

import asyncio
from dolbyio_rest_apis.media import io

ACCESS_TOKEN = "YOUR_API_TOKEN"

task = io.download_file(
    access_token=ACCESS_TOKEN,
    dlb_url='dlb://out/file.mp4',
    file_path='/path/to/processed_file.mp4'
)
loop.run_until_complete(task)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dolbyio-rest-apis-3.4.2.tar.gz (41.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dolbyio_rest_apis-3.4.2-py3-none-any.whl (48.2 kB view details)

Uploaded Python 3

File details

Details for the file dolbyio-rest-apis-3.4.2.tar.gz.

File metadata

  • Download URL: dolbyio-rest-apis-3.4.2.tar.gz
  • Upload date:
  • Size: 41.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.15

File hashes

Hashes for dolbyio-rest-apis-3.4.2.tar.gz
Algorithm Hash digest
SHA256 6320c886f7b556c055d2648768fe12da161e1d21a198eda5a9db0a147e7afeb4
MD5 7077d6d0838bcb3e0db7628cf5dfc0ff
BLAKE2b-256 32a076e3ee7e5778907d9b5d34ba5eaffd440f6e5e45de5de9170766e9f179c4

See more details on using hashes here.

File details

Details for the file dolbyio_rest_apis-3.4.2-py3-none-any.whl.

File metadata

File hashes

Hashes for dolbyio_rest_apis-3.4.2-py3-none-any.whl
Algorithm Hash digest
SHA256 bc30c5b65f91a525d029ada6a18e494b1150de11886f217115a44034afa38ee7
MD5 a01331625ad8b09429f7cc6421db4710
BLAKE2b-256 497d511272f4cb551844d5ef52ec2db4eb4b8930a4e9c52c0890a6b69ece4c7f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page