Skip to content

Commit

Permalink
feat(ivs-alpha): support advanced channel type (#30086)
Browse files Browse the repository at this point in the history
### Issue # (if applicable)

Closes #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*
  • Loading branch information
mazyu36 committed May 24, 2024
1 parent 58b024d commit 544e54a
Show file tree
Hide file tree
Showing 13 changed files with 32,871 additions and 10 deletions.
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

0 comments on commit 544e54a

Please sign in to comment.