diff --git a/packages/@aws-cdk/aws-ivs-alpha/README.md b/packages/@aws-cdk/aws-ivs-alpha/README.md index f8ea242c9990d..62b4176cde74a 100644 --- a/packages/@aws-cdk/aws-ivs-alpha/README.md +++ b/packages/@aws-cdk/aws-ivs-alpha/README.md @@ -67,6 +67,26 @@ const myRtmpChannel = new ivs.Channel(this, 'myRtmpChannel', { }); ``` +### Multitrack Video + +Multitrack video is a new, low-latency streaming paradigm supported by Amazon Interactive Video Service (IVS) and services that use Amazon IVS. + +You can use Multitrack Video by setting the `multitrackInputConfiguration` property. +Multitrack Video requires both a STANDARD Channel and Fragmented Mp4. + +For more information, see [Amazon IVS Multitrack Video](https://docs.aws.amazon.com/ivs/latest/LowLatencyUserGuide/multitrack-video.html). + +```ts +new ivs.Channel(this, 'ChannelWithMultitrackVideo', { + type: ivs.ChannelType.STANDARD, + containerFormat: ivs.ContainerFormat.FRAGMENTED_MP4, + multitrackInputConfiguration: { + maximumResolution: ivs.MaximumResolution.HD, + policy: ivs.Policy.ALLOW, + }, +}); +``` + ### Importing an existing channel You can reference an existing channel, for example, if you need to create a diff --git a/packages/@aws-cdk/aws-ivs-alpha/lib/channel.ts b/packages/@aws-cdk/aws-ivs-alpha/lib/channel.ts index 566fb0e7db6a3..d4abfc7c682c9 100644 --- a/packages/@aws-cdk/aws-ivs-alpha/lib/channel.ts +++ b/packages/@aws-cdk/aws-ivs-alpha/lib/channel.ts @@ -38,7 +38,22 @@ abstract class ChannelBase extends core.Resource implements IChannel { } /** - Channel latency mode + * Container Format + */ +export enum ContainerFormat { + /** + * Use MPEG-TS. + */ + TS = 'TS', + + /** + * Use fMP4. + */ + FRAGMENTED_MP4 = 'FRAGMENTED_MP4', +} + +/** + * Channel latency mode */ export enum LatencyMode { /** @@ -119,6 +134,16 @@ export interface ChannelProps { */ readonly authorized?: boolean; + /** + * Indicates which content-packaging format is used (MPEG-TS or fMP4). + * + * If `multitrackInputConfiguration` is specified, only fMP4 can be used. + * Otherwise, `containerFormat` may be set to `ContainerFormat.TS` or `ContainerFormat.FRAGMENTED_MP4`. + * + * @default - `ContainerFormat.FRAGMENTED_MP4` is automatically set when the `multitrackInputConfiguration` is specified. If not specified, it remains undefined and uses the IVS default setting (TS). + */ + readonly containerFormat?: ContainerFormat; + /** * Whether the channel allows insecure RTMP ingest. * @@ -140,6 +165,17 @@ export interface ChannelProps { */ readonly channelName?: string; + /** + * Object specifying multitrack input configuration. + * You must specify `multitrackInputConfiguration` if you want to use MultiTrack Video. + * + * `multitrackInputConfiguration` is only supported for `ChannelType.STANDARD`. + * + * @default undefined - IVS default setting is not use MultiTrack Video. + * @see https://docs.aws.amazon.com/ivs/latest/LowLatencyUserGuide/multitrack-video.html + */ + readonly multitrackInputConfiguration?: MultitrackInputConfiguration; + /** * The channel type, which determines the allowable resolution and bitrate. * If you exceed the allowable resolution or bitrate, the stream will disconnect immediately @@ -164,6 +200,56 @@ export interface ChannelProps { readonly recordingConfiguration?: IRecordingConfiguration; } +/** + * Maximum resolution for multitrack input. + */ +export enum MaximumResolution { + /** + * Full HD (1080p) + */ + FULL_HD = 'FULL_HD', + + /** + * HD (720p) + */ + HD = 'HD', + + /** + * SD (480p) + */ + SD = 'SD', +} + +/** + * Whether multitrack input is allowed or required. + */ +export enum Policy { + /** + * Multitrack input is allowed. + */ + ALLOW = 'ALLOW', + + /** + * Multitrack input is required. + */ + REQUIRE = 'REQUIRE', +} + +/** + * A complex type that specifies multitrack input configuration. + */ +export interface MultitrackInputConfiguration { + /** + * Maximum resolution for multitrack input. + */ + readonly maximumResolution: MaximumResolution; + + /** + * Indicates whether multitrack input is allowed or required. + */ + readonly policy: Policy; +} + /** A new IVS channel */ @@ -227,6 +313,16 @@ export class Channel extends ChannelBase { preset = props.preset; } + if (props.multitrackInputConfiguration !== undefined) { + if (props.type !== undefined && props.type !== ChannelType.STANDARD) { + throw new Error(`\`multitrackInputConfiguration\` is only supported for \`ChannelType.STANDARD\`, got: ${props.type}.`); + } + + if (props.containerFormat !== undefined && props.containerFormat !== ContainerFormat.FRAGMENTED_MP4) { + throw new Error(`\`containerFormat\` must be set to \`ContainerFormat.FRAGMENTED_MP4\` when \`multitrackInputConfiguration\` is specified, got: ${props.containerFormat}.`); + } + } + const resource = new CfnChannel(this, 'Resource', { authorized: props.authorized, insecureIngest: props.insecureIngest, @@ -235,6 +331,15 @@ export class Channel extends ChannelBase { type: props.type, preset, recordingConfigurationArn: props.recordingConfiguration?.recordingConfigurationArn, + containerFormat: props.containerFormat ?? + (props.multitrackInputConfiguration ? ContainerFormat.FRAGMENTED_MP4 : undefined), + multitrackInputConfiguration: props.multitrackInputConfiguration ? + { + enabled: true, + maximumResolution: props.multitrackInputConfiguration.maximumResolution, + policy: props.multitrackInputConfiguration.policy, + } + : undefined, }); this.channelArn = resource.attrArn; diff --git a/packages/@aws-cdk/aws-ivs-alpha/test/integ.ivs-multitrack-video.js.snapshot/aws-cdk-ivs-multitarck-video.assets.json b/packages/@aws-cdk/aws-ivs-alpha/test/integ.ivs-multitrack-video.js.snapshot/aws-cdk-ivs-multitarck-video.assets.json new file mode 100644 index 0000000000000..4810fab2ca706 --- /dev/null +++ b/packages/@aws-cdk/aws-ivs-alpha/test/integ.ivs-multitrack-video.js.snapshot/aws-cdk-ivs-multitarck-video.assets.json @@ -0,0 +1,19 @@ +{ + "version": "39.0.0", + "files": { + "e0d37ee6ba31d5a59e1ba06c8c5ca6fe67cc4392968f9b983b163f29c1a468f2": { + "source": { + "path": "aws-cdk-ivs-multitarck-video.template.json", + "packaging": "file" + }, + "destinations": { + "current_account-current_region": { + "bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}", + "objectKey": "e0d37ee6ba31d5a59e1ba06c8c5ca6fe67cc4392968f9b983b163f29c1a468f2.json", + "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}" + } + } + } + }, + "dockerImages": {} +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-ivs-alpha/test/integ.ivs-multitrack-video.js.snapshot/aws-cdk-ivs-multitarck-video.template.json b/packages/@aws-cdk/aws-ivs-alpha/test/integ.ivs-multitrack-video.js.snapshot/aws-cdk-ivs-multitarck-video.template.json new file mode 100644 index 0000000000000..ffcff51494c8b --- /dev/null +++ b/packages/@aws-cdk/aws-ivs-alpha/test/integ.ivs-multitrack-video.js.snapshot/aws-cdk-ivs-multitarck-video.template.json @@ -0,0 +1,51 @@ +{ + "Resources": { + "ChannelWithMultitrackVideoE5332214": { + "Type": "AWS::IVS::Channel", + "Properties": { + "ContainerFormat": "FRAGMENTED_MP4", + "MultitrackInputConfiguration": { + "Enabled": true, + "MaximumResolution": "HD", + "Policy": "ALLOW" + }, + "Name": "aws-cdk-ivs-multitarck-videoChannelWithMultitrackVideoCC53F319", + "Type": "STANDARD" + } + } + }, + "Parameters": { + "BootstrapVersion": { + "Type": "AWS::SSM::Parameter::Value", + "Default": "/cdk-bootstrap/hnb659fds/version", + "Description": "Version of the CDK Bootstrap resources in this environment, automatically retrieved from SSM Parameter Store. [cdk:skip]" + } + }, + "Rules": { + "CheckBootstrapVersion": { + "Assertions": [ + { + "Assert": { + "Fn::Not": [ + { + "Fn::Contains": [ + [ + "1", + "2", + "3", + "4", + "5" + ], + { + "Ref": "BootstrapVersion" + } + ] + } + ] + }, + "AssertDescription": "CDK bootstrap stack version 6 required. Please run 'cdk bootstrap' with a recent version of the CDK CLI." + } + ] + } + } +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-ivs-alpha/test/integ.ivs-multitrack-video.js.snapshot/awscdkivsmultitarckvideotestDefaultTestDeployAssert4DE3589F.assets.json b/packages/@aws-cdk/aws-ivs-alpha/test/integ.ivs-multitrack-video.js.snapshot/awscdkivsmultitarckvideotestDefaultTestDeployAssert4DE3589F.assets.json new file mode 100644 index 0000000000000..137be64992f70 --- /dev/null +++ b/packages/@aws-cdk/aws-ivs-alpha/test/integ.ivs-multitrack-video.js.snapshot/awscdkivsmultitarckvideotestDefaultTestDeployAssert4DE3589F.assets.json @@ -0,0 +1,19 @@ +{ + "version": "39.0.0", + "files": { + "21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22": { + "source": { + "path": "awscdkivsmultitarckvideotestDefaultTestDeployAssert4DE3589F.template.json", + "packaging": "file" + }, + "destinations": { + "current_account-current_region": { + "bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}", + "objectKey": "21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22.json", + "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}" + } + } + } + }, + "dockerImages": {} +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-ivs-alpha/test/integ.ivs-multitrack-video.js.snapshot/awscdkivsmultitarckvideotestDefaultTestDeployAssert4DE3589F.template.json b/packages/@aws-cdk/aws-ivs-alpha/test/integ.ivs-multitrack-video.js.snapshot/awscdkivsmultitarckvideotestDefaultTestDeployAssert4DE3589F.template.json new file mode 100644 index 0000000000000..ad9d0fb73d1dd --- /dev/null +++ b/packages/@aws-cdk/aws-ivs-alpha/test/integ.ivs-multitrack-video.js.snapshot/awscdkivsmultitarckvideotestDefaultTestDeployAssert4DE3589F.template.json @@ -0,0 +1,36 @@ +{ + "Parameters": { + "BootstrapVersion": { + "Type": "AWS::SSM::Parameter::Value", + "Default": "/cdk-bootstrap/hnb659fds/version", + "Description": "Version of the CDK Bootstrap resources in this environment, automatically retrieved from SSM Parameter Store. [cdk:skip]" + } + }, + "Rules": { + "CheckBootstrapVersion": { + "Assertions": [ + { + "Assert": { + "Fn::Not": [ + { + "Fn::Contains": [ + [ + "1", + "2", + "3", + "4", + "5" + ], + { + "Ref": "BootstrapVersion" + } + ] + } + ] + }, + "AssertDescription": "CDK bootstrap stack version 6 required. Please run 'cdk bootstrap' with a recent version of the CDK CLI." + } + ] + } + } +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-ivs-alpha/test/integ.ivs-multitrack-video.js.snapshot/cdk.out b/packages/@aws-cdk/aws-ivs-alpha/test/integ.ivs-multitrack-video.js.snapshot/cdk.out new file mode 100644 index 0000000000000..91e1a8b9901d5 --- /dev/null +++ b/packages/@aws-cdk/aws-ivs-alpha/test/integ.ivs-multitrack-video.js.snapshot/cdk.out @@ -0,0 +1 @@ +{"version":"39.0.0"} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-ivs-alpha/test/integ.ivs-multitrack-video.js.snapshot/integ.json b/packages/@aws-cdk/aws-ivs-alpha/test/integ.ivs-multitrack-video.js.snapshot/integ.json new file mode 100644 index 0000000000000..c57227741662a --- /dev/null +++ b/packages/@aws-cdk/aws-ivs-alpha/test/integ.ivs-multitrack-video.js.snapshot/integ.json @@ -0,0 +1,12 @@ +{ + "version": "39.0.0", + "testCases": { + "aws-cdk-ivs-multitarck-video-test/DefaultTest": { + "stacks": [ + "aws-cdk-ivs-multitarck-video" + ], + "assertionStack": "aws-cdk-ivs-multitarck-video-test/DefaultTest/DeployAssert", + "assertionStackName": "awscdkivsmultitarckvideotestDefaultTestDeployAssert4DE3589F" + } + } +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-ivs-alpha/test/integ.ivs-multitrack-video.js.snapshot/manifest.json b/packages/@aws-cdk/aws-ivs-alpha/test/integ.ivs-multitrack-video.js.snapshot/manifest.json new file mode 100644 index 0000000000000..1bfc2c17e81a9 --- /dev/null +++ b/packages/@aws-cdk/aws-ivs-alpha/test/integ.ivs-multitrack-video.js.snapshot/manifest.json @@ -0,0 +1,113 @@ +{ + "version": "39.0.0", + "artifacts": { + "aws-cdk-ivs-multitarck-video.assets": { + "type": "cdk:asset-manifest", + "properties": { + "file": "aws-cdk-ivs-multitarck-video.assets.json", + "requiresBootstrapStackVersion": 6, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version" + } + }, + "aws-cdk-ivs-multitarck-video": { + "type": "aws:cloudformation:stack", + "environment": "aws://unknown-account/unknown-region", + "properties": { + "templateFile": "aws-cdk-ivs-multitarck-video.template.json", + "terminationProtection": false, + "validateOnSynth": false, + "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-deploy-role-${AWS::AccountId}-${AWS::Region}", + "cloudFormationExecutionRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-cfn-exec-role-${AWS::AccountId}-${AWS::Region}", + "stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/e0d37ee6ba31d5a59e1ba06c8c5ca6fe67cc4392968f9b983b163f29c1a468f2.json", + "requiresBootstrapStackVersion": 6, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version", + "additionalDependencies": [ + "aws-cdk-ivs-multitarck-video.assets" + ], + "lookupRole": { + "arn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-lookup-role-${AWS::AccountId}-${AWS::Region}", + "requiresBootstrapStackVersion": 8, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version" + } + }, + "dependencies": [ + "aws-cdk-ivs-multitarck-video.assets" + ], + "metadata": { + "/aws-cdk-ivs-multitarck-video/ChannelWithMultitrackVideo/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "ChannelWithMultitrackVideoE5332214" + } + ], + "/aws-cdk-ivs-multitarck-video/BootstrapVersion": [ + { + "type": "aws:cdk:logicalId", + "data": "BootstrapVersion" + } + ], + "/aws-cdk-ivs-multitarck-video/CheckBootstrapVersion": [ + { + "type": "aws:cdk:logicalId", + "data": "CheckBootstrapVersion" + } + ] + }, + "displayName": "aws-cdk-ivs-multitarck-video" + }, + "awscdkivsmultitarckvideotestDefaultTestDeployAssert4DE3589F.assets": { + "type": "cdk:asset-manifest", + "properties": { + "file": "awscdkivsmultitarckvideotestDefaultTestDeployAssert4DE3589F.assets.json", + "requiresBootstrapStackVersion": 6, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version" + } + }, + "awscdkivsmultitarckvideotestDefaultTestDeployAssert4DE3589F": { + "type": "aws:cloudformation:stack", + "environment": "aws://unknown-account/unknown-region", + "properties": { + "templateFile": "awscdkivsmultitarckvideotestDefaultTestDeployAssert4DE3589F.template.json", + "terminationProtection": false, + "validateOnSynth": false, + "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-deploy-role-${AWS::AccountId}-${AWS::Region}", + "cloudFormationExecutionRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-cfn-exec-role-${AWS::AccountId}-${AWS::Region}", + "stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22.json", + "requiresBootstrapStackVersion": 6, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version", + "additionalDependencies": [ + "awscdkivsmultitarckvideotestDefaultTestDeployAssert4DE3589F.assets" + ], + "lookupRole": { + "arn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-lookup-role-${AWS::AccountId}-${AWS::Region}", + "requiresBootstrapStackVersion": 8, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version" + } + }, + "dependencies": [ + "awscdkivsmultitarckvideotestDefaultTestDeployAssert4DE3589F.assets" + ], + "metadata": { + "/aws-cdk-ivs-multitarck-video-test/DefaultTest/DeployAssert/BootstrapVersion": [ + { + "type": "aws:cdk:logicalId", + "data": "BootstrapVersion" + } + ], + "/aws-cdk-ivs-multitarck-video-test/DefaultTest/DeployAssert/CheckBootstrapVersion": [ + { + "type": "aws:cdk:logicalId", + "data": "CheckBootstrapVersion" + } + ] + }, + "displayName": "aws-cdk-ivs-multitarck-video-test/DefaultTest/DeployAssert" + }, + "Tree": { + "type": "cdk:tree", + "properties": { + "file": "tree.json" + } + } + } +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-ivs-alpha/test/integ.ivs-multitrack-video.js.snapshot/tree.json b/packages/@aws-cdk/aws-ivs-alpha/test/integ.ivs-multitrack-video.js.snapshot/tree.json new file mode 100644 index 0000000000000..b311ab13d708f --- /dev/null +++ b/packages/@aws-cdk/aws-ivs-alpha/test/integ.ivs-multitrack-video.js.snapshot/tree.json @@ -0,0 +1,133 @@ +{ + "version": "tree-0.1", + "tree": { + "id": "App", + "path": "", + "children": { + "aws-cdk-ivs-multitarck-video": { + "id": "aws-cdk-ivs-multitarck-video", + "path": "aws-cdk-ivs-multitarck-video", + "children": { + "ChannelWithMultitrackVideo": { + "id": "ChannelWithMultitrackVideo", + "path": "aws-cdk-ivs-multitarck-video/ChannelWithMultitrackVideo", + "children": { + "Resource": { + "id": "Resource", + "path": "aws-cdk-ivs-multitarck-video/ChannelWithMultitrackVideo/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::IVS::Channel", + "aws:cdk:cloudformation:props": { + "containerFormat": "FRAGMENTED_MP4", + "multitrackInputConfiguration": { + "enabled": true, + "maximumResolution": "HD", + "policy": "ALLOW" + }, + "name": "aws-cdk-ivs-multitarck-videoChannelWithMultitrackVideoCC53F319", + "type": "STANDARD" + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ivs.CfnChannel", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.Resource", + "version": "0.0.0", + "metadata": [] + } + }, + "BootstrapVersion": { + "id": "BootstrapVersion", + "path": "aws-cdk-ivs-multitarck-video/BootstrapVersion", + "constructInfo": { + "fqn": "aws-cdk-lib.CfnParameter", + "version": "0.0.0" + } + }, + "CheckBootstrapVersion": { + "id": "CheckBootstrapVersion", + "path": "aws-cdk-ivs-multitarck-video/CheckBootstrapVersion", + "constructInfo": { + "fqn": "aws-cdk-lib.CfnRule", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.Stack", + "version": "0.0.0" + } + }, + "aws-cdk-ivs-multitarck-video-test": { + "id": "aws-cdk-ivs-multitarck-video-test", + "path": "aws-cdk-ivs-multitarck-video-test", + "children": { + "DefaultTest": { + "id": "DefaultTest", + "path": "aws-cdk-ivs-multitarck-video-test/DefaultTest", + "children": { + "Default": { + "id": "Default", + "path": "aws-cdk-ivs-multitarck-video-test/DefaultTest/Default", + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.4.2" + } + }, + "DeployAssert": { + "id": "DeployAssert", + "path": "aws-cdk-ivs-multitarck-video-test/DefaultTest/DeployAssert", + "children": { + "BootstrapVersion": { + "id": "BootstrapVersion", + "path": "aws-cdk-ivs-multitarck-video-test/DefaultTest/DeployAssert/BootstrapVersion", + "constructInfo": { + "fqn": "aws-cdk-lib.CfnParameter", + "version": "0.0.0" + } + }, + "CheckBootstrapVersion": { + "id": "CheckBootstrapVersion", + "path": "aws-cdk-ivs-multitarck-video-test/DefaultTest/DeployAssert/CheckBootstrapVersion", + "constructInfo": { + "fqn": "aws-cdk-lib.CfnRule", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.Stack", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/integ-tests-alpha.IntegTestCase", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/integ-tests-alpha.IntegTest", + "version": "0.0.0" + } + }, + "Tree": { + "id": "Tree", + "path": "Tree", + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.4.2" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.App", + "version": "0.0.0" + } + } +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-ivs-alpha/test/integ.ivs-multitrack-video.ts b/packages/@aws-cdk/aws-ivs-alpha/test/integ.ivs-multitrack-video.ts new file mode 100644 index 0000000000000..5d57c42173025 --- /dev/null +++ b/packages/@aws-cdk/aws-ivs-alpha/test/integ.ivs-multitrack-video.ts @@ -0,0 +1,20 @@ +import { App, Stack } from 'aws-cdk-lib'; +import * as ivs from '../lib'; +import * as integ from '@aws-cdk/integ-tests-alpha'; + +const app = new App(); + +const stack = new Stack(app, 'aws-cdk-ivs-multitarck-video'); + +new ivs.Channel(stack, 'ChannelWithMultitrackVideo', { + type: ivs.ChannelType.STANDARD, + containerFormat: ivs.ContainerFormat.FRAGMENTED_MP4, + multitrackInputConfiguration: { + maximumResolution: ivs.MaximumResolution.HD, + policy: ivs.Policy.ALLOW, + }, +}); + +new integ.IntegTest(app, 'aws-cdk-ivs-multitarck-video-test', { + testCases: [stack], +}); diff --git a/packages/@aws-cdk/aws-ivs-alpha/test/ivs.test.ts b/packages/@aws-cdk/aws-ivs-alpha/test/ivs.test.ts index 0f99e1868b553..8f9bd7f8ced10 100644 --- a/packages/@aws-cdk/aws-ivs-alpha/test/ivs.test.ts +++ b/packages/@aws-cdk/aws-ivs-alpha/test/ivs.test.ts @@ -211,3 +211,86 @@ test.each([true, false])('channel with insecureIngest set to %s.', (insecureInge InsecureIngest: insecureIngest, }); }); + +test.each([ivs.ContainerFormat.FRAGMENTED_MP4, ivs.ContainerFormat.TS])('channel when containerFormat is set to %s.', (containerFormat) => { + new ivs.Channel(stack, 'Channel', { + type: ivs.ChannelType.STANDARD, + containerFormat, + }); + + Template.fromStack(stack).hasResourceProperties('AWS::IVS::Channel', { + Type: 'STANDARD', + ContainerFormat: containerFormat, + }); +}); + +test.each([ + [ivs.MaximumResolution.FULL_HD, ivs.Policy.ALLOW], + [ivs.MaximumResolution.HD, ivs.Policy.REQUIRE], + [ivs.MaximumResolution.SD, ivs.Policy.ALLOW], +])('create channel when multitrackInputConfiguration is specified, maximumResolution: %s, policy: %s.', (maximumResolution, policy) => { + new ivs.Channel(stack, 'Channel', { + type: ivs.ChannelType.STANDARD, + containerFormat: ivs.ContainerFormat.FRAGMENTED_MP4, + multitrackInputConfiguration: { + maximumResolution, + policy, + }, + }); + + Template.fromStack(stack).hasResourceProperties('AWS::IVS::Channel', { + Type: 'STANDARD', + ContainerFormat: 'FRAGMENTED_MP4', + MultitrackInputConfiguration: { + Enabled: true, + MaximumResolution: maximumResolution, + Policy: policy, + }, + }); +}); + +test('create channel when multitrackInputConfiguration is specified without containerFormat', () => { + new ivs.Channel(stack, 'Channel', { + type: ivs.ChannelType.STANDARD, + multitrackInputConfiguration: { + maximumResolution: ivs.MaximumResolution.HD, + policy: ivs.Policy.ALLOW, + }, + }); + + Template.fromStack(stack).hasResourceProperties('AWS::IVS::Channel', { + Type: 'STANDARD', + ContainerFormat: 'FRAGMENTED_MP4', + MultitrackInputConfiguration: { + Enabled: true, + MaximumResolution: ivs.MaximumResolution.HD, + Policy: ivs.Policy.ALLOW, + }, + }); +}); + +test.each([ + ivs.ChannelType.ADVANCED_HD, + ivs.ChannelType.ADVANCED_SD, + ivs.ChannelType.BASIC, +])('throws an error when `multitrackInputConfiguration` is specified with %s ', (type) => { + expect(() => new ivs.Channel(stack, 'Channel', { + type, + containerFormat: ivs.ContainerFormat.FRAGMENTED_MP4, + multitrackInputConfiguration: { + maximumResolution: ivs.MaximumResolution.SD, + policy: ivs.Policy.ALLOW, + }, + })).toThrow(`\`multitrackInputConfiguration\` is only supported for \`ChannelType.STANDARD\`, got: ${type}.`); +}); + +test('throws an error when `multitrackInputConfiguration` is specified with `ContainerFormat.TS`', () => { + expect(() => new ivs.Channel(stack, 'Channel', { + type: ivs.ChannelType.STANDARD, + containerFormat: ivs.ContainerFormat.TS, + multitrackInputConfiguration: { + maximumResolution: ivs.MaximumResolution.SD, + policy: ivs.Policy.ALLOW, + }, + })).toThrow(`\`containerFormat\` must be set to \`ContainerFormat.FRAGMENTED_MP4\` when \`multitrackInputConfiguration\` is specified, got: ${ivs.ContainerFormat.TS}.`); +});