From 6f5ae12f141fb28cb463c43d96529b74d4266bb3 Mon Sep 17 00:00:00 2001 From: Juliusz Chroboczek Date: Fri, 18 Sep 2020 10:28:05 +0200 Subject: [PATCH] Move RTP-specific code into its own package. --- rtpconn.go => rtpconn/rtpconn.go | 7 +------ rtpstats.go => rtpconn/rtpstats.go | 2 +- rtpwriter.go => rtpconn/rtpwriter.go | 2 +- webclient.go => rtpconn/webclient.go | 9 ++------- webserver.go | 3 ++- 5 files changed, 7 insertions(+), 16 deletions(-) rename rtpconn.go => rtpconn/rtpconn.go (99%) rename rtpstats.go => rtpconn/rtpstats.go (99%) rename rtpwriter.go => rtpconn/rtpwriter.go (99%) rename webclient.go => rtpconn/webclient.go (98%) diff --git a/rtpconn.go b/rtpconn/rtpconn.go similarity index 99% rename from rtpconn.go rename to rtpconn/rtpconn.go index 0e42737..23deb8f 100644 --- a/rtpconn.go +++ b/rtpconn/rtpconn.go @@ -1,9 +1,4 @@ -// Copyright (c) 2020 by Juliusz Chroboczek. - -// This is not open source software. Copy it, and I'll break into your -// house and tell your three year-old that Santa doesn't exist. - -package main +package rtpconn import ( "errors" diff --git a/rtpstats.go b/rtpconn/rtpstats.go similarity index 99% rename from rtpstats.go rename to rtpconn/rtpstats.go index 4e66784..83e3fe6 100644 --- a/rtpstats.go +++ b/rtpconn/rtpstats.go @@ -1,4 +1,4 @@ -package main +package rtpconn import ( "sort" diff --git a/rtpwriter.go b/rtpconn/rtpwriter.go similarity index 99% rename from rtpwriter.go rename to rtpconn/rtpwriter.go index 1910cea..2150c43 100644 --- a/rtpwriter.go +++ b/rtpconn/rtpwriter.go @@ -1,4 +1,4 @@ -package main +package rtpconn import ( "errors" diff --git a/webclient.go b/rtpconn/webclient.go similarity index 98% rename from webclient.go rename to rtpconn/webclient.go index b6d9178..eae6950 100644 --- a/webclient.go +++ b/rtpconn/webclient.go @@ -1,9 +1,4 @@ -// Copyright (c) 2020 by Juliusz Chroboczek. - -// This is not open source software. Copy it, and I'll break into your -// house and tell your three year-old that Santa doesn't exist. - -package main +package rtpconn import ( "encoding/json" @@ -580,7 +575,7 @@ func (c *webClient) PushConn(id string, up conn.Up, tracks []conn.UpTrack, label return nil } -func startClient(conn *websocket.Conn) (err error) { +func StartClient(conn *websocket.Conn) (err error) { var m clientMessage err = conn.SetReadDeadline(time.Now().Add(15 * time.Second)) diff --git a/webserver.go b/webserver.go index a1f98bc..824735f 100644 --- a/webserver.go +++ b/webserver.go @@ -21,6 +21,7 @@ import ( "sfu/disk" "sfu/group" + "sfu/rtpconn" "sfu/stats" ) @@ -306,7 +307,7 @@ func wsHandler(w http.ResponseWriter, r *http.Request) { return } go func() { - err := startClient(conn) + err := rtpconn.StartClient(conn) if err != nil { log.Printf("client: %v", err) }