mirror of
https://github.com/pion/webrtc.git
synced 2025-10-27 17:21:27 +08:00
committed by
Sean DuBois
parent
f5e8f0fa4a
commit
c40e4a53ef
@@ -75,6 +75,7 @@ Check out the **[contributing wiki](https://github.com/pions/webrtc/wiki/Contrib
|
|||||||
* [Yutaka Takeda](https://github.com/enobufs) *Fix ICE connection timeout*
|
* [Yutaka Takeda](https://github.com/enobufs) *Fix ICE connection timeout*
|
||||||
* [Hugo Arregui](https://github.com/hugoArregui) *Fix connection timeout*
|
* [Hugo Arregui](https://github.com/hugoArregui) *Fix connection timeout*
|
||||||
* [Rob Deutsch](https://github.com/rob-deutsch) *RTCRtpReceiver graceful shutdown*
|
* [Rob Deutsch](https://github.com/rob-deutsch) *RTCRtpReceiver graceful shutdown*
|
||||||
|
* [Jin Lei](https://github.com/jinleileiking) - *SFU example use http*
|
||||||
|
|
||||||
### License
|
### License
|
||||||
MIT License - see [LICENSE](LICENSE) for full text
|
MIT License - see [LICENSE](LICENSE) for full text
|
||||||
|
|||||||
@@ -17,10 +17,15 @@ go get github.com/pions/webrtc/examples/sfu
|
|||||||
Run `sfu` OR run `main.go` in `github.com/pions/webrtc/examples/sfu`
|
Run `sfu` OR run `main.go` in `github.com/pions/webrtc/examples/sfu`
|
||||||
|
|
||||||
### Start a publisher
|
### Start a publisher
|
||||||
Click `Publish a Broadcast` and paste the SDP into your terminal. The `sfu` application will respond with an offer, paste this into the second input field. Then press `Start Session`
|
|
||||||
|
* Click `Publish a Broadcast`
|
||||||
|
* `curl localhost:8080/sdp -d "YOUR SDP"`. The `sfu` application will respond with an offer, paste this into the second input field. Then press `Start Session`
|
||||||
|
|
||||||
### Join the broadcast
|
### Join the broadcast
|
||||||
Click `Join a Broadcast` and paste the SDP into your terminal. The `sfu` application will respond with an offer, paste this into the second input field. Then press `Start Session`
|
* Click `Join a Broadcast`
|
||||||
|
* `curl localhost:8080/sdp -d "YOUR SDP"`. The `sfu` application will respond with an offer, paste this into the second input field. Then press `Start Session`
|
||||||
|
|
||||||
|
You can change the listening port using `-port 8011`
|
||||||
|
|
||||||
You can `Join the broadcast` as many times as you want. The `sfu` Golang application is relaying all traffic, so your browser only has to upload once.
|
You can `Join the broadcast` as many times as you want. The `sfu` Golang application is relaying all traffic, so your browser only has to upload once.
|
||||||
|
|
||||||
|
|||||||
@@ -2,8 +2,11 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bufio"
|
"bufio"
|
||||||
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"io/ioutil"
|
||||||
|
"net/http"
|
||||||
|
"strconv"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@@ -29,15 +32,32 @@ func mustReadStdin(reader *bufio.Reader) string {
|
|||||||
return rawSd
|
return rawSd
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func mustReadHttp(sdp chan string) string {
|
||||||
|
ret := <-sdp
|
||||||
|
return ret
|
||||||
|
}
|
||||||
|
|
||||||
const (
|
const (
|
||||||
rtcpPLIInterval = time.Second * 3
|
rtcpPLIInterval = time.Second * 3
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
reader := bufio.NewReader(os.Stdin)
|
port := flag.Int("port", 8080, "http server port")
|
||||||
|
flag.Parse()
|
||||||
|
|
||||||
|
sdp := make(chan string)
|
||||||
|
http.HandleFunc("/sdp", func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
body, _ := ioutil.ReadAll(r.Body)
|
||||||
|
fmt.Fprintf(w, "done")
|
||||||
|
sdp <- string(body)
|
||||||
|
})
|
||||||
|
|
||||||
|
go func() {
|
||||||
|
http.ListenAndServe(":"+strconv.Itoa(*port), nil)
|
||||||
|
}()
|
||||||
|
|
||||||
offer := webrtc.RTCSessionDescription{}
|
offer := webrtc.RTCSessionDescription{}
|
||||||
util.Decode(mustReadStdin(reader), &offer)
|
util.Decode(mustReadHttp(sdp), &offer)
|
||||||
fmt.Println("")
|
fmt.Println("")
|
||||||
|
|
||||||
/* Everything below is the pion-WebRTC API, thanks for using it! */
|
/* Everything below is the pion-WebRTC API, thanks for using it! */
|
||||||
@@ -101,10 +121,10 @@ func main() {
|
|||||||
outboundPayloadType := <-inboundPayloadType
|
outboundPayloadType := <-inboundPayloadType
|
||||||
for {
|
for {
|
||||||
fmt.Println("")
|
fmt.Println("")
|
||||||
fmt.Println("Paste an base64 SDP to start sendonly peer connection")
|
fmt.Println("Curl an base64 SDP to start sendonly peer connection")
|
||||||
|
|
||||||
recvOnlyOffer := webrtc.RTCSessionDescription{}
|
recvOnlyOffer := webrtc.RTCSessionDescription{}
|
||||||
util.Decode(mustReadStdin(reader), &recvOnlyOffer)
|
util.Decode(mustReadHttp(sdp), &recvOnlyOffer)
|
||||||
|
|
||||||
// Create a new RTCPeerConnection
|
// Create a new RTCPeerConnection
|
||||||
peerConnection, err := webrtc.New(peerConnectionConfig)
|
peerConnection, err := webrtc.New(peerConnectionConfig)
|
||||||
|
|||||||
Reference in New Issue
Block a user