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

feat(ivs-alpha): support advanced channel type #30086

Merged
merged 16 commits into from
May 24, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
20 changes: 18 additions & 2 deletions packages/@aws-cdk/aws-ivs-alpha/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,24 @@ You can create a channel
const myChannel = new ivs.Channel(this, 'Channel');
```

You can use Advanced Channel type by setting the `type` property to
`ivs.ChannelType.ADVANCED_HD` or `ivs.ChannelType.ADVANCED_SD`.

Additionally, when using the Advanced Channel type, you can set
the `preset` property to `ivs.Preset.CONSTRAINED_BANDWIDTH_DELIVERY`
or `ivs.Preset.HIGHER_BANDWIDTH_DELIVERY`.
If you don't specify the `preset`, `ivs.Preset.CONSTRAINED_BANDWIDTH_DELIVERY` is set by default.
mazyu36 marked this conversation as resolved.
Show resolved Hide resolved

For more information, see [Amazon IVS Streaming Configuration](See also: https://docs.aws.amazon.com/ivs/latest/LowLatencyUserGuide/streaming-config.html).
mazyu36 marked this conversation as resolved.
Show resolved Hide resolved

```ts
const myChannel = new ivs.Channel(this, 'myChannel', {
type: ivs.ChannelType.ADVANCED_HD,
preset: ivs.Preset.CONSTRAINED_BANDWIDTH_DELIVERY,
});
```


### Importing an existing channel

You can reference an existing channel, for example, if you need to create a
Expand Down Expand Up @@ -87,5 +105,3 @@ const myChannel = new ivs.Channel(this, 'Channel', {
authorized: true, // default value is false
});
```


59 changes: 57 additions & 2 deletions packages/@aws-cdk/aws-ivs-alpha/lib/channel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,9 @@ export enum LatencyMode {
*/
export enum ChannelType {
/**
* Multiple qualities are generated from the original input, to automatically give viewers the best experience for
* their devices and network conditions.
* Multiple qualities are generated from the original input, to automatically give viewers the best experience for their devices and network conditions.
* Transcoding allows higher playback quality across a range of download speeds. Resolution can be up to 1080p and bitrate can be up to 8.5 Mbps.
* Audio is transcoded only for renditions 360p and below; above that, audio is passed through.
*
* @see https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-ivs-channel.html
*/
Expand All @@ -69,6 +70,42 @@ export enum ChannelType {
* @see https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-ivs-channel.html
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These @see tags should be moved to the enum TSDoc, no need to repeat them if they're pointing to the same link

Copy link
Contributor Author

@mazyu36 mazyu36 May 7, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nmussy
Thank you for your review!
I moved @see to the enum TSDoc.

*/
BASIC = 'BASIC',

/**
* Multiple qualities are generated from the original input, to automatically give viewers the best experience for their devices and network conditions.
* Input resolution can be up to 1080p and bitrate can be up to 8.5 Mbps; output is capped at SD quality (480p).
* Audio for all renditions is transcoded, and an audio-only rendition is available.
*
* @see https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-ivs-channel.html
*/
ADVANCED_SD = 'ADVANCED_SD',

/**
* Multiple qualities are generated from the original input, to automatically give viewers the best experience for their devices and network conditions.
* Input resolution can be up to 1080p and bitrate can be up to 8.5 Mbps; output is capped at HD quality (720p).
* Audio for all renditions is transcoded, and an audio-only rendition is available.
*
* @see https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-ivs-channel.html
*/
ADVANCED_HD = 'ADVANCED_HD',
}

/**
* An optional transcode preset for the channel. This is selectable only for ADVANCED_HD and ADVANCED_SD channel types.
*/
export enum Preset {
/**
* Use a lower bitrate than STANDARD for each quality level. Use it if you have low download bandwidth and/or simple video content (e.g., talking heads).
* @see https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-ivs-channel.html
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again, @see should be moved to the Preset TSDoc

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Likewise, I moved to the enum docs.

*/
CONSTRAINED_BANDWIDTH_DELIVERY = 'CONSTRAINED_BANDWIDTH_DELIVERY',

/**
* Use a higher bitrate for each quality level. Use it if you have high download bandwidth and/or complex video content (e.g., flashes and quick scene changes).
* @see https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-ivs-channel.html
*/
HIGHER_BANDWIDTH_DELIVERY = 'HIGHER_BANDWIDTH_DELIVERY',

}

/**
Expand Down Expand Up @@ -107,6 +144,13 @@ export interface ChannelProps {
* @default ChannelType.STANDARD
*/
readonly type?: ChannelType;

/**
* An optional transcode preset for the channel. Can be used for ADVANCED_HD and ADVANCED_SD channel types.
*
* @default - Preset.HIGHER_BANDWIDTH_DELIVERY when channel type is ADVANCED_SD or ADVANCED_HD.
mazyu36 marked this conversation as resolved.
Show resolved Hide resolved
*/
readonly preset?: Preset;
}

/**
Expand Down Expand Up @@ -162,11 +206,22 @@ export class Channel extends ChannelBase {
throw new Error(`channelName must contain only numbers, letters, hyphens and underscores, got: '${this.physicalName}'`);
}

if ((props.type === ChannelType.STANDARD || props.type === ChannelType.BASIC) && props.preset !== undefined) {
mazyu36 marked this conversation as resolved.
Show resolved Hide resolved
throw new Error('preset cannot be used when STANDARD or BASIC channel type');
shikha372 marked this conversation as resolved.
Show resolved Hide resolved
}

let preset = undefined;

if (props.type === ChannelType.ADVANCED_HD || props.type === ChannelType.ADVANCED_SD) {
preset = props.preset || Preset.HIGHER_BANDWIDTH_DELIVERY;
}
mazyu36 marked this conversation as resolved.
Show resolved Hide resolved

const resource = new CfnChannel(this, 'Resource', {
authorized: props.authorized,
latencyMode: props.latencyMode,
name: this.physicalName,
type: props.type,
preset: preset,
mazyu36 marked this conversation as resolved.
Show resolved Hide resolved
});

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,54 @@
{
"Resources": {
"AdvancedChannelWithoutPresetSetting56CDB01B": {
"Type": "AWS::IVS::Channel",
"Properties": {
"Name": "aws-cdk-ivsAdvancedChannelWithoutPresetSettingDB3FDF65",
"Preset": "HIGHER_BANDWIDTH_DELIVERY",
"Type": "ADVANCED_SD"
}
},
"AdvancedChannelWithPresetSetting5981FCA9": {
"Type": "AWS::IVS::Channel",
"Properties": {
"Name": "aws-cdk-ivsAdvancedChannelWithPresetSettingA6588A59",
"Preset": "CONSTRAINED_BANDWIDTH_DELIVERY",
"Type": "ADVANCED_HD"
}
}
},
"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.

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

Loading