Skip to content

Commit 86ecc86

Browse files
committed
refactor: Better field name for audio profile
1 parent f5b6d9f commit 86ecc86

File tree

5 files changed

+8
-8
lines changed

5 files changed

+8
-8
lines changed

Diff for: internal/model/input.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ type Input struct {
1414

1515
type AudioProfile struct {
1616
InputID uuid.UUID
17-
Rate int `json:"rate"`
17+
Bitrate int `json:"bitrate"`
1818
Codec string `json:"codec"`
1919
}
2020

Diff for: internal/service/input_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ func TestGetInput(t *testing.T) {
4646
Name: "big buck bunny",
4747
Format: "rtmp",
4848
VideoProfiles: []model.VideoProfile{{Codec: "h264", Bitrate: 1000}},
49-
AudioProfiles: []model.AudioProfile{{Codec: "aac", Rate: 128}},
49+
AudioProfiles: []model.AudioProfile{{Codec: "aac", Bitrate: 128}},
5050
}
5151

5252
mockStore.EXPECT().GetInput(ctx, expectedID).Return(expectedInput, nil).Times(1)
@@ -62,7 +62,7 @@ func TestGetInput(t *testing.T) {
6262
assert.Equal(t, "h264", result.VideoProfiles[0].Codec)
6363
assert.Equal(t, 1000, result.VideoProfiles[0].Bitrate)
6464
assert.Equal(t, "aac", result.AudioProfiles[0].Codec)
65-
assert.Equal(t, 128, result.AudioProfiles[0].Rate)
65+
assert.Equal(t, 128, result.AudioProfiles[0].Bitrate)
6666
}
6767

6868
func TestDeleteInput(t *testing.T) {

Diff for: internal/task/command.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@ func NewDefaultCommandConfig() *CommandConfig {
6161
//nolint:gomnd // values are self explanatory
6262
DefaultAudioProfiles: []model.AudioProfile{
6363
{
64-
Codec: defaultAudioCodec,
65-
Rate: 128,
64+
Codec: defaultAudioCodec,
65+
Bitrate: 128,
6666
},
6767
},
6868
}
@@ -120,7 +120,7 @@ func (g *GPACCommand) Execute() error {
120120
}
121121

122122
for _, a := range g.Input.AudioProfiles {
123-
args = append(args, "@@", fmt.Sprintf("c=aac:b=%dk", a.Rate))
123+
args = append(args, "@@", fmt.Sprintf("c=aac:b=%dk", a.Bitrate))
124124
}
125125

126126
// connect filters

Diff for: internal/task/command_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import (
1111
func TestGPACCommandExecute(t *testing.T) {
1212
input := model.Input{
1313
VideoProfiles: []model.VideoProfile{{Bitrate: 1000}, {Bitrate: 2000}},
14-
AudioProfiles: []model.AudioProfile{{Rate: 128}},
14+
AudioProfiles: []model.AudioProfile{{Bitrate: 128}},
1515
}
1616
cmd := task.NewGPACCommand("1234", "rtmp://localhost", "/output", input)
1717

Diff for: schema.sql

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ CREATE TABLE inputs (
77
CREATE TABLE audio_profiles (
88
id SERIAL PRIMARY KEY,
99
input_id UUID NOT NULL,
10-
rate INT,
10+
bitrate INT,
1111
codec TEXT NOT NULL,
1212
FOREIGN KEY (input_id) REFERENCES inputs(id)
1313
);

0 commit comments

Comments
 (0)