Skip to content

Commit

Permalink
docs(samples): add Video Stitcher VOD and live session code samples a… (
Browse files Browse the repository at this point in the history
#9)

* docs(samples): add Video Stitcher VOD and live session code samples and tests

* Remove async from slate and live session before and after hooks

* clean out old slates and CDN keys

* 🦉 Updates from OwlBot post-processor

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

* update SHA

Co-authored-by: sofisl <[email protected]>
Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
  • Loading branch information
3 people committed Jan 13, 2023
1 parent 3cc9dd0 commit 440fc24
Show file tree
Hide file tree
Showing 11 changed files with 793 additions and 33 deletions.
66 changes: 66 additions & 0 deletions media/video-stitcher/createLiveSession.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
/**
* Copyright 2022, Google, Inc.
* 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.
*/

'use strict';

function main(projectId, location, sourceUri, adTagUri, slateId) {
// [START video_stitcher_create_live_session]
/**
* TODO(developer): Uncomment these variables before running the sample.
*/
// projectId = 'my-project-id';
// location = 'us-central1';
// sourceUri = 'https://storage.googleapis.com/my-bucket/main.mpd';
// Single Inline Linear (https://developers.google.com/interactive-media-ads/docs/sdks/html5/client-side/tags)
// (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 createLiveSession() {
// Construct request
const request = {
parent: stitcherClient.locationPath(projectId, location),
liveSession: {
sourceUri: sourceUri,
adTagMap: {
default: {
uri: adTagUri,
},
},
defaultSlateId: slateId,
},
};

const [session] = await stitcherClient.createLiveSession(request);
console.log(`Live session: ${session.name}`);
console.log(`Play URI: ${session.playUri}`);
}

createLiveSession();
// [END video_stitcher_create_live_session]
}

// node createLiveSession.js <projectId> <location> <sourceUri> <adTagUri> <slateId>
process.on('unhandledRejection', err => {
console.error(err.message);
process.exitCode = 1;
});
main(...process.argv.slice(2));
58 changes: 58 additions & 0 deletions media/video-stitcher/createVodSession.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/**
* Copyright 2022, Google, Inc.
* 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.
*/

'use strict';

function main(projectId, location, sourceUri, adTagUri) {
// [START video_stitcher_create_vod_session]
/**
* TODO(developer): Uncomment these variables before running the sample.
*/
// projectId = 'my-project-id';
// location = 'us-central1';
// 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)
// adTagUri = 'https://pubads.g.doubleclick.net/gampad/ads...';

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

async function createVodSession() {
// Construct request
const request = {
parent: stitcherClient.locationPath(projectId, location),
vodSession: {
sourceUri: sourceUri,
adTagUri: adTagUri,
},
};
const [session] = await stitcherClient.createVodSession(request);
console.log(`VOD session: ${session.name}`);
}

createVodSession();
// [END video_stitcher_create_vod_session]
}

// node createVodSession.js <projectId> <location> <sourceUri> <adTagUri>
process.on('unhandledRejection', err => {
console.error(err.message);
process.exitCode = 1;
});
main(...process.argv.slice(2));
57 changes: 57 additions & 0 deletions media/video-stitcher/getLiveAdTagDetail.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/**
* Copyright 2022, Google, Inc.
* 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.
*/

'use strict';

function main(projectId, location, sessionId, adTagDetailId) {
// [START video_stitcher_get_live_ad_tag_detail]
/**
* 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();
// [END video_stitcher_get_live_ad_tag_detail]
}

// node getLiveAdTagDetail.js <projectId> <location> <sessionId> <adTagDetailId>
process.on('unhandledRejection', err => {
console.error(err.message);
process.exitCode = 1;
});
main(...process.argv.slice(2));
51 changes: 51 additions & 0 deletions media/video-stitcher/getLiveSession.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/**
* Copyright 2022, Google, Inc.
* 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.
*/

'use strict';

function main(projectId, location, sessionId) {
// [START video_stitcher_get_live_session]
/**
* 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();
// [END video_stitcher_get_live_session]
}

// node getLiveSession.js <projectId> <location> <sessionId>
process.on('unhandledRejection', err => {
console.error(err.message);
process.exitCode = 1;
});
main(...process.argv.slice(2));
57 changes: 57 additions & 0 deletions media/video-stitcher/getVodAdTagDetail.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/**
* Copyright 2022, Google, Inc.
* 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.
*/

'use strict';

function main(projectId, location, sessionId, adTagDetailId) {
// [START video_stitcher_get_vod_ad_tag_detail]
/**
* 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 getVodAdTagDetail() {
// Construct request
const request = {
name: stitcherClient.vodAdTagDetailPath(
projectId,
location,
sessionId,
adTagDetailId
),
};
const [adTagDetail] = await stitcherClient.getVodAdTagDetail(request);
console.log(`VOD ad tag detail: ${adTagDetail.name}`);
}

getVodAdTagDetail();
// [END video_stitcher_get_vod_ad_tag_detail]
}

// node getVodAdTagDetail.js <projectId> <location> <sessionId> <adTagDetailId>
process.on('unhandledRejection', err => {
console.error(err.message);
process.exitCode = 1;
});
main(...process.argv.slice(2));
51 changes: 51 additions & 0 deletions media/video-stitcher/getVodSession.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/**
* Copyright 2022, Google, Inc.
* 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.
*/

'use strict';

function main(projectId, location, sessionId) {
// [START video_stitcher_get_vod_session]
/**
* 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 getVodSession() {
// Construct request
const request = {
name: stitcherClient.vodSessionPath(projectId, location, sessionId),
};
const [session] = await stitcherClient.getVodSession(request);
console.log(`VOD session: ${session.name}`);
}

getVodSession();
// [END video_stitcher_get_vod_session]
}

// node getVodSession.js <projectId> <location> <sessionId>
process.on('unhandledRejection', err => {
console.error(err.message);
process.exitCode = 1;
});
main(...process.argv.slice(2));
Loading

0 comments on commit 440fc24

Please sign in to comment.