-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.go
More file actions
35 lines (28 loc) · 1.2 KB
/
main.go
File metadata and controls
35 lines (28 loc) · 1.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package main
import (
"flag"
"log"
"net/http"
"strings"
)
func main() {
haddr := flag.String("haddr", "127.0.0.1:8080", "The host/port to run the API server on")
rtphost := flag.String("rtphost", "127.0.0.1", "The port to listen on for RTP packets")
rtpport := flag.Int("rtpport", 8082, "The port to listen on for RTP packets")
trackName := flag.String("track", "default", "The WebRTC name of the track")
iceServersStr := flag.String("ice", "stun:stun.l.google.com:19302", "Comma-separated list of ICE servers")
codec := flag.String("codec", "video/VP8", "Codec to report to WebRTC client ('video/VP8' or 'video/H264')")
serveFiles := flag.Bool("static", true, "Should the static files be served by the app")
webroot := flag.String("webroot", "./static/", "Location of files to serve")
apibase := flag.String("apibase", "/webrtc/apiv1/offer", "Location of files to serve")
flag.Parse()
iceServers := strings.Split(*iceServersStr, ",")
InitWebRTCTrack(*codec, *trackName)
InitWebRTCPApi(iceServers)
go RunUDPRTPServer(*rtphost, *rtpport)
if *serveFiles {
http.Handle("/", http.FileServer(http.Dir(*webroot)))
}
http.HandleFunc(*apibase, OnNewPeer)
log.Panicln(http.ListenAndServe(*haddr, nil))
}