Skip to content

Commit d07f1a4

Browse files
committed
Initial commit
0 parents  commit d07f1a4

32 files changed

+1319
-0
lines changed

.github/workflows/test.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: test
2+
3+
on:
4+
push:
5+
branches:
6+
- '*'
7+
pull_request:
8+
branches:
9+
- '*'
10+
release:
11+
types: [ released ]
12+
13+
permissions:
14+
contents: read
15+
16+
jobs:
17+
tests:
18+
runs-on: ${{ matrix.os }}
19+
strategy:
20+
fail-fast: true
21+
matrix:
22+
os: [ ubuntu-latest, windows-latest ]
23+
php: [ 8.1 ]
24+
stability: [ prefer-lowest, prefer-stable ]
25+
26+
name: P${{ matrix.php }} - ${{ matrix.stability }} - ${{ matrix.os }}
27+
28+
steps:
29+
- name: Checkout code
30+
uses: actions/checkout@v3
31+
32+
- name: Setup PHP
33+
uses: shivammathur/setup-php@v2
34+
with:
35+
php-version: ${{ matrix.php }}
36+
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick, fileinfo
37+
coverage: none
38+
39+
- name: Setup problem matchers
40+
run: |
41+
echo "::add-matcher::${{ runner.tool_cache }}/php.json"
42+
echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
43+
44+
- name: Install dependencies
45+
run: |
46+
composer update --${{ matrix.stability }} --prefer-dist --no-interaction
47+
- name: Execute tests
48+
run: vendor/bin/pest

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
.idea
2+
.DS_Store
3+
vendor
4+
composer.lock
5+
.phpunit.result.cache
6+
.php-cs-fixer.cache

.php-cs-fixer.dist.php

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<?php
2+
3+
$finder = Symfony\Component\Finder\Finder::create()
4+
->in([
5+
__DIR__,
6+
])
7+
->name('*.php')
8+
->notName('*.blade.php')
9+
->ignoreDotFiles(true)
10+
->ignoreVCS(true)
11+
->exclude(['vendor', 'node_modules']);
12+
13+
$config = new PhpCsFixer\Config();
14+
15+
// Rules from: https://cs.symfony.com/doc/rules/index.html
16+
17+
return $config->setRules([
18+
'@PSR2' => true,
19+
'array_syntax' => ['syntax' => 'short'],
20+
'ordered_imports' => ['sort_algorithm' => 'length'],
21+
'no_unused_imports' => true,
22+
'not_operator_with_successor_space' => true,
23+
'trailing_comma_in_multiline' => true,
24+
'single_quote' => ['strings_containing_single_quote_chars' => true],
25+
'phpdoc_scalar' => true,
26+
'unary_operator_spaces' => true,
27+
'binary_operator_spaces' => true,
28+
'blank_line_before_statement' => [
29+
'statements' => ['declare', 'return', 'throw', 'try'],
30+
],
31+
'phpdoc_single_line_var_spacing' => true,
32+
'phpdoc_var_without_name' => true,
33+
'method_argument_space' => [
34+
'on_multiline' => 'ensure_fully_multiline',
35+
'keep_multiple_spaces_after_comma' => true,
36+
],
37+
'return_type_declaration' => [
38+
'space_before' => 'none'
39+
],
40+
'declare_strict_types' => true,
41+
'blank_line_after_opening_tag' => true,
42+
'single_import_per_statement' => true,
43+
'mb_str_functions' => true,
44+
])->setFinder($finder);

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Changelog
2+
3+
## 1.0.0
4+
5+
- Initial release

LICENSE.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2023 Andreia Bohner <[email protected]>
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in
13+
all copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21+
THE SOFTWARE.

README.md

Lines changed: 248 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,248 @@
1+
# PHP SDK for Dolby API
2+
3+
Provides a PHP wrapper for [Dolby API](https://docs.dolby.io/).
4+
5+
## Installation
6+
7+
Installing via Composer:
8+
9+
```bash
10+
composer require andreia/php-sdk-dolby-api
11+
```
12+
13+
## Usage
14+
15+
### Instantiate the API class
16+
17+
```php
18+
use DolbyApi\DolbyApi;
19+
20+
$dolbyApi = new DolbyApi('your-api-token');
21+
```
22+
23+
### Media APIs
24+
25+
Media API
26+
https://docs.dolby.io/media-apis/docs
27+
28+
```php
29+
$dolbyApi->api('media')
30+
```
31+
32+
#### [Enhance API](https://docs.dolby.io/media-apis/docs/enhance-api-guide)
33+
34+
[Start Enhancing](https://docs.dolby.io/media-apis/reference/media-enhance-post)
35+
36+
```php
37+
$dolbyApi->api('media')->enhance('input-string', 'output-string');
38+
```
39+
40+
E.g.:
41+
```php
42+
$startEnhance = $dolbyApi->api('media')->enhance('https://dolbyio.s3-us-west-1.amazonaws.com/public/shelby/tunnel.original.mp4', 'dlb://example_out');
43+
44+
$startEnhance->body()); // "{"job_id":"5970da3d-cdbc-4128-b2f8-21ab61573d2e"}"
45+
$startEnhance->json()); // decoded body: [ "job_id" => "44fccc05-54cc-4bda-84ba-a8c9ee4b8335"]
46+
$startEnhance->status()); // 200
47+
```
48+
49+
[Get Enhance Results](https://docs.dolby.io/media-apis/reference/media-enhance-get)
50+
51+
```php
52+
$dolbyApi->api('media')->enhanceStatus('job-id');
53+
```
54+
55+
E.g.:
56+
```php
57+
$enhanceStatus = $dolbyApi->api('media')->enhanceStatus('44fccc05-54cc-4bda-84ba-a8c9ee4b8335');
58+
$enhanceStatus->body()); // {"path":"/media/enhance","status":"Success","progress":100,"api_version":"v1.1.2","result":{}}"
59+
```
60+
61+
#### Input and Output API
62+
63+
**Input**
64+
65+
[Get Upload URL](https://docs.dolby.io/media-apis/reference/media-input-post)
66+
67+
```php
68+
$uploadUrl = $dolbyApi->api('media')->getUploadUrl('your-dlb-url');
69+
```
70+
71+
E.g.:
72+
```php
73+
$uploadUrl = $dolbyApi->api('media')->getUploadUrl('dlb://input/file.wav');
74+
$uploadUrl->body()); // {"url":"https://media-api-proxfyprug.s3-accelerate.amazonaws.com/1129d723-42e6-40c6-a35d-07986d1be4af/input/file.wav?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=ASIA2N2ZL3VQGKHMR3VL%2F20230228%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20230228T184217Z&X-Amz-Expires=3600&X-Amz-Security-Token=IQoJb3a79hu6%2B52SmSMc...CN20ld5RAqWNhRdKNOCNX%2BH%2BV8%3D&X-Amz-Signature=d866b39b6...54008d18970&X-Amz-SignedHeaders=host&x-id=PutObject"}
75+
```
76+
77+
**Output**
78+
79+
[Get Download URL](https://docs.dolby.io/media-apis/reference/media-output-post)
80+
81+
```php
82+
$mediaDownloadResponse = $dolbyApi->api('media')->getDownloadUrl('your-dlb-url');
83+
```
84+
85+
E.g:
86+
```php
87+
$mediaDownloadResponse = $dolbyApi->api('media')->getDownloadUrl('dlb://example_out');
88+
$mediaDownloadResponse->body(); // {"url":"https://media-api-proxfyprug.s3-accelerate.amazonaws.com/1129d723-42e6-40c6-a35d-07986d1be4af/example_out?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=ASIA2N2ZL3VQJGFYC2XN%2F20230228%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20230228T180833Z&X-Amz-Expires=3600&X-Amz-Security-Token=IQoJb3JpZ2luX2V..XFAHFKaFjPaCd%2Bk%3D&X-Amz-Signature=2cd8a66224c...3614e79d65d0fb2&X-Amz-SignedHeaders=host&x-id=GetObject"}
89+
```
90+
91+
E.g. response with error:
92+
```php
93+
[
94+
"type" => "/problems/validation-error"
95+
"title" => "Your request parameters didn't validate"
96+
"status" => 400
97+
"instance" => "/media/output"
98+
"detail" => "Request body contains invalid json"
99+
]
100+
```
101+
102+
#### [Auto Diagnose API](https://docs.dolby.io/media-apis/docs/diagnose-api-guide)
103+
104+
[Start Diagnosing](https://docs.dolby.io/media-apis/reference/media-diagnose-post)
105+
106+
```php
107+
$diagnoseResponse = $dolbyApi->api('media')->diagnose('input-string', 'content-array');
108+
```
109+
110+
E.g.:
111+
```php
112+
$diagnoseResponse = $dolbyApi->api('media')->diagnose('https://dolbyio.s3-us-west-1.amazonaws.com/public/shelby/tunnel.original.mp4', ['type' => 'mobile_phone']);
113+
$diagnoseResponse->body(); // "{"job_id":"671230t0-e785-4472-b4w3-c57fa31u645b"}"
114+
```
115+
116+
[Get Diagnose Results](https://docs.dolby.io/media-apis/reference/media-diagnose-get)
117+
118+
```php
119+
$diagnoseStatusResponse = $dolbyApi->api('media')->diagnoseStatus('job-id');
120+
```
121+
122+
E.g.:
123+
```php
124+
$diagnoseStatusResponse = $dolbyApi->api('media')->diagnoseStatus('174230d0-e785-4472-b4a3-c57fa31f665b');
125+
$diagnoseStatusResponse->body()); // "{"path":"/media/diagnose","status":"Success","progress":100,"api_version":"b1.0","result":{"media_info":{"container":{"kind":"mp4","duration":10.45,"bitrate":822169,"size":1073958},"audio":{"codec":"aac","channels":2,"sample_rate":44100,"duration":10.45,"bitrate":96000},"video":{"codec":"h264","frame_rate":30,"height":360,"width":640,"duration":10.45,"bitrate":711452}},"audio":{"quality_score":{"average":3.7,"distribution":[{"lower_bound":0,"upper_bound":1,"duration":0,"percentage":0},{"lower_bound":1,"upper_bound":2,"duration":0,"percentage":0},{"lower_bound":2,"upper_bound":3,"duration":2.5,"percentage":26.3},{"lower_bound":3,"upper_bound":4,"duration":3,"percentage":31.6},{"lower_bound":4,"upper_bound":5,"duration":4,"percentage":42.1},{"lower_bound":5,"upper_bound":6,"duration":0,"percentage":0},{"lower_bound":6,"upper_bound":7,"duration":0,"percentage":0},{"lower_bound":7,"upper_bound":8,"duration":0,"percentage":0},{"lower_bound":8,"upper_bound":9,"duration":0,"percentage":0},{"lower_bound":9,"upper_bound":10,"duration":0,"percentage":0}],"worst_segment":{"start":3.5,"end":8.5,"score":3.3}},"noise_score":{"average":0.9,"distribution":[{"lower_bound":0,"upper_bound":1,"duration":7,"percentage":73.7},{"lower_bound":1,"upper_bound":2,"duration":0.5,"percentage":5.3},{"lower_bound":2,"upper_bound":3,"duration":0.5,"percentage":5.3},{"lower_bound":3,"upper_bound":4,"duration":1,"percentage":10.5},{"lower_bound":4,"upper_bound":5,"duration":0.5,"percentage":5.3},{"lower_bound":5,"upper_bound":6,"duration":0,"percentage":0},{"lower_bound":6,"upper_bound":7,"duration":0,"percentage":0},{"lower_bound":7,"upper_bound":8,"duration":0,"percentage":0},{"lower_bound":8,"upper_bound":9,"duration":0,"percentage":0},{"lower_bound":9,"upper_bound":10,"duration":0,"percentage":0}]},"clipping":{"events":0},"loudness":{"measured":-14.91,"range":2.26,"gating_mode":"speech","sample_peak":-0.82,"true_peak":-0.81},"music":{"percentage":0},"silence":{"percentage":0,"at_beginning":0,"at_end":0,"num_sections":0,"silent_channels":[]},"speech":{"percentage":100,"events":{"plosive":6,"sibilance":0}}}}}"
126+
```
127+
128+
#### [Analyse API](https://docs.dolby.io/media-apis/docs/analyze-api-guide)
129+
130+
[Start Analyzing](https://docs.dolby.io/media-apis/reference/media-analyze-post)
131+
132+
```php
133+
$analyzeResponse = $dolbyApi->api('media')->analyze('input-string', 'output-string', ['profile' => 'selected-profile']);
134+
```
135+
136+
E.g.:
137+
```php
138+
$loudness = [
139+
"profile" => "service_amazon",
140+
];
141+
142+
$analyzeResponse = $dolbyApi->api('media')->analyze('https://dolbyio.s3-us-west-1.amazonaws.com/public/shelby/tunnel.original.mp4', 'dlb://analyze_out', $loudness);
143+
$analyzeResponse->body(); // "{"job_id":"6202f5dd-21f7-433-8r66-42fta96c9f5e"}"
144+
```
145+
146+
[Get Analyze Status](https://docs.dolby.io/media-apis/reference/media-analyze-get)
147+
148+
```php
149+
$analyzeStatusResponse = $dolbyApi->api('media')->analyzeStatus('job-id');
150+
```
151+
152+
E.g.:
153+
```php
154+
$analyzeStatusResponse = $dolbyApi->api('media')->analyzeStatus('6214f5ed-28t7-4961-8f26-40kcr96c9q5m');
155+
$analyzeStatusResponse->body(); // "{"path":"/media/analyze","status":"Success","progress":100,"api_version":"b1.4","result":{}}"
156+
```
157+
158+
159+
#### [Analyse Speech API](https://docs.dolby.io/media-apis/docs/speech-analytics-api-guide)
160+
161+
[Start Analyzing Speech](https://docs.dolby.io/media-apis/reference/media-analyze-speech-post)
162+
163+
```php
164+
$analyzeSpeechResponse = $dolbyApi->api('media')->analyzeSpeech('input-string', 'output-string', ["url" => "webhook-address-to-be-called-on-complete"]);
165+
```
166+
167+
E.g.:
168+
```php
169+
$analyzeSpeechResponse = $dolbyApi->api('media')->analyzeSpeech('https://dolbyio.s3-us-west-1.amazonaws.com/public/shelby/tunnel.original.mp4', 'dlb://analyze_speech_out', ["url" => "https://webhookaddresstobecalledoncomplete.com/"]);
170+
$analyzeSpeechResponse->body(); // "{"job_id":"1ba639sd-d876-46ga-845w-33ec4c5cer00"}"
171+
```
172+
173+
[Get Analyze Speech Status](https://docs.dolby.io/media-apis/reference/media-analyze-speech-get)
174+
175+
```php
176+
$analyzeSpeechStatusResponse = $dolbyApi->api('media')->analyzeSpeechStatus('job-id');
177+
```
178+
179+
E.g.:
180+
```php
181+
$analyzeSpeechStatusResponse = $dolbyApi->api('media')->analyzeSpeechStatus('1ba639sd-d876-46ga-845w-33ec4c5cer00');
182+
$analyzeSpeechStatusResponse->body()); // "{"path":"/media/analyze/speech","status":"Success","progress":100,"api_version":"b1.0","result":{}}"
183+
```
184+
185+
#### [Analyse Music API](https://docs.dolby.io/media-apis/docs/analyze-music-api-guide)
186+
187+
[Start Analyzing Music](https://docs.dolby.io/media-apis/reference/media-analyze-music-post)
188+
189+
```php
190+
$analyzeMusicResponse = $dolbyApi->api('media')->analyzeMusic('input-string', 'output-string', ["url" => "webhook-address-to-be-called-on-complete"]);
191+
```
192+
193+
E.g.:
194+
```php
195+
$analyzeMusicResponse = $dolbyApi->api('media')->analyzeMusic('https://dolbyio.s3-us-west-1.amazonaws.com/public/shelby/tunnel.original.mp4', 'dlb://analyze_music_out', ["url" => "https://webhookaddresstobecalledoncomplete.com/"]);
196+
$analyzeMusicResponse->body(); // "{"job_id":"0c1fae6e-39e5-4a36-a076-bf3315d5179f"}"
197+
```
198+
199+
[Get Analyze Music Status](https://docs.dolby.io/media-apis/reference/media-analyze-music-get)
200+
201+
```php
202+
$analyzeMusicStatusResponse = $dolbyApi->api('media')->analyzeMusicStatus('job-id');
203+
```
204+
205+
E.g.:
206+
```php
207+
$analyzeMusicStatusResponse = $dolbyApi->api('media')->analyzeMusicStatus('0c1faw6e-39e5-4a36-a056-af3615e5189f');
208+
$analyzeMusicStatusResponse->body()); // "{"path":"/media/analyze/music","status":"Success","progress":100,"api_version":"b1.0","result":{}}"
209+
```
210+
211+
#### [Transcode API](https://docs.dolby.io/media-apis/docs/transcode-api-guide)
212+
213+
TODO
214+
215+
#### [Music Mastering API](https://docs.dolby.io/media-apis/docs/music-mastering-api-guide)
216+
217+
TODO
218+
219+
220+
### Communication APIs
221+
222+
TODO
223+
224+
### Streaming APIs
225+
226+
TODO
227+
228+
## Sponsor
229+
230+
[💚️ Become a Sponsor](https://github.com/sponsors/andreia)
231+
232+
## Testing
233+
234+
```bash
235+
./vendor/bin/pest
236+
```
237+
238+
## Changelog
239+
240+
Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.
241+
242+
## Contributing
243+
244+
Contributions are welcome! :)
245+
246+
## License
247+
248+
The MIT License (MIT). Read [License](LICENSE) for more information.

0 commit comments

Comments
 (0)