Skip to content

Commit efdc644

Browse files
authored
chore: upgrade medialivestream samples to new GAPIC (GoogleCloudPlatform#1870)
1 parent 8d62377 commit efdc644

18 files changed

+96
-35
lines changed

media/livestream/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22
"name": "google/live-stream-sample",
33
"type": "project",
44
"require": {
5-
"google/cloud-video-live-stream": "^0.3.0"
5+
"google/cloud-video-live-stream": "^0.5.0"
66
}
77
}

media/livestream/src/create_channel.php

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

2727
// [START livestream_create_channel]
28-
use Google\Cloud\Video\LiveStream\V1\LivestreamServiceClient;
2928
use Google\Cloud\Video\LiveStream\V1\AudioStream;
3029
use Google\Cloud\Video\LiveStream\V1\Channel;
3130
use Google\Cloud\Video\LiveStream\V1\ElementaryStream;
3231
use Google\Cloud\Video\LiveStream\V1\InputAttachment;
32+
use Google\Cloud\Video\LiveStream\V1\Client\LivestreamServiceClient;
33+
use Google\Cloud\Video\LiveStream\V1\CreateChannelRequest;
3334
use Google\Cloud\Video\LiveStream\V1\Manifest;
3435
use Google\Cloud\Video\LiveStream\V1\MuxStream;
3536
use Google\Cloud\Video\LiveStream\V1\SegmentSettings;
@@ -118,7 +119,11 @@ function create_channel(
118119
]);
119120

120121
// Run the channel creation request. The response is a long-running operation ID.
121-
$operationResponse = $livestreamClient->createChannel($parent, $channel, $channelId);
122+
$request = (new CreateChannelRequest())
123+
->setParent($parent)
124+
->setChannel($channel)
125+
->setChannelId($channelId);
126+
$operationResponse = $livestreamClient->createChannel($request);
122127
$operationResponse->pollUntilComplete();
123128
if ($operationResponse->operationSucceeded()) {
124129
$result = $operationResponse->getResult();

media/livestream/src/create_channel_event.php

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

2727
// [START livestream_create_channel_event]
28-
use Google\Cloud\Video\LiveStream\V1\LivestreamServiceClient;
2928
use Google\Cloud\Video\LiveStream\V1\Event;
29+
use Google\Cloud\Video\LiveStream\V1\Client\LivestreamServiceClient;
30+
use Google\Cloud\Video\LiveStream\V1\CreateEventRequest;
3031
use Google\Protobuf\Duration;
3132

3233
/**
@@ -56,7 +57,11 @@ function create_channel_event(
5657
->setExecuteNow(true);
5758

5859
// Run the channel event creation request.
59-
$response = $livestreamClient->createEvent($parent, $event, $eventId);
60+
$request = (new CreateEventRequest())
61+
->setParent($parent)
62+
->setEvent($event)
63+
->setEventId($eventId);
64+
$response = $livestreamClient->createEvent($request);
6065
// Print results.
6166
printf('Channel event: %s' . PHP_EOL, $response->getName());
6267
}

media/livestream/src/create_channel_with_backup_input.php

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

2727
// [START livestream_create_channel_with_backup_input]
28-
use Google\Cloud\Video\LiveStream\V1\LivestreamServiceClient;
2928
use Google\Cloud\Video\LiveStream\V1\AudioStream;
3029
use Google\Cloud\Video\LiveStream\V1\Channel;
3130
use Google\Cloud\Video\LiveStream\V1\ElementaryStream;
3231
use Google\Cloud\Video\LiveStream\V1\InputAttachment;
32+
use Google\Cloud\Video\LiveStream\V1\Client\LivestreamServiceClient;
33+
use Google\Cloud\Video\LiveStream\V1\CreateChannelRequest;
3334
use Google\Cloud\Video\LiveStream\V1\Manifest;
3435
use Google\Cloud\Video\LiveStream\V1\MuxStream;
3536
use Google\Cloud\Video\LiveStream\V1\SegmentSettings;
@@ -128,7 +129,11 @@ function create_channel_with_backup_input(
128129
]);
129130

130131
// Run the channel creation request. The response is a long-running operation ID.
131-
$operationResponse = $livestreamClient->createChannel($parent, $channel, $channelId);
132+
$request = (new CreateChannelRequest())
133+
->setParent($parent)
134+
->setChannel($channel)
135+
->setChannelId($channelId);
136+
$operationResponse = $livestreamClient->createChannel($request);
132137
$operationResponse->pollUntilComplete();
133138
if ($operationResponse->operationSucceeded()) {
134139
$result = $operationResponse->getResult();

media/livestream/src/create_input.php

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

2727
// [START livestream_create_input]
28-
use Google\Cloud\Video\LiveStream\V1\LivestreamServiceClient;
2928
use Google\Cloud\Video\LiveStream\V1\Input;
29+
use Google\Cloud\Video\LiveStream\V1\Client\LivestreamServiceClient;
30+
use Google\Cloud\Video\LiveStream\V1\CreateInputRequest;
3031

3132
/**
3233
* Creates an input. You send an input video stream to this endpoint.
@@ -48,7 +49,11 @@ function create_input(
4849
->setType(Input\Type::RTMP_PUSH);
4950

5051
// Run the input creation request. The response is a long-running operation ID.
51-
$operationResponse = $livestreamClient->createInput($parent, $input, $inputId);
52+
$request = (new CreateInputRequest())
53+
->setParent($parent)
54+
->setInput($input)
55+
->setInputId($inputId);
56+
$operationResponse = $livestreamClient->createInput($request);
5257
$operationResponse->pollUntilComplete();
5358
if ($operationResponse->operationSucceeded()) {
5459
$result = $operationResponse->getResult();

media/livestream/src/delete_channel.php

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

2727
// [START livestream_delete_channel]
28-
use Google\Cloud\Video\LiveStream\V1\LivestreamServiceClient;
28+
use Google\Cloud\Video\LiveStream\V1\Client\LivestreamServiceClient;
29+
use Google\Cloud\Video\LiveStream\V1\DeleteChannelRequest;
2930

3031
/**
3132
* Deletes a channel.
@@ -44,7 +45,9 @@ function delete_channel(
4445
$formattedName = $livestreamClient->channelName($callingProjectId, $location, $channelId);
4546

4647
// Run the channel deletion request. The response is a long-running operation ID.
47-
$operationResponse = $livestreamClient->deleteChannel($formattedName);
48+
$request = (new DeleteChannelRequest())
49+
->setName($formattedName);
50+
$operationResponse = $livestreamClient->deleteChannel($request);
4851
$operationResponse->pollUntilComplete();
4952
if ($operationResponse->operationSucceeded()) {
5053
// Print status

media/livestream/src/delete_channel_event.php

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

2727
// [START livestream_delete_channel_event]
28-
use Google\Cloud\Video\LiveStream\V1\LivestreamServiceClient;
28+
use Google\Cloud\Video\LiveStream\V1\Client\LivestreamServiceClient;
29+
use Google\Cloud\Video\LiveStream\V1\DeleteEventRequest;
2930

3031
/**
3132
* Deletes a channel event.
@@ -46,7 +47,9 @@ function delete_channel_event(
4647
$formattedName = $livestreamClient->eventName($callingProjectId, $location, $channelId, $eventId);
4748

4849
// Run the channel event deletion request.
49-
$livestreamClient->deleteEvent($formattedName);
50+
$request = (new DeleteEventRequest())
51+
->setName($formattedName);
52+
$livestreamClient->deleteEvent($request);
5053
printf('Deleted channel event %s' . PHP_EOL, $eventId);
5154
}
5255
// [END livestream_delete_channel_event]

media/livestream/src/delete_input.php

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

2727
// [START livestream_delete_input]
28-
use Google\Cloud\Video\LiveStream\V1\LivestreamServiceClient;
28+
use Google\Cloud\Video\LiveStream\V1\Client\LivestreamServiceClient;
29+
use Google\Cloud\Video\LiveStream\V1\DeleteInputRequest;
2930

3031
/**
3132
* Deletes an input.
@@ -44,7 +45,9 @@ function delete_input(
4445
$formattedName = $livestreamClient->inputName($callingProjectId, $location, $inputId);
4546

4647
// Run the input deletion request. The response is a long-running operation ID.
47-
$operationResponse = $livestreamClient->deleteInput($formattedName);
48+
$request = (new DeleteInputRequest())
49+
->setName($formattedName);
50+
$operationResponse = $livestreamClient->deleteInput($request);
4851
$operationResponse->pollUntilComplete();
4952
if ($operationResponse->operationSucceeded()) {
5053
// Print status

media/livestream/src/get_channel.php

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

2727
// [START livestream_get_channel]
28-
use Google\Cloud\Video\LiveStream\V1\LivestreamServiceClient;
28+
use Google\Cloud\Video\LiveStream\V1\Client\LivestreamServiceClient;
29+
use Google\Cloud\Video\LiveStream\V1\GetChannelRequest;
2930

3031
/**
3132
* Gets a channel.
@@ -44,7 +45,9 @@ function get_channel(
4445
$formattedName = $livestreamClient->channelName($callingProjectId, $location, $channelId);
4546

4647
// Get the channel.
47-
$response = $livestreamClient->getChannel($formattedName);
48+
$request = (new GetChannelRequest())
49+
->setName($formattedName);
50+
$response = $livestreamClient->getChannel($request);
4851
// Print results
4952
printf('Channel: %s' . PHP_EOL, $response->getName());
5053
}

media/livestream/src/get_channel_event.php

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

2727
// [START livestream_get_channel_event]
28-
use Google\Cloud\Video\LiveStream\V1\LivestreamServiceClient;
28+
use Google\Cloud\Video\LiveStream\V1\Client\LivestreamServiceClient;
29+
use Google\Cloud\Video\LiveStream\V1\GetEventRequest;
2930

3031
/**
3132
* Gets a channel event.
@@ -46,7 +47,9 @@ function get_channel_event(
4647
$formattedName = $livestreamClient->eventName($callingProjectId, $location, $channelId, $eventId);
4748

4849
// Get the channel event.
49-
$response = $livestreamClient->getEvent($formattedName);
50+
$request = (new GetEventRequest())
51+
->setName($formattedName);
52+
$response = $livestreamClient->getEvent($request);
5053
printf('Channel event: %s' . PHP_EOL, $response->getName());
5154
}
5255
// [END livestream_get_channel_event]

0 commit comments

Comments
 (0)