Skip to content

Commit 456d622

Browse files
Merge pull request #32 from DolbyIO/dev/fabien
Improve Dolby Millicast APIs
2 parents d7e9dea + b0ba607 commit 456d622

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+663
-3067
lines changed

.github/workflows/build-package.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
runs-on: ubuntu-latest
1111
steps:
1212
- name: Checkout 🛎️
13-
uses: actions/checkout@v3
13+
uses: actions/checkout@v4
1414
with:
1515
persist-credentials: false
1616

.github/workflows/codeql-analysis.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ jobs:
3838

3939
steps:
4040
- name: Checkout repository
41-
uses: actions/checkout@v3
41+
uses: actions/checkout@v4
4242

4343
# Initializes the CodeQL tools for scanning.
4444
- name: Initialize CodeQL

.github/workflows/publish-package-to-pypi.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ jobs:
99
runs-on: ubuntu-latest
1010
steps:
1111
- name: Checkout 🛎️
12-
uses: actions/checkout@v3
12+
uses: actions/checkout@v4
1313
with:
1414
persist-credentials: false
1515

LICENSE

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2023 Dolby Laboratories
3+
Copyright (c) 2024 Dolby Laboratories
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
# Dolby.io REST APIs Client for Python
88

9-
Python wrapper for the dolby.io REST [Communications](https://docs.dolby.io/communications-apis/reference/authentication-api), [Streaming](https://docs.dolby.io/streaming-apis/reference) and [Media](https://docs.dolby.io/media-processing/reference/media-enhance-overview) APIs.
9+
Python wrapper for the [Dolby Millicast](https://docs.dolby.io/streaming-apis/reference) and [Media](https://docs.dolby.io/media-processing/reference/media-enhance-overview) APIs.
1010

1111
## Build the builder
1212

client/README.md

+17-135
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Dolby.io REST APIs Client for Python
22

3-
Python wrapper for the dolby.io REST [Communications](https://docs.dolby.io/communications-apis/reference/authentication-api), [Streaming](https://docs.dolby.io/streaming-apis/reference) and [Media](https://docs.dolby.io/media-processing/reference/media-enhance-overview) APIs.
3+
Python wrapper for the [Dolby Millicast](https://docs.dolby.io/streaming-apis/reference) and [Media](https://docs.dolby.io/media-processing/reference/media-enhance-overview) APIs.
44

55
## Install this project
66

@@ -16,148 +16,19 @@ Upgrade your package to the latest version:
1616
python3 -m pip install --upgrade dolbyio-rest-apis
1717
```
1818

19-
## Logging
20-
21-
You can change the log level by using the Python [logging](https://docs.python.org/3/library/logging.html) library.
22-
23-
```python
24-
import logging
25-
26-
logging.basicConfig(level='DEBUG')
27-
```
28-
29-
## Authentication
30-
31-
In order to make API calls for most operations of the **Communications APIs** and **Media APIs**, you must get an access token using this API:
32-
33-
```python
34-
import asyncio
35-
from dolbyio_rest_apis import authentication
36-
37-
APP_KEY = 'YOUR_APP_KEY'
38-
APP_SECRET = 'YOUR_APP_SECRET'
39-
40-
loop = asyncio.get_event_loop()
41-
42-
task = authentication.get_api_token(APP_KEY, APP_SECRET)
43-
at = loop.run_until_complete(task)
44-
45-
print(f'API Token: {at.access_token}')
46-
```
47-
48-
To request a particular scope for this access token:
49-
50-
```python
51-
task = authentication.get_api_token(APP_KEY, APP_SECRET, scope=['comms:*'])
52-
at = loop.run_until_complete(task)
53-
54-
print(f'API Token: {at.access_token}')
55-
print(f'Scope: {at.scope}')
56-
```
57-
58-
## Communications Examples
59-
60-
### Get a client access token
61-
62-
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:
63-
64-
```python
65-
import asyncio
66-
from dolbyio_rest_apis import authentication as auth
67-
from dolbyio_rest_apis.communications import authentication
68-
69-
APP_KEY = 'YOUR_APP_KEY'
70-
APP_SECRET = 'YOUR_APP_SECRET'
71-
72-
loop = asyncio.get_event_loop()
73-
74-
# Request an API Token
75-
task = auth.get_api_token(APP_KEY, APP_SECRET, scope=['comms:client_access_token:create'])
76-
api_token = loop.run_until_complete(task)
77-
78-
print(f'API Token: {api_token.access_token}')
79-
80-
# Request the Client Access Token
81-
task = authentication.get_client_access_token_v2(api_token.access_token, ['*'])
82-
cat = loop.run_until_complete(task)
83-
84-
print(f'Client Access Token: {cat.access_token}')
85-
```
86-
87-
Because most of the APIs are asynchronous, you can write an async function like that:
88-
89-
```python
90-
from dolbyio_rest_apis import authentication as auth
91-
from dolbyio_rest_apis.communications import authentication
92-
93-
APP_KEY = 'YOUR_APP_KEY'
94-
APP_SECRET = 'YOUR_APP_SECRET'
95-
96-
async def get_client_access_token():
97-
# Request an API Token
98-
api_token = await auth.get_api_token(APP_KEY, APP_SECRET, scope=['comms:client_access_token:create'])
99-
100-
# Request the Client Access Token
101-
cat = await authentication.get_client_access_token_v2(api_token.access_token, ['*'])
102-
print(f'Client Access Token: {cat.access_token}')
103-
104-
return cat.access_token
105-
106-
```
107-
108-
### Create a conference
109-
110-
To create a Dolby Voice conference, you first must retrieve an API Access Token, then use the following code to create the conference.
111-
112-
```python
113-
import asyncio
114-
from dolbyio_rest_apis import authentication
115-
from dolbyio_rest_apis.communications import conference
116-
from dolbyio_rest_apis.communications.models import Participant, Permission, VideoCodec
117-
118-
APP_KEY = 'YOUR_APP_KEY'
119-
APP_SECRET = 'YOUR_APP_SECRET'
120-
121-
owner_id = '' # Identifier of the owner of the conference
122-
alias = '' # Conference alias
123-
124-
participants = [
125-
Participant('hostA', [Permission.JOIN, Permission.SEND_AUDIO, Permission.SEND_VIDEO], notify=True),
126-
Participant('listener1', [Permission.JOIN], notify=False),
127-
]
128-
129-
loop = asyncio.get_event_loop()
130-
131-
# Request an API token
132-
task = authentication.get_api_token(APP_KEY, APP_SECRET, scope=['comms:conf:create'])
133-
at = loop.run_until_complete(task)
134-
135-
# Create the conference
136-
task = conference.create_conference(
137-
at.access_token,
138-
owner_id,
139-
alias,
140-
video_codec=VideoCodec.VP8,
141-
participants=participants
142-
)
143-
conf = loop.run_until_complete(task)
144-
145-
print(f'Conference created: {conf.id}')
146-
```
147-
14819
## Real-time Streaming Examples
14920

15021
### Create a publish token
15122

15223
```python
15324
import asyncio
15425
from dolbyio_rest_apis.streaming import publish_token
155-
from dolbyio_rest_apis.streaming.models.publish_token import CreatePublishToken, CreateUpdatePublishTokenStream
26+
from dolbyio_rest_apis.streaming.models.publish_token import CreatePublishToken, TokenStreamName
15627

15728
API_SECRET = '' # Retrieve your API Secret from the dashboard
15829

15930
create_token = CreatePublishToken('my_token')
160-
create_token.streams.append(CreateUpdatePublishTokenStream('feed1', False))
31+
create_token.streams.append(TokenStreamName('feed1', False))
16132

16233
loop = asyncio.get_event_loop()
16334

@@ -172,12 +43,13 @@ print(token)
17243
```python
17344
import asyncio
17445
from dolbyio_rest_apis.streaming import subscribe_token
175-
from dolbyio_rest_apis.streaming.models.subscribe_token import CreateSubscribeToken, CreateUpdateSubscribeTokenStream
46+
from dolbyio_rest_apis.streaming.models.publish_token import TokenStreamName
47+
from dolbyio_rest_apis.streaming.models.subscribe_token import CreateSubscribeToken
17648

17749
API_SECRET = '' # Retrieve your API Secret from the dashboard
17850

17951
create_token = CreateSubscribeToken('my_token')
180-
create_token.streams.append(CreateUpdateSubscribeTokenStream('feed1', False))
52+
create_token.streams.append(TokenStreamName('feed1', False))
18153

18254
loop = asyncio.get_event_loop()
18355

@@ -197,7 +69,7 @@ Get the App Key and Secret from the Dolby.io dashboard and use the following cod
19769

19870
```python
19971
import asyncio
200-
from dolbyio_rest_apis import authentication
72+
from dolbyio_rest_apis.media import authentication
20173

20274
APP_KEY = 'YOUR_APP_KEY'
20375
APP_SECRET = 'YOUR_APP_SECRET'
@@ -320,3 +192,13 @@ task = io.download_file(
320192
)
321193
loop.run_until_complete(task)
322194
```
195+
196+
## Logging
197+
198+
You can change the log level by using the Python [logging](https://docs.python.org/3/library/logging.html) library.
199+
200+
```python
201+
import logging
202+
203+
logging.basicConfig(level='DEBUG')
204+
```

client/requirements.txt

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
aiohttp>=3.7.4
22
aiofiles>=0.7.0
33
aiohttp-retry>=2.4.6
4-
certifi>=2022.12.7
4+
certifi>=2024.7.4
5+
dataclasses-json>=0.6.7

client/setup.py

+3-5
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,13 @@
2424
license='MIT',
2525
url='https://github.com/dolbyio/dolbyio-rest-apis-client-python',
2626
project_urls={
27-
'Documentation': 'https://docs.dolby.io/communications-apis/reference',
27+
'Documentation': 'https://docs.dolby.io/streaming-apis/reference',
2828
'Source': 'https://github.com/dolbyio/dolbyio-rest-apis-client-python',
2929
'Bug Tracker': 'https://github.com/dolbyio/dolbyio-rest-apis-client-python/issues',
3030
},
3131
package_dir={'': os.path.join(current_path, 'src')},
3232
packages=setuptools.find_packages(where=os.path.join(current_path, 'src')),
33-
python_requires='>=3.7',
33+
python_requires='>=3.10',
3434
use_scm_version= {
3535
'local_scheme': 'no-local-version',
3636
'version_scheme': 'release-branch-semver',
@@ -43,10 +43,8 @@
4343
'License :: OSI Approved :: MIT License',
4444
'Programming Language :: Python',
4545
'Programming Language :: Python :: 3',
46-
'Programming Language :: Python :: 3.7',
47-
'Programming Language :: Python :: 3.8',
48-
'Programming Language :: Python :: 3.9',
4946
'Programming Language :: Python :: 3.10',
47+
'Programming Language :: Python :: 3.11',
5048
'Programming Language :: Python :: 3 :: Only',
5149
'Operating System :: OS Independent',
5250
'Intended Audience :: Developers',

client/src/dolbyio_rest_apis/authentication.py

-74
This file was deleted.

client/src/dolbyio_rest_apis/communications/__init__.py

Whitespace-only changes.

0 commit comments

Comments
 (0)