Repository navigation
feat(videostitcher): add VOD config samples and tests #9412
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
6c3bf8d
feat: add VOD config samples and tests
2df4f4a
Update media/stitcher/src/main/java/com/example/stitcher/CreateVodCon…
irataxy fc8bc56
Update media/stitcher/src/main/java/com/example/stitcher/CreateVodCon…
irataxy b77d0f8
Update media/stitcher/src/main/java/com/example/stitcher/ListVodConfi…
irataxy 4846ad7
address feedback and refactor VOD tests (configs and sessions)
e2124fe
update local var to test var
73c4478
refactor VOD tests
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
76 changes: 76 additions & 0 deletions
76
media/stitcher/src/main/java/com/example/stitcher/CreateVodConfig.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
media/stitcher/src/main/java/com/example/stitcher/DeleteVodConfig.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
media/stitcher/src/main/java/com/example/stitcher/GetVodConfig.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.