Skip to content

Commit 544e54a

Browse files
authoredMay 24, 2024
feat(ivs-alpha): support advanced channel type (aws#30086)
### Issue # (if applicable) Closes aws#30075 ### Reason for this change As described in the issue. ### Description of changes * Add `ADVANCED_HD` and `ADVANCED_SD` to the `ivs.ChannelType`. * Add `preset` property to the Channel Construct. Additionally, validation has been implemented to allow setting the preset property only when using the Advanced channel type ### Description of how you validated changes Add both unit tests and integ tests. ### 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*
1 parent 58b024d commit 544e54a

File tree

13 files changed

+32871
-10
lines changed

13 files changed

+32871
-10
lines changed
 

‎packages/@aws-cdk/aws-ivs-alpha/README.md

+17-2
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,23 @@ You can create a channel
3939
const myChannel = new ivs.Channel(this, 'Channel');
4040
```
4141

42+
You can use Advanced Channel type by setting the `type` property to
43+
`ivs.ChannelType.ADVANCED_HD` or `ivs.ChannelType.ADVANCED_SD`.
44+
45+
Additionally, when using the Advanced Channel type, you can set
46+
the `preset` property to `ivs.Preset.CONSTRAINED_BANDWIDTH_DELIVERY`
47+
or `ivs.Preset.HIGHER_BANDWIDTH_DELIVERY`.
48+
49+
For more information, see [Amazon IVS Streaming Configuration](https://docs.aws.amazon.com/ivs/latest/LowLatencyUserGuide/streaming-config.html).
50+
51+
```ts
52+
const myChannel = new ivs.Channel(this, 'myChannel', {
53+
type: ivs.ChannelType.ADVANCED_HD,
54+
preset: ivs.Preset.CONSTRAINED_BANDWIDTH_DELIVERY,
55+
});
56+
```
57+
58+
4259
### Importing an existing channel
4360

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

‎packages/@aws-cdk/aws-ivs-alpha/lib/channel.ts

+55-7
Original file line numberDiff line numberDiff line change
@@ -53,22 +53,53 @@ export enum LatencyMode {
5353
/**
5454
* The channel type, which determines the allowable resolution and bitrate.
5555
* If you exceed the allowable resolution or bitrate, the stream probably will disconnect immediately.
56+
*
57+
* @see https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-ivs-channel.html
5658
*/
5759
export enum ChannelType {
5860
/**
59-
* Multiple qualities are generated from the original input, to automatically give viewers the best experience for
60-
* their devices and network conditions.
61-
*
62-
* @see https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-ivs-channel.html
61+
* Multiple qualities are generated from the original input, to automatically give viewers the best experience for their devices and network conditions.
62+
* 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.
63+
* Audio is transcoded only for renditions 360p and below; above that, audio is passed through.
6364
*/
6465
STANDARD = 'STANDARD',
6566

6667
/**
67-
* delivers the original input to viewers. The viewer’s video-quality choice is limited to the original input.
68-
*
69-
* @see https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-ivs-channel.html
68+
* Delivers the original input to viewers. The viewer’s video-quality choice is limited to the original input.
7069
*/
7170
BASIC = 'BASIC',
71+
72+
/**
73+
* Multiple qualities are generated from the original input, to automatically give viewers the best experience for their devices and network conditions.
74+
* Input resolution can be up to 1080p and bitrate can be up to 8.5 Mbps; output is capped at SD quality (480p).
75+
* Audio for all renditions is transcoded, and an audio-only rendition is available.
76+
*/
77+
ADVANCED_SD = 'ADVANCED_SD',
78+
79+
/**
80+
* Multiple qualities are generated from the original input, to automatically give viewers the best experience for their devices and network conditions.
81+
* Input resolution can be up to 1080p and bitrate can be up to 8.5 Mbps; output is capped at HD quality (720p).
82+
* Audio for all renditions is transcoded, and an audio-only rendition is available.
83+
*/
84+
ADVANCED_HD = 'ADVANCED_HD',
85+
}
86+
87+
/**
88+
* An optional transcode preset for the channel. This is selectable only for ADVANCED_HD and ADVANCED_SD channel types.
89+
*
90+
* @see https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-ivs-channel.html
91+
*/
92+
export enum Preset {
93+
/**
94+
* 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).
95+
*/
96+
CONSTRAINED_BANDWIDTH_DELIVERY = 'CONSTRAINED_BANDWIDTH_DELIVERY',
97+
98+
/**
99+
* 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).
100+
*/
101+
HIGHER_BANDWIDTH_DELIVERY = 'HIGHER_BANDWIDTH_DELIVERY',
102+
72103
}
73104

74105
/**
@@ -107,6 +138,14 @@ export interface ChannelProps {
107138
* @default ChannelType.STANDARD
108139
*/
109140
readonly type?: ChannelType;
141+
142+
/**
143+
* An optional transcode preset for the channel. Can be used for ADVANCED_HD and ADVANCED_SD channel types.
144+
* When LOW or STANDARD is used, the preset will be overridden and set to none regardless of the value provided.
145+
*
146+
* @default - Preset.HIGHER_BANDWIDTH_DELIVERY if channelType is ADVANCED_SD or ADVANCED_HD, none otherwise
147+
*/
148+
readonly preset?: Preset;
110149
}
111150

112151
/**
@@ -162,11 +201,20 @@ export class Channel extends ChannelBase {
162201
throw new Error(`channelName must contain only numbers, letters, hyphens and underscores, got: '${this.physicalName}'`);
163202
}
164203

204+
let preset;
205+
206+
if (props.type && [ChannelType.STANDARD, ChannelType.BASIC].includes(props.type) && props.preset) {
207+
preset = '';
208+
} else {
209+
preset = props.preset;
210+
}
211+
165212
const resource = new CfnChannel(this, 'Resource', {
166213
authorized: props.authorized,
167214
latencyMode: props.latencyMode,
168215
name: this.physicalName,
169216
type: props.type,
217+
preset,
170218
});
171219

172220
this.channelArn = resource.attrArn;

0 commit comments

Comments
 (0)