Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public static void main(String[] args) throws Exception {

// createCdnKey creates a Media CDN key or a Cloud CDN key. A CDN key is used to retrieve
// protected media.
public static void createCdnKey(
public static CdnKey createCdnKey(
String projectId,
String location,
String cdnKeyId,
Expand All @@ -61,45 +61,46 @@ public static void createCdnKey(
Boolean isMediaCdn)
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();
CdnKey cdnKey;
if (isMediaCdn) {
cdnKey =
CdnKey.newBuilder()
.setHostname(hostname)
.setMediaCdnKey(
MediaCdnKey.newBuilder()
.setKeyName(keyName)
.setPrivateKey(ByteString.copyFromUtf8(privateKey))
.build())
.build();
} else {
cdnKey =
CdnKey.newBuilder()
.setHostname(hostname)
.setGoogleCdnKey(
GoogleCdnKey.newBuilder()
.setKeyName(keyName)
.setPrivateKey(ByteString.copyFromUtf8(privateKey))
.build())
.build();
}
// once, and can be reused for multiple requests.
try (VideoStitcherServiceClient videoStitcherServiceClient =
VideoStitcherServiceClient.create()) {
CdnKey cdnKey;
if (isMediaCdn) {
cdnKey =
CdnKey.newBuilder()
.setHostname(hostname)
.setMediaCdnKey(
MediaCdnKey.newBuilder()
.setKeyName(keyName)
.setPrivateKey(ByteString.copyFromUtf8(privateKey))
.build())
.build();
} else {
cdnKey =
CdnKey.newBuilder()
.setHostname(hostname)
.setGoogleCdnKey(
GoogleCdnKey.newBuilder()
.setKeyName(keyName)
.setPrivateKey(ByteString.copyFromUtf8(privateKey))
.build())
.build();
}

CreateCdnKeyRequest createCdnKeyRequest =
CreateCdnKeyRequest.newBuilder()
.setParent(LocationName.of(projectId, location).toString())
.setCdnKeyId(cdnKeyId)
.setCdnKey(cdnKey)
.build();
CreateCdnKeyRequest createCdnKeyRequest =
CreateCdnKeyRequest.newBuilder()
.setParent(LocationName.of(projectId, location).toString())
.setCdnKeyId(cdnKeyId)
.setCdnKey(cdnKey)
.build();

CdnKey result =
videoStitcherServiceClient
.createCdnKeyAsync(createCdnKeyRequest)
.get(TIMEOUT_IN_MINUTES, TimeUnit.MINUTES);
System.out.println("Created new CDN key: " + result.getName());
videoStitcherServiceClient.close();
CdnKey result =
videoStitcherServiceClient
.createCdnKeyAsync(createCdnKeyRequest)
.get(TIMEOUT_IN_MINUTES, TimeUnit.MINUTES);
System.out.println("Created new CDN key: " + result.getName());
return result;
}
}
}
// [END videostitcher_create_cdn_key]
Original file line number Diff line number Diff line change
Expand Up @@ -45,35 +45,36 @@ public static void main(String[] args) throws Exception {
}

// createCdnKeyAkamai creates an Akamai CDN key. A CDN key is used to retrieve protected media.
public static void createCdnKeyAkamai(
public static CdnKey createCdnKeyAkamai(
String projectId, String location, String cdnKeyId, String hostname, String akamaiTokenKey)
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();
CdnKey cdnKey =
CdnKey.newBuilder()
.setHostname(hostname)
.setAkamaiCdnKey(
AkamaiCdnKey.newBuilder()
.setTokenKey(ByteString.copyFromUtf8(akamaiTokenKey))
.build())
.build();
// once, and can be reused for multiple requests.
try (VideoStitcherServiceClient videoStitcherServiceClient =
VideoStitcherServiceClient.create()) {
CdnKey cdnKey =
CdnKey.newBuilder()
.setHostname(hostname)
.setAkamaiCdnKey(
AkamaiCdnKey.newBuilder()
.setTokenKey(ByteString.copyFromUtf8(akamaiTokenKey))
.build())
.build();

CreateCdnKeyRequest createCdnKeyRequest =
CreateCdnKeyRequest.newBuilder()
.setParent(LocationName.of(projectId, location).toString())
.setCdnKeyId(cdnKeyId)
.setCdnKey(cdnKey)
.build();
CreateCdnKeyRequest createCdnKeyRequest =
CreateCdnKeyRequest.newBuilder()
.setParent(LocationName.of(projectId, location).toString())
.setCdnKeyId(cdnKeyId)
.setCdnKey(cdnKey)
.build();

CdnKey result =
videoStitcherServiceClient
.createCdnKeyAsync(createCdnKeyRequest)
.get(TIMEOUT_IN_MINUTES, TimeUnit.MINUTES);
System.out.println("Created new CDN key: " + result.getName());
videoStitcherServiceClient.close();
CdnKey result =
videoStitcherServiceClient
.createCdnKeyAsync(createCdnKeyRequest)
.get(TIMEOUT_IN_MINUTES, TimeUnit.MINUTES);
System.out.println("Created new CDN key: " + result.getName());
return result;
}
}
}
// [END videostitcher_create_cdn_key_akamai]
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,10 @@ public static void main(String[] args) throws Exception {
createLiveConfig(projectId, location, liveConfigId, sourceUri, adTagUri, slateId);
}

public static void createLiveConfig(
// Creates a live config. Live configs are used to configure live sessions.
// For more information, see
// https://cloud.google.com/video-stitcher/docs/how-to/managing-live-configs.
public static LiveConfig createLiveConfig(
String projectId,
String location,
String liveConfigId,
Expand All @@ -59,29 +62,30 @@ public static void createLiveConfig(
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();
// once, and can be reused for multiple requests.
try (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();
LiveConfig response =
videoStitcherServiceClient
.createLiveConfigAsync(createLiveConfigRequest)
.get(TIMEOUT_IN_MINUTES, TimeUnit.MINUTES);
System.out.println("Created new live config: " + response.getName());
return response;
}
}
}
// [END videostitcher_create_live_config]
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,13 @@ public static void main(String[] args) throws Exception {
createLiveSession(projectId, location, liveConfigId);
}

public static void createLiveSession(String projectId, String location, String liveConfigId)
throws IOException {
// 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. In this example, try-with-resources is used
// which automatically calls close() on the client to clean up resources.
// once, and can be reused for multiple requests.
try (VideoStitcherServiceClient videoStitcherServiceClient =
VideoStitcherServiceClient.create()) {
CreateLiveSessionRequest createLiveSessionRequest =
Expand All @@ -54,6 +56,7 @@ public static void createLiveSession(String projectId, String location, String l
LiveSession response = videoStitcherServiceClient.createLiveSession(createLiveSessionRequest);
System.out.println("Created live session: " + response.getName());
System.out.println("Play URI: " + response.getPlayUri());
return response;
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,25 +42,30 @@ public static void main(String[] args) throws Exception {
createSlate(projectId, location, slateId, slateUri);
}

public static void createSlate(String projectId, String location, String slateId, String slateUri)
// Creates a slate. Slates are content that can be served when there are gaps in a livestream
// ad break that cannot be filled with a dynamically served ad. For more information, see
// https://cloud.google.com/video-stitcher/docs/how-to/managing-slates.
public static Slate createSlate(
String projectId, String location, String slateId, String slateUri)
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();
CreateSlateRequest createSlateRequest =
CreateSlateRequest.newBuilder()
.setParent(LocationName.of(projectId, location).toString())
.setSlateId(slateId)
.setSlate(Slate.newBuilder().setUri(slateUri).build())
.build();
// once, and can be reused for multiple requests.
try (VideoStitcherServiceClient videoStitcherServiceClient =
VideoStitcherServiceClient.create()) {
CreateSlateRequest createSlateRequest =
CreateSlateRequest.newBuilder()
.setParent(LocationName.of(projectId, location).toString())
.setSlateId(slateId)
.setSlate(Slate.newBuilder().setUri(slateUri).build())
.build();

Slate response =
videoStitcherServiceClient
.createSlateAsync(createSlateRequest)
.get(TIMEOUT_IN_MINUTES, TimeUnit.MINUTES);
System.out.println("Created new slate: " + response.getName());
videoStitcherServiceClient.close();
Slate response =
videoStitcherServiceClient
.createSlateAsync(createSlateRequest)
.get(TIMEOUT_IN_MINUTES, TimeUnit.MINUTES);
System.out.println("Created new slate: " + response.getName());
return response;
}
}
}
// [END videostitcher_create_slate]
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ public static void main(String[] args) throws Exception {
}

// Creates a video on demand (VOD) session using the parameters in the designated VOD config.
// For more information, see
// https://cloud.google.com/video-stitcher/docs/how-to/creating-vod-sessions.
public static VodSession createVodSession(String projectId, String location, String vodConfigId)
throws IOException {
// Initialize client that will be used to send requests. This client only needs to be created
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,22 +39,23 @@ public static void main(String[] args) throws Exception {
deleteCdnKey(projectId, location, cdnKeyId);
}

// Deletes a CDN key.
public static void deleteCdnKey(String projectId, String location, String cdnKeyId)
throws InterruptedException, ExecutionException, TimeoutException, 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. 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();
DeleteCdnKeyRequest deleteCdnKeyRequest =
DeleteCdnKeyRequest.newBuilder()
.setName(CdnKeyName.of(projectId, location, cdnKeyId).toString())
.build();

videoStitcherServiceClient
.deleteCdnKeyAsync(deleteCdnKeyRequest)
.get(TIMEOUT_IN_MINUTES, TimeUnit.MINUTES);
System.out.println("Deleted CDN key");
videoStitcherServiceClient.close();
// once, and can be reused for multiple requests.
try (VideoStitcherServiceClient videoStitcherServiceClient =
VideoStitcherServiceClient.create()) {
DeleteCdnKeyRequest deleteCdnKeyRequest =
DeleteCdnKeyRequest.newBuilder()
.setName(CdnKeyName.of(projectId, location, cdnKeyId).toString())
.build();

videoStitcherServiceClient
.deleteCdnKeyAsync(deleteCdnKeyRequest)
.get(TIMEOUT_IN_MINUTES, TimeUnit.MINUTES);
System.out.println("Deleted CDN key");
}
}
}
// [END videostitcher_delete_cdn_key]
Original file line number Diff line number Diff line change
Expand Up @@ -39,22 +39,23 @@ public static void main(String[] args) throws Exception {
deleteLiveConfig(projectId, location, liveConfigId);
}

// Deletes a live config.
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();
// once, and can be reused for multiple requests.
try (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");
}
}
}
// [END videostitcher_delete_live_config]
Loading