Skip to content
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

migrate code from googleapis/nodejs-video-stitcher #2986

Merged
merged 15 commits into from
Jan 13, 2023
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
71 changes: 71 additions & 0 deletions .github/workflows/media-video-stitcher.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
name: media-video-stitcher
on:
push:
branches:
- main
paths:
- 'media/video-stitcher/**'
- '.github/workflows/media-video-stitcher.yaml'
pull_request:
paths:
- 'media/video-stitcher/**'
- '.github/workflows/media-video-stitcher.yaml'
pull_request_target:
types: [labeled]
paths:
- 'media/video-stitcher/**'
- '.github/workflows/media-video-stitcher.yaml'
schedule:
- cron: '0 0 * * 0'
jobs:
test:
if: ${{ github.event.action != 'labeled' || github.event.label.name == 'actions:force-run' }}
runs-on: ubuntu-latest
timeout-minutes: 60
permissions:
contents: 'write'
pull-requests: 'write'
id-token: 'write'
steps:
- uses: actions/checkout@v3.1.0
with:
ref: ${{github.event.pull_request.head.sha}}
- uses: 'google-github-actions/auth@v1.0.0'
with:
workload_identity_provider: 'projects/1046198160504/locations/global/workloadIdentityPools/github-actions-pool/providers/github-actions-provider'
service_account: 'kokoro-system-test@long-door-651.iam.gserviceaccount.com'
create_credentials_file: 'true'
access_token_lifetime: 600s
- uses: actions/setup-node@v3.5.1
with:
node-version: 16
- run: npm install
working-directory: media/video-stitcher
- run: npm test
working-directory: media/video-stitcher
env:
MOCHA_REPORTER_SUITENAME: media_video_stitcher
MOCHA_REPORTER_OUTPUT: media_video_stitcher_sponge_log.xml
MOCHA_REPORTER: xunit
- if: ${{ github.event.action == 'labeled' && github.event.label.name == 'actions:force-run' }}
uses: actions/github-script@v6
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
try {
await github.rest.issues.removeLabel({
name: 'actions:force-run',
owner: 'GoogleCloudPlatform',
repo: 'nodejs-docs-samples',
issue_number: context.payload.pull_request.number
});
} catch (e) {
if (!e.message.includes('Label does not exist')) {
throw e;
}
}
- if: ${{ github.event_name == 'schedule' && always() }}
run: |
curl https://github.com/googleapis/repo-automation-bots/releases/download/flakybot-1.1.0/flakybot -o flakybot -s -L
chmod +x ./flakybot
./flakybot --repo GoogleCloudPlatform/nodejs-docs-samples --commit_hash ${{github.sha}} --build_url https://github.com/${{github.repository}}/actions/runs/${{github.run_id}}
1 change: 1 addition & 0 deletions .github/workflows/workflows.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
"healthcare/hl7v2",
"iam",
"kms",
"media/video-stitcher",
"mediatranslation",
"monitoring/opencensus",
"monitoring/prometheus",
Expand Down
1 change: 1 addition & 0 deletions CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -76,3 +76,4 @@ vision @GoogleCloudPlatform/dee-data-ai @GoogleCloudPlatform/nodejs-samples-revi

# Self-service
retail @GoogleCloudPlatform/cloud-retail-team @GoogleCloudPlatform/nodejs-samples-reviewers
media @GoogleCloudPlatform/cloud-media-team @GoogleCloudPlatform/nodejs-samples-reviewers
79 changes: 79 additions & 0 deletions media/video-stitcher/createCdnKey.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
/**
* 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,
cdnKeyId,
hostname,
gCdnKeyname,
gCdnPrivateKey,
akamaiTokenKey = ''
) {
// [START videostitcher_create_cdn_key]
/**
* TODO(developer): Uncomment these variables before running the sample.
*/
// projectId = 'my-project-id';
// location = 'us-central1';
// cdnKeyId = 'my-cdn-key';
// hostname = 'cdn.example.com';
// gCdnKeyname = 'gcdn-key';
// gCdnPrivateKey = 'VGhpcyBpcyBhIHRlc3Qgc3RyaW5nLg==';
// akamaiTokenKey = 'VGhpcyBpcyBhIHRlc3Qgc3RyaW5nLg==';

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

async function createCdnKey() {
// Construct request
const request = {
parent: stitcherClient.locationPath(projectId, location),
cdnKey: {
hostname: hostname,
},
cdnKeyId: cdnKeyId,
};

if (akamaiTokenKey !== '') {
request.cdnKey.akamaiCdnKey = {
tokenKey: akamaiTokenKey,
};
} else {
request.cdnKey.googleCdnKey = {
keyName: gCdnKeyname,
privateKey: gCdnPrivateKey,
};
}

const [cdnKey] = await stitcherClient.createCdnKey(request);
console.log(`CDN key: ${cdnKey.name}`);
}

createCdnKey();
// [END videostitcher_create_cdn_key]
}

// node createCdnKey.js <projectId> <location> <cdnKeyId> <hostname> <gCdnKeyname> <gCdnPrivateKey> <akamaiTokenKey>
process.on('unhandledRejection', err => {
console.error(err.message);
process.exitCode = 1;
});
main(...process.argv.slice(2));
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 videostitcher_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 videostitcher_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));
56 changes: 56 additions & 0 deletions media/video-stitcher/createSlate.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/**
* 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, slateId, slateUri) {
// [START videostitcher_create_slate]
/**
* TODO(developer): Uncomment these variables before running the sample.
*/
// projectId = 'my-project-id';
// location = 'us-central1';
// slateId = 'my-slate';
// slateUri = 'https://my-slate-uri/test.mp4';

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

async function createSlate() {
// Construct request
const request = {
parent: stitcherClient.locationPath(projectId, location),
slate: {
uri: slateUri,
},
slateId: slateId,
};
const [slate] = await stitcherClient.createSlate(request);
console.log(`Slate: ${slate.name}`);
}

createSlate();
// [END videostitcher_create_slate]
}

// node createSlate.js <projectId> <location> <slateId> <slateUri>
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 videostitcher_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 videostitcher_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));
51 changes: 51 additions & 0 deletions media/video-stitcher/deleteCdnKey.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, cdnKeyId) {
// [START videostitcher_delete_cdn_key]
/**
* TODO(developer): Uncomment these variables before running the sample.
*/
// projectId = 'my-project-id';
// location = 'us-central1';
// cdnKeyId = 'my-cdn-key';

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

async function deleteCdnKey() {
// Construct request
const request = {
name: stitcherClient.cdnKeyPath(projectId, location, cdnKeyId),
};
await stitcherClient.deleteCdnKey(request);
console.log('Deleted CDN key');
}

deleteCdnKey();
// [END videostitcher_delete_cdn_key]
}

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