commit 96a874b067dad9a5704171d9c63a5594b6d42e3d from: Oliver Lowe date: Sat Aug 10 08:56:32 2024 UTC sdp: resolve remaining validation, documentation TODOs No real changes, just notes. Always encode a valid timestamp when session start time is unset but an end time is set. Document the TTL in ConnInfo is a specific property of multicast traffic. No need to impose more structure on session Attributes when the data is pretty free-form anyway (similar to http.Header). Safely round times in session repeat schedules to ensure we never write invalid decimal places. commit - 8d2c4bc42dfbbe01d8d7cfd968ca60c8048ae6f9 commit + 96a874b067dad9a5704171d9c63a5594b6d42e3d blob - 7900cc1839e80e544e72c0a1bb5d1c794428cb06 blob + 5313912265ce515dae4646ee4ad514b2c8b77bf3 --- sdp/encode.go +++ sdp/encode.go @@ -39,7 +39,6 @@ func (s Session) String() string { fmt.Fprintln(buf, s.Bandwidth) } - // TODO(otl): what about the invalid case where Time[0] is zero but Time[1] is not? if s.Time[0].IsZero() { fmt.Fprintln(buf, "t=0 0") } else { blob - a1c8a7a3ba48919af7f7b89a81dcf3a3d65f9c4a blob + 70284b62ddfaf49a11b2ad016a4eb0701a6be5bf --- sdp/parser.go +++ sdp/parser.go @@ -12,7 +12,6 @@ type parser struct { *bufio.Scanner err error // Field name and value from the current line. - // TODO(otl): rename? key, value is very non-specific... key, value string next []string // expected next field names blob - a585ba049e5f2a655641d29db9b5200b753e2d85 blob + a80d57737405406ce3d79c7ec9bb6dc5fc4787ca --- sdp/sdp.go +++ sdp/sdp.go @@ -141,7 +141,6 @@ func parseBandwidth(s string) (Bandwidth, error) { if !ok { return Bandwidth{}, fmt.Errorf("missing %s separator", ":") } - // TODO(otl): check bandwith type is actually one specified in section 5.8. if t == "" { return Bandwidth{}, fmt.Errorf("missing bandwidth type") } @@ -170,7 +169,6 @@ type Media struct { Title string Connection *ConnInfo Bandwidth *Bandwidth - // TODO(otl): store as k, v pairs Attributes []string } @@ -311,9 +309,11 @@ func parseMedia(s string) (Media, error) { // ConnInfo represents connection information. type ConnInfo struct { Address netip.Addr - // TODO(otl): what are these units? seconds? - TTL uint8 // time to live - Count int // number of addresses after Address + // TTL is the time-to-live of multicast packets. + TTL uint8 + // Count is the number of subsequent IP addresses after + // Address used in the session. + Count int } func (c *ConnInfo) String() string { blob - c6c55c1a7bedffe093c5c07461db4861f9bf6d2a blob + 7e78b08c0e3145e90872e89926f38dff6dbacc35 --- sdp/time.go +++ sdp/time.go @@ -3,6 +3,7 @@ package sdp import ( "errors" "fmt" + "math" "strconv" "strings" "time" @@ -44,8 +45,9 @@ type Repeat struct { } func (rp *Repeat) String() string { - // TODO(otl): print with no decimal places? - s := fmt.Sprintf("r=%f %f ", rp.Interval.Round(time.Second).Seconds(), rp.Active.Round(time.Second).Seconds()) + interval := math.Round(rp.Interval.Round(time.Second).Seconds()) + active := math.Round(rp.Active.Round(time.Second).Seconds()) + s := fmt.Sprintf("r=%d %d ", int(interval), int(active)) if len(rp.Offsets) > 0 { ss := make([]string, len(rp.Offsets)) for i := range rp.Offsets {