Skip to content

Commit

Permalink
Merge pull request #29807 from tv2/b-include_bitrate_and_sample_rate_…
Browse files Browse the repository at this point in the history
…for_aac

Fix casting of bitrate and sample rate for aac settings
  • Loading branch information
johnsonaj authored Mar 14, 2023
2 parents 0c616dd + 2289e36 commit bd40a5b
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
3 changes: 3 additions & 0 deletions .changelog/29807.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
resource/aws_medialive_channel: Fix setting of `bitrate` and `sample_rate` for `aac_settings`.
```
12 changes: 6 additions & 6 deletions internal/service/medialive/channel_encoder_settings_schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -2539,8 +2539,8 @@ func expandAudioDescriptionsCodecSettingsAacSettings(tfList []interface{}) *type
m := tfList[0].(map[string]interface{})

var out types.AacSettings
if v, ok := m["bitrate"].(float32); ok {
out.Bitrate = float64(v)
if v, ok := m["bitrate"].(float64); ok {
out.Bitrate = v
}
if v, ok := m["coding_mode"].(string); ok && v != "" {
out.CodingMode = types.AacCodingMode(v)
Expand All @@ -2557,8 +2557,8 @@ func expandAudioDescriptionsCodecSettingsAacSettings(tfList []interface{}) *type
if v, ok := m["raw_format"].(string); ok && v != "" {
out.RawFormat = types.AacRawFormat(v)
}
if v, ok := m["sample_rate"].(float32); ok {
out.SampleRate = float64(v)
if v, ok := m["sample_rate"].(float64); ok {
out.SampleRate = v
}
if v, ok := m["spec"].(string); ok && v != "" {
out.Spec = types.AacSpec(v)
Expand Down Expand Up @@ -5535,13 +5535,13 @@ func flattenCodecSettingsAacSettings(in *types.AacSettings) []interface{} {
}

m := map[string]interface{}{
"bitrate": float32(in.Bitrate),
"bitrate": in.Bitrate,
"coding_mode": string(in.CodingMode),
"input_type": string(in.InputType),
"profile": string(in.Profile),
"rate_control_mode": string(in.RateControlMode),
"raw_format": string(in.RawFormat),
"sample_rate": float32(in.SampleRate),
"sample_rate": in.SampleRate,
"spec": string(in.Spec),
"vbr_quality": string(in.VbrQuality),
}
Expand Down
4 changes: 4 additions & 0 deletions internal/service/medialive/channel_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,8 @@ func TestAccMediaLiveChannel_audioDescriptions_codecSettings(t *testing.T) {
"audio_selector_name": rName,
"name": rName,
"codec_settings.0.aac_settings.0.rate_control_mode": string(types.AacRateControlModeCbr),
"codec_settings.0.aac_settings.0.bitrate": "192000",
"codec_settings.0.aac_settings.0.sample_rate": "48000",
}),
resource.TestCheckTypeSetElemNestedAttrs(resourceName, "encoder_settings.0.video_descriptions.*", map[string]string{
"name": "test-video-name",
Expand Down Expand Up @@ -997,6 +999,8 @@ resource "aws_medialive_channel" "test" {
codec_settings {
aac_settings {
rate_control_mode = "CBR"
bitrate = 192000
sample_rate = 48000
}
}
}
Expand Down

0 comments on commit bd40a5b

Please sign in to comment.