Skip to content

Commit cab377b

Browse files
authored
chore: upgrade mediatranscoder samples to new GAPIC (GoogleCloudPlatform#1869)
1 parent efdc644 commit cab377b

17 files changed

+91
-33
lines changed

media/transcoder/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"require": {
3-
"google/cloud-video-transcoder": "^0.6.0",
3+
"google/cloud-video-transcoder": "^0.8.2",
44
"google/cloud-storage": "^1.9",
55
"ext-bcmath": "*"
66
}

media/transcoder/src/create_job_from_ad_hoc.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,12 @@
2626

2727
# [START transcoder_create_job_from_ad_hoc]
2828
use Google\Cloud\Video\Transcoder\V1\AudioStream;
29+
use Google\Cloud\Video\Transcoder\V1\Client\TranscoderServiceClient;
30+
use Google\Cloud\Video\Transcoder\V1\CreateJobRequest;
2931
use Google\Cloud\Video\Transcoder\V1\ElementaryStream;
3032
use Google\Cloud\Video\Transcoder\V1\Job;
3133
use Google\Cloud\Video\Transcoder\V1\JobConfig;
3234
use Google\Cloud\Video\Transcoder\V1\MuxStream;
33-
use Google\Cloud\Video\Transcoder\V1\TranscoderServiceClient;
3435
use Google\Cloud\Video\Transcoder\V1\VideoStream;
3536

3637
/**
@@ -95,8 +96,11 @@ function create_job_from_ad_hoc($projectId, $location, $inputUri, $outputUri)
9596
->setInputUri($inputUri)
9697
->setOutputUri($outputUri)
9798
->setConfig($jobConfig);
99+
$request = (new CreateJobRequest())
100+
->setParent($formattedParent)
101+
->setJob($job);
98102

99-
$response = $transcoderServiceClient->createJob($formattedParent, $job);
103+
$response = $transcoderServiceClient->createJob($request);
100104

101105
// Print job name.
102106
printf('Job: %s' . PHP_EOL, $response->getName());

media/transcoder/src/create_job_from_preset.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@
2525
namespace Google\Cloud\Samples\Media\Transcoder;
2626

2727
# [START transcoder_create_job_from_preset]
28-
use Google\Cloud\Video\Transcoder\V1\TranscoderServiceClient;
28+
use Google\Cloud\Video\Transcoder\V1\Client\TranscoderServiceClient;
29+
use Google\Cloud\Video\Transcoder\V1\CreateJobRequest;
2930
use Google\Cloud\Video\Transcoder\V1\Job;
3031

3132
/**
@@ -47,8 +48,11 @@ function create_job_from_preset($projectId, $location, $inputUri, $outputUri, $p
4748
$job->setInputUri($inputUri);
4849
$job->setOutputUri($outputUri);
4950
$job->setTemplateId($preset);
51+
$request = (new CreateJobRequest())
52+
->setParent($formattedParent)
53+
->setJob($job);
5054

51-
$response = $transcoderServiceClient->createJob($formattedParent, $job);
55+
$response = $transcoderServiceClient->createJob($request);
5256

5357
// Print job name.
5458
printf('Job: %s' . PHP_EOL, $response->getName());

media/transcoder/src/create_job_from_template.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@
2525
namespace Google\Cloud\Samples\Media\Transcoder;
2626

2727
# [START transcoder_create_job_from_template]
28-
use Google\Cloud\Video\Transcoder\V1\TranscoderServiceClient;
28+
use Google\Cloud\Video\Transcoder\V1\Client\TranscoderServiceClient;
29+
use Google\Cloud\Video\Transcoder\V1\CreateJobRequest;
2930
use Google\Cloud\Video\Transcoder\V1\Job;
3031

3132
/**
@@ -47,8 +48,11 @@ function create_job_from_template($projectId, $location, $inputUri, $outputUri,
4748
$job->setInputUri($inputUri);
4849
$job->setOutputUri($outputUri);
4950
$job->setTemplateId($templateId);
51+
$request = (new CreateJobRequest())
52+
->setParent($formattedParent)
53+
->setJob($job);
5054

51-
$response = $transcoderServiceClient->createJob($formattedParent, $job);
55+
$response = $transcoderServiceClient->createJob($request);
5256

5357
// Print job name.
5458
printf('Job: %s' . PHP_EOL, $response->getName());

media/transcoder/src/create_job_template.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,12 @@
2626

2727
# [START transcoder_create_job_template]
2828
use Google\Cloud\Video\Transcoder\V1\AudioStream;
29+
use Google\Cloud\Video\Transcoder\V1\Client\TranscoderServiceClient;
30+
use Google\Cloud\Video\Transcoder\V1\CreateJobTemplateRequest;
2931
use Google\Cloud\Video\Transcoder\V1\ElementaryStream;
3032
use Google\Cloud\Video\Transcoder\V1\JobConfig;
3133
use Google\Cloud\Video\Transcoder\V1\JobTemplate;
3234
use Google\Cloud\Video\Transcoder\V1\MuxStream;
33-
use Google\Cloud\Video\Transcoder\V1\TranscoderServiceClient;
3435
use Google\Cloud\Video\Transcoder\V1\VideoStream;
3536

3637
/**
@@ -89,8 +90,12 @@ function create_job_template($projectId, $location, $templateId)
8990
->setElementaryStreams(['video-stream1', 'audio-stream0'])
9091
])
9192
);
93+
$request = (new CreateJobTemplateRequest())
94+
->setParent($formattedParent)
95+
->setJobTemplate($jobTemplate)
96+
->setJobTemplateId($templateId);
9297

93-
$response = $transcoderServiceClient->createJobTemplate($formattedParent, $jobTemplate, $templateId);
98+
$response = $transcoderServiceClient->createJobTemplate($request);
9499

95100
// Print job template name.
96101
printf('Job template: %s' . PHP_EOL, $response->getName());

media/transcoder/src/create_job_with_animated_overlay.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,13 @@
2626

2727
# [START transcoder_create_job_with_animated_overlay]
2828
use Google\Cloud\Video\Transcoder\V1\AudioStream;
29+
use Google\Cloud\Video\Transcoder\V1\Client\TranscoderServiceClient;
30+
use Google\Cloud\Video\Transcoder\V1\CreateJobRequest;
2931
use Google\Cloud\Video\Transcoder\V1\ElementaryStream;
3032
use Google\Cloud\Video\Transcoder\V1\Job;
3133
use Google\Cloud\Video\Transcoder\V1\JobConfig;
3234
use Google\Cloud\Video\Transcoder\V1\MuxStream;
3335
use Google\Cloud\Video\Transcoder\V1\Overlay;
34-
use Google\Cloud\Video\Transcoder\V1\TranscoderServiceClient;
3536
use Google\Cloud\Video\Transcoder\V1\VideoStream;
3637
use Google\Protobuf\Duration;
3738

@@ -115,8 +116,11 @@ function create_job_with_animated_overlay($projectId, $location, $inputUri, $ove
115116
->setInputUri($inputUri)
116117
->setOutputUri($outputUri)
117118
->setConfig($jobConfig);
119+
$request = (new CreateJobRequest())
120+
->setParent($formattedParent)
121+
->setJob($job);
118122

119-
$response = $transcoderServiceClient->createJob($formattedParent, $job);
123+
$response = $transcoderServiceClient->createJob($request);
120124

121125
// Print job name.
122126
printf('Job: %s' . PHP_EOL, $response->getName());

media/transcoder/src/create_job_with_concatenated_inputs.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,14 @@
2626

2727
# [START transcoder_create_job_with_concatenated_inputs]
2828
use Google\Cloud\Video\Transcoder\V1\AudioStream;
29+
use Google\Cloud\Video\Transcoder\V1\Client\TranscoderServiceClient;
30+
use Google\Cloud\Video\Transcoder\V1\CreateJobRequest;
2931
use Google\Cloud\Video\Transcoder\V1\EditAtom;
3032
use Google\Cloud\Video\Transcoder\V1\ElementaryStream;
3133
use Google\Cloud\Video\Transcoder\V1\Input;
3234
use Google\Cloud\Video\Transcoder\V1\Job;
3335
use Google\Cloud\Video\Transcoder\V1\JobConfig;
3436
use Google\Cloud\Video\Transcoder\V1\MuxStream;
35-
use Google\Cloud\Video\Transcoder\V1\TranscoderServiceClient;
3637
use Google\Cloud\Video\Transcoder\V1\VideoStream;
3738
use Google\Protobuf\Duration;
3839

@@ -113,8 +114,11 @@ function create_job_with_concatenated_inputs($projectId, $location, $input1Uri,
113114
$job = (new Job())
114115
->setOutputUri($outputUri)
115116
->setConfig($jobConfig);
117+
$request = (new CreateJobRequest())
118+
->setParent($formattedParent)
119+
->setJob($job);
116120

117-
$response = $transcoderServiceClient->createJob($formattedParent, $job);
121+
$response = $transcoderServiceClient->createJob($request);
118122

119123
// Print job name.
120124
printf('Job: %s' . PHP_EOL, $response->getName());

media/transcoder/src/create_job_with_periodic_images_spritesheet.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,13 @@
2626

2727
# [START transcoder_create_job_with_periodic_images_spritesheet]
2828
use Google\Cloud\Video\Transcoder\V1\AudioStream;
29+
use Google\Cloud\Video\Transcoder\V1\Client\TranscoderServiceClient;
30+
use Google\Cloud\Video\Transcoder\V1\CreateJobRequest;
2931
use Google\Cloud\Video\Transcoder\V1\ElementaryStream;
3032
use Google\Cloud\Video\Transcoder\V1\Job;
3133
use Google\Cloud\Video\Transcoder\V1\JobConfig;
3234
use Google\Cloud\Video\Transcoder\V1\MuxStream;
3335
use Google\Cloud\Video\Transcoder\V1\SpriteSheet;
34-
use Google\Cloud\Video\Transcoder\V1\TranscoderServiceClient;
3536
use Google\Cloud\Video\Transcoder\V1\VideoStream;
3637
use Google\Protobuf\Duration;
3738

@@ -96,8 +97,11 @@ function create_job_with_periodic_images_spritesheet($projectId, $location, $inp
9697
->setInputUri($inputUri)
9798
->setOutputUri($outputUri)
9899
->setConfig($jobConfig);
100+
$request = (new CreateJobRequest())
101+
->setParent($formattedParent)
102+
->setJob($job);
99103

100-
$response = $transcoderServiceClient->createJob($formattedParent, $job);
104+
$response = $transcoderServiceClient->createJob($request);
101105

102106
// Print job name.
103107
printf('Job: %s' . PHP_EOL, $response->getName());

media/transcoder/src/create_job_with_set_number_images_spritesheet.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,13 @@
2626

2727
# [START transcoder_create_job_with_set_number_images_spritesheet]
2828
use Google\Cloud\Video\Transcoder\V1\AudioStream;
29+
use Google\Cloud\Video\Transcoder\V1\Client\TranscoderServiceClient;
30+
use Google\Cloud\Video\Transcoder\V1\CreateJobRequest;
2931
use Google\Cloud\Video\Transcoder\V1\ElementaryStream;
3032
use Google\Cloud\Video\Transcoder\V1\Job;
3133
use Google\Cloud\Video\Transcoder\V1\JobConfig;
3234
use Google\Cloud\Video\Transcoder\V1\MuxStream;
3335
use Google\Cloud\Video\Transcoder\V1\SpriteSheet;
34-
use Google\Cloud\Video\Transcoder\V1\TranscoderServiceClient;
3536
use Google\Cloud\Video\Transcoder\V1\VideoStream;
3637

3738
/**
@@ -96,8 +97,11 @@ function create_job_with_set_number_images_spritesheet($projectId, $location, $i
9697
->setInputUri($inputUri)
9798
->setOutputUri($outputUri)
9899
->setConfig($jobConfig);
100+
$request = (new CreateJobRequest())
101+
->setParent($formattedParent)
102+
->setJob($job);
99103

100-
$response = $transcoderServiceClient->createJob($formattedParent, $job);
104+
$response = $transcoderServiceClient->createJob($request);
101105

102106
// Print job name.
103107
printf('Job: %s' . PHP_EOL, $response->getName());

media/transcoder/src/create_job_with_static_overlay.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,13 @@
2626

2727
# [START transcoder_create_job_with_static_overlay]
2828
use Google\Cloud\Video\Transcoder\V1\AudioStream;
29+
use Google\Cloud\Video\Transcoder\V1\Client\TranscoderServiceClient;
30+
use Google\Cloud\Video\Transcoder\V1\CreateJobRequest;
2931
use Google\Cloud\Video\Transcoder\V1\ElementaryStream;
3032
use Google\Cloud\Video\Transcoder\V1\Job;
3133
use Google\Cloud\Video\Transcoder\V1\JobConfig;
3234
use Google\Cloud\Video\Transcoder\V1\MuxStream;
3335
use Google\Cloud\Video\Transcoder\V1\Overlay;
34-
use Google\Cloud\Video\Transcoder\V1\TranscoderServiceClient;
3536
use Google\Cloud\Video\Transcoder\V1\VideoStream;
3637
use Google\Protobuf\Duration;
3738

@@ -117,8 +118,11 @@ function create_job_with_static_overlay($projectId, $location, $inputUri, $overl
117118
->setInputUri($inputUri)
118119
->setOutputUri($outputUri)
119120
->setConfig($jobConfig);
121+
$request = (new CreateJobRequest())
122+
->setParent($formattedParent)
123+
->setJob($job);
120124

121-
$response = $transcoderServiceClient->createJob($formattedParent, $job);
125+
$response = $transcoderServiceClient->createJob($request);
122126

123127
// Print job name.
124128
printf('Job: %s' . PHP_EOL, $response->getName());

0 commit comments

Comments
 (0)