streaming

Media streaming and broadcast systems in Go
Log | Files | Refs | README | LICENSE

commit 0da91c7d665bcbadeb67e22762a4bcb818e1ca4f
parent 34e2532ac4dd304348fb3babce0f85c8b272610d
Author: Oliver Lowe <o@olowe.co>
Date:   Fri,  5 Jul 2024 13:28:55 +1000

sdp: don't bother storing network class

There's only one valid value in the spec. If we need to support
something else later we can add it. Makes the package easier to use;
one less thing to document, keep track of...

Diffstat:
Msdp/sdp.go | 5+++--
Msdp/sdp_test.go | 4++--
2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/sdp/sdp.go b/sdp/sdp.go @@ -30,7 +30,6 @@ type Origin struct { Username string ID int Version int - Network string // TODO(otl): only "IN" is valid... so int type? AddressType string // TODO(otl): only "IP4", "IP6" valid... new int type? Address string // IPv4, IPv6 literal or a hostname } @@ -173,7 +172,9 @@ func parseOrigin(line string) (Origin, error) { if err != nil { return o, fmt.Errorf("parse version: %w", err) } - o.Network = fields[3] + if fields[3] != "IN" { + return o, fmt.Errorf("unknown network class %q", fields[3]) + } o.AddressType = fields[4] o.Address = fields[5] return o, nil diff --git a/sdp/sdp_test.go b/sdp/sdp_test.go @@ -18,7 +18,7 @@ func TestReadSession(t *testing.T) { name: "good.sdp", want: Session{ Name: "Call to John Smith", - Origin: Origin{"jdoe", 3724394400, 3724394405, "IN", "IP4", "198.51.100.1"}, + Origin: Origin{"jdoe", 3724394400, 3724394405, "IP4", "198.51.100.1"}, Info: "SDP Offer #1", URI: &url.URL{ Scheme: "http", @@ -37,7 +37,7 @@ func TestReadSession(t *testing.T) { { name: "some_optional.sdp", want: Session{ - Origin: Origin{"jdoe", 3724394400, 3724394405, "IN", "IP4", "198.51.100.1"}, + Origin: Origin{"jdoe", 3724394400, 3724394405, "IP4", "198.51.100.1"}, Name: "Call to John Smith", Email: &mail.Address{"Jane Doe", "jane@jdoe.example.com"}, },