Skip to content

Commit 2ad4b3f

Browse files
authored
feat: add Video Stitcher samples and tests (GoogleCloudPlatform#1756)
1 parent 62723a2 commit 2ad4b3f

File tree

7 files changed

+455
-4
lines changed

7 files changed

+455
-4
lines changed
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
<?php
2+
3+
/**
4+
* Copyright 2022 Google LLC.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
/**
20+
* For instructions on how to run the samples:
21+
*
22+
* @see https://github.com/GoogleCloudPlatform/php-docs-samples/tree/master/media/videostitcher/README.md
23+
*/
24+
25+
namespace Google\Cloud\Samples\Media\Stitcher;
26+
27+
// [START videostitcher_create_vod_session]
28+
use Google\Cloud\Video\Stitcher\V1\VideoStitcherServiceClient;
29+
use Google\Cloud\Video\Stitcher\V1\VodSession;
30+
31+
/**
32+
* Creates a VOD session. VOD sessions are ephemeral resources that expire
33+
* after a few hours.
34+
*
35+
* @param string $callingProjectId The project ID to run the API call under
36+
* @param string $location The location of the session
37+
* @param string $sourceUri Uri of the media to stitch; this URI must
38+
* reference either an MPEG-DASH manifest
39+
* (.mpd) file or an M3U playlist manifest
40+
* (.m3u8) file.
41+
* @param string $adTagUri The Uri of the ad tag
42+
*/
43+
function create_vod_session(
44+
string $callingProjectId,
45+
string $location,
46+
string $sourceUri,
47+
string $adTagUri
48+
): void {
49+
// Instantiate a client.
50+
$stitcherClient = new VideoStitcherServiceClient();
51+
52+
$parent = $stitcherClient->locationName($callingProjectId, $location);
53+
$vodSession = new VodSession();
54+
$vodSession->setSourceUri($sourceUri);
55+
$vodSession->setAdTagUri($adTagUri);
56+
57+
// Run VOD session creation request
58+
$response = $stitcherClient->createVodSession($parent, $vodSession);
59+
60+
// Print results
61+
printf('VOD session: %s' . PHP_EOL, $response->getName());
62+
}
63+
// [END videostitcher_create_vod_session]
64+
65+
// The following 2 lines are only needed to run the samples
66+
require_once __DIR__ . '/../../../testing/sample_helpers.php';
67+
\Google\Cloud\Samples\execute_sample(__FILE__, __NAMESPACE__, $argv);
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
<?php
2+
3+
/**
4+
* Copyright 2022 Google LLC.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
/**
20+
* For instructions on how to run the samples:
21+
*
22+
* @see https://github.com/GoogleCloudPlatform/php-docs-samples/tree/master/media/videostitcher/README.md
23+
*/
24+
25+
namespace Google\Cloud\Samples\Media\Stitcher;
26+
27+
// [START videostitcher_get_vod_ad_tag_detail]
28+
use Google\Cloud\Video\Stitcher\V1\VideoStitcherServiceClient;
29+
30+
/**
31+
* Gets the specified ad tag detail for the VOD session.
32+
*
33+
* @param string $callingProjectId The project ID to run the API call under
34+
* @param string $location The location of the session
35+
* @param string $sessionId The ID of the session
36+
* @param string $adTagDetailId The ID of the ad tag detail
37+
*/
38+
function get_vod_ad_tag_detail(
39+
string $callingProjectId,
40+
string $location,
41+
string $sessionId,
42+
string $adTagDetailId
43+
): void {
44+
// Instantiate a client.
45+
$stitcherClient = new VideoStitcherServiceClient();
46+
47+
$formattedName = $stitcherClient->vodAdTagDetailName($callingProjectId, $location, $sessionId, $adTagDetailId);
48+
$adTagDetail = $stitcherClient->getVodAdTagDetail($formattedName);
49+
50+
// Print results
51+
printf('VOD ad tag detail: %s' . PHP_EOL, $adTagDetail->getName());
52+
}
53+
// [END videostitcher_get_vod_ad_tag_detail]
54+
55+
// The following 2 lines are only needed to run the samples
56+
require_once __DIR__ . '/../../../testing/sample_helpers.php';
57+
\Google\Cloud\Samples\execute_sample(__FILE__, __NAMESPACE__, $argv);
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
<?php
2+
3+
/**
4+
* Copyright 2022 Google LLC.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
/**
20+
* For instructions on how to run the samples:
21+
*
22+
* @see https://github.com/GoogleCloudPlatform/php-docs-samples/tree/master/media/videostitcher/README.md
23+
*/
24+
25+
namespace Google\Cloud\Samples\Media\Stitcher;
26+
27+
// [START videostitcher_get_vod_session]
28+
use Google\Cloud\Video\Stitcher\V1\VideoStitcherServiceClient;
29+
30+
/**
31+
* Gets a VOD session.
32+
*
33+
* @param string $callingProjectId The project ID to run the API call under
34+
* @param string $location The location of the session
35+
* @param string $sessionId The ID of the session
36+
*/
37+
function get_vod_session(
38+
string $callingProjectId,
39+
string $location,
40+
string $sessionId
41+
): void {
42+
// Instantiate a client.
43+
$stitcherClient = new VideoStitcherServiceClient();
44+
45+
$formattedName = $stitcherClient->vodSessionName($callingProjectId, $location, $sessionId);
46+
$session = $stitcherClient->getVodSession($formattedName);
47+
48+
// Print results
49+
printf('VOD session: %s' . PHP_EOL, $session->getName());
50+
}
51+
// [END videostitcher_get_vod_session]
52+
53+
// The following 2 lines are only needed to run the samples
54+
require_once __DIR__ . '/../../../testing/sample_helpers.php';
55+
\Google\Cloud\Samples\execute_sample(__FILE__, __NAMESPACE__, $argv);
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
<?php
2+
3+
/**
4+
* Copyright 2022 Google LLC.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
/**
20+
* For instructions on how to run the samples:
21+
*
22+
* @see https://github.com/GoogleCloudPlatform/php-docs-samples/tree/master/media/videostitcher/README.md
23+
*/
24+
25+
namespace Google\Cloud\Samples\Media\Stitcher;
26+
27+
// [START videostitcher_get_vod_stitch_detail]
28+
use Google\Cloud\Video\Stitcher\V1\VideoStitcherServiceClient;
29+
30+
/**
31+
* Gets the specified stitch detail for the VOD session.
32+
*
33+
* @param string $callingProjectId The project ID to run the API call under
34+
* @param string $location The location of the session
35+
* @param string $sessionId The ID of the session
36+
* @param string $stitchDetailId The ID of the stitch detail
37+
*/
38+
function get_vod_stitch_detail(
39+
string $callingProjectId,
40+
string $location,
41+
string $sessionId,
42+
string $stitchDetailId
43+
): void {
44+
// Instantiate a client.
45+
$stitcherClient = new VideoStitcherServiceClient();
46+
47+
$formattedName = $stitcherClient->vodStitchDetailName($callingProjectId, $location, $sessionId, $stitchDetailId);
48+
$stitchDetail = $stitcherClient->getVodStitchDetail($formattedName);
49+
50+
// Print results
51+
printf('VOD stitch detail: %s' . PHP_EOL, $stitchDetail->getName());
52+
}
53+
// [END videostitcher_get_vod_stitch_detail]
54+
55+
// The following 2 lines are only needed to run the samples
56+
require_once __DIR__ . '/../../../testing/sample_helpers.php';
57+
\Google\Cloud\Samples\execute_sample(__FILE__, __NAMESPACE__, $argv);
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
<?php
2+
3+
/**
4+
* Copyright 2022 Google LLC.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
/**
20+
* For instructions on how to run the samples:
21+
*
22+
* @see https://github.com/GoogleCloudPlatform/php-docs-samples/tree/master/media/videostitcher/README.md
23+
*/
24+
25+
namespace Google\Cloud\Samples\Media\Stitcher;
26+
27+
// [START videostitcher_list_vod_ad_tag_details]
28+
use Google\Cloud\Video\Stitcher\V1\VideoStitcherServiceClient;
29+
30+
/**
31+
* Lists the ad tag details for the specified VOD session.
32+
*
33+
* @param string $callingProjectId The project ID to run the API call under
34+
* @param string $location The location of the session
35+
* @param string $sessionId The ID of the session
36+
*/
37+
function list_vod_ad_tag_details(
38+
string $callingProjectId,
39+
string $location,
40+
string $sessionId
41+
): void {
42+
// Instantiate a client.
43+
$stitcherClient = new VideoStitcherServiceClient();
44+
45+
$formattedName = $stitcherClient->vodSessionName($callingProjectId, $location, $sessionId);
46+
$response = $stitcherClient->listVodAdTagDetails($formattedName);
47+
48+
// Print the ad tag details list.
49+
$adTagDetails = $response->iterateAllElements();
50+
print('VOD ad tag details:' . PHP_EOL);
51+
foreach ($adTagDetails as $adTagDetail) {
52+
printf('%s' . PHP_EOL, $adTagDetail->getName());
53+
}
54+
}
55+
// [END videostitcher_list_vod_ad_tag_details]
56+
57+
// The following 2 lines are only needed to run the samples
58+
require_once __DIR__ . '/../../../testing/sample_helpers.php';
59+
\Google\Cloud\Samples\execute_sample(__FILE__, __NAMESPACE__, $argv);
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
<?php
2+
3+
/**
4+
* Copyright 2022 Google LLC.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
/**
20+
* For instructions on how to run the samples:
21+
*
22+
* @see https://github.com/GoogleCloudPlatform/php-docs-samples/tree/master/media/videostitcher/README.md
23+
*/
24+
25+
namespace Google\Cloud\Samples\Media\Stitcher;
26+
27+
// [START videostitcher_list_vod_stitch_details]
28+
use Google\Cloud\Video\Stitcher\V1\VideoStitcherServiceClient;
29+
30+
/**
31+
* Lists the stitch details for the specified VOD session.
32+
*
33+
* @param string $callingProjectId The project ID to run the API call under
34+
* @param string $location The location of the session
35+
* @param string $sessionId The ID of the session
36+
*/
37+
function list_vod_stitch_details(
38+
string $callingProjectId,
39+
string $location,
40+
string $sessionId
41+
): void {
42+
// Instantiate a client.
43+
$stitcherClient = new VideoStitcherServiceClient();
44+
45+
$formattedName = $stitcherClient->vodSessionName($callingProjectId, $location, $sessionId);
46+
$response = $stitcherClient->listVodStitchDetails($formattedName);
47+
48+
// Print the stitch details list.
49+
$stitchDetails = $response->iterateAllElements();
50+
print('VOD stitch details:' . PHP_EOL);
51+
foreach ($stitchDetails as $stitchDetail) {
52+
printf('%s' . PHP_EOL, $stitchDetail->getName());
53+
}
54+
}
55+
// [END videostitcher_list_vod_stitch_details]
56+
57+
// The following 2 lines are only needed to run the samples
58+
require_once __DIR__ . '/../../../testing/sample_helpers.php';
59+
\Google\Cloud\Samples\execute_sample(__FILE__, __NAMESPACE__, $argv);

0 commit comments

Comments
 (0)