Skip to content

Commit

Permalink
mpegts: prevent wrong results in codec comparisons (#167)
Browse files Browse the repository at this point in the history
  • Loading branch information
aler9 authored Jan 1, 2025
1 parent 6b50d9b commit d0642e1
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 6 deletions.
7 changes: 6 additions & 1 deletion pkg/formats/mpegts/codec_h264.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@ import (
)

// CodecH264 is a H264 codec.
type CodecH264 struct{}
type CodecH264 struct {
// in Go, empty structs share the same pointer,
// therefore they cannot be used as map keys
// or in equality operations. Prevent this.
unused int //nolint:unused
}

// IsVideo implements Codec.
func (CodecH264) IsVideo() bool {
Expand Down
7 changes: 6 additions & 1 deletion pkg/formats/mpegts/codec_h265.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@ import (
)

// CodecH265 is a H265 codec.
type CodecH265 struct{}
type CodecH265 struct {
// in Go, empty structs share the same pointer,
// therefore they cannot be used as map keys
// or in equality operations. Prevent this.
unused int //nolint:unused
}

// IsVideo implements Codec.
func (CodecH265) IsVideo() bool {
Expand Down
7 changes: 6 additions & 1 deletion pkg/formats/mpegts/codec_mpeg1_audio.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@ import (
)

// CodecMPEG1Audio is a MPEG-1 Audio codec.
type CodecMPEG1Audio struct{}
type CodecMPEG1Audio struct {
// in Go, empty structs share the same pointer,
// therefore they cannot be used as map keys
// or in equality operations. Prevent this.
unused int //nolint:unused
}

// IsVideo implements Codec.
func (CodecMPEG1Audio) IsVideo() bool {
Expand Down
7 changes: 6 additions & 1 deletion pkg/formats/mpegts/codec_mpeg1_video.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@ import (
)

// CodecMPEG1Video is a MPEG-1/2 Video codec.
type CodecMPEG1Video struct{}
type CodecMPEG1Video struct {
// in Go, empty structs share the same pointer,
// therefore they cannot be used as map keys
// or in equality operations. Prevent this.
unused int //nolint:unused
}

// IsVideo implements Codec.
func (CodecMPEG1Video) IsVideo() bool {
Expand Down
7 changes: 6 additions & 1 deletion pkg/formats/mpegts/codec_mpeg4_video.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@ import (
)

// CodecMPEG4Video is a MPEG-4 Video codec.
type CodecMPEG4Video struct{}
type CodecMPEG4Video struct {
// in Go, empty structs share the same pointer,
// therefore they cannot be used as map keys
// or in equality operations. Prevent this.
unused int //nolint:unused
}

// IsVideo implements Codec.
func (CodecMPEG4Video) IsVideo() bool {
Expand Down
7 changes: 6 additions & 1 deletion pkg/formats/mpegts/codec_unsupported.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@ import (
)

// CodecUnsupported is an unsupported codec.
type CodecUnsupported struct{}
type CodecUnsupported struct {
// in Go, empty structs share the same pointer,
// therefore they cannot be used as map keys
// or in equality operations. Prevent this.
unused int //nolint:unused
}

// IsVideo implements Codec.
func (CodecUnsupported) IsVideo() bool {
Expand Down

0 comments on commit d0642e1

Please sign in to comment.