Skip to content

Commit

Permalink
refactor: Better field name for audio profile
Browse files Browse the repository at this point in the history
  • Loading branch information
mauricioabreu committed Apr 22, 2024
1 parent f5b6d9f commit 86ecc86
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion internal/model/input.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ type Input struct {

type AudioProfile struct {
InputID uuid.UUID
Rate int `json:"rate"`
Bitrate int `json:"bitrate"`
Codec string `json:"codec"`
}

Expand Down
4 changes: 2 additions & 2 deletions internal/service/input_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func TestGetInput(t *testing.T) {
Name: "big buck bunny",
Format: "rtmp",
VideoProfiles: []model.VideoProfile{{Codec: "h264", Bitrate: 1000}},
AudioProfiles: []model.AudioProfile{{Codec: "aac", Rate: 128}},
AudioProfiles: []model.AudioProfile{{Codec: "aac", Bitrate: 128}},
}

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

func TestDeleteInput(t *testing.T) {
Expand Down
6 changes: 3 additions & 3 deletions internal/task/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ func NewDefaultCommandConfig() *CommandConfig {
//nolint:gomnd // values are self explanatory
DefaultAudioProfiles: []model.AudioProfile{
{
Codec: defaultAudioCodec,
Rate: 128,
Codec: defaultAudioCodec,
Bitrate: 128,
},
},
}
Expand Down Expand Up @@ -120,7 +120,7 @@ func (g *GPACCommand) Execute() error {
}

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

// connect filters
Expand Down
2 changes: 1 addition & 1 deletion internal/task/command_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
func TestGPACCommandExecute(t *testing.T) {
input := model.Input{
VideoProfiles: []model.VideoProfile{{Bitrate: 1000}, {Bitrate: 2000}},
AudioProfiles: []model.AudioProfile{{Rate: 128}},
AudioProfiles: []model.AudioProfile{{Bitrate: 128}},
}
cmd := task.NewGPACCommand("1234", "rtmp://localhost", "/output", input)

Expand Down
2 changes: 1 addition & 1 deletion schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ CREATE TABLE inputs (
CREATE TABLE audio_profiles (
id SERIAL PRIMARY KEY,
input_id UUID NOT NULL,
rate INT,
bitrate INT,
codec TEXT NOT NULL,
FOREIGN KEY (input_id) REFERENCES inputs(id)
);
Expand Down

0 comments on commit 86ecc86

Please sign in to comment.