ライブ構成の作成と管理

このドキュメントでは、ライブ構成ファイルを管理する方法について説明します。ライブ構成ファイルはライブ セッションの構成に使用されます。詳細については、REST のドキュメントをご覧ください。

始める前に

ライブ セッションを作成するには、まず、Video Stitcher API のソース HLS または DASH マニフェストを生成するライブ ストリーム エンコーダを構成する必要があります。これらのマニフェストには、広告合成の目的で Video Stitcher API によって識別されるミッドロール挿入点の境界に特定の広告マーカーが含まれます。Live Stream API クイックスタートのいずれかに沿って、互換性のあるマニフェストを使用してライブ ストリームを作成できます。

サポートされている HLS と DASH の広告マーカーの詳細については、広告マーカーのドキュメントをご覧ください。

ライブ構成を定義する

ライブ構成を定義する場合は、次のフィールドは必須です。

  • sourceUri
  • adTagUri
  • defaultSlate
  • adTracking

sourceUri では、広告を挿入するソース ライブ ストリームの HLS または DASH マニフェストへの URL を指定します。Video Stitcher API は、指定された URL が HLS マニフェストを参照する場合は HLS 再生 URL を返し、指定された URL が DASH マニフェストを参照する場合は DASH 再生 URL を返します。

adTagUri は、広告メタデータを返す広告サーバーの URL を指定します。

defaultSlate パラメータは、ミッドロール挿入点の広告マーカー SCTE-35 メッセージでスレートが指定されていない場合に使用されるデフォルトのスレートを指定します。スレートの管理の詳細については、スレートのドキュメントをご覧ください。

adTracking は、クライアント プレーヤーで再生イベントとアクティビティ イベントがトリガーされるか、Video Stitcher API がクライアント プレーヤーに代わって再生イベントをトリガーするかを決定します。クライアント側の広告トラッキングの詳細については、ライブ クライアント広告のトラッキングを処理するをご覧ください。

ライブ構成ファイルを登録する

ライブ構成を登録するには、projects.locations.liveConfigs.create メソッドを使用します。

REST

リクエストのデータを使用する前に、次のように置き換えます。

  • PROJECT_NUMBER: IAM 設定ページの [プロジェクト番号] フィールドにある Google Cloud プロジェクト番号
  • LOCATION: ライブ構成ファイルを作成するロケーション。サポートされているリージョンのいずれかを使用します。
    3~7 つの店舗を表示
    • us-central1
    • us-east1
    • us-west1
    • asia-east1
    • asia-south1
    • asia-southeast1
    • europe-west1
    • southamerica-east1
  • LIVE_CONFIG_ID: ライブ構成のユーザー定義の識別子。この ID に使用できるのは、小文字、数字、ハイフンに限られます。 最初の文字は英字で、最後の文字は英字または数字で、ID 全体は最大 63 文字です。
  • SOURCE_LIVESTREAM_URI: ライブ ストリーム マニフェストの URI。CDN 鍵を登録した公開 URI または署名されていない URI を使用します。
  • AD_TAG_URI: デフォルト広告タグの公開 URI。まだ作成していない場合は、単一インライン線形のサンプルを使用できます。
  • SLATE_ID: 合成された広告がない場合に使用するスレートの ID

リクエストを送信するには、次のいずれかのオプションを展開します。

次のような JSON レスポンスが返されます。

{
  "name": "projects/PROJECT_NUMBER/locations/LOCATION/operations/OPERATION_ID",
  "metadata": {
    "@type": "type.googleapis.com/google.cloud.common.OperationMetadata",
    "createTime": CREATE_TIME,
    "target": "projects/PROJECT_NUMBER/locations/LOCATION/liveConfigs/LIVE_CONFIG_ID",
    "verb": "create",
    "cancelRequested": false,
    "apiVersion": "v1"
  },
  "done": false
}
このコマンドは、進行状況を追跡するためにクエリできる長時間実行オペレーション(LRO)を作成します。次のセクションで使用するために、返された OPERATION_IDname フィールドの最後の部分)をコピーします。

C#

このサンプルを試す前に、クライアント ライブラリを使用した Video Stitcher API クイックスタートにある C# の設定手順を実施してください。詳細については、Video Stitcher API C# API リファレンス ドキュメントをご覧ください。

Video Stitcher API への認証を行うには、アプリケーションのデフォルト認証情報を設定します。 詳細については、ローカル開発環境の認証の設定をご覧ください。


using Google.Api.Gax.ResourceNames;
using Google.Cloud.Video.Stitcher.V1;
using Google.LongRunning;
using System.Threading.Tasks;

public class CreateLiveConfigSample
{
    public async Task<LiveConfig> CreateLiveConfigAsync(
        string projectId, string location, string liveConfigId, string sourceUri, string adTagUri, string slateId)
    {
        // Create the client.
        VideoStitcherServiceClient client = VideoStitcherServiceClient.Create();

        CreateLiveConfigRequest request = new CreateLiveConfigRequest
        {
            ParentAsLocationName = LocationName.FromProjectLocation(projectId, location),
            LiveConfigId = liveConfigId,
            LiveConfig = new LiveConfig
            {
                SourceUri = sourceUri,
                AdTagUri = adTagUri,
                DefaultSlate = SlateName.FormatProjectLocationSlate(projectId, location, slateId),
                AdTracking = AdTracking.Server,
                StitchingPolicy = LiveConfig.Types.StitchingPolicy.CutCurrent
            }
        };

        // Make the request.
        Operation<LiveConfig, OperationMetadata> response = await client.CreateLiveConfigAsync(request);

        // Poll until the returned long-running operation is complete.
        Operation<LiveConfig, OperationMetadata> completedResponse = await response.PollUntilCompletedAsync();

        // Retrieve the operation result.
        return completedResponse.Result;
    }
}

Go

このサンプルを試す前に、クライアント ライブラリを使用した Video Stitcher API クイックスタートにある Go の設定手順を実施してください。詳細については、Video Stitcher API Go API リファレンス ドキュメントをご覧ください。

Video Stitcher API への認証を行うには、アプリケーションのデフォルト認証情報を設定します。 詳細については、ローカル開発環境の認証の設定をご覧ください。

import (
	"context"
	"fmt"
	"io"

	stitcher "cloud.google.com/go/video/stitcher/apiv1"
	stitcherstreampb "cloud.google.com/go/video/stitcher/apiv1/stitcherpb"
)

// createLiveConfig creates a live config. Live configs are used to configure live sessions.
func createLiveConfig(w io.Writer, projectID, liveConfigID, sourceURI, slateID string) error {
	// projectID := "my-project-id"
	// liveConfigID := "my-live-config-id"

	// Uri of the media to stitch; this URI must reference either an MPEG-DASH
	// manifest (.mpd) file or an M3U playlist manifest (.m3u8) file.
	// sourceURI := "https://storage.googleapis.com/my-bucket/main.mpd"

	// See https://cloud.google.com/video-stitcher/docs/concepts for information
	// on ad tags and ad metadata. This sample uses an ad tag URL that displays
	// a Single Inline Linear ad
	// (https://developers.google.com/interactive-media-ads/docs/sdks/html5/client-side/tags).
	adTagURI := "https://pubads.g.doubleclick.net/gampad/ads?iu=/21775744923/external/single_ad_samples&sz=640x480&cust_params=sample_ct%3Dlinear&ciu_szs=300x250%2C728x90&gdfp_req=1&output=vast&unviewed_position_start=1&env=vp&impl=s&correlator="
	// slateID := "my-slate-id"
	location := "us-central1"
	ctx := context.Background()
	client, err := stitcher.NewVideoStitcherClient(ctx)
	if err != nil {
		return fmt.Errorf("stitcher.NewVideoStitcherClient: %w", err)
	}
	defer client.Close()

	req := &stitcherstreampb.CreateLiveConfigRequest{
		Parent:       fmt.Sprintf("projects/%s/locations/%s", projectID, location),
		LiveConfigId: liveConfigID,
		LiveConfig: &stitcherstreampb.LiveConfig{
			SourceUri:       sourceURI,
			AdTagUri:        adTagURI,
			AdTracking:      stitcherstreampb.AdTracking_SERVER,
			StitchingPolicy: stitcherstreampb.LiveConfig_CUT_CURRENT,
			DefaultSlate:    fmt.Sprintf("projects/%s/locations/%s/slates/%s", projectID, location, slateID),
		},
	}
	// Creates the live config.
	op, err := client.CreateLiveConfig(ctx, req)
	if err != nil {
		return fmt.Errorf("client.createLiveConfig: %w", err)
	}
	response, err := op.Wait(ctx)
	if err != nil {
		return err
	}

	fmt.Fprintf(w, "Live config: %v", response.GetName())
	return nil
}

Java

このサンプルを試す前に、クライアント ライブラリを使用した Video Stitcher API クイックスタートにある Java の設定手順を実施してください。詳細については、Video Stitcher API Java API リファレンス ドキュメントをご覧ください。

Video Stitcher API への認証を行うには、アプリケーションのデフォルト認証情報を設定します。 詳細については、ローカル開発環境の認証の設定をご覧ください。


import com.google.cloud.video.stitcher.v1.AdTracking;
import com.google.cloud.video.stitcher.v1.CreateLiveConfigRequest;
import com.google.cloud.video.stitcher.v1.LiveConfig;
import com.google.cloud.video.stitcher.v1.LiveConfig.StitchingPolicy;
import com.google.cloud.video.stitcher.v1.LocationName;
import com.google.cloud.video.stitcher.v1.SlateName;
import com.google.cloud.video.stitcher.v1.VideoStitcherServiceClient;
import java.io.IOException;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;

public class CreateLiveConfig {

  private static final int TIMEOUT_IN_MINUTES = 2;

  public static void main(String[] args) throws Exception {
    // TODO(developer): Replace these variables before running the sample.
    String projectId = "my-project-id";
    String location = "us-central1";
    String liveConfigId = "my-live-config-id";
    // Uri of the live stream to stitch; this URI must reference either an MPEG-DASH
    // manifest (.mpd) file or an M3U playlist manifest (.m3u8) file.
    String sourceUri = "https://storage.googleapis.com/my-bucket/main.mpd";
    // See Single Inline Linear
    // (https://developers.google.com/interactive-media-ads/docs/sdks/html5/client-side/tags)
    String adTagUri = "https://pubads.g.doubleclick.net/gampad/ads...";
    String slateId = "my-slate-id";

    createLiveConfig(projectId, location, liveConfigId, sourceUri, adTagUri, slateId);
  }

  public static void createLiveConfig(
      String projectId,
      String location,
      String liveConfigId,
      String sourceUri,
      String adTagUri,
      String slateId)
      throws IOException, ExecutionException, InterruptedException, TimeoutException {
    // Initialize client that will be used to send requests. This client only needs to be created
    // once, and can be reused for multiple requests. After completing all of your requests, call
    // the "close" method on the client to safely clean up any remaining background resources.
    VideoStitcherServiceClient videoStitcherServiceClient = VideoStitcherServiceClient.create();
    CreateLiveConfigRequest createLiveConfigRequest =
        CreateLiveConfigRequest.newBuilder()
            .setParent(LocationName.of(projectId, location).toString())
            .setLiveConfigId(liveConfigId)
            .setLiveConfig(
                LiveConfig.newBuilder()
                    .setSourceUri(sourceUri)
                    .setAdTagUri(adTagUri)
                    .setDefaultSlate(SlateName.format(projectId, location, slateId))
                    .setAdTracking(AdTracking.SERVER)
                    .setStitchingPolicy(StitchingPolicy.CUT_CURRENT)
                    .build())
            .build();

    LiveConfig response =
        videoStitcherServiceClient
            .createLiveConfigAsync(createLiveConfigRequest)
            .get(TIMEOUT_IN_MINUTES, TimeUnit.MINUTES);
    System.out.println("Created new live config: " + response.getName());
    videoStitcherServiceClient.close();
  }
}

Node.js

このサンプルを試す前に、クライアント ライブラリを使用した Video Stitcher API クイックスタートにある Node.js の設定手順を実施してください。詳細については、Video Stitcher API Node.js API リファレンス ドキュメントをご覧ください。

Video Stitcher API への認証を行うには、アプリケーションのデフォルト認証情報を設定します。 詳細については、ローカル開発環境の認証の設定をご覧ください。

/**
 * TODO(developer): Uncomment these variables before running the sample.
 */
// projectId = 'my-project-id';
// location = 'us-central1';
// liveConfigId = 'my-live-config-id';
// sourceUri = 'https://storage.googleapis.com/my-bucket/main.mpd';
// See Single Inline Linear
// (https://developers.google.com/interactive-media-ads/docs/sdks/html5/client-side/tags)
// adTagUri = 'https://pubads.g.doubleclick.net/gampad/ads...';
// slateId = 'my-slate';

// Imports the Video Stitcher library
const {VideoStitcherServiceClient} =
  require('@google-cloud/video-stitcher').v1;
// Instantiates a client
const stitcherClient = new VideoStitcherServiceClient();

async function createLiveConfig() {
  // Construct request
  const request = {
    parent: stitcherClient.locationPath(projectId, location),
    liveConfig: {
      sourceUri: sourceUri,
      adTagUri: adTagUri,
      adTracking: 'SERVER',
      stitchingPolicy: 'CUT_CURRENT',
      defaultSlate: stitcherClient.slatePath(projectId, location, slateId),
    },
    liveConfigId: liveConfigId,
  };
  const [operation] = await stitcherClient.createLiveConfig(request);
  const [response] = await operation.promise();
  console.log(`response.name: ${response.name}`);
}

createLiveConfig();

PHP

このサンプルを試す前に、クライアント ライブラリを使用した Video Stitcher API クイックスタートにある PHP の設定手順を実施してください。詳細については、Video Stitcher API PHP API リファレンス ドキュメントをご覧ください。

Video Stitcher API への認証を行うには、アプリケーションのデフォルト認証情報を設定します。 詳細については、ローカル開発環境の認証の設定をご覧ください。

use Google\Cloud\Video\Stitcher\V1\AdTracking;
use Google\Cloud\Video\Stitcher\V1\Client\VideoStitcherServiceClient;
use Google\Cloud\Video\Stitcher\V1\CreateLiveConfigRequest;
use Google\Cloud\Video\Stitcher\V1\LiveConfig;

/**
 * Creates a live config. Live configs are used to configure live sessions.
 *
 * @param string $callingProjectId     The project ID to run the API call under
 * @param string $location             The location of the live config
 * @param string $liveConfigId         The name of the live config to be created
 * @param string $sourceUri            Uri of the media to stitch; this URI must
 *                                     reference either an MPEG-DASH manifest
 *                                     (.mpd) file or an M3U playlist manifest
 *                                     (.m3u8) file.
 * @param string $adTagUri             The Uri of the ad tag
 * @param string $slateId              The user-defined slate ID of the default
 *                                     slate to use when no slates are specified
 *                                     in an ad break's message
 */
function create_live_config(
    string $callingProjectId,
    string $location,
    string $liveConfigId,
    string $sourceUri,
    string $adTagUri,
    string $slateId
): void {
    // Instantiate a client.
    $stitcherClient = new VideoStitcherServiceClient();

    $parent = $stitcherClient->locationName($callingProjectId, $location);
    $defaultSlate = $stitcherClient->slateName($callingProjectId, $location, $slateId);

    $liveConfig = (new LiveConfig())
        ->setSourceUri($sourceUri)
        ->setAdTagUri($adTagUri)
        ->setAdTracking(AdTracking::SERVER)
        ->setStitchingPolicy(LiveConfig\StitchingPolicy::CUT_CURRENT)
        ->setDefaultSlate($defaultSlate);

    // Run live config creation request
    $request = (new CreateLiveConfigRequest())
        ->setParent($parent)
        ->setLiveConfigId($liveConfigId)
        ->setLiveConfig($liveConfig);
    $operationResponse = $stitcherClient->createLiveConfig($request);
    $operationResponse->pollUntilComplete();
    if ($operationResponse->operationSucceeded()) {
        $result = $operationResponse->getResult();
        // Print results
        printf('Live config: %s' . PHP_EOL, $result->getName());
    } else {
        $error = $operationResponse->getError();
        // handleError($error)
    }
}

Python

このサンプルを試す前に、クライアント ライブラリを使用した Video Stitcher API クイックスタートにある Python の設定手順を実施してください。詳細については、Video Stitcher API Python API リファレンス ドキュメントをご覧ください。

Video Stitcher API への認証を行うには、アプリケーションのデフォルト認証情報を設定します。 詳細については、ローカル開発環境の認証の設定をご覧ください。


import argparse

from google.cloud.video import stitcher_v1
from google.cloud.video.stitcher_v1.services.video_stitcher_service import (
    VideoStitcherServiceClient,
)

def create_live_config(
    project_id: str,
    location: str,
    live_config_id: str,
    live_stream_uri: str,
    ad_tag_uri: str,
    slate_id: str,
) -> stitcher_v1.types.LiveConfig:
    """Creates a live config.
    Args:
        project_id: The GCP project ID.
        location: The location in which to create the live config.
        live_config_id: The user-defined live config ID.
        live_stream_uri: Uri of the livestream to stitch; this URI must reference either an MPEG-DASH
                    manifest (.mpd) file or an M3U playlist manifest (.m3u8) file.
        ad_tag_uri: Uri of the ad tag.
        slate_id: The user-defined slate ID of the default slate to use when no slates are specified in an ad break's message.

    Returns:
        The live config resource.
    """

    client = VideoStitcherServiceClient()

    parent = f"projects/{project_id}/locations/{location}"
    default_slate = f"projects/{project_id}/locations/{location}/slates/{slate_id}"

    live_config = stitcher_v1.types.LiveConfig(
        source_uri=live_stream_uri,
        ad_tag_uri=ad_tag_uri,
        ad_tracking="SERVER",
        stitching_policy="CUT_CURRENT",
        default_slate=default_slate,
    )

    operation = client.create_live_config(
        parent=parent, live_config_id=live_config_id, live_config=live_config
    )
    response = operation.result()
    print(f"Live config: {response.name}")
    return response

Ruby

このサンプルを試す前に、クライアント ライブラリを使用した Video Stitcher API クイックスタートにある Ruby の設定手順を実施してください。詳細については、Video Stitcher API Ruby API リファレンス ドキュメントをご覧ください。

Video Stitcher API への認証を行うには、アプリケーションのデフォルト認証情報を設定します。 詳細については、ローカル開発環境の認証の設定をご覧ください。

require "google/cloud/video/stitcher"

##
# Create a live config
#
# @param project_id [String] Your Google Cloud project (e.g. "my-project")
# @param location [String] The location (e.g. "us-central1")
# @param live_config_id [String] Your live config name (e.g. "my-live-config")
# @param source_uri [String] Uri of the live stream to stitch
#   (e.g. "https://storage.googleapis.com/my-bucket/main.mpd")
# @param ad_tag_uri [String] Uri of the ad tag
#   (e.g. "https://pubads.g.doubleclick.net/gampad/ads...")
# @param slate_id [String] The default slate ID to use when no slates are
#   specified in an ad break's message (e.g. "my-slate-id")
#
def create_live_config project_id:, location:, live_config_id:, source_uri:,
                       ad_tag_uri:, slate_id:
  # Create a Video Stitcher client.
  client = Google::Cloud::Video::Stitcher.video_stitcher_service

  # Build the resource name of the parent.
  parent = client.location_path project: project_id, location: location

  # Build the resource name of the default slate.
  slate_name = client.slate_path project: project_id, location: location,
                                 slate: slate_id

  # Set the live config fields.
  new_live_config = {
    source_uri: source_uri,
    ad_tag_uri: ad_tag_uri,
    ad_tracking: Google::Cloud::Video::Stitcher::V1::AdTracking::SERVER,
    stitching_policy: Google::Cloud::Video::Stitcher::V1::LiveConfig::StitchingPolicy::CUT_CURRENT,
    default_slate: slate_name
  }

  operation = client.create_live_config parent: parent,
                                        live_config_id: live_config_id,
                                        live_config: new_live_config

  # The returned object is of type Gapic::Operation. You can use this
  # object to check the status of an operation, cancel it, or wait
  # for results. Here is how to block until completion:
  operation.wait_until_done!

  # Print the live config name.
  puts "Live config: #{operation.response.name}"
end

結果を確認する

ライブ構成が作成されたかどうかを確認するには、projects.locations.operations.get メソッドを使用します。レスポンスに "done: false" が含まれている場合は、レスポンスに "done: true" が含まれるまでコマンドを繰り返します。

リクエストのデータを使用する前に、次のように置き換えます。

  • PROJECT_NUMBER: IAM 設定ページの [プロジェクト番号] フィールドにある Google Cloud プロジェクト番号
  • LOCATION: データのロケーション。サポートされているリージョンのいずれかを使用します。
    3~7 つの店舗を表示
    • us-central1
    • us-east1
    • us-west1
    • asia-east1
    • asia-south1
    • asia-southeast1
    • europe-west1
    • southamerica-east1
  • OPERATION_ID: オペレーションの ID。

リクエストを送信するには、次のいずれかのオプションを展開します。

次のような JSON レスポンスが返されます。

{
  "name": "projects/PROJECT_NUMBER/locations/LOCATION/operations/OPERATION_ID",
  "metadata": {
    "@type": "type.googleapis.com/google.cloud.common.OperationMetadata",
    "createTime": CREATE_TIME,
    "endTime": END_TIME,
    "target": "projects/PROJECT_NUMBER/locations/LOCATION/liveConfigs/LIVE_CONFIG_ID",
    "verb": "create",
    "cancelRequested": false,
    "apiVersion": "v1"
  },
  "done": true,
  "response": {
    "@type": "type.googleapis.com/google.cloud.video.stitcher.v1.LiveConfig",
    "name": "projects/PROJECT_NUMBER/locations/LOCATION/liveConfigs/LIVE_CONFIG_ID",
    "sourceUri": "SOURCE_LIVESTREAM_URI",
    "adTagUri": "AD_TAG_URI",
    "state": "READY",
    "adTracking": "CLIENT",
    "defaultSlate": "projects/PROJECT_NUMBER/locations/LOCATION/slates/SLATE_ID",
    "stitchingPolicy": "CUT_CURRENT",
    "defaultAdBreakDuration": "30s"
  }
}

ライブ構成ファイルの取得

特定のライブ構成ファイルの詳細を取得するには、projects.locations.liveConfigs.get メソッドを使用します。

REST

リクエストのデータを使用する前に、次のように置き換えます。

  • PROJECT_NUMBER: IAM 設定ページの [プロジェクト番号] フィールドにある Google Cloud プロジェクト番号
  • LOCATION: ライブ構成ファイルのロケーション。サポートされているリージョンのいずれかを使用します。
    3~7 つの店舗を表示
    • us-central1
    • us-east1
    • us-west1
    • asia-east1
    • asia-south1
    • asia-southeast1
    • europe-west1
    • southamerica-east1
  • LIVE_CONFIG_ID: ライブ構成ファイルのユーザー定義の識別子。

リクエストを送信するには、次のいずれかのオプションを展開します。

次のような JSON レスポンスが返されます。

{
  "name": "projects/PROJECT_NUMBER/locations/LOCATION/liveConfigs/LIVE_CONFIG_ID",
  "sourceUri": "SOURCE_LIVESTREAM_URI",
  "adTagUri": "AD_TAG_URI",
  "state": "READY",
  "adTracking": "SERVER",
  "defaultSlate": "projects/PROJECT_NUMBER/locations/LOCATION/slates/SLATE_ID",
  "stitchingPolicy": "CUT_CURRENT"
}

C#

このサンプルを試す前に、クライアント ライブラリを使用した Video Stitcher API クイックスタートにある C# の設定手順を実施してください。詳細については、Video Stitcher API C# API リファレンス ドキュメントをご覧ください。

Video Stitcher API への認証を行うには、アプリケーションのデフォルト認証情報を設定します。 詳細については、ローカル開発環境の認証の設定をご覧ください。


using Google.Cloud.Video.Stitcher.V1;

public class GetLiveConfigSample
{
    public LiveConfig GetLiveConfig(
        string projectId, string location, string liveConfigId)
    {
        // Create the client.
        VideoStitcherServiceClient client = VideoStitcherServiceClient.Create();

        GetLiveConfigRequest request = new GetLiveConfigRequest
        {
            LiveConfigName = LiveConfigName.FromProjectLocationLiveConfig(projectId, location, liveConfigId)
        };

        // Call the API.
        LiveConfig response = client.GetLiveConfig(request);

        // Return the result.
        return response;
    }
}

Go

このサンプルを試す前に、クライアント ライブラリを使用した Video Stitcher API クイックスタートにある Go の設定手順を実施してください。詳細については、Video Stitcher API Go API リファレンス ドキュメントをご覧ください。

Video Stitcher API への認証を行うには、アプリケーションのデフォルト認証情報を設定します。 詳細については、ローカル開発環境の認証の設定をご覧ください。

import (
	"context"
	"encoding/json"
	"fmt"
	"io"

	stitcher "cloud.google.com/go/video/stitcher/apiv1"
	stitcherstreampb "cloud.google.com/go/video/stitcher/apiv1/stitcherpb"
)

// getLiveConfig gets a previously-created live config.
func getLiveConfig(w io.Writer, projectID, liveConfigID string) error {
	// projectID := "my-project-id"
	// liveConfigID := "my-live-config-id"
	location := "us-central1"
	ctx := context.Background()
	client, err := stitcher.NewVideoStitcherClient(ctx)
	if err != nil {
		return fmt.Errorf("stitcher.NewVideoStitcherClient: %w", err)
	}
	defer client.Close()

	req := &stitcherstreampb.GetLiveConfigRequest{
		Name: fmt.Sprintf("projects/%s/locations/%s/liveConfigs/%s", projectID, location, liveConfigID),
	}

	response, err := client.GetLiveConfig(ctx, req)
	if err != nil {
		return fmt.Errorf("client.GetLiveConfig: %w", err)
	}
	b, err := json.MarshalIndent(response, "", " ")
	if err != nil {
		return fmt.Errorf("json.MarshalIndent: %w", err)
	}

	fmt.Fprintf(w, "Live config:\n%s", string(b))
	return nil
}

Java

このサンプルを試す前に、クライアント ライブラリを使用した Video Stitcher API クイックスタートにある Java の設定手順を実施してください。詳細については、Video Stitcher API Java API リファレンス ドキュメントをご覧ください。

Video Stitcher API への認証を行うには、アプリケーションのデフォルト認証情報を設定します。 詳細については、ローカル開発環境の認証の設定をご覧ください。


import com.google.cloud.video.stitcher.v1.GetLiveConfigRequest;
import com.google.cloud.video.stitcher.v1.LiveConfig;
import com.google.cloud.video.stitcher.v1.LiveConfigName;
import com.google.cloud.video.stitcher.v1.VideoStitcherServiceClient;
import java.io.IOException;

public class GetLiveConfig {

  public static void main(String[] args) throws Exception {
    // TODO(developer): Replace these variables before running the sample.
    String projectId = "my-project-id";
    String location = "us-central1";
    String liveConfigId = "my-live-config-id";

    getLiveConfig(projectId, location, liveConfigId);
  }

  public static void getLiveConfig(String projectId, String location, String liveConfigId)
      throws IOException {
    // Initialize client that will be used to send requests. This client only needs to be created
    // once, and can be reused for multiple requests. In this example, try-with-resources is used
    // which automatically calls close() on the client to clean up resources.
    try (VideoStitcherServiceClient videoStitcherServiceClient =
        VideoStitcherServiceClient.create()) {
      GetLiveConfigRequest getLiveConfigRequest =
          GetLiveConfigRequest.newBuilder()
              .setName(LiveConfigName.of(projectId, location, liveConfigId).toString())
              .build();

      LiveConfig response = videoStitcherServiceClient.getLiveConfig(getLiveConfigRequest);
      System.out.println("Live config: " + response.getName());
    }
  }
}

Node.js

このサンプルを試す前に、クライアント ライブラリを使用した Video Stitcher API クイックスタートにある Node.js の設定手順を実施してください。詳細については、Video Stitcher API Node.js API リファレンス ドキュメントをご覧ください。

Video Stitcher API への認証を行うには、アプリケーションのデフォルト認証情報を設定します。 詳細については、ローカル開発環境の認証の設定をご覧ください。

/**
 * TODO(developer): Uncomment these variables before running the sample.
 */
// projectId = 'my-project-id';
// location = 'us-central1';
// liveConfigId = 'my-live-config-id';

// Imports the Video Stitcher library
const {VideoStitcherServiceClient} =
  require('@google-cloud/video-stitcher').v1;
// Instantiates a client
const stitcherClient = new VideoStitcherServiceClient();

async function getLiveConfig() {
  // Construct request
  const request = {
    name: stitcherClient.liveConfigPath(projectId, location, liveConfigId),
  };
  const [liveConfig] = await stitcherClient.getLiveConfig(request);
  console.log(`Live config: ${liveConfig.name}`);
}

getLiveConfig();

PHP

このサンプルを試す前に、クライアント ライブラリを使用した Video Stitcher API クイックスタートにある PHP の設定手順を実施してください。詳細については、Video Stitcher API PHP API リファレンス ドキュメントをご覧ください。

Video Stitcher API への認証を行うには、アプリケーションのデフォルト認証情報を設定します。 詳細については、ローカル開発環境の認証の設定をご覧ください。

use Google\Cloud\Video\Stitcher\V1\Client\VideoStitcherServiceClient;
use Google\Cloud\Video\Stitcher\V1\GetLiveConfigRequest;

/**
 * Gets a live config.
 *
 * @param string $callingProjectId     The project ID to run the API call under
 * @param string $location             The location of the live config
 * @param string $liveConfigId         The ID of the live config
 */
function get_live_config(
    string $callingProjectId,
    string $location,
    string $liveConfigId
): void {
    // Instantiate a client.
    $stitcherClient = new VideoStitcherServiceClient();

    $formattedName = $stitcherClient->liveConfigName($callingProjectId, $location, $liveConfigId);
    $request = (new GetLiveConfigRequest())
        ->setName($formattedName);
    $liveConfig = $stitcherClient->getLiveConfig($request);

    // Print results
    printf('Live config: %s' . PHP_EOL, $liveConfig->getName());
}

Python

このサンプルを試す前に、クライアント ライブラリを使用した Video Stitcher API クイックスタートにある Python の設定手順を実施してください。詳細については、Video Stitcher API Python API リファレンス ドキュメントをご覧ください。

Video Stitcher API への認証を行うには、アプリケーションのデフォルト認証情報を設定します。 詳細については、ローカル開発環境の認証の設定をご覧ください。


import argparse

from google.cloud.video import stitcher_v1
from google.cloud.video.stitcher_v1.services.video_stitcher_service import (
    VideoStitcherServiceClient,
)

def get_live_config(
    project_id: str, location: str, live_config_id: str
) -> stitcher_v1.types.LiveConfig:
    """Gets a live config.
    Args:
        project_id: The GCP project ID.
        location: The location of the live config.
        live_config_id: The user-defined live config ID.

    Returns:
        The live config resource.
    """

    client = VideoStitcherServiceClient()

    name = f"projects/{project_id}/locations/{location}/liveConfigs/{live_config_id}"
    response = client.get_live_config(name=name)
    print(f"Live config: {response.name}")
    return response

Ruby

このサンプルを試す前に、クライアント ライブラリを使用した Video Stitcher API クイックスタートにある Ruby の設定手順を実施してください。詳細については、Video Stitcher API Ruby API リファレンス ドキュメントをご覧ください。

Video Stitcher API への認証を行うには、アプリケーションのデフォルト認証情報を設定します。 詳細については、ローカル開発環境の認証の設定をご覧ください。

require "google/cloud/video/stitcher"

##
# Get a live config
#
# @param project_id [String] Your Google Cloud project (e.g. "my-project")
# @param location [String] The location (e.g. "us-central1")
# @param live_config_id [String] Your live config name (e.g. "my-live-config")
#
def get_live_config project_id:, location:, live_config_id:
  # Create a Video Stitcher client.
  client = Google::Cloud::Video::Stitcher.video_stitcher_service

  # Build the resource name of the live config.
  name = client.live_config_path project: project_id, location: location,
                                 live_config: live_config_id

  # Get the live config.
  live_config = client.get_live_config name: name

  # Print the live config name.
  puts "Live config: #{live_config.name}"
end

登録されているすべてのライブ構成ファイルを一覧表示する

プロジェクト内の特定のロケーションに登録されているすべてのライブ構成ファイルを一覧表示するには、projects.locations.liveConfigs.list メソッドを使用します。

REST

リクエストのデータを使用する前に、次のように置き換えます。

  • PROJECT_NUMBER: IAM 設定ページの [プロジェクト番号] フィールドにある Google Cloud プロジェクト番号
  • LOCATION: ライブ構成ファイルのロケーション。サポートされているリージョンのいずれかを使用します。
    3~7 つの店舗を表示
    • us-central1
    • us-east1
    • us-west1
    • asia-east1
    • asia-south1
    • asia-southeast1
    • europe-west1
    • southamerica-east1

リクエストを送信するには、次のいずれかのオプションを展開します。

次のような JSON レスポンスが返されます。

{
  "liveConfigs": [
    {
      "name": "projects/PROJECT_NUMBER/locations/LOCATION/liveConfigs/LIVE_CONFIG_ID",
      "sourceUri": "SOURCE_LIVESTREAM_URI",
      "adTagUri": "AD_TAG_URI",
      "state": "READY",
      "adTracking": "SERVER",
      "defaultSlate": "projects/PROJECT_NUMBER/locations/LOCATION/slates/SLATE_ID",
      "stitchingPolicy": "CUT_CURRENT"
    },
    {
      "name": "projects/PROJECT_NUMBER/locations/LOCATION/liveConfigs/my-other-live-config",
      "sourceUri": "my-other-live-stream-uri",
      "adTagUri": "my-other-ad-tag-uri",
      "state": "READY",
      "adTracking": "SERVER",
      "defaultSlate": "projects/PROJECT_NUMBER/locations/LOCATION/slates/my-other-slate",
      "stitchingPolicy": "CUT_CURRENT"
    }
}

C#

このサンプルを試す前に、クライアント ライブラリを使用した Video Stitcher API クイックスタートにある C# の設定手順を実施してください。詳細については、Video Stitcher API C# API リファレンス ドキュメントをご覧ください。

Video Stitcher API への認証を行うには、アプリケーションのデフォルト認証情報を設定します。 詳細については、ローカル開発環境の認証の設定をご覧ください。


using Google.Api.Gax;
using Google.Api.Gax.ResourceNames;
using Google.Cloud.Video.Stitcher.V1;

public class ListLiveConfigsSample
{
    public PagedEnumerable<ListLiveConfigsResponse, LiveConfig> ListLiveConfigs(
        string projectId, string regionId)
    {
        // Create the client.
        VideoStitcherServiceClient client = VideoStitcherServiceClient.Create();

        ListLiveConfigsRequest request = new ListLiveConfigsRequest
        {
            ParentAsLocationName = LocationName.FromProjectLocation(projectId, regionId)
        };

        // Make the request.
        PagedEnumerable<ListLiveConfigsResponse, LiveConfig> response = client.ListLiveConfigs(request);

        // Return the result.
        return response;
    }
}

Go

このサンプルを試す前に、クライアント ライブラリを使用した Video Stitcher API クイックスタートにある Go の設定手順を実施してください。詳細については、Video Stitcher API Go API リファレンス ドキュメントをご覧ください。

Video Stitcher API への認証を行うには、アプリケーションのデフォルト認証情報を設定します。 詳細については、ローカル開発環境の認証の設定をご覧ください。

import (
	"context"
	"fmt"
	"io"

	stitcher "cloud.google.com/go/video/stitcher/apiv1"
	stitcherstreampb "cloud.google.com/go/video/stitcher/apiv1/stitcherpb"
	"google.golang.org/api/iterator"
)

// listLiveConfigs lists all live configs for a given location.
func listLiveConfigs(w io.Writer, projectID string) error {
	// projectID := "my-project-id"
	location := "us-central1"
	ctx := context.Background()
	client, err := stitcher.NewVideoStitcherClient(ctx)
	if err != nil {
		return fmt.Errorf("stitcher.NewVideoStitcherClient: %w", err)
	}
	defer client.Close()

	req := &stitcherstreampb.ListLiveConfigsRequest{
		Parent: fmt.Sprintf("projects/%s/locations/%s", projectID, location),
	}

	it := client.ListLiveConfigs(ctx, req)
	fmt.Fprintln(w, "Live configs:")

	for {
		response, err := it.Next()
		if err == iterator.Done {
			break
		}
		if err != nil {
			return fmt.Errorf("it.Next(): %w", err)
		}
		fmt.Fprintln(w, response.GetName())
	}
	return nil
}

Java

このサンプルを試す前に、クライアント ライブラリを使用した Video Stitcher API クイックスタートにある Java の設定手順を実施してください。詳細については、Video Stitcher API Java API リファレンス ドキュメントをご覧ください。

Video Stitcher API への認証を行うには、アプリケーションのデフォルト認証情報を設定します。 詳細については、ローカル開発環境の認証の設定をご覧ください。


import com.google.cloud.video.stitcher.v1.ListLiveConfigsRequest;
import com.google.cloud.video.stitcher.v1.LiveConfig;
import com.google.cloud.video.stitcher.v1.LocationName;
import com.google.cloud.video.stitcher.v1.VideoStitcherServiceClient;
import java.io.IOException;

public class ListLiveConfigs {

  public static void main(String[] args) throws Exception {
    // TODO(developer): Replace these variables before running the sample.
    String projectId = "my-project-id";
    String location = "us-central1";

    listLiveConfigs(projectId, location);
  }

  public static void listLiveConfigs(String projectId, String location) throws IOException {
    // Initialize client that will be used to send requests. This client only needs to be created
    // once, and can be reused for multiple requests. In this example, try-with-resources is used
    // which automatically calls close() on the client to clean up resources.
    try (VideoStitcherServiceClient videoStitcherServiceClient =
        VideoStitcherServiceClient.create()) {
      ListLiveConfigsRequest listLiveConfigsRequest =
          ListLiveConfigsRequest.newBuilder()
              .setParent(LocationName.of(projectId, location).toString())
              .build();

      VideoStitcherServiceClient.ListLiveConfigsPagedResponse response =
          videoStitcherServiceClient.listLiveConfigs(listLiveConfigsRequest);
      System.out.println("Live configs:");

      for (LiveConfig liveConfig : response.iterateAll()) {
        System.out.println(liveConfig.getName());
      }
    }
  }
}

Node.js

このサンプルを試す前に、クライアント ライブラリを使用した Video Stitcher API クイックスタートにある Node.js の設定手順を実施してください。詳細については、Video Stitcher API Node.js API リファレンス ドキュメントをご覧ください。

Video Stitcher API への認証を行うには、アプリケーションのデフォルト認証情報を設定します。 詳細については、ローカル開発環境の認証の設定をご覧ください。

/**
 * TODO(developer): Uncomment these variables before running the sample.
 */
// projectId = 'my-project-id';
// location = 'us-central1';

// Imports the Video Stitcher library
const {VideoStitcherServiceClient} =
  require('@google-cloud/video-stitcher').v1;
// Instantiates a client
const stitcherClient = new VideoStitcherServiceClient();

async function listLiveConfigs() {
  const iterable = await stitcherClient.listLiveConfigsAsync({
    parent: stitcherClient.locationPath(projectId, location),
  });
  console.info('Live configs:');
  for await (const response of iterable) {
    console.log(response.name);
  }
}

listLiveConfigs();

PHP

このサンプルを試す前に、クライアント ライブラリを使用した Video Stitcher API クイックスタートにある PHP の設定手順を実施してください。詳細については、Video Stitcher API PHP API リファレンス ドキュメントをご覧ください。

Video Stitcher API への認証を行うには、アプリケーションのデフォルト認証情報を設定します。 詳細については、ローカル開発環境の認証の設定をご覧ください。

use Google\Cloud\Video\Stitcher\V1\Client\VideoStitcherServiceClient;
use Google\Cloud\Video\Stitcher\V1\ListLiveConfigsRequest;

/**
 * Lists all live configs for a location.
 *
 * @param string $callingProjectId     The project ID to run the API call under
 * @param string $location             The location of the live configs
 */
function list_live_configs(
    string $callingProjectId,
    string $location
): void {
    // Instantiate a client.
    $stitcherClient = new VideoStitcherServiceClient();

    $parent = $stitcherClient->locationName($callingProjectId, $location);
    $request = (new ListLiveConfigsRequest())
        ->setParent($parent);
    $response = $stitcherClient->listLiveConfigs($request);

    // Print the live config list.
    $liveConfigs = $response->iterateAllElements();
    print('Live configs:' . PHP_EOL);
    foreach ($liveConfigs as $liveConfig) {
        printf('%s' . PHP_EOL, $liveConfig->getName());
    }
}

Python

このサンプルを試す前に、クライアント ライブラリを使用した Video Stitcher API クイックスタートにある Python の設定手順を実施してください。詳細については、Video Stitcher API Python API リファレンス ドキュメントをご覧ください。

Video Stitcher API への認証を行うには、アプリケーションのデフォルト認証情報を設定します。 詳細については、ローカル開発環境の認証の設定をご覧ください。


import argparse

from google.cloud.video.stitcher_v1.services.video_stitcher_service import (
    pagers,
    VideoStitcherServiceClient,
)

def list_live_configs(project_id: str, location: str) -> pagers.ListLiveConfigsPager:
    """Lists all live configs in a location.
    Args:
        project_id: The GCP project ID.
        location: The location of the live configs.

    Returns:
        An iterable object containing live config resources.
    """

    client = VideoStitcherServiceClient()

    parent = f"projects/{project_id}/locations/{location}"
    response = client.list_live_configs(parent=parent)
    print("Live configs:")
    for live_config in response.live_configs:
        print({live_config.name})

    return response

Ruby

このサンプルを試す前に、クライアント ライブラリを使用した Video Stitcher API クイックスタートにある Ruby の設定手順を実施してください。詳細については、Video Stitcher API Ruby API リファレンス ドキュメントをご覧ください。

Video Stitcher API への認証を行うには、アプリケーションのデフォルト認証情報を設定します。 詳細については、ローカル開発環境の認証の設定をご覧ください。

require "google/cloud/video/stitcher"

##
# List live configs for a given location
#
# @param project_id [String] Your Google Cloud project (e.g. "my-project")
# @param location [String] The location (e.g. "us-central1")
#
def list_live_configs project_id:, location:
  # Create a Video Stitcher client.
  client = Google::Cloud::Video::Stitcher.video_stitcher_service

  # Build the resource name of the parent.
  parent = client.location_path project: project_id, location: location

  response = client.list_live_configs parent: parent

  puts "Live configs:"
  # Print out all live configs.
  response.each do |live_config|
    puts live_config.name
  end
end

その他の成果

curl レスポンスには nextPageToken が含まれている場合があります。これを使用して、追加の結果を取得できます。

{
  "liveConfigs": [
    ...
  ],
  "nextPageToken": "NEXT_PAGE_TOKEN"
}

追加の構成ファイルを一覧表示するには、NEXT_PAGE_TOKEN の値を含む別の curl リクエストを送信します。前述の API 呼び出しの URL に次を追加します。

?pageToken=NEXT_PAGE_TOKEN

このトークンの使用について詳しくは、関連するクライアント ライブラリをご覧ください。

ライブ構成ファイルの削除

登録したライブ構成ファイルが不要になった場合は、projects.locations.liveConfigs.delete メソッドを使用して削除します。

REST

リクエストのデータを使用する前に、次のように置き換えます。

  • PROJECT_NUMBER: IAM 設定ページの [プロジェクト番号] フィールドにある Google Cloud プロジェクト番号
  • LOCATION: ライブ構成ファイルのロケーション。サポートされているリージョンのいずれかを使用します。
    3~7 つの店舗を表示
    • us-central1
    • us-east1
    • us-west1
    • asia-east1
    • asia-south1
    • asia-southeast1
    • europe-west1
    • southamerica-east1
  • LIVE_CONFIG_ID: ライブ構成ファイルのユーザー定義の識別子。

リクエストを送信するには、次のいずれかのオプションを展開します。

次のような JSON レスポンスが返されます。

{
  "name": "projects/PROJECT_NUMBER/locations/LOCATION/operations/OPERATION_ID",
  "metadata": {
    "@type": "type.googleapis.com/google.cloud.common.OperationMetadata",
    "createTime": CREATE_TIME,
    "target": "projects/PROJECT_NUMBER/locations/LOCATION/liveConfigs/LIVE_CONFIG_ID",
    "verb": "delete",
    "cancelRequested": false,
    "apiVersion": "v1"
  },
  "done": false
}
このコマンドは、進行状況を追跡するためにクエリできる長時間実行オペレーション(LRO)を作成します。詳細については、結果を確認するをご覧ください。

C#

このサンプルを試す前に、クライアント ライブラリを使用した Video Stitcher API クイックスタートにある C# の設定手順を実施してください。詳細については、Video Stitcher API C# API リファレンス ドキュメントをご覧ください。

Video Stitcher API への認証を行うには、アプリケーションのデフォルト認証情報を設定します。 詳細については、ローカル開発環境の認証の設定をご覧ください。


using Google.Cloud.Video.Stitcher.V1;
using Google.LongRunning;
using Google.Protobuf.WellKnownTypes;
using System.Threading.Tasks;

public class DeleteLiveConfigSample
{
    public async Task DeleteLiveConfigAsync(
        string projectId, string location, string liveConfigId)
    {
        // Create the client.
        VideoStitcherServiceClient client = VideoStitcherServiceClient.Create();

        DeleteLiveConfigRequest request = new DeleteLiveConfigRequest
        {
            LiveConfigName = LiveConfigName.FromProjectLocationLiveConfig(projectId, location, liveConfigId)
        };

        // Make the request.
        Operation<Empty, OperationMetadata> response = await client.DeleteLiveConfigAsync(request);

        // Poll until the returned long-running operation is complete.
        await response.PollUntilCompletedAsync();
    }
}

Go

このサンプルを試す前に、クライアント ライブラリを使用した Video Stitcher API クイックスタートにある Go の設定手順を実施してください。詳細については、Video Stitcher API Go API リファレンス ドキュメントをご覧ください。

Video Stitcher API への認証を行うには、アプリケーションのデフォルト認証情報を設定します。 詳細については、ローカル開発環境の認証の設定をご覧ください。

import (
	"context"
	"fmt"
	"io"

	stitcher "cloud.google.com/go/video/stitcher/apiv1"
	stitcherstreampb "cloud.google.com/go/video/stitcher/apiv1/stitcherpb"
)

// deleteLiveConfig deletes a previously-created live config.
func deleteLiveConfig(w io.Writer, projectID, liveConfigID string) error {
	// projectID := "my-project-id"
	// liveConfigID := "my-live-config-id"
	location := "us-central1"
	ctx := context.Background()
	client, err := stitcher.NewVideoStitcherClient(ctx)
	if err != nil {
		return fmt.Errorf("stitcher.NewVideoStitcherClient: %w", err)
	}
	defer client.Close()

	req := &stitcherstreampb.DeleteLiveConfigRequest{
		Name: fmt.Sprintf("projects/%s/locations/%s/liveConfigs/%s", projectID, location, liveConfigID),
	}
	// Deletes the live config.
	op, err := client.DeleteLiveConfig(ctx, req)
	if err != nil {
		return fmt.Errorf("client.DeleteLiveConfig: %w", err)
	}
	err = op.Wait(ctx)
	if err != nil {
		return err
	}

	fmt.Fprintf(w, "Deleted live config")
	return nil
}

Java

このサンプルを試す前に、クライアント ライブラリを使用した Video Stitcher API クイックスタートにある Java の設定手順を実施してください。詳細については、Video Stitcher API Java API リファレンス ドキュメントをご覧ください。

Video Stitcher API への認証を行うには、アプリケーションのデフォルト認証情報を設定します。 詳細については、ローカル開発環境の認証の設定をご覧ください。


import com.google.cloud.video.stitcher.v1.DeleteLiveConfigRequest;
import com.google.cloud.video.stitcher.v1.LiveConfigName;
import com.google.cloud.video.stitcher.v1.VideoStitcherServiceClient;
import java.io.IOException;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;

public class DeleteLiveConfig {

  private static final int TIMEOUT_IN_MINUTES = 2;

  public static void main(String[] args) throws Exception {
    // TODO(developer): Replace these variables before running the sample.
    String projectId = "my-project-id";
    String location = "us-central1";
    String liveConfigId = "my-live-config-id";

    deleteLiveConfig(projectId, location, liveConfigId);
  }

  public static void deleteLiveConfig(String projectId, String location, String liveConfigId)
      throws IOException, ExecutionException, InterruptedException, TimeoutException {
    // Initialize client that will be used to send requests. This client only needs to be created
    // once, and can be reused for multiple requests. After completing all of your requests, call
    // the "close" method on the client to safely clean up any remaining background resources.
    VideoStitcherServiceClient videoStitcherServiceClient = VideoStitcherServiceClient.create();
    DeleteLiveConfigRequest deleteLiveConfigRequest =
        DeleteLiveConfigRequest.newBuilder()
            .setName(LiveConfigName.of(projectId, location, liveConfigId).toString())
            .build();

    videoStitcherServiceClient
        .deleteLiveConfigAsync(deleteLiveConfigRequest)
        .get(TIMEOUT_IN_MINUTES, TimeUnit.MINUTES);
    System.out.println("Deleted live config");
    videoStitcherServiceClient.close();
  }
}

Node.js

このサンプルを試す前に、クライアント ライブラリを使用した Video Stitcher API クイックスタートにある Node.js の設定手順を実施してください。詳細については、Video Stitcher API Node.js API リファレンス ドキュメントをご覧ください。

Video Stitcher API への認証を行うには、アプリケーションのデフォルト認証情報を設定します。 詳細については、ローカル開発環境の認証の設定をご覧ください。

/**
 * TODO(developer): Uncomment these variables before running the sample.
 */
// projectId = 'my-project-id';
// location = 'us-central1';
// liveConfigId = 'my-live-config-id';

// Imports the Video Stitcher library
const {VideoStitcherServiceClient} =
  require('@google-cloud/video-stitcher').v1;
// Instantiates a client
const stitcherClient = new VideoStitcherServiceClient();

async function deleteLiveConfig() {
  // Construct request
  const request = {
    name: stitcherClient.liveConfigPath(projectId, location, liveConfigId),
  };
  const [operation] = await stitcherClient.deleteLiveConfig(request);
  await operation.promise();
  console.log('Deleted live config');
}

deleteLiveConfig();

PHP

このサンプルを試す前に、クライアント ライブラリを使用した Video Stitcher API クイックスタートにある PHP の設定手順を実施してください。詳細については、Video Stitcher API PHP API リファレンス ドキュメントをご覧ください。

Video Stitcher API への認証を行うには、アプリケーションのデフォルト認証情報を設定します。 詳細については、ローカル開発環境の認証の設定をご覧ください。

use Google\Cloud\Video\Stitcher\V1\Client\VideoStitcherServiceClient;
use Google\Cloud\Video\Stitcher\V1\DeleteLiveConfigRequest;

/**
 * Deletes a live config.
 *
 * @param string $callingProjectId     The project ID to run the API call under
 * @param string $location             The location of the live config
 * @param string $liveConfigId         The ID of the live config
 */
function delete_live_config(
    string $callingProjectId,
    string $location,
    string $liveConfigId
): void {
    // Instantiate a client.
    $stitcherClient = new VideoStitcherServiceClient();

    $formattedName = $stitcherClient->liveConfigName($callingProjectId, $location, $liveConfigId);
    $request = (new DeleteLiveConfigRequest())
        ->setName($formattedName);
    $operationResponse = $stitcherClient->deleteLiveConfig($request);
    $operationResponse->pollUntilComplete();
    if ($operationResponse->operationSucceeded()) {
        // Print status
        printf('Deleted live config %s' . PHP_EOL, $liveConfigId);
    } else {
        $error = $operationResponse->getError();
        // handleError($error)
    }
}

Python

このサンプルを試す前に、クライアント ライブラリを使用した Video Stitcher API クイックスタートにある Python の設定手順を実施してください。詳細については、Video Stitcher API Python API リファレンス ドキュメントをご覧ください。

Video Stitcher API への認証を行うには、アプリケーションのデフォルト認証情報を設定します。 詳細については、ローカル開発環境の認証の設定をご覧ください。


import argparse

from google.cloud.video.stitcher_v1.services.video_stitcher_service import (
    VideoStitcherServiceClient,
)
from google.protobuf import empty_pb2 as empty

def delete_live_config(
    project_id: str, location: str, live_config_id: str
) -> empty.Empty:
    """Deletes a live config.
    Args:
        project_id: The GCP project ID.
        location: The location of the live config.
        live_config_id: The user-defined live config ID."""

    client = VideoStitcherServiceClient()

    name = f"projects/{project_id}/locations/{location}/liveConfigs/{live_config_id}"
    operation = client.delete_live_config(name=name)
    response = operation.result()
    print("Deleted live config")
    return response

Ruby

このサンプルを試す前に、クライアント ライブラリを使用した Video Stitcher API クイックスタートにある Ruby の設定手順を実施してください。詳細については、Video Stitcher API Ruby API リファレンス ドキュメントをご覧ください。

Video Stitcher API への認証を行うには、アプリケーションのデフォルト認証情報を設定します。 詳細については、ローカル開発環境の認証の設定をご覧ください。

require "google/cloud/video/stitcher"

##
# Delete a live config
#
# @param project_id [String] Your Google Cloud project (e.g. "my-project")
# @param location [String] The location (e.g. "us-central1")
# @param live_config_id [String] Your live config name (e.g. "my-live-config")
#
def delete_live_config project_id:, location:, live_config_id:
  # Create a Video Stitcher client.
  client = Google::Cloud::Video::Stitcher.video_stitcher_service

  # Build the resource name of the live config.
  name = client.live_config_path project: project_id, location: location,
                                 live_config: live_config_id

  # Delete the live config.
  operation = client.delete_live_config name: name

  # The returned object is of type Gapic::Operation. You can use this
  # object to check the status of an operation, cancel it, or wait
  # for results. Here is how to block until completion:
  operation.wait_until_done!

  # Print a success message.
  puts "Deleted live config"
end