Skip to content

Commit

Permalink
feat(ivs): support Multitrack Video (#33370)
Browse files Browse the repository at this point in the history
### Issue # (if applicable)
N/A

### Reason for this change
To support Multitrack video features.



### Description of changes
Add following properties:

* containerFormat
* multitrackInputConfiguration




### Describe any new or updated permissions being added

Nothing.




### Description of how you validated changes

Add unit tests and an integ test.



### Checklist
- [x] My code adheres to the [CONTRIBUTING GUIDE](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) and [DESIGN GUIDELINES](https://github.com/aws/aws-cdk/blob/main/docs/DESIGN_GUIDELINES.md)

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
  • Loading branch information
mazyu36 authored Feb 13, 2025
1 parent ede5842 commit 29d1945
Show file tree
Hide file tree
Showing 12 changed files with 613 additions and 1 deletion.
20 changes: 20 additions & 0 deletions packages/@aws-cdk/aws-ivs-alpha/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
107 changes: 106 additions & 1 deletion packages/@aws-cdk/aws-ivs-alpha/lib/channel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
/**
Expand Down Expand Up @@ -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.
*
Expand All @@ -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
Expand All @@ -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
*/
Expand Down Expand Up @@ -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,
Expand All @@ -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;
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -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<String>",
"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."
}
]
}
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 29d1945

Please sign in to comment.