streaming

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

commit 18185121cc63011d9f097754c13cdc4cc11fd72b
parent c782d7505d2481993f034dc8c80060f1ae176698
Author: Oliver Lowe <o@olowe.co>
Date:   Wed, 23 Apr 2025 09:36:02 +1000

avhelp: delete

The idea was to have a little playground using the packages we
developed. But it didn't really turn out to be useful.

Diffstat:
Dcmd/avhelp/avhelp.go | 69---------------------------------------------------------------------
Dcmd/avhelp/template/index.html | 12------------
Dcmd/avhelp/template/rtp.html | 66------------------------------------------------------------------
3 files changed, 0 insertions(+), 147 deletions(-)

diff --git a/cmd/avhelp/avhelp.go b/cmd/avhelp/avhelp.go @@ -1,69 +0,0 @@ -// Command avhelp serves... -package main - -import ( - "embed" - "html/template" - "log" - "net" - "net/http" - - "github.com/untangledco/streaming/rtp" -) - -//go:embed template -var content embed.FS - -type server struct { - templates *template.Template - pconn net.PacketConn - buf [5]rtp.Packet -} - -func (srv *server) serveRTPInfo(w http.ResponseWriter, req *http.Request) { - if err := srv.templates.ExecuteTemplate(w, "rtp.html", srv.buf); err != nil { - log.Println("serve %s: render rtp.html: %v", req.URL, err) - } -} - -func (srv *server) receive() { - buf := make([]byte, 1360) - var i int - for { - n, _, err := srv.pconn.ReadFrom(buf) - if err != nil { - log.Printf("receive packet: %v", err) - } - var packet rtp.Packet - if err := rtp.Unmarshal(buf[:n], &packet); err != nil { - log.Printf("unmarshal packet: %v", err) - } - if i == 5 { - srv.buf[0] = packet - i = 1 - } else { - srv.buf[i] = packet - i++ - } - } -} - -func main() { - tmpl, err := template.ParseFS(content, "template/*.html") - if err != nil { - log.Fatal(err) - } - pc, err := net.ListenPacket("udp", ":6969") - if err != nil { - log.Fatal(err) - } - - srv := &server{ - templates: tmpl, - pconn: pc, - } - go srv.receive() - - http.HandleFunc("/rtp/", srv.serveRTPInfo) - log.Fatal(http.ListenAndServe(":8080", nil)) -} diff --git a/cmd/avhelp/template/index.html b/cmd/avhelp/template/index.html @@ -1,12 +0,0 @@ -<html> -<head> -<meta charset="utf-8"> -<meta name="viewport" content="width=device-width, initial-scale=1"> -<title>avhelp</title> -<link rel="stylesheet" href="/style.css"> -</head> - -<body> -<p>Hello, {{ . }}!</p> -</body> -</html> diff --git a/cmd/avhelp/template/rtp.html b/cmd/avhelp/template/rtp.html @@ -1,66 +0,0 @@ -<html> -<head> -<meta charset="utf-8"> -<meta name="viewport" content="width=device-width, initial-scale=1"> -<title>avhelp</title> -<link rel="stylesheet" href="https://unpkg.com/missing.css@1.1.2"> -</head> - -<body> -<header></header> - -<main> -<h1>RTP</h1> -<p>Real-time Transport Protocol is specified in -<a href="https://www.rfc-editor.org/rfc/rfc3550.html">RFC 3550</a>.</p> - -<h2>Packet layout</h2> - -<dl> - <dt>Version</dt> - <dd>Version specifies the version of RTP used.</dd> - <dt>Marker</dt> - <dd>The payload determines how this value is interpreted.</dd> - <dt>...</dt> - <dd>...</dd> -</dl> - -<h2>Troubleshooting</h2> - -<p>Send RTP packets to <code>[::1]:6969</code></p> - -<table> - <caption>Recently received packets</caption> - <thead> - <tr> - <th scope="col">Version</th> - <th scope="col">Marker</th> - <th scope="col">Type</th> - <th scope="col">Sequence</th> - <th scope="col">Timestamp</th> - <th scope="col">Sync. source</th> - <th scope="col">Contrib. sources</th> - </tr> - </thead> - <tbody> - {{range .}} - <tr> - <td>{{ .Header.Version }}</td> - <td>{{if .Header.Marker}}set{{else}}unset{{end}}</td> - <td>{{ .Header.Type}}</td> - <td>{{ .Header.Sequence }}</td> - <td>{{ .Header.Timestamp }}</td> - <td>{{ .Header.SyncSource }}</td> - <td>{{ range .Header.ContribSource }} {{ . }}, {{ end }}</td> - </tr> - {{end}} - </tbody> -</table> -</main> - -<footer> -<a href="https://github.com/untangledco/streaming">Source code</code> -</footer> - -</body> -</html>