Skip to content

chore: upgrade medialivestream samples to new surface #1870

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion media/livestream/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
"name": "google/live-stream-sample",
"type": "project",
"require": {
"google/cloud-video-live-stream": "^0.3.0"
"google/cloud-video-live-stream": "^0.5.0"
}
}
9 changes: 7 additions & 2 deletions media/livestream/src/create_channel.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,12 @@
namespace Google\Cloud\Samples\Media\LiveStream;

// [START livestream_create_channel]
use Google\Cloud\Video\LiveStream\V1\LivestreamServiceClient;
use Google\Cloud\Video\LiveStream\V1\AudioStream;
use Google\Cloud\Video\LiveStream\V1\Channel;
use Google\Cloud\Video\LiveStream\V1\ElementaryStream;
use Google\Cloud\Video\LiveStream\V1\InputAttachment;
use Google\Cloud\Video\LiveStream\V1\Client\LivestreamServiceClient;
use Google\Cloud\Video\LiveStream\V1\CreateChannelRequest;
use Google\Cloud\Video\LiveStream\V1\Manifest;
use Google\Cloud\Video\LiveStream\V1\MuxStream;
use Google\Cloud\Video\LiveStream\V1\SegmentSettings;
Expand Down Expand Up @@ -118,7 +119,11 @@ function create_channel(
]);

// Run the channel creation request. The response is a long-running operation ID.
$operationResponse = $livestreamClient->createChannel($parent, $channel, $channelId);
$request = (new CreateChannelRequest())
->setParent($parent)
->setChannel($channel)
->setChannelId($channelId);
$operationResponse = $livestreamClient->createChannel($request);
$operationResponse->pollUntilComplete();
if ($operationResponse->operationSucceeded()) {
$result = $operationResponse->getResult();
Expand Down
9 changes: 7 additions & 2 deletions media/livestream/src/create_channel_event.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@
namespace Google\Cloud\Samples\Media\LiveStream;

// [START livestream_create_channel_event]
use Google\Cloud\Video\LiveStream\V1\LivestreamServiceClient;
use Google\Cloud\Video\LiveStream\V1\Event;
use Google\Cloud\Video\LiveStream\V1\Client\LivestreamServiceClient;
use Google\Cloud\Video\LiveStream\V1\CreateEventRequest;
use Google\Protobuf\Duration;

/**
Expand Down Expand Up @@ -56,7 +57,11 @@ function create_channel_event(
->setExecuteNow(true);

// Run the channel event creation request.
$response = $livestreamClient->createEvent($parent, $event, $eventId);
$request = (new CreateEventRequest())
->setParent($parent)
->setEvent($event)
->setEventId($eventId);
$response = $livestreamClient->createEvent($request);
// Print results.
printf('Channel event: %s' . PHP_EOL, $response->getName());
}
Expand Down
9 changes: 7 additions & 2 deletions media/livestream/src/create_channel_with_backup_input.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,12 @@
namespace Google\Cloud\Samples\Media\LiveStream;

// [START livestream_create_channel_with_backup_input]
use Google\Cloud\Video\LiveStream\V1\LivestreamServiceClient;
use Google\Cloud\Video\LiveStream\V1\AudioStream;
use Google\Cloud\Video\LiveStream\V1\Channel;
use Google\Cloud\Video\LiveStream\V1\ElementaryStream;
use Google\Cloud\Video\LiveStream\V1\InputAttachment;
use Google\Cloud\Video\LiveStream\V1\Client\LivestreamServiceClient;
use Google\Cloud\Video\LiveStream\V1\CreateChannelRequest;
use Google\Cloud\Video\LiveStream\V1\Manifest;
use Google\Cloud\Video\LiveStream\V1\MuxStream;
use Google\Cloud\Video\LiveStream\V1\SegmentSettings;
Expand Down Expand Up @@ -128,7 +129,11 @@ function create_channel_with_backup_input(
]);

// Run the channel creation request. The response is a long-running operation ID.
$operationResponse = $livestreamClient->createChannel($parent, $channel, $channelId);
$request = (new CreateChannelRequest())
->setParent($parent)
->setChannel($channel)
->setChannelId($channelId);
$operationResponse = $livestreamClient->createChannel($request);
$operationResponse->pollUntilComplete();
if ($operationResponse->operationSucceeded()) {
$result = $operationResponse->getResult();
Expand Down
9 changes: 7 additions & 2 deletions media/livestream/src/create_input.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@
namespace Google\Cloud\Samples\Media\LiveStream;

// [START livestream_create_input]
use Google\Cloud\Video\LiveStream\V1\LivestreamServiceClient;
use Google\Cloud\Video\LiveStream\V1\Input;
use Google\Cloud\Video\LiveStream\V1\Client\LivestreamServiceClient;
use Google\Cloud\Video\LiveStream\V1\CreateInputRequest;

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

// Run the input creation request. The response is a long-running operation ID.
$operationResponse = $livestreamClient->createInput($parent, $input, $inputId);
$request = (new CreateInputRequest())
->setParent($parent)
->setInput($input)
->setInputId($inputId);
$operationResponse = $livestreamClient->createInput($request);
$operationResponse->pollUntilComplete();
if ($operationResponse->operationSucceeded()) {
$result = $operationResponse->getResult();
Expand Down
7 changes: 5 additions & 2 deletions media/livestream/src/delete_channel.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
namespace Google\Cloud\Samples\Media\LiveStream;

// [START livestream_delete_channel]
use Google\Cloud\Video\LiveStream\V1\LivestreamServiceClient;
use Google\Cloud\Video\LiveStream\V1\Client\LivestreamServiceClient;
use Google\Cloud\Video\LiveStream\V1\DeleteChannelRequest;

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

// Run the channel deletion request. The response is a long-running operation ID.
$operationResponse = $livestreamClient->deleteChannel($formattedName);
$request = (new DeleteChannelRequest())
->setName($formattedName);
$operationResponse = $livestreamClient->deleteChannel($request);
$operationResponse->pollUntilComplete();
if ($operationResponse->operationSucceeded()) {
// Print status
Expand Down
7 changes: 5 additions & 2 deletions media/livestream/src/delete_channel_event.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
namespace Google\Cloud\Samples\Media\LiveStream;

// [START livestream_delete_channel_event]
use Google\Cloud\Video\LiveStream\V1\LivestreamServiceClient;
use Google\Cloud\Video\LiveStream\V1\Client\LivestreamServiceClient;
use Google\Cloud\Video\LiveStream\V1\DeleteEventRequest;

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

// Run the channel event deletion request.
$livestreamClient->deleteEvent($formattedName);
$request = (new DeleteEventRequest())
->setName($formattedName);
$livestreamClient->deleteEvent($request);
printf('Deleted channel event %s' . PHP_EOL, $eventId);
}
// [END livestream_delete_channel_event]
Expand Down
7 changes: 5 additions & 2 deletions media/livestream/src/delete_input.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
namespace Google\Cloud\Samples\Media\LiveStream;

// [START livestream_delete_input]
use Google\Cloud\Video\LiveStream\V1\LivestreamServiceClient;
use Google\Cloud\Video\LiveStream\V1\Client\LivestreamServiceClient;
use Google\Cloud\Video\LiveStream\V1\DeleteInputRequest;

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

// Run the input deletion request. The response is a long-running operation ID.
$operationResponse = $livestreamClient->deleteInput($formattedName);
$request = (new DeleteInputRequest())
->setName($formattedName);
$operationResponse = $livestreamClient->deleteInput($request);
$operationResponse->pollUntilComplete();
if ($operationResponse->operationSucceeded()) {
// Print status
Expand Down
7 changes: 5 additions & 2 deletions media/livestream/src/get_channel.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
namespace Google\Cloud\Samples\Media\LiveStream;

// [START livestream_get_channel]
use Google\Cloud\Video\LiveStream\V1\LivestreamServiceClient;
use Google\Cloud\Video\LiveStream\V1\Client\LivestreamServiceClient;
use Google\Cloud\Video\LiveStream\V1\GetChannelRequest;

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

// Get the channel.
$response = $livestreamClient->getChannel($formattedName);
$request = (new GetChannelRequest())
->setName($formattedName);
$response = $livestreamClient->getChannel($request);
// Print results
printf('Channel: %s' . PHP_EOL, $response->getName());
}
Expand Down
7 changes: 5 additions & 2 deletions media/livestream/src/get_channel_event.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
namespace Google\Cloud\Samples\Media\LiveStream;

// [START livestream_get_channel_event]
use Google\Cloud\Video\LiveStream\V1\LivestreamServiceClient;
use Google\Cloud\Video\LiveStream\V1\Client\LivestreamServiceClient;
use Google\Cloud\Video\LiveStream\V1\GetEventRequest;

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

// Get the channel event.
$response = $livestreamClient->getEvent($formattedName);
$request = (new GetEventRequest())
->setName($formattedName);
$response = $livestreamClient->getEvent($request);
printf('Channel event: %s' . PHP_EOL, $response->getName());
}
// [END livestream_get_channel_event]
Expand Down
7 changes: 5 additions & 2 deletions media/livestream/src/get_input.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
namespace Google\Cloud\Samples\Media\LiveStream;

// [START livestream_get_input]
use Google\Cloud\Video\LiveStream\V1\LivestreamServiceClient;
use Google\Cloud\Video\LiveStream\V1\Client\LivestreamServiceClient;
use Google\Cloud\Video\LiveStream\V1\GetInputRequest;

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

// Get the input.
$response = $livestreamClient->getInput($formattedName);
$request = (new GetInputRequest())
->setName($formattedName);
$response = $livestreamClient->getInput($request);
// Print results
printf('Input: %s' . PHP_EOL, $response->getName());
}
Expand Down
7 changes: 5 additions & 2 deletions media/livestream/src/list_channel_events.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
namespace Google\Cloud\Samples\Media\LiveStream;

// [START livestream_list_channel_events]
use Google\Cloud\Video\LiveStream\V1\LivestreamServiceClient;
use Google\Cloud\Video\LiveStream\V1\Client\LivestreamServiceClient;
use Google\Cloud\Video\LiveStream\V1\ListEventsRequest;

/**
* Lists the channel events for a given channel.
Expand All @@ -42,8 +43,10 @@ function list_channel_events(
// Instantiate a client.
$livestreamClient = new LivestreamServiceClient();
$parent = $livestreamClient->channelName($callingProjectId, $location, $channelId);
$request = (new ListEventsRequest())
->setParent($parent);

$response = $livestreamClient->listEvents($parent);
$response = $livestreamClient->listEvents($request);
// Print the channel list.
$events = $response->iterateAllElements();
print('Channel events:' . PHP_EOL);
Expand Down
7 changes: 5 additions & 2 deletions media/livestream/src/list_channels.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
namespace Google\Cloud\Samples\Media\LiveStream;

// [START livestream_list_channels]
use Google\Cloud\Video\LiveStream\V1\LivestreamServiceClient;
use Google\Cloud\Video\LiveStream\V1\Client\LivestreamServiceClient;
use Google\Cloud\Video\LiveStream\V1\ListChannelsRequest;

/**
* Lists the channels for a given location.
Expand All @@ -40,8 +41,10 @@ function list_channels(
// Instantiate a client.
$livestreamClient = new LivestreamServiceClient();
$parent = $livestreamClient->locationName($callingProjectId, $location);
$request = (new ListChannelsRequest())
->setParent($parent);

$response = $livestreamClient->listChannels($parent);
$response = $livestreamClient->listChannels($request);
// Print the channel list.
$channels = $response->iterateAllElements();
print('Channels:' . PHP_EOL);
Expand Down
7 changes: 5 additions & 2 deletions media/livestream/src/list_inputs.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
namespace Google\Cloud\Samples\Media\LiveStream;

// [START livestream_list_inputs]
use Google\Cloud\Video\LiveStream\V1\LivestreamServiceClient;
use Google\Cloud\Video\LiveStream\V1\Client\LivestreamServiceClient;
use Google\Cloud\Video\LiveStream\V1\ListInputsRequest;

/**
* Lists the inputs for a given location.
Expand All @@ -40,8 +41,10 @@ function list_inputs(
// Instantiate a client.
$livestreamClient = new LivestreamServiceClient();
$parent = $livestreamClient->locationName($callingProjectId, $location);
$request = (new ListInputsRequest())
->setParent($parent);

$response = $livestreamClient->listInputs($parent);
$response = $livestreamClient->listInputs($request);
// Print the input list.
$inputs = $response->iterateAllElements();
print('Inputs:' . PHP_EOL);
Expand Down
7 changes: 5 additions & 2 deletions media/livestream/src/start_channel.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
namespace Google\Cloud\Samples\Media\LiveStream;

// [START livestream_start_channel]
use Google\Cloud\Video\LiveStream\V1\LivestreamServiceClient;
use Google\Cloud\Video\LiveStream\V1\Client\LivestreamServiceClient;
use Google\Cloud\Video\LiveStream\V1\StartChannelRequest;

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

// Run the channel start request. The response is a long-running operation ID.
$operationResponse = $livestreamClient->startChannel($formattedName);
$request = (new StartChannelRequest())
->setName($formattedName);
$operationResponse = $livestreamClient->startChannel($request);
$operationResponse->pollUntilComplete();
if ($operationResponse->operationSucceeded()) {
// Print results
Expand Down
7 changes: 5 additions & 2 deletions media/livestream/src/stop_channel.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
namespace Google\Cloud\Samples\Media\LiveStream;

// [START livestream_stop_channel]
use Google\Cloud\Video\LiveStream\V1\LivestreamServiceClient;
use Google\Cloud\Video\LiveStream\V1\Client\LivestreamServiceClient;
use Google\Cloud\Video\LiveStream\V1\StopChannelRequest;

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

// Run the channel stop request. The response is a long-running operation ID.
$operationResponse = $livestreamClient->stopChannel($formattedName);
$request = (new StopChannelRequest())
->setName($formattedName);
$operationResponse = $livestreamClient->stopChannel($request);
$operationResponse->pollUntilComplete();
if ($operationResponse->operationSucceeded()) {
// Print results
Expand Down
8 changes: 6 additions & 2 deletions media/livestream/src/update_channel.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,10 @@
namespace Google\Cloud\Samples\Media\LiveStream;

// [START livestream_update_channel]
use Google\Cloud\Video\LiveStream\V1\LivestreamServiceClient;
use Google\Cloud\Video\LiveStream\V1\Channel;
use Google\Cloud\Video\LiveStream\V1\InputAttachment;
use Google\Cloud\Video\LiveStream\V1\Client\LivestreamServiceClient;
use Google\Cloud\Video\LiveStream\V1\UpdateChannelRequest;
use Google\Protobuf\FieldMask;

/**
Expand Down Expand Up @@ -62,7 +63,10 @@ function update_channel(
]);

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

$operationResponse->pollUntilComplete();
if ($operationResponse->operationSucceeded()) {
Expand Down
8 changes: 6 additions & 2 deletions media/livestream/src/update_input.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,10 @@
namespace Google\Cloud\Samples\Media\LiveStream;

// [START livestream_update_input]
use Google\Cloud\Video\LiveStream\V1\LivestreamServiceClient;
use Google\Cloud\Video\LiveStream\V1\Input;
use Google\Cloud\Video\LiveStream\V1\Client\LivestreamServiceClient;
use Google\Cloud\Video\LiveStream\V1\PreprocessingConfig;
use Google\Cloud\Video\LiveStream\V1\UpdateInputRequest;
use Google\Protobuf\FieldMask;

/**
Expand Down Expand Up @@ -60,7 +61,10 @@ function update_input(
]);

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

$operationResponse->pollUntilComplete();
if ($operationResponse->operationSucceeded()) {
Expand Down