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 all 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
19 changes: 17 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,23 @@ 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`.

For more information, see [Amazon IVS Streaming Configuration](https://docs.aws.amazon.com/ivs/latest/LowLatencyUserGuide/streaming-config.html).

```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 +104,3 @@ const myChannel = new ivs.Channel(this, 'Channel', {
authorized: true, // default value is false
});
```


62 changes: 55 additions & 7 deletions packages/@aws-cdk/aws-ivs-alpha/lib/channel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,22 +53,53 @@ export enum LatencyMode {
/**
* The channel type, which determines the allowable resolution and bitrate.
* If you exceed the allowable resolution or bitrate, the stream probably will disconnect immediately.
*
* @see https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-ivs-channel.html
*/
export enum ChannelType {
/**
* Multiple qualities are generated from the original input, to automatically give viewers the best experience for
* their devices and network conditions.
*
* @see https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-ivs-channel.html
* 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.
*/
STANDARD = 'STANDARD',

/**
* delivers the original input to viewers. The viewer’s video-quality choice is limited to the original input.
*
* @see https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-ivs-channel.html
* Delivers the original input to viewers. The viewer’s video-quality choice is limited to the original input.
*/
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.
*/
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.
*/
ADVANCED_HD = 'ADVANCED_HD',
}

/**
* An optional transcode preset for the channel. This is selectable only for ADVANCED_HD and ADVANCED_SD channel types.
*
* @see https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-ivs-channel.html
*/
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).
*/
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).
*/
HIGHER_BANDWIDTH_DELIVERY = 'HIGHER_BANDWIDTH_DELIVERY',

}

/**
Expand Down Expand Up @@ -107,6 +138,14 @@ 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.
* When LOW or STANDARD is used, the preset will be overridden and set to none regardless of the value provided.
*
* @default - Preset.HIGHER_BANDWIDTH_DELIVERY if channelType is ADVANCED_SD or ADVANCED_HD, none otherwise
*/
readonly preset?: Preset;
}

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

let preset;

if (props.type && [ChannelType.STANDARD, ChannelType.BASIC].includes(props.type) && props.preset) {
preset = '';
} else {
preset = props.preset;
}

const resource = new CfnChannel(this, 'Resource', {
authorized: props.authorized,
latencyMode: props.latencyMode,
name: this.physicalName,
type: props.type,
preset,
});

this.channelArn = resource.attrArn;
Expand Down
Loading