ライブ セッションを管理する

Video Stitcher API では、ライブストリームの再生を開始するたびにライブ セッションを作成し、ミッドロール挿入点で広告が動的に合成されます。 レスポンスには、再生 URL とライブ セッションの構成を指定します。

このページでは、Google アド マネージャーで有効になっていないライブ セッションを作成、管理する方法について説明します。これらのタイプのライブ セッションの詳細については、Google アド マネージャーで有効になっているライブ セッションを管理するをご覧ください。

始める前に

ライブ セッションを作成する

ライブ セッションを作成するには、projects.locations.liveSessions.create メソッドを使用します。

ライブ セッションを作成する場合、次のフィールドは省略可能です。

REST

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

  • PROJECT_NUMBER: IAM 設定ページの [プロジェクト番号] フィールドにある Google Cloud プロジェクト番号
  • LOCATION: セッションを作成するロケーション。サポートされているリージョンのいずれかを使用します。
    ロケーションを表示
    • 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/liveSessions/SESSION_ID",   "playUri": "PLAY_URI",   "liveConfig": "projects/PROJECT_NUMBER/locations/LOCATION/liveConfigs/LIVE_CONFIG_ID", } 

C#

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

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

 using Google.Cloud.Video.Stitcher.V1;  public class CreateLiveSessionSample {     public LiveSession CreateLiveSession(         string projectId, string location, string liveConfigId)     {         // Create the client.         VideoStitcherServiceClient client = VideoStitcherServiceClient.Create();          CreateLiveSessionRequest request = new CreateLiveSessionRequest         {             Parent = $"projects/{projectId}/locations/{location}",             LiveSession = new LiveSession             {                 LiveConfig = LiveConfigName.FormatProjectLocationLiveConfig(projectId, location, liveConfigId)             }         };          // Call the API.         LiveSession session = client.CreateLiveSession(request);          // Return the result.         return session;     } } 

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" 	"cloud.google.com/go/video/stitcher/apiv1/stitcherpb" )  // createLiveSession creates a livestream session in which to insert ads. // Live sessions are ephemeral resources that expire after a few minutes. func createLiveSession(w io.Writer, projectID, liveConfigID string) error { 	// projectID := "my-project-id" 	// liveConfigID := "my-live-config" 	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 := &stitcherpb.CreateLiveSessionRequest{ 		Parent: fmt.Sprintf("projects/%s/locations/%s", projectID, location), 		LiveSession: &stitcherpb.LiveSession{ 			LiveConfig: fmt.Sprintf("projects/%s/locations/%s/liveConfigs/%s", projectID, location, liveConfigID), 		}, 	} 	// Creates the live session. 	response, err := client.CreateLiveSession(ctx, req) 	if err != nil { 		return fmt.Errorf("client.CreateLiveSession: %w", err) 	}  	fmt.Fprintf(w, "Live session: %v\n", response.GetName()) 	fmt.Fprintf(w, "Play URI: %v", response.GetPlayUri()) 	return nil } 

Java

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

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

 import com.google.cloud.video.stitcher.v1.CreateLiveSessionRequest; import com.google.cloud.video.stitcher.v1.LiveConfigName; import com.google.cloud.video.stitcher.v1.LiveSession; import com.google.cloud.video.stitcher.v1.LocationName; import com.google.cloud.video.stitcher.v1.VideoStitcherServiceClient; import java.io.IOException;  public class CreateLiveSession {    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";      createLiveSession(projectId, location, liveConfigId);   }    // Creates a live session given the parameters in the supplied live config.   // For more information, see   // https://cloud.google.com/video-stitcher/docs/how-to/managing-live-sessions.   public static LiveSession createLiveSession(       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.     try (VideoStitcherServiceClient videoStitcherServiceClient =         VideoStitcherServiceClient.create()) {       CreateLiveSessionRequest createLiveSessionRequest =           CreateLiveSessionRequest.newBuilder()               .setParent(LocationName.of(projectId, location).toString())               .setLiveSession(                   LiveSession.newBuilder()                       .setLiveConfig(LiveConfigName.format(projectId, location, liveConfigId)))               .build();        LiveSession response = videoStitcherServiceClient.createLiveSession(createLiveSessionRequest);       System.out.println("Created live session: " + response.getName());       System.out.println("Play URI: " + response.getPlayUri());       return response;     }   } }

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 createLiveSession() {   // Construct request   const request = {     parent: stitcherClient.locationPath(projectId, location),     liveSession: {       liveConfig: stitcherClient.liveConfigPath(         projectId,         location,         liveConfigId       ),     },   };    const [session] = await stitcherClient.createLiveSession(request);   console.log(`Live session: ${session.name}`);   console.log(`Play URI: ${session.playUri}`); }  createLiveSession().catch(err => {   console.error(err.message);   process.exitCode = 1; });

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\CreateLiveSessionRequest; use Google\Cloud\Video\Stitcher\V1\LiveSession;  /**  * Creates a live session. Live sessions are ephemeral resources that expire  * after a few minutes.  *  * @param string $callingProjectId     The project ID to run the API call under  * @param string $location             The location of the session  * @param string $liveConfigId         The live config ID to use to create the  *                                     live session  */ function create_live_session(     string $callingProjectId,     string $location,     string $liveConfigId ): void {     // Instantiate a client.     $stitcherClient = new VideoStitcherServiceClient();      $parent = $stitcherClient->locationName($callingProjectId, $location);     $liveConfig = $stitcherClient->liveConfigName($callingProjectId, $location, $liveConfigId);     $liveSession = new LiveSession();     $liveSession->setLiveConfig($liveConfig);      // Run live session creation request     $request = (new CreateLiveSessionRequest())         ->setParent($parent)         ->setLiveSession($liveSession);     $response = $stitcherClient->createLiveSession($request);      // Print results     printf('Live session: %s' . PHP_EOL, $response->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 create_live_session(     project_id: str, location: str, live_config_id: str ) -> stitcher_v1.types.LiveSession:     """Creates a live session. Live sessions are ephemeral resources that expire     after a few minutes.     Args:         project_id: The GCP project ID.         location: The location in which to create the session.         live_config_id: The user-defined live config ID.      Returns:         The live session resource.     """      client = VideoStitcherServiceClient()      parent = f"projects/{project_id}/locations/{location}"     live_config = (         f"projects/{project_id}/locations/{location}/liveConfigs/{live_config_id}"     )      live_session = stitcher_v1.types.LiveSession(live_config=live_config)      response = client.create_live_session(parent=parent, live_session=live_session)     print(f"Live session: {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 stream session. Live sessions are ephemeral resources # that expire after a few minutes. # # @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 create_live_session 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 parent.   parent = client.location_path project: project_id, location: location    # Build the resource name of the live config.   live_config_name = client.live_config_path project: project_id,                                              location: location,                                              live_config: live_config_id    # Set the session fields.   new_live_session = {     live_config: live_config_name   }    response = client.create_live_session parent: parent,                                         live_session: new_live_session    # Print the live session name.   puts "Live session: #{response.name}" end

レスポンスはライブ セッション オブジェクトです。playUri は、クライアント デバイスがこのライブ セッションの広告結合されたストリームの再生に使用する URL です。

Video Stitcher API は、リクエストごとに一意のセッション ID を生成します。過去 5 分以内に playUri のリクエストがない場合、セッションは期限切れとなります。

ライブ セッションに広告を合成する前にエンコードする必要があります。広告合成されが動画のセッションを作成すると、Video Stitcher API によって、前のセッションから取得した広告がすでにエンコードされているかどうかが判断されます。API は、 Google Cloud プロジェクトに関連付けられたセッションによって作成されたエンコード済みの広告のみを検索します。このプロセスの詳細については、概要をご覧ください。

クライアントのデバイスに代わってセッションを生成する場合は、HTTP ヘッダーを使用して次のパラメータを設定できます。

パラメータ HTTP ヘッダー
CLIENT_IP x-forwarded-for
REFERRER_URL referer
USER_AGENT user-agent

前述の curl リクエストには、次のヘッダーを追加できます。

-H "x-forwarded-for: CLIENT_IP" \ -H "referer: REFERRER_URL" \ -H "user-agent: USER_AGENT" \

x-forwarded-for ヘッダーが指定されていない場合、Video Stitcher API は広告メタデータ リクエストでクライアントの IP アドレスを使用します。クライアントのデバイスに代わってセッションが生成された場合、クライアントの IP アドレスがクライアントのデバイスの IP と一致しない場合があります。

広告タグマクロ

広告タグにはマクロを含めることができ、セッションごとに異なる広告タグを生成できます。マクロは、次の例のように、角かっこで示されます。

AD_TAG_URI&macro=[my-key]

adTagUri は、ライブ構成で定義されています。

広告タグマクロの値と置き換えるには、adTagMacros フィールドにマッピングを指定します。たとえば、[my-key] マクロを文字列 my-value に置き換える場合は、次の情報を指定する必要があります。

{   ...   "adTagMacros": {     "my-key": "my-value"   },   ... }

Video Stitcher API が広告メタデータをリクエストすると、次の広告タグが使用されます。

AD_TAG_URI&macro=my-value

セッションを取得する

ライブ セッションを取得するには、projects.locations.liveSessions.get メソッドを使用します。

REST

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

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

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

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

 {   "name": "projects/PROJECT_NUMBER/locations/LOCATION/liveSessions/SESSION_ID",   "playUri": "ad-stitched-live-stream-uri",   "liveConfig": "projects/PROJECT_NUMBER/locations/LOCATION/liveConfigs/LIVE_CONFIG_ID", } 

C#

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

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

 using Google.Cloud.Video.Stitcher.V1;  public class GetLiveSessionSample {     public LiveSession GetLiveSession(         string projectId, string location, string sessionId)     {         // Create the client.         VideoStitcherServiceClient client = VideoStitcherServiceClient.Create();          GetLiveSessionRequest request = new GetLiveSessionRequest         {             LiveSessionName = LiveSessionName.FromProjectLocationLiveSession(projectId, location, sessionId)         };          // Call the API.         LiveSession session = client.GetLiveSession(request);          // Return the result.         return session;     } } 

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" 	"cloud.google.com/go/video/stitcher/apiv1/stitcherpb" )  // getLiveSession gets a livestream session by ID. func getLiveSession(w io.Writer, projectID, sessionID string) error { 	// projectID := "my-project-id" 	// sessionID := "123-456-789" 	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 := &stitcherpb.GetLiveSessionRequest{ 		Name: fmt.Sprintf("projects/%s/locations/%s/liveSessions/%s", projectID, location, sessionID), 	} 	// Gets the session. 	response, err := client.GetLiveSession(ctx, req) 	if err != nil { 		return fmt.Errorf("client.GetLiveSession: %w", err) 	}  	fmt.Fprintf(w, "Live session: %+v", response) 	return nil } 

Java

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

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

 import com.google.cloud.video.stitcher.v1.GetLiveSessionRequest; import com.google.cloud.video.stitcher.v1.LiveSession; import com.google.cloud.video.stitcher.v1.LiveSessionName; import com.google.cloud.video.stitcher.v1.VideoStitcherServiceClient; import java.io.IOException;  public class GetLiveSession {    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 sessionId = "my-session-id";      getLiveSession(projectId, location, sessionId);   }    // Gets a live session.   public static LiveSession getLiveSession(String projectId, String location, String sessionId)       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.     try (VideoStitcherServiceClient videoStitcherServiceClient =         VideoStitcherServiceClient.create()) {       GetLiveSessionRequest getLiveSessionRequest =           GetLiveSessionRequest.newBuilder()               .setName(LiveSessionName.of(projectId, location, sessionId).toString())               .build();        LiveSession response = videoStitcherServiceClient.getLiveSession(getLiveSessionRequest);       System.out.println("Live session: " + response.getName());       return response;     }   } }

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'; // sessionId = 'my-session-id';  // Imports the Video Stitcher library const {VideoStitcherServiceClient} =   require('@google-cloud/video-stitcher').v1; // Instantiates a client const stitcherClient = new VideoStitcherServiceClient();  async function getLiveSession() {   // Construct request   const request = {     name: stitcherClient.liveSessionPath(projectId, location, sessionId),   };   const [session] = await stitcherClient.getLiveSession(request);   console.log(`Live session: ${session.name}`); }  getLiveSession().catch(err => {   console.error(err.message);   process.exitCode = 1; });

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\GetLiveSessionRequest;  /**  * Gets a live session.  *  * @param string $callingProjectId     The project ID to run the API call under  * @param string $location             The location of the session  * @param string $sessionId            The ID of the session  */ function get_live_session(     string $callingProjectId,     string $location,     string $sessionId ): void {     // Instantiate a client.     $stitcherClient = new VideoStitcherServiceClient();      $formattedName = $stitcherClient->liveSessionName($callingProjectId, $location, $sessionId);     $request = (new GetLiveSessionRequest())         ->setName($formattedName);     $session = $stitcherClient->getLiveSession($request);      // Print results     printf('Live session: %s' . PHP_EOL, $session->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_session(     project_id: str, location: str, session_id: str ) -> stitcher_v1.types.LiveSession:     """Gets a live session. Live sessions are ephemeral resources that expire     after a few minutes.     Args:         project_id: The GCP project ID.         location: The location of the session.         session_id: The ID of the live session.      Returns:         The live session resource.     """      client = VideoStitcherServiceClient()      name = client.live_session_path(project_id, location, session_id)     response = client.get_live_session(name=name)     print(f"Live session: {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 session. Live sessions are ephemeral resources # that expire after a few minutes. # # @param project_id [String] Your Google Cloud project (e.g. `my-project`) # @param location [String] The location (e.g. `us-central1`) # @param session_id [String] The live session ID (e.g. `my-live-session-id`) # def get_live_session project_id:, location:, session_id:   # Create a Video Stitcher client.   client = Google::Cloud::Video::Stitcher.video_stitcher_service    # Build the resource name of the live session.   name = client.live_session_path project: project_id, location: location,                                   live_session: session_id    # Get the live session.   session = client.get_live_session name: name    # Print the live session name.   puts "Live session: #{session.name}" end

広告合成された再生リストの例

以下は、広告合成前のソースライブ再生リストのサンプルです。

#EXTM3U #EXT-X-TARGETDURATION:10 #EXT-X-VERSION:4 #EXT-X-MEDIA-SEQUENCE:5 #EXTINF:10.010 segment_00005.ts #EXTINF:10.010 segment_00006.ts #EXT-X-DATERANGE:ID="2415919105",START-DATE="2021-06-22T08:32:00Z",DURATION=60,SCTE35-OUT=0xF... #EXTINF:10.010 segment_00007.ts #EXTINF:10.010 segment_00008.ts #EXT-X-DATERANGE:ID="2415919105",START-DATE="2021-06-22T08:39:20Z",SCTE35-IN=0xF... #EXTINF:10.010 segment_00009.ts 

以下は、広告合成後のソースライブ再生リストのサンプルです。

#EXTM3U #EXT-X-TARGETDURATION:10 #EXT-X-VERSION:4 #EXT-X-MEDIA-SEQUENCE:5 #EXTINF:10.010 segment_00005.ts #EXTINF:10.010 segment_00006.ts #EXT-X-DISCONTINUITY #EXTINF:6.000 https://ads.us-west1.cdn.videostitcher.goog/ad-1/seg-1.ts #EXTINF:5.000 https://ads.us-west1.cdn.videostitcher.goog/ad-1/seg-2.ts #EXT-X-DISCONTINUITY #EXTINF:6.000 https://ads.us-west1.cdn.videostitcher.goog/ad-2/seg-1.ts #EXTINF:5.000 https://ads.us-west1.cdn.videostitcher.goog/ad-2/seg-2.ts #EXT-X-DISCONTINUITY #EXTINF:10.010 segment_00009.ts 

クライアントサイドの広告トラッキングを処理する

クライアント広告トラッキングが有効になっている場合、プレーヤーは広告トラッキング イベントをトリガーする役割を担います。Video Stitcher API から提供される広告メタデータには、広告トラッキングとコンパニオン広告の情報が含まれます。Video Stitcher API は、広告タグのレスポンスからこの情報を解析します。

マニフェストから HLS 広告メタデータ URI を取得する

HLS レンディション マニフェストでは、AdMetadataURI はタグ #EXT-X-DATERANGE の属性 X-VAST-META でエンコードされます。#EXT-X-DATERANGE タグは、各広告の最初のステッチ セグメントの前にあります。

HLS のタイムド メタデータ タグの例を次に示します。

#EXT-X-DATERANGE:ID="id123",START-DATE=2014-03-05T11:15:00Z,DURATION=15,X-VAST-META="eyJBZE1ldGFkYXRhVXJpIjogImh0dHBzOi8vZXhhbXBsZS5jb20vdjFhbHBoYS9wcm9qZWN0cy8xMjMvbG9jYXRpb25zL3VzLWNlbnRyYWwxL2xpdmVTZXNzaW9ucy9hYmMzMjEvYWRNZXRhZGF0YS9pZDEyMyJ9" 

X-VAST-META 属性の値は、base64 でエンコードされた JSON 文字列です。デコード後、JSON から AdMetadataURI を抽出できます。

次の例は、デコードされた X-VAST-META を示しています。

{   "AdMetadataUri": "https://example.com/v1/projects/123/locations/us-central1/liveSessions/abc321/adMetadata/id123" } 

マニフェストから DASH 広告メタデータ URI を取得する

DASH マニフェストでは、ステッチされた各広告期間に 1 つの VAST 広告が含まれており、その広告メタデータ URI は EventStream タグ内から抽出できます。AdMetadataURIEvent 要素の属性 messageData でエンコードされます。Event は、schemeIdUriurn:videostitcher:admetadata:202008 のタグ EventStream 内の要素です。

DASH イベント ストリームタグの例を次に示します。

<EventStream schemeIdUri="urn:videostitcher:admetadata:202008" timescale="1000">   <Event duration="5000" messageData="eyJBZE1ldGFkYXRhVXJpIjogImh0dHBzOi8vZXhhbXBsZS5jb20vdjFhbHBoYS9wcm9qZWN0cy8xMjMvbG9jYXRpb25zL3VzLWNlbnRyYWwxL2xpdmVTZXNzaW9ucy9hYmMzMjEvYWRNZXRhZGF0YS9pZDEyMyJ9"></Event> </EventStream> 

base64 を使用して messageData を JSON にデコードします。

次の例は、デコードされた messageData を示しています。

{   "AdMetadataUri": "https://example.com/v1/projects/123/locations/us-central1/liveSessions/abc321/adMetadata/id123" } 

広告トラッキング イベントを取得して処理する

AdMetadataURI を取得したら、広告メタデータを取得できます。

次の例は、広告のメタデータを示しています。

{   "activityEvents": [     {       "type": "PAUSE",       "uri": "https://example.com/pause"     }   ],   "progressiveEvents": [     {       "timeOffset": "0s",       "events": [         {           "type": "IMPRESSION",           "uri": "https://example.com/impression"         },         {           "type": "START",           "uri": "https://example.com/start"         }       ]     },     {       "timeOffset": "2.500s",       "events": [         {           "type": "FIRST_QUARTILE",           "uri": "https://example.com/firstquartile"         }       ]     }   ],   "adDuration": "10s" } 

上記の例では、クライアントは次の処理を行う必要があります。

  • 広告動画の開始時に https://example.com/start をリクエストする
  • 広告動画の開始時に https://example.com/impression をリクエストする
  • 視聴者が広告動画を一時停止するたびに https://example.com/pause をリクエストする
  • 広告動画の 2.5 秒目に https://example.com/firstQuartile をリクエスト

ライブ セッションを検査する

このページでは、ライブセッションと特定のライブセッションの広告タグの詳細を検査する方法について説明します。詳細については、REST のドキュメントをご覧ください。

Video Stitcher API は、ライブ セッション リクエストの本文で広告タグに指定されている広告プロバイダにリクエストを送信します。これらのリクエストのリクエスト メタデータとレスポンス メタデータは 14 日間保存され、ライブ セッションを調べることで表示できます。

Video Stitcher API では、以下を使用して広告タグの詳細が作成されます。

  • 特定のミッドロール挿入点でリクエストされる広告タグ URL(指定されていない場合はデフォルトの広告タグ)
  • ライブ セッション リクエストからの構成された広告タグマクロ
  • 追加のユーザー メタデータ

この情報は、レスポンスの本文とメタデータとともに、Video Stitcher API の動作に関する分析情報を提供します。

広告タグの詳細を一覧表示する

ライブ セッションの広告タグの詳細を一覧表示するには、projects.locations.liveSessions.liveAdTagDetails.list メソッドを使用します。

以前作成したライブ セッションに対する次のレスポンスを考えてみます(一部のフィールドは省略されています)。

{   "name": "projects/PROJECT_NUMBER/locations/LOCATION/liveSessions/SESSION_ID",   ... }

REST

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

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

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

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

 {   "liveAdTagDetails" : [     {       "name": "projects/PROJECT_NUMBER/locations/LOCATION/liveSessions/SESSION_ID/liveAdTagDetails/LIVE_AD_TAG_DETAILS_ID",       "adRequests": [         {           "uri": "REQUEST_URL",           "requestMetadata": "AD_TAG_REQUEST_METADATA",           "responseMetadata": "AD_TAG_RESPONSE_METADATA"         }       ]     }   ] } 

返された LIVE_AD_TAG_DETAILS_ID をコピーします。単一の広告タグの詳細を取得するために必要です。

C#

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

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

 using Google.Api.Gax; using Google.Cloud.Video.Stitcher.V1; using System;  public class ListLiveAdTagDetailsSample {     public PagedEnumerable<ListLiveAdTagDetailsResponse, LiveAdTagDetail> ListLiveAdTagDetails(         string projectId, string regionId, string sessionId)     {         // Create the client.         VideoStitcherServiceClient client = VideoStitcherServiceClient.Create();          ListLiveAdTagDetailsRequest request = new ListLiveAdTagDetailsRequest         {             ParentAsLiveSessionName = LiveSessionName.FromProjectLocationLiveSession(projectId, regionId, sessionId)         };          // Make the request.         PagedEnumerable<ListLiveAdTagDetailsResponse, LiveAdTagDetail> response = client.ListLiveAdTagDetails(request);         foreach (LiveAdTagDetail liveAdTagDetail in response)         {             Console.WriteLine($"{liveAdTagDetail.Name}");         }          // 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" )  // listLiveAdTagDetails lists the ad tag details for the specified live session. func listLiveAdTagDetails(w io.Writer, projectID, sessionID string) error { 	// projectID := "my-project-id" 	// sessionID := "my-session-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.ListLiveAdTagDetailsRequest{ 		Parent: fmt.Sprintf("projects/%s/locations/%s/liveSessions/%s", projectID, location, sessionID), 	}  	it := client.ListLiveAdTagDetails(ctx, req) 	fmt.Fprintln(w, "Live ad tag details:") 	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.ListLiveAdTagDetailsRequest; import com.google.cloud.video.stitcher.v1.LiveAdTagDetail; import com.google.cloud.video.stitcher.v1.LiveSessionName; import com.google.cloud.video.stitcher.v1.VideoStitcherServiceClient; import com.google.cloud.video.stitcher.v1.VideoStitcherServiceClient.ListLiveAdTagDetailsPagedResponse; import java.io.IOException;  public class ListLiveAdTagDetails {    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 sessionId = "my-session-id";      listLiveAdTagDetails(projectId, location, sessionId);   }    // Lists the live ad tag details for a given live session.   public static ListLiveAdTagDetailsPagedResponse listLiveAdTagDetails(       String projectId, String location, String sessionId) 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.     try (VideoStitcherServiceClient videoStitcherServiceClient =         VideoStitcherServiceClient.create()) {       ListLiveAdTagDetailsRequest listLiveAdTagDetailsRequest =           ListLiveAdTagDetailsRequest.newBuilder()               .setParent(LiveSessionName.of(projectId, location, sessionId).toString())               .build();        VideoStitcherServiceClient.ListLiveAdTagDetailsPagedResponse response =           videoStitcherServiceClient.listLiveAdTagDetails(listLiveAdTagDetailsRequest);        System.out.println("Live ad tag details:");       for (LiveAdTagDetail adTagDetail : response.iterateAll()) {         System.out.println(adTagDetail.toString());       }       return response;     }   } }

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'; // sessionId = 'my-session-id';  // Imports the Video Stitcher library const {VideoStitcherServiceClient} =   require('@google-cloud/video-stitcher').v1; // Instantiates a client const stitcherClient = new VideoStitcherServiceClient();  async function listLiveAdTagDetails() {   // Construct request   const request = {     parent: stitcherClient.liveSessionPath(projectId, location, sessionId),   };   const iterable = await stitcherClient.listLiveAdTagDetailsAsync(request);   console.log('Live ad tag details:');   for await (const response of iterable) {     console.log(response.name);   } }  listLiveAdTagDetails().catch(err => {   console.error(err.message);   process.exitCode = 1; });

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\ListLiveAdTagDetailsRequest;  /**  * Lists the ad tag details for the specified live session.  *  * @param string $callingProjectId     The project ID to run the API call under  * @param string $location             The location of the session  * @param string $sessionId            The ID of the session  */ function list_live_ad_tag_details(     string $callingProjectId,     string $location,     string $sessionId ): void {     // Instantiate a client.     $stitcherClient = new VideoStitcherServiceClient();      $formattedName = $stitcherClient->liveSessionName($callingProjectId, $location, $sessionId);     $request = (new ListLiveAdTagDetailsRequest())         ->setParent($formattedName);     $response = $stitcherClient->listLiveAdTagDetails($request);      // Print the ad tag details list.     $adTagDetails = $response->iterateAllElements();     print('Live ad tag details:' . PHP_EOL);     foreach ($adTagDetails as $adTagDetail) {         printf('%s' . PHP_EOL, $adTagDetail->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_ad_tag_details(     project_id: str, location: str, session_id: str ) -> pagers.ListLiveAdTagDetailsPager:     """Lists the ad tag details for the specified live session.     Args:         project_id: The GCP project ID.         location: The location of the session.         session_id: The ID of the live session.      Returns:         An iterable object containing live ad tag details resources.     """      client = VideoStitcherServiceClient()      parent = client.live_session_path(project_id, location, session_id)     page_result = client.list_live_ad_tag_details(parent=parent)     print("Live ad tag details:")     for response in page_result:         print(response)      return page_result  

Ruby

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

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

require "google/cloud/video/stitcher"  ## # List the ad tag details for a live session # # @param project_id [String] Your Google Cloud project (e.g. `my-project`) # @param location [String] The location (e.g. `us-central1`) # @param session_id [String] The live session ID (e.g. `my-live-session-id`) # def list_live_ad_tag_details project_id:, location:, session_id:   # Create a Video Stitcher client.   client = Google::Cloud::Video::Stitcher.video_stitcher_service    # Build the resource name of the parent.   parent = client.live_session_path project: project_id, location: location,                                     live_session: session_id    # List all ad tag details for the live session.   response = client.list_live_ad_tag_details parent: parent    puts "Live ad tag details:"   # Print out all live ad tag details.   response.each do |live_ad_tag_detail|     puts live_ad_tag_detail.name   end end

広告タグの詳細を取得する

ライブ セッションで単一の広告タグの詳細を取得するには、projects.locations.liveSessions.liveAdTagDetails.get メソッドを使用します。

次の例では、前のリクエストから返された広告タグの詳細の名前を使用して、ライブ セッションの単一のタグの詳細を示しています。

REST

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

  • PROJECT_NUMBER: IAM 設定ページの [プロジェクト番号] フィールドにある Google Cloud プロジェクト番号
  • LOCATION: セッションのロケーション。サポートされているリージョンのいずれかを使用します。
    ロケーションを表示
    • us-central1
    • us-east1
    • us-west1
    • asia-east1
    • asia-south1
    • asia-southeast1
    • europe-west1
    • southamerica-east1
  • SESSION_ID: ライブ セッションの ID
  • LIVE_AD_TAG_DETAILS_ID: ライブ広告タグの詳細の ID

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

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

 {   "name": "projects/PROJECT_NUMBER/locations/LOCATION/liveSessions/SESSION_ID/liveAdTagDetails/LIVE_AD_TAG_DETAILS_ID",   "adRequests": [     {       "uri": "REQUEST_URL",       "requestMetadata": "AD_TAG_REQUEST_METADATA",       "responseMetadata": "AD_TAG_RESPONSE_METADATA"     }   ] } 

C#

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

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

 using Google.Cloud.Video.Stitcher.V1;  public class GetLiveAdTagDetailSample {     public LiveAdTagDetail GetLiveAdTagDetail(         string projectId, string location, string sessionId, string adTagDetailId)     {         // Create the client.         VideoStitcherServiceClient client = VideoStitcherServiceClient.Create();          GetLiveAdTagDetailRequest request = new GetLiveAdTagDetailRequest         {             LiveAdTagDetailName = LiveAdTagDetailName.FromProjectLocationLiveSessionLiveAdTagDetail(projectId, location, sessionId, adTagDetailId)         };          // Call the API.         LiveAdTagDetail liveAdTagDetail = client.GetLiveAdTagDetail(request);          // Return the result.         return liveAdTagDetail;     } } 

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" )  // getLiveAdTagDetail gets the specified ad tag detail for a live session. func getLiveAdTagDetail(w io.Writer, projectID, sessionID, adTagDetailID string) error { 	// projectID := "my-project-id" 	// sessionID := "my-session-id" 	// adTagDetailID := "my-ad-tag-detail-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.GetLiveAdTagDetailRequest{ 		Name: fmt.Sprintf("projects/%s/locations/%s/liveSessions/%s/liveAdTagDetails/%s", projectID, location, sessionID, adTagDetailID), 	} 	// Gets the ad tag detail. 	response, err := client.GetLiveAdTagDetail(ctx, req) 	if err != nil { 		return fmt.Errorf("client.GetLiveAdTagDetail: %w", err) 	} 	b, err := json.MarshalIndent(response, "", " ") 	if err != nil { 		return fmt.Errorf("json.MarshalIndent: %w", err) 	} 	fmt.Fprintf(w, "Live ad tag detail:\n%v", string(b)) 	return nil } 

Java

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

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

 import com.google.cloud.video.stitcher.v1.GetLiveAdTagDetailRequest; import com.google.cloud.video.stitcher.v1.LiveAdTagDetail; import com.google.cloud.video.stitcher.v1.LiveAdTagDetailName; import com.google.cloud.video.stitcher.v1.VideoStitcherServiceClient; import java.io.IOException;  public class GetLiveAdTagDetail {    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 sessionId = "my-session-id";     String adTagDetailId = "my-ad-tag-detail-id";      getLiveAdTagDetail(projectId, location, sessionId, adTagDetailId);   }    // Gets a live ad tag detail in a live session.   public static LiveAdTagDetail getLiveAdTagDetail(       String projectId, String location, String sessionId, String adTagDetailId)       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.     try (VideoStitcherServiceClient videoStitcherServiceClient =         VideoStitcherServiceClient.create()) {       GetLiveAdTagDetailRequest getLiveAdTagDetailRequest =           GetLiveAdTagDetailRequest.newBuilder()               .setName(                   LiveAdTagDetailName.of(projectId, location, sessionId, adTagDetailId).toString())               .build();        LiveAdTagDetail response =           videoStitcherServiceClient.getLiveAdTagDetail(getLiveAdTagDetailRequest);       System.out.println("Live ad tag detail: " + response.getName());       return response;     }   } }

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'; // sessionId = 'my-session-id'; // adTagDetailId = 'my-ad-tag-detail-id';  // Imports the Video Stitcher library const {VideoStitcherServiceClient} =   require('@google-cloud/video-stitcher').v1; // Instantiates a client const stitcherClient = new VideoStitcherServiceClient();  async function getLiveAdTagDetail() {   // Construct request   const request = {     name: stitcherClient.liveAdTagDetailPath(       projectId,       location,       sessionId,       adTagDetailId     ),   };   const [adTagDetail] = await stitcherClient.getLiveAdTagDetail(request);   console.log(`Live ad tag detail: ${adTagDetail.name}`); }  getLiveAdTagDetail().catch(err => {   console.error(err.message);   process.exitCode = 1; });

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\GetLiveAdTagDetailRequest;  /**  * Gets the specified ad tag detail for the live session.  *  * @param string $callingProjectId     The project ID to run the API call under  * @param string $location             The location of the session  * @param string $sessionId            The ID of the session  * @param string $adTagDetailId        The ID of the ad tag detail  */ function get_live_ad_tag_detail(     string $callingProjectId,     string $location,     string $sessionId,     string $adTagDetailId ): void {     // Instantiate a client.     $stitcherClient = new VideoStitcherServiceClient();      $formattedName = $stitcherClient->liveAdTagDetailName($callingProjectId, $location, $sessionId, $adTagDetailId);     $request = (new GetLiveAdTagDetailRequest())         ->setName($formattedName);     $adTagDetail = $stitcherClient->getLiveAdTagDetail($request);      // Print results     printf('Live ad tag detail: %s' . PHP_EOL, $adTagDetail->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_ad_tag_detail(     project_id: str, location: str, session_id: str, ad_tag_detail_id: str ) -> stitcher_v1.types.LiveAdTagDetail:     """Gets the specified ad tag detail for a live session.     Args:         project_id: The GCP project ID.         location: The location of the session.         session_id: The ID of the live session.         ad_tag_detail_id: The ID of the ad tag details.      Returns:         The live ad tag detail resource.     """      client = VideoStitcherServiceClient()      name = client.live_ad_tag_detail_path(         project_id, location, session_id, ad_tag_detail_id     )     response = client.get_live_ad_tag_detail(name=name)     print(f"Live ad tag detail: {response.name}")     return response  

Ruby

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

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

require "google/cloud/video/stitcher"  ## # Get the specified ad tag detail for a live session # # @param project_id [String] Your Google Cloud project (e.g. `my-project`) # @param location [String] The location (e.g. `us-central1`) # @param session_id [String] The live session ID (e.g. `my-live-session-id`) # @param ad_tag_detail_id [String] The ad tag detail ID (e.g. `my-ad-tag-id`) # def get_live_ad_tag_detail project_id:, location:, session_id:,                            ad_tag_detail_id:   # Create a Video Stitcher client.   client = Google::Cloud::Video::Stitcher.video_stitcher_service    # Build the resource name of the live ad tag detail.   name = client.live_ad_tag_detail_path project: project_id, location: location,                                         live_session: session_id,                                         live_ad_tag_detail: ad_tag_detail_id    # Get the live ad tag detail.   ad_tag_detail = client.get_live_ad_tag_detail name: name    # Print the live ad tag detail name.   puts "Live ad tag detail: #{ad_tag_detail.name}" end