streaming

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

commit 7d382dc385db1ecdfe2c37b21a782cba8f31cc23
parent 9b7bc68411aa435947ce2b33c49c4e2cf2b8de88
Author: Oliver Lowe <o@olowe.co>
Date:   Tue, 23 Jul 2024 15:55:47 +1000

cmcd: round request durations to nearest 100ms

This is spec compliant.

Diffstat:
Mcmcd/cmcd.go | 7++++---
Mcmcd/encode.go | 8+++-----
2 files changed, 7 insertions(+), 8 deletions(-)

diff --git a/cmcd/cmcd.go b/cmcd/cmcd.go @@ -100,10 +100,11 @@ func ExtractInfo(header http.Header) (Info, error) { // Request represents data relating to the client's... type Request struct { // Playback duration of the requested content. When encoded, - // values are rounded to the nearest millisecond. + // values are rounded to the nearest 100 milliseconds. BufLength time.Duration - // Time limit, in milliseconds, to receive a response to the - // request before the client may experience playback problems. + // Time limit to receive a response to the request before the + // client may experience playback problems. + // When encoded, values are rounded to the nearest 100 milliseconds. Deadline time.Duration // Kilobits per second between client and server, as measured by the client. Throughput int diff --git a/cmcd/encode.go b/cmcd/encode.go @@ -4,18 +4,17 @@ import ( "fmt" "net/url" "strings" + "time" ) func (r Request) Encode() string { var attrs []string if r.BufLength > 0 { - // TODO(otl): round to nearest 100ms - a := fmt.Sprintf("bl=%d", r.BufLength.Milliseconds()) + a := fmt.Sprintf("bl=%d", r.BufLength.Round(100*time.Millisecond).Milliseconds()) attrs = append(attrs, a) } if r.Deadline > 0 { - // TODO(otl): round to nearest 100ms - a := fmt.Sprintf("dl=%d", r.Deadline.Milliseconds()) + a := fmt.Sprintf("dl=%d", r.Deadline.Round(100*time.Millisecond).Milliseconds()) attrs = append(attrs, a) } if r.Throughput > 0 { @@ -41,7 +40,6 @@ func (o Object) Encode() string { attrs = append(attrs, fmt.Sprintf("br=%d", o.Bitrate)) } if o.Duration > 0 { - // TODO(otl): round to nearest 100ms a := fmt.Sprintf("d=%d", o.Duration.Milliseconds()) attrs = append(attrs, a) }