This repository has been archived by the owner on Nov 27, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 94
/
main.go
54 lines (44 loc) · 1.47 KB
/
main.go
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package main
import (
"fmt"
//"github.com/djwackey/dorsvr/auth"
"github.com/djwackey/dorsvr/rtspserver"
"github.com/djwackey/gitea/log"
)
func main() {
// open a logger writer of console or file mode.
mode := "console"
config := `{"level":1,"filename":"test.log"}`
log.NewLogger(0, mode, config)
// to implement client access control to the RTSP server, do the following:
// var realm string
// authdb = auth.NewAuthDatabase(realm)
// authdb.InsertUserRecord("username1", "password1")
// repeat the above with each <username>, <password> that you wish to allow
// access to the server.
// create a rtsp server
server := rtspserver.New(nil)
portNum := 8554
err := server.Listen(portNum)
if err != nil {
fmt.Printf("Failed to bind port: %d\n", portNum)
return
}
// also, attempt to create a HTTP server for RTSP-over-HTTP tunneling.
// Try first with the default HTTP port (80), and then with the alternative HTTP
// port numbers (8000 and 8080).
if !server.SetupTunnelingOverHTTP(80) ||
!server.SetupTunnelingOverHTTP(8000) ||
!server.SetupTunnelingOverHTTP(8080) {
fmt.Printf("We use port %d for optional RTSP-over-HTTP tunneling, "+
"or for HTTP live streaming (for indexed Transport Stream files only).\n",
server.HTTPServerPortNum())
} else {
fmt.Println("(RTSP-over-HTTP tunneling is not available.)")
}
urlPrefix := server.RtspURLPrefix()
fmt.Println("This server's URL: " + urlPrefix + "<filename>.")
server.Start()
// do event loop
select {}
}