-
Notifications
You must be signed in to change notification settings - Fork 4k
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
feat(ivs): support Multitrack Video #33370
Changes from all commits
338bad3
f180842
bd045de
12393ae
bfd490d
d6b72a3
02791bb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There are two configuration patterns for
I felt that implementing these patterns in validation would become complex, and there's no real need to explicitly set There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. agree with this |
||
maximumResolution: props.multitrackInputConfiguration.maximumResolution, | ||
policy: props.multitrackInputConfiguration.policy, | ||
} | ||
: undefined, | ||
}); | ||
|
||
this.channelArn = resource.attrArn; | ||
|
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When using multitrack video, the containerFormat needs to be set to fMP4.
Therefore, when multitrackInputConfiguration is set but containerFormat is not specified, I configured it to automatically set fMP4.
While I considered making it a validation error when containerFormat is not set, I decided this approach would be more user-friendly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
agree with this approach 👍