Skip to content
Closed
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: 2 additions & 1 deletion header.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ package rtcp

import (
"encoding/binary"
"fmt"
)

// PacketType specifies the type of an RTCP packet.
Expand Down Expand Up @@ -59,7 +60,7 @@ func (p PacketType) String() string {
case TypeExtendedReport:
return "XR"
default:
return string(p)
return fmt.Sprintf("invalid value %d", uint8(p))
}
}

Expand Down
14 changes: 14 additions & 0 deletions header_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,3 +105,17 @@ func TestHeaderRoundTrip(t *testing.T) {
assert.Equalf(t, test.Header, decoded, "%q header round trip mismatch", test.Name)
}
}

func TestPacketTypeString(t *testing.T) {
for _, test := range []struct {
Type PacketType
Want string
}{
{TypeSenderReport, "SR"},
{TypeExtendedReport, "XR"},
{PacketType(65), "invalid value 65"},
{PacketType(0), "invalid value 0"},
} {
assert.Equal(t, test.Want, test.Type.String())
}
}
2 changes: 1 addition & 1 deletion source_description.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func (s SDESType) String() string {
case SDESPrivate:
return "PRIV"
default:
return string(s)
return fmt.Sprintf("invalid value %d", uint8(s))
}
}

Expand Down
14 changes: 14 additions & 0 deletions source_description_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -375,3 +375,17 @@ func TestSourceDescriptionRoundTripMaxLength(t *testing.T) {
assert.NoError(t, decoded.Unmarshal(data))
assert.Equal(t, desc, decoded)
}

func TestSDESTypeString(t *testing.T) {
for _, test := range []struct {
Type SDESType
Want string
}{
{SDESCNAME, "CNAME"},
{SDESPrivate, "PRIV"},
{SDESType(65), "invalid value 65"},
{SDESType(200), "invalid value 200"},
} {
assert.Equal(t, test.Want, test.Type.String())
}
}