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

Fixed buf_fill_pct and gop_size in h264_settings #30063

Merged
merged 5 commits into from
Mar 23, 2023
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
3 changes: 3 additions & 0 deletions .changelog/30063.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
resource/aws_medialive_channel: Fix type casting for `h264_settings` in `video_descriptions`
```
Original file line number Diff line number Diff line change
Expand Up @@ -4316,8 +4316,8 @@ func expandsVideoDescriptionsCodecSettingsH264Settings(tfList []interface{}) *ty
if v, ok := m["gop_num_b_frames"].(int); ok {
out.GopNumBFrames = int32(v)
}
if v, ok := m["gop_size"].(float32); ok {
out.GopSize = float64(v)
if v, ok := m["gop_size"].(float64); ok {
out.GopSize = v
}
if v, ok := m["gop_size_units"].(string); ok && v != "" {
out.GopSizeUnits = types.H264GopSizeUnits(v)
Expand Down Expand Up @@ -5396,6 +5396,7 @@ func flattenCodecSettingsH264Settings(in *types.H264Settings) []interface{} {
"adaptive_quantization": string(in.AdaptiveQuantization),
"afd_signaling": string(in.AfdSignaling),
"bitrate": int(in.Bitrate),
"buf_fill_pct": int(in.BufFillPct),
"buf_size": int(in.BufSize),
"color_metadata": string(in.ColorMetadata),
"entropy_encoding": string(in.EntropyEncoding),
Expand All @@ -5409,7 +5410,7 @@ func flattenCodecSettingsH264Settings(in *types.H264Settings) []interface{} {
"gop_b_reference": string(in.GopBReference),
"gop_closed_cadence": int(in.GopClosedCadence),
"gop_num_b_frames": int(in.GopNumBFrames),
"gop_size": float32(in.GopSize),
"gop_size": in.GopSize,
"gop_size_units": string(in.GopSizeUnits),
"level": string(in.Level),
"look_ahead_rate_control": string(in.LookAheadRateControl),
Expand Down
229 changes: 229 additions & 0 deletions internal/service/medialive/channel_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,109 @@ func TestAccMediaLiveChannel_audioDescriptions_codecSettings(t *testing.T) {
})
}

func TestAccMediaLiveChannel_videoDescriptions_codecSettings_h264Settings(t *testing.T) {
ctx := acctest.Context(t)
if testing.Short() {
t.Skip("skipping long-running test in short mode")
}

var channel medialive.DescribeChannelOutput
rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix)
resourceName := "aws_medialive_channel.test"

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() {
acctest.PreCheck(ctx, t)
acctest.PreCheckPartitionHasService(t, names.MediaLiveEndpointID)
testAccChannelsPreCheck(ctx, t)
},
ErrorCheck: acctest.ErrorCheck(t, names.MediaLiveEndpointID),
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories,
CheckDestroy: testAccCheckChannelDestroy(ctx),
Steps: []resource.TestStep{
{
Config: testAccChannelConfig_videoDescriptionCodecSettingsH264Settings(rName),
Check: resource.ComposeTestCheckFunc(
testAccCheckChannelExists(ctx, resourceName, &channel),
resource.TestCheckResourceAttrSet(resourceName, "channel_id"),
resource.TestCheckResourceAttr(resourceName, "channel_class", "STANDARD"),
resource.TestCheckResourceAttr(resourceName, "name", rName),
resource.TestCheckResourceAttrSet(resourceName, "role_arn"),
resource.TestCheckResourceAttr(resourceName, "input_specification.0.codec", "AVC"),
resource.TestCheckResourceAttr(resourceName, "input_specification.0.input_resolution", "HD"),
resource.TestCheckResourceAttr(resourceName, "input_specification.0.maximum_bitrate", "MAX_20_MBPS"),
resource.TestCheckTypeSetElemNestedAttrs(resourceName, "input_attachments.*", map[string]string{
"input_attachment_name": "example-input1",
}),
resource.TestCheckTypeSetElemNestedAttrs(resourceName, "destinations.*", map[string]string{
"id": rName,
}),
resource.TestCheckResourceAttr(resourceName, "encoder_settings.0.timecode_config.0.source", "EMBEDDED"),
resource.TestCheckTypeSetElemNestedAttrs(resourceName, "encoder_settings.0.audio_descriptions.*", map[string]string{
"audio_selector_name": rName,
"name": rName,
}),
resource.TestCheckTypeSetElemNestedAttrs(resourceName, "encoder_settings.0.video_descriptions.*", map[string]string{
"name": "test-video-name",
"respond_to_afd": "NONE",
"scaling_behavior": "DEFAULT",
"sharpness": "100",
"height": "720",
"width": "1280",
}),
resource.TestCheckTypeSetElemNestedAttrs(resourceName, "encoder_settings.0.video_descriptions.0.codec_settings.0.h264_settings.*", map[string]string{
"adaptive_quantization": "LOW",
"afd_signaling": "NONE",
"bitrate": "5400000",
"buf_fill_pct": "90",
"buf_size": "10800000",
"color_metadata": "IGNORE",
"entropy_encoding": "CABAC",
"filter_settings": "",
"fixed_afd": "",
"flicker_aq": "ENABLED",
"force_field_pictures": "DISABLED",
"framerate_control": "SPECIFIED",
"framerate_denominator": "1",
"framerate_numerator": "50",
"gop_b_reference": "DISABLED",
"gop_closed_cadence": "1",
"gop_num_b_frames": "1",
"gop_size": "1.92",
"gop_size_units": "SECONDS",
"level": "H264_LEVEL_AUTO",
"look_ahead_rate_control": "HIGH",
"max_bitrate": "0",
"min_i_interval": "0",
"num_ref_frames": "3",
"par_control": "INITIALIZE_FROM_SOURCE",
"par_denominator": "0",
"par_numerator": "0",
"profile": "HIGH",
"quality_level": "",
"qvbr_quality_level": "0",
"rate_control_mode": "CBR",
"scan_type": "PROGRESSIVE",
"scene_change_detect": "DISABLED",
"slices": "1",
"spatial_aq": "0",
"subgop_length": "FIXED",
"syntax": "DEFAULT",
"temporal_aq": "ENABLED",
"timecode_insertion": "PIC_TIMING_SEI",
}),
),
},
{
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"start_channel"},
},
},
})
}

func TestAccMediaLiveChannel_hls(t *testing.T) {
ctx := acctest.Context(t)
if testing.Short() {
Expand Down Expand Up @@ -1191,6 +1294,132 @@ resource "aws_medialive_channel" "test" {
`, rName))
}

func testAccChannelConfig_videoDescriptionCodecSettingsH264Settings(rName string) string {
return acctest.ConfigCompose(
testAccChannelBaseConfig(rName),
testAccChannelBaseS3Config(rName),
testAccChannelBaseMultiplexConfig(rName),
fmt.Sprintf(`
resource "aws_medialive_channel" "test" {
name = %[1]q
channel_class = "STANDARD"
role_arn = aws_iam_role.test.arn

input_specification {
codec = "AVC"
input_resolution = "HD"
maximum_bitrate = "MAX_20_MBPS"
}

input_attachments {
input_attachment_name = "example-input1"
input_id = aws_medialive_input.test.id
}

destinations {
id = %[1]q

settings {
url = "s3://${aws_s3_bucket.test1.id}/test1"
}

settings {
url = "s3://${aws_s3_bucket.test2.id}/test2"
}
}

encoder_settings {
timecode_config {
source = "EMBEDDED"
}

audio_descriptions {
audio_selector_name = %[1]q
name = %[1]q
codec_settings {
aac_settings {
rate_control_mode = "CBR"
}
}
}

video_descriptions {
name = "test-video-name"
respond_to_afd = "NONE"
sharpness = 100
scaling_behavior = "DEFAULT"
width = 1280
height = 720
codec_settings {
h264_settings {
afd_signaling = "NONE"
color_metadata = "IGNORE"
adaptive_quantization = "LOW"
bitrate = "5400000"
buf_size = "10800000"
buf_fill_pct = "90"
entropy_encoding = "CABAC"
flicker_aq = "ENABLED"
force_field_pictures = "DISABLED"
framerate_control = "SPECIFIED"
framerate_numerator = "50"
framerate_denominator = "1"
gop_b_reference = "DISABLED"
gop_closed_cadence = "1"
gop_num_b_frames = "1"
gop_size = "1.92"
gop_size_units = "SECONDS"
subgop_length = "FIXED"
scan_type = "PROGRESSIVE"
level = "H264_LEVEL_AUTO"
look_ahead_rate_control = "HIGH"
num_ref_frames = "3"
par_control = "INITIALIZE_FROM_SOURCE"
profile = "HIGH"
rate_control_mode = "CBR"
syntax = "DEFAULT"
scene_change_detect = "ENABLED"
slices = "1"
spatial_aq = "ENABLED"
temporal_aq = "ENABLED"
timecode_insertion = "PIC_TIMING_SEI"
}
}
}

output_groups {
output_group_settings {
archive_group_settings {
destination {
destination_ref_id = %[1]q
}
}
}

outputs {
output_name = "test-output-name"
video_description_name = "test-video-name"
audio_description_names = [%[1]q]
output_settings {
archive_output_settings {
name_modifier = "_1"
extension = "m2ts"
container_settings {
m2ts_settings {
audio_buffer_model = "ATSC"
buffer_model = "MULTIPLEX"
rate_mode = "CBR"
}
}
}
}
}
}
}
}
`, rName))
}

func testAccChannelConfig_hls(rName string) string {
return acctest.ConfigCompose(
testAccChannelBaseConfig(rName),
Expand Down