├── .dockerignore ├── .gitignore ├── CONTRIBUTING.md ├── LICENSE.md ├── README.md ├── create-ssl-cert.sh ├── docker-compose.yml ├── signaler ├── Dockerfile ├── go.mod ├── go.sum └── main.go ├── turn ├── Dockerfile ├── go.mod ├── go.sum └── main.go └── www ├── Dockerfile └── index.html /.dockerignore: -------------------------------------------------------------------------------- 1 | .git 2 | vendor 3 | gin-bin 4 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | gin-bin 2 | 3 | signaler/localhost.pem 4 | signaler/localhost.key 5 | 6 | www/localhost.pem 7 | www/localhost.key 8 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing 2 | 3 | ## Issues 4 | Use the Pion Slack for discussions and support, the issue tracker is only meant for actionable issues. 5 | 6 | Feel free to create feature requests, submit bugs and anything else to the tracker. Even if it gets closed, it may 7 | help someone in the future 8 | 9 | ## Pull Request Process 10 | Thank you for contributing! First make an issue, this ensures that you don't write code that isn't accepted. 11 | 12 | ### Types of issues 13 | * Any divergence from an RFC will always be accepted after code review 14 | * Bug fixes will always be accepted after code review 15 | * API or Feature changes must go through review by maintainers from the project, but very likely will be accepted 16 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | Copyright 2018 Pion LLC 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 4 | 5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 6 | 7 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 8 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # This package is deprecated 2 | 3 | For a Go implementation of the PeerConnection see [pion/webrtc](https://github.com/pion/webrtc) 4 | 5 | For a SFU see [ion-sfu](https://github.com/pion/ion-sfu) 6 | 7 | For a full featured Media Server see [ion](https://github.com/pion/ion) 8 | 9 | Also see [awesome-pion](https://github.com/pion/awesome-pion) for projects created by the Pion community. 10 | 11 | ---- 12 | 13 | # Pion demo-conference 14 | demo-conference is an example of fully featured Pion deploy. A working signaler, TURN server and web app. 15 | 16 | This is a good template for building your application, fork and start adding features to the frontend or implement 17 | the callbacks in TURN/Signaler to get auth working with your existing application. 18 | 19 | ### Prerequisites 20 | A working Docker and Docker Compose setup. 21 | 22 | ### Running 23 | For developing a docker-compose.yml is available with features like hot-reloads so you can quickly start developing. 24 | 25 | * Trust all localhost HTTPS certificates -- open [chrome://flags](chrome://flags/#allow-insecure-localhost) in a new tab and enable `#allow-insecure-localhost` 26 | * Generate your SSL certificates, WebRTC only works over HTTPS so we have to serve `www` and `signaler` via HTTPS 27 | ``` 28 | ./create-ssl-cert.sh 29 | ``` 30 | * Start demo-conference 31 | ``` 32 | docker-compose up --build 33 | ``` 34 | * Open up [demo-conference](https://localhost:5000/) After you share your webcam you have joined the conference! Open multiple tabs, chat with yourself... 35 | 36 | Now start hacking! Everything is hot-reload, so you can start making changes in the signaler, turn or www folder and your changes will be reflected right away. 37 | 38 | ## Contributing 39 | See [CONTRIBUTING.md](CONTRIBUTING.md) 40 | 41 | ## License 42 | MIT License - see [LICENSE.md](LICENSE.md) for full text 43 | -------------------------------------------------------------------------------- /create-ssl-cert.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | echo "Creating SSL Certificates needed for signaler and www" 4 | openssl req -nodes -new -x509 -keyout localhost.key -out localhost.pem -days 365 -subj '/CN=localhost' 5 | 6 | DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" 7 | cp $DIR/*.key $DIR/*.pem $DIR/signaler 8 | cp $DIR/*.key $DIR/*.pem $DIR/www 9 | rm $DIR/*.key $DIR/*.pem 10 | -------------------------------------------------------------------------------- /docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: "3" 2 | 3 | services: 4 | signaler: 5 | build: ./signaler 6 | ports: 7 | - "5001:443" 8 | volumes: 9 | - ./signaler:/usr/local/src/github.com/pion/demo-conference/signaler 10 | turn: 11 | build: ./turn 12 | environment: 13 | - REALM=localhost 14 | ports: 15 | - "3478:3478/udp" 16 | volumes: 17 | - ./turn:/usr/local/src/github.com/pion/demo-conference/turn 18 | www: 19 | build: ./www 20 | ports: 21 | - "5000:443" 22 | volumes: 23 | - ./www:/usr/local/src/github.com/pion/demo-conference/www 24 | -------------------------------------------------------------------------------- /signaler/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM alpine:latest 2 | 3 | ENV GOPATH /usr/local 4 | 5 | RUN apk --no-cache add go git musl-dev && rm -rf /var/cache/apk/* 6 | RUN go get -u -v github.com/codegangsta/gin 7 | RUN go get -u -v github.com/pion/signaler 8 | COPY localhost* /root/ 9 | 10 | WORKDIR /usr/local/src/github.com/pion/demo-conference/signaler 11 | CMD gin -p 443\ 12 | --certFile=/root/localhost.pem\ 13 | --keyFile=/root/localhost.key 14 | -------------------------------------------------------------------------------- /signaler/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/pion/demo-conference/signaler 2 | 3 | go 1.14 4 | 5 | require ( 6 | github.com/gorilla/mux v1.7.4 // indirect 7 | github.com/gorilla/websocket v1.4.2 // indirect 8 | github.com/pion/signaler v0.0.0-20190529065413-c11bee937879 9 | github.com/pkg/errors v0.9.1 // indirect 10 | github.com/rs/zerolog v1.19.0 // indirect 11 | ) 12 | -------------------------------------------------------------------------------- /signaler/go.sum: -------------------------------------------------------------------------------- 1 | github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= 2 | github.com/gorilla/mux v1.7.4 h1:VuZ8uybHlWmqV03+zRzdwKL4tUnIp1MAQtp1mIFE1bc= 3 | github.com/gorilla/mux v1.7.4/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So= 4 | github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc= 5 | github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= 6 | github.com/pion/signaler v0.0.0-20190529065413-c11bee937879 h1:61dFjP2YfQUTqH9t2x6IRc6Kt6LUJT2sbLoHcjTmGy8= 7 | github.com/pion/signaler v0.0.0-20190529065413-c11bee937879/go.mod h1:7oFSpi02itJjgJvhqw2FBDWAO8ICeLdD2sP5BpfOQ0I= 8 | github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= 9 | github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= 10 | github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= 11 | github.com/rs/xid v1.2.1/go.mod h1:+uKXf+4Djp6Md1KODXJxgGQPKngRmWyn10oCKFzNHOQ= 12 | github.com/rs/zerolog v1.19.0 h1:hYz4ZVdUgjXTBUmrkrw55j1nHx68LfOKIQk5IYtyScg= 13 | github.com/rs/zerolog v1.19.0/go.mod h1:IzD0RJ65iWH0w97OQQebJEvTZYvsCUm9WVLWBQrJRjo= 14 | golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= 15 | golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= 16 | golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= 17 | golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= 18 | golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= 19 | golang.org/x/tools v0.0.0-20190828213141-aed303cbaa74/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= 20 | golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= 21 | -------------------------------------------------------------------------------- /signaler/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "log" 6 | "math/rand" 7 | "net/url" 8 | "os" 9 | 10 | "github.com/pion/signaler" 11 | ) 12 | 13 | type MySignalerServer struct { 14 | } 15 | 16 | func randSeq(n int) string { 17 | letters := []rune("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ") 18 | b := make([]rune, n) 19 | for i := range b { 20 | b[i] = letters[rand.Intn(len(letters))] 21 | } 22 | return string(b) 23 | } 24 | 25 | func (m *MySignalerServer) AuthenticateRequest(params url.Values) (apiKey, room, sessionKey string, ok bool) { 26 | return "ABC", "ABC", randSeq(16), true 27 | } 28 | 29 | func (m *MySignalerServer) OnClientMessage(ApiKey, Room, SessionKey string, raw []byte) { 30 | } 31 | 32 | func main() { 33 | port := os.Getenv("PORT") 34 | if port == "" { 35 | log.Panic("PORT is a required environment variable") 36 | } 37 | 38 | fmt.Println(signaler.Start(&MySignalerServer{}, port)) 39 | } 40 | -------------------------------------------------------------------------------- /turn/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM alpine:latest 2 | 3 | ENV GOPATH /usr/local 4 | ENV REALM localhost 5 | 6 | RUN apk --no-cache add go git musl-dev && rm -rf /var/cache/apk/* 7 | RUN go get -u -v github.com/cespare/reflex 8 | RUN go get -u -v github.com/pion/turn 9 | 10 | WORKDIR /usr/local/src/github.com/pion/demo-conference/turn 11 | CMD reflex -r . -s go run main.go 12 | -------------------------------------------------------------------------------- /turn/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/pion/demo-conference/turn 2 | 3 | go 1.14 4 | 5 | require github.com/pion/turn v1.4.0 // indirect 6 | -------------------------------------------------------------------------------- /turn/go.sum: -------------------------------------------------------------------------------- 1 | github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= 2 | github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= 3 | github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= 4 | github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= 5 | github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= 6 | github.com/pion/logging v0.2.2 h1:M9+AIj/+pxNsDfAT64+MAVgJO0rsyLnoJKCqf//DoeY= 7 | github.com/pion/logging v0.2.2/go.mod h1:k0/tDVsRCX2Mb2ZEmTqNa7CWsQPc+YYCB7Q+5pahoms= 8 | github.com/pion/stun v0.3.3 h1:brYuPl9bN9w/VM7OdNzRSLoqsnwlyNvD9MVeJrHjDQw= 9 | github.com/pion/stun v0.3.3/go.mod h1:xrCld6XM+6GWDZdvjPlLMsTU21rNxnO6UO8XsAvHr/M= 10 | github.com/pion/transport v0.8.9 h1:3PUZULb0WZd/QNfXKKMwcUHzLR+XfNem6lF2M9UrxSU= 11 | github.com/pion/transport v0.8.9/go.mod h1:lpeSM6KJFejVtZf8k0fgeN7zE73APQpTF83WvA1FVP8= 12 | github.com/pion/turn v1.4.0 h1:7NUMRehQz4fIo53Qv9ui1kJ0Kr1CA82I81RHKHCeM80= 13 | github.com/pion/turn v1.4.0/go.mod h1:aDSi6hWX/hd1+gKia9cExZOR0MU95O7zX9p3Gw/P2aU= 14 | github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I= 15 | github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= 16 | github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= 17 | github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= 18 | github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= 19 | github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= 20 | gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= 21 | gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= 22 | gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= 23 | -------------------------------------------------------------------------------- /turn/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "log" 5 | "net" 6 | "os" 7 | "os/signal" 8 | "strconv" 9 | "syscall" 10 | "time" 11 | 12 | "github.com/pion/logging" 13 | "github.com/pion/turn" 14 | ) 15 | 16 | func createAuthHandler() turn.AuthHandler { 17 | return func(username string, srcAddr net.Addr) (string, bool) { 18 | return "password", true 19 | } 20 | } 21 | 22 | func main() { 23 | sigs := make(chan os.Signal, 1) 24 | signal.Notify(sigs, syscall.SIGINT, syscall.SIGTERM) 25 | 26 | realm := os.Getenv("REALM") 27 | if realm == "" { 28 | log.Panic("REALM is a required environment variable") 29 | } 30 | 31 | udpPortStr := os.Getenv("UDP_PORT") 32 | if udpPortStr == "" { 33 | udpPortStr = "3478" 34 | } 35 | udpPort, err := strconv.Atoi(udpPortStr) 36 | if err != nil { 37 | log.Panic(err) 38 | } 39 | 40 | var channelBindTimeout time.Duration 41 | channelBindTimeoutStr := os.Getenv("CHANNEL_BIND_TIMEOUT") 42 | if channelBindTimeoutStr != "" { 43 | channelBindTimeout, err = time.ParseDuration(channelBindTimeoutStr) 44 | if err != nil { 45 | log.Panicf("CHANNEL_BIND_TIMEOUT=%s is an invalid time Duration", channelBindTimeoutStr) 46 | } 47 | } 48 | 49 | s := turn.NewServer(&turn.ServerConfig{ 50 | Realm: realm, 51 | AuthHandler: createAuthHandler(), 52 | ChannelBindTimeout: channelBindTimeout, 53 | ListeningPort: udpPort, 54 | LoggerFactory: logging.NewDefaultLoggerFactory(), 55 | Software: os.Getenv("SOFTWARE"), 56 | }) 57 | 58 | err = s.Start() 59 | if err != nil { 60 | log.Panic(err) 61 | } 62 | 63 | <-sigs 64 | 65 | err = s.Close() 66 | if err != nil { 67 | log.Panic(err) 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /www/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM alpine:latest 2 | 3 | ENV GOPATH /usr/local 4 | 5 | RUN apk --no-cache add go git musl-dev && rm -rf /var/cache/apk/* 6 | RUN go get -u github.com/m3ng9i/ran 7 | COPY localhost* /root/ 8 | 9 | WORKDIR /usr/local/src/github.com/pion/demo-conference/www 10 | CMD ran -p 443\ 11 | --cert=/root/localhost.pem\ 12 | --key=/root/localhost.key 13 | -------------------------------------------------------------------------------- /www/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 8 | 9 | 11 |
12 |
13 | 14 | 15 | 16 | 93 | 94 | 95 | --------------------------------------------------------------------------------