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
2 changes: 1 addition & 1 deletion media/stitcher/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>libraries-bom</artifactId>
<version>26.32.0</version>
<version>26.42.0</version>
<type>pom</type>
<scope>import</scope>
</dependency>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.example.stitcher;

// [START videostitcher_create_vod_config]

import com.google.cloud.video.stitcher.v1.CreateVodConfigRequest;
import com.google.cloud.video.stitcher.v1.LocationName;
import com.google.cloud.video.stitcher.v1.VideoStitcherServiceClient;
import com.google.cloud.video.stitcher.v1.VodConfig;
import java.io.IOException;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;

public class CreateVodConfig {

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 vodConfigId = "my-vod-config-id";
// URI of the VOD 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 VMAP Pre-roll
// (https://developers.google.com/interactive-media-ads/docs/sdks/html5/client-side/tags)
String adTagUri = "https://pubads.g.doubleclick.net/gampad/ads...";

createVodConfig(projectId, location, vodConfigId, sourceUri, adTagUri);
}

// Creates a video on demand (VOD) config. VOD configs are used to configure VOD
// sessions. For more information, see
// https://cloud.google.com/video-stitcher/docs/how-to/managing-vod-configs.
public static VodConfig createVodConfig(
String projectId, String location, String vodConfigId, String sourceUri, String adTagUri)
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.
try (VideoStitcherServiceClient videoStitcherServiceClient =
VideoStitcherServiceClient.create()) {
CreateVodConfigRequest createVodConfigRequest =
CreateVodConfigRequest.newBuilder()
.setParent(LocationName.of(projectId, location).toString())
.setVodConfigId(vodConfigId)
.setVodConfig(
VodConfig.newBuilder().setSourceUri(sourceUri).setAdTagUri(adTagUri).build())
.build();

VodConfig response =
videoStitcherServiceClient
.createVodConfigAsync(createVodConfigRequest)
.get(TIMEOUT_IN_MINUTES, TimeUnit.MINUTES);
System.out.println("Created new VOD config: " + response.getName());
return response;
}
}
}
// [END videostitcher_create_vod_config]
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import com.google.cloud.video.stitcher.v1.CreateVodSessionRequest;
import com.google.cloud.video.stitcher.v1.LocationName;
import com.google.cloud.video.stitcher.v1.VideoStitcherServiceClient;
import com.google.cloud.video.stitcher.v1.VodConfigName;
import com.google.cloud.video.stitcher.v1.VodSession;
import java.io.IOException;

Expand All @@ -31,35 +32,31 @@ 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";
// Uri of the media 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 VMAP Pre-roll
// (https://developers.google.com/interactive-media-ads/docs/sdks/html5/client-side/tags)
String adTagUri = "https://pubads.g.doubleclick.net/gampad/ads...";
Comment thread
irataxy marked this conversation as resolved.
Resolved
createVodSession(projectId, location, sourceUri, adTagUri);
String vodConfigId = "my-vod-config-id";

createVodSession(projectId, location, vodConfigId);
}

public static void createVodSession(
String projectId, String location, String sourceUri, String adTagUri) throws IOException {
// Creates a video on demand (VOD) session using the parameters in the designated VOD config.
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
// 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()) {
CreateVodSessionRequest createVodSessionRequest =
CreateVodSessionRequest.newBuilder()
.setParent(LocationName.of(projectId, location).toString())
.setVodSession(
VodSession.newBuilder()
.setSourceUri(sourceUri)
.setAdTagUri(adTagUri)
.setVodConfig(VodConfigName.format(projectId, location, vodConfigId))
.setAdTracking(AdTracking.SERVER)
.build())
.build();

VodSession response = videoStitcherServiceClient.createVodSession(createVodSessionRequest);
System.out.println("Created VOD session: " + response.getName());
return response;
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.example.stitcher;

// [START videostitcher_delete_vod_config]

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

public class DeleteVodConfig {

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 vodConfigId = "my-vod-config-id";

deleteVodConfig(projectId, location, vodConfigId);
}

// Deletes a video on demand (VOD) config.
public static void deleteVodConfig(String projectId, String location, String vodConfigId)
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.
try (VideoStitcherServiceClient videoStitcherServiceClient =
VideoStitcherServiceClient.create()) {
DeleteVodConfigRequest deleteVodConfigRequest =
DeleteVodConfigRequest.newBuilder()
.setName(VodConfigName.of(projectId, location, vodConfigId).toString())
.build();

videoStitcherServiceClient
.deleteVodConfigAsync(deleteVodConfigRequest)
.get(TIMEOUT_IN_MINUTES, TimeUnit.MINUTES);
System.out.println("Deleted VOD config");
}
}
}
// [END videostitcher_delete_vod_config]
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@ public static void main(String[] args) throws Exception {
getVodAdTagDetail(projectId, location, sessionId, adTagDetailId);
}

public static void getVodAdTagDetail(
// Gets an ad tag detail for a video on demand (VOD) session.
public static VodAdTagDetail getVodAdTagDetail(
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. 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()) {
GetVodAdTagDetailRequest getVodAdTagDetailRequest =
Expand All @@ -53,6 +53,7 @@ public static void getVodAdTagDetail(
VodAdTagDetail response =
videoStitcherServiceClient.getVodAdTagDetail(getVodAdTagDetailRequest);
System.out.println("VOD ad tag detail: " + response.getName());
return response;
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.example.stitcher;

// [START videostitcher_get_vod_config]

import com.google.cloud.video.stitcher.v1.GetVodConfigRequest;
import com.google.cloud.video.stitcher.v1.VideoStitcherServiceClient;
import com.google.cloud.video.stitcher.v1.VodConfig;
import com.google.cloud.video.stitcher.v1.VodConfigName;
import java.io.IOException;

public class GetVodConfig {

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 vodConfigId = "my-vod-config-id";

getVodConfig(projectId, location, vodConfigId);
}

// Gets a video on demand (VOD) config.
public static VodConfig getVodConfig(String projectId, String location, String vodConfigId)
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()) {
GetVodConfigRequest getVodConfigRequest =
GetVodConfigRequest.newBuilder()
.setName(VodConfigName.of(projectId, location, vodConfigId).toString())
.build();

VodConfig response = videoStitcherServiceClient.getVodConfig(getVodConfigRequest);
System.out.println("VOD config: " + response.getName());
return response;
}
}
}
// [END videostitcher_get_vod_config]
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ public static void main(String[] args) throws Exception {
getVodSession(projectId, location, sessionId);
}

public static void getVodSession(String projectId, String location, String sessionId)
// Gets a video on demand (VOD) session.
public static VodSession getVodSession(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. 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()) {
GetVodSessionRequest getVodSessionRequest =
Expand All @@ -49,6 +49,7 @@ public static void getVodSession(String projectId, String location, String sessi

VodSession response = videoStitcherServiceClient.getVodSession(getVodSessionRequest);
System.out.println("VOD session: " + response.getName());
return response;
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@ public static void main(String[] args) throws Exception {
getVodStitchDetail(projectId, location, sessionId, stitchDetailId);
}

public static void getVodStitchDetail(
// Gets a stitch detail for a video on demand (VOD) session.
public static VodStitchDetail getVodStitchDetail(
String projectId, String location, String sessionId, String stitchDetailId)
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()) {
GetVodStitchDetailRequest getVodStitchDetailRequest =
Expand All @@ -53,6 +53,7 @@ public static void getVodStitchDetail(
VodStitchDetail response =
videoStitcherServiceClient.getVodStitchDetail(getVodStitchDetailRequest);
System.out.println("VOD stitch detail: " + response.getName());
return response;
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

import com.google.cloud.video.stitcher.v1.ListVodAdTagDetailsRequest;
import com.google.cloud.video.stitcher.v1.VideoStitcherServiceClient;
import com.google.cloud.video.stitcher.v1.VideoStitcherServiceClient.ListVodAdTagDetailsPagedResponse;
import com.google.cloud.video.stitcher.v1.VodAdTagDetail;
import com.google.cloud.video.stitcher.v1.VodSessionName;
import java.io.IOException;
Expand All @@ -35,11 +36,11 @@ public static void main(String[] args) throws Exception {
listVodAdTagDetails(projectId, location, sessionId);
}

public static void listVodAdTagDetails(String projectId, String location, String sessionId)
throws IOException {
// Lists the ad tag details for a video on demand (VOD) session.
public static ListVodAdTagDetailsPagedResponse listVodAdTagDetails(
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. 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()) {
ListVodAdTagDetailsRequest listVodAdTagDetailsRequest =
Expand All @@ -49,11 +50,12 @@ public static void listVodAdTagDetails(String projectId, String location, String

VideoStitcherServiceClient.ListVodAdTagDetailsPagedResponse response =
videoStitcherServiceClient.listVodAdTagDetails(listVodAdTagDetailsRequest);
System.out.println("VOD ad tag details:");

System.out.println("VOD ad tag details:");
for (VodAdTagDetail adTagDetail : response.iterateAll()) {
System.out.println(adTagDetail.toString());
}
return response;
}
}
}
Expand Down
Loading