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

core: Rename 'InArray' to 'HasCapabilities' #3118

Merged
merged 1 commit into from
Aug 7, 2024
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
2 changes: 1 addition & 1 deletion core/capabilities.go
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,7 @@ func CapabilityToName(capability Capability) (string, error) {
return capName, nil
}

func InArray(capability Capability, caps []Capability) bool {
func HasCapability(caps []Capability, capability Capability) bool {
for _, c := range caps {
if capability == c {
return true
Expand Down
20 changes: 10 additions & 10 deletions core/capabilities_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,22 +148,22 @@ func TestCapability_TranscoderCapabilities(t *testing.T) {
if devicesAvailable {
nvidiaCaps, err := TestTranscoderCapabilities(devices, NewNvidiaTranscoder)
assert.Nil(t, err)
assert.False(t, InArray(Capability_H264_Decode_444_8bit, nvidiaCaps), "Nvidia device should not support decode of 444_8bit")
assert.False(t, InArray(Capability_H264_Decode_422_8bit, nvidiaCaps), "Nvidia device should not support decode of 422_8bit")
assert.False(t, InArray(Capability_H264_Decode_444_10bit, nvidiaCaps), "Nvidia device should not support decode of 444_10bit")
assert.False(t, InArray(Capability_H264_Decode_422_10bit, nvidiaCaps), "Nvidia device should not support decode of 422_10bit")
assert.False(t, InArray(Capability_H264_Decode_420_10bit, nvidiaCaps), "Nvidia device should not support decode of 420_10bit")
assert.False(t, HasCapability(nvidiaCaps, Capability_H264_Decode_444_8bit), "Nvidia device should not support decode of 444_8bit")
assert.False(t, HasCapability(nvidiaCaps, Capability_H264_Decode_422_8bit), "Nvidia device should not support decode of 422_8bit")
assert.False(t, HasCapability(nvidiaCaps, Capability_H264_Decode_444_10bit), "Nvidia device should not support decode of 444_10bit")
assert.False(t, HasCapability(nvidiaCaps, Capability_H264_Decode_422_10bit), "Nvidia device should not support decode of 422_10bit")
assert.False(t, HasCapability(nvidiaCaps, Capability_H264_Decode_420_10bit), "Nvidia device should not support decode of 420_10bit")
}

// Same test with software transcoder:
softwareCaps, err := TestSoftwareTranscoderCapabilities(tmpdir)
assert.Nil(t, err)
// Software transcoder supports: [h264_444_8bit h264_422_8bit h264_444_10bit h264_422_10bit h264_420_10bit]
assert.True(t, InArray(Capability_H264_Decode_444_8bit, softwareCaps), "software decoder should support 444_8bit input")
assert.True(t, InArray(Capability_H264_Decode_422_8bit, softwareCaps), "software decoder should support 422_8bit input")
assert.True(t, InArray(Capability_H264_Decode_444_10bit, softwareCaps), "software decoder should support 444_10bit input")
assert.True(t, InArray(Capability_H264_Decode_422_10bit, softwareCaps), "software decoder should support 422_10bit input")
assert.True(t, InArray(Capability_H264_Decode_420_10bit, softwareCaps), "software decoder should support 420_10bit input")
assert.True(t, HasCapability(softwareCaps, Capability_H264_Decode_444_8bit), "software decoder should support 444_8bit input")
assert.True(t, HasCapability(softwareCaps, Capability_H264_Decode_422_8bit), "software decoder should support 422_8bit input")
assert.True(t, HasCapability(softwareCaps, Capability_H264_Decode_444_10bit), "software decoder should support 444_10bit input")
assert.True(t, HasCapability(softwareCaps, Capability_H264_Decode_422_10bit), "software decoder should support 422_10bit input")
assert.True(t, HasCapability(softwareCaps, Capability_H264_Decode_420_10bit), "software decoder should support 420_10bit input")
}

func TestCapability_JobCapabilities(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion core/transcoder.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@
}

func (params transcodeTestParams) IsRequired() bool {
return InArray(params.Cap, DefaultCapabilities())
return HasCapability(DefaultCapabilities(), params.Cap)

Check warning on line 175 in core/transcoder.go

View check run for this annotation

Codecov / codecov/patch

core/transcoder.go#L175

Added line #L175 was not covered by tests
}

func (params transcodeTestParams) Kind() string {
Expand Down
Loading