Skip to content

Commit efdc644

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

18 files changed

+96
-35
lines changed

media/livestream/composer.json

+1-1
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

+7-2
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

+7-2
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

+7-2
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

+7-2
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

+5-2
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

+5-2
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

+5-2
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

+5-2
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

+5-2
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]

media/livestream/src/get_input.php

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

2727
// [START livestream_get_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\GetInputRequest;
2930

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

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

media/livestream/src/list_channel_events.php

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

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

3031
/**
3132
* Lists the channel events for a given channel.
@@ -42,8 +43,10 @@ function list_channel_events(
4243
// Instantiate a client.
4344
$livestreamClient = new LivestreamServiceClient();
4445
$parent = $livestreamClient->channelName($callingProjectId, $location, $channelId);
46+
$request = (new ListEventsRequest())
47+
->setParent($parent);
4548

46-
$response = $livestreamClient->listEvents($parent);
49+
$response = $livestreamClient->listEvents($request);
4750
// Print the channel list.
4851
$events = $response->iterateAllElements();
4952
print('Channel events:' . PHP_EOL);

media/livestream/src/list_channels.php

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

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

3031
/**
3132
* Lists the channels for a given location.
@@ -40,8 +41,10 @@ function list_channels(
4041
// Instantiate a client.
4142
$livestreamClient = new LivestreamServiceClient();
4243
$parent = $livestreamClient->locationName($callingProjectId, $location);
44+
$request = (new ListChannelsRequest())
45+
->setParent($parent);
4346

44-
$response = $livestreamClient->listChannels($parent);
47+
$response = $livestreamClient->listChannels($request);
4548
// Print the channel list.
4649
$channels = $response->iterateAllElements();
4750
print('Channels:' . PHP_EOL);

media/livestream/src/list_inputs.php

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

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

3031
/**
3132
* Lists the inputs for a given location.
@@ -40,8 +41,10 @@ function list_inputs(
4041
// Instantiate a client.
4142
$livestreamClient = new LivestreamServiceClient();
4243
$parent = $livestreamClient->locationName($callingProjectId, $location);
44+
$request = (new ListInputsRequest())
45+
->setParent($parent);
4346

44-
$response = $livestreamClient->listInputs($parent);
47+
$response = $livestreamClient->listInputs($request);
4548
// Print the input list.
4649
$inputs = $response->iterateAllElements();
4750
print('Inputs:' . PHP_EOL);

media/livestream/src/start_channel.php

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

2727
// [START livestream_start_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\StartChannelRequest;
2930

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

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

media/livestream/src/stop_channel.php

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

2727
// [START livestream_stop_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\StopChannelRequest;
2930

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

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

media/livestream/src/update_channel.php

+6-2
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,10 @@
2525
namespace Google\Cloud\Samples\Media\LiveStream;
2626

2727
// [START livestream_update_channel]
28-
use Google\Cloud\Video\LiveStream\V1\LivestreamServiceClient;
2928
use Google\Cloud\Video\LiveStream\V1\Channel;
3029
use Google\Cloud\Video\LiveStream\V1\InputAttachment;
30+
use Google\Cloud\Video\LiveStream\V1\Client\LivestreamServiceClient;
31+
use Google\Cloud\Video\LiveStream\V1\UpdateChannelRequest;
3132
use Google\Protobuf\FieldMask;
3233

3334
/**
@@ -62,7 +63,10 @@ function update_channel(
6263
]);
6364

6465
// Run the channel update request. The response is a long-running operation ID.
65-
$operationResponse = $livestreamClient->updateChannel($channel, ['updateMask' => $updateMask]);
66+
$request = (new UpdateChannelRequest())
67+
->setChannel($channel)
68+
->setUpdateMask($updateMask);
69+
$operationResponse = $livestreamClient->updateChannel($request);
6670

6771
$operationResponse->pollUntilComplete();
6872
if ($operationResponse->operationSucceeded()) {

media/livestream/src/update_input.php

+6-2
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,10 @@
2525
namespace Google\Cloud\Samples\Media\LiveStream;
2626

2727
// [START livestream_update_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;
3030
use Google\Cloud\Video\LiveStream\V1\PreprocessingConfig;
31+
use Google\Cloud\Video\LiveStream\V1\UpdateInputRequest;
3132
use Google\Protobuf\FieldMask;
3233

3334
/**
@@ -60,7 +61,10 @@ function update_input(
6061
]);
6162

6263
// Run the input update request. The response is a long-running operation ID.
63-
$operationResponse = $livestreamClient->updateInput($input, ['updateMask' => $updateMask]);
64+
$request = (new UpdateInputRequest())
65+
->setInput($input)
66+
->setUpdateMask($updateMask);
67+
$operationResponse = $livestreamClient->updateInput($request);
6468

6569
$operationResponse->pollUntilComplete();
6670
if ($operationResponse->operationSucceeded()) {

0 commit comments

Comments
 (0)