diff --git a/index.html b/index.html
index 0f967554..c5cad153 100644
--- a/index.html
+++ b/index.html
@@ -297,8 +297,11 @@ function endInput() {
function startWebRTC() {
+ // receiver only tracks
+ pc.addTransceiver('video', {'direction': 'recvonly'});
+
// create SDP
- pc.createOffer({offerToReceiveVideo: true, offerToReceiveAudio: true}).then(d => {
+ pc.createOffer({offerToReceiveVideo: true, offerToReceiveAudio: false}).then(d => {
pc.setLocalDescription(d, () => {
// send to ws
session = btoa(JSON.stringify(pc.localDescription));
diff --git a/main.go b/main.go
index 61193c49..e88d644a 100644
--- a/main.go
+++ b/main.go
@@ -174,15 +174,12 @@ func postSession(w http.ResponseWriter, r *http.Request) {
// func screenshotLoop(imageChannel chan *image.RGBA) {
func screenshotLoop(imageChannel chan *image.RGBA, webRTC *webrtc.WebRTC) {
for image := range imageChannel {
- // Client stopped
- if webRTC.IsClosed() {
- break
- }
-
// encode frame
if webRTC.IsConnected() {
yuv := util.RgbaToYuv(image)
webRTC.ImageChannel <- yuv
+ } else {
+ break
}
}
}
diff --git a/ui/director.go b/ui/director.go
index bed29af5..6997b171 100644
--- a/ui/director.go
+++ b/ui/director.go
@@ -65,7 +65,7 @@ func (d *Director) Start(paths []string) {
func (d *Director) Run() {
for {
// quit game
- if d.webRTC.IsClosed() {
+ if !d.webRTC.IsConnected() {
break
}
diff --git a/webrtc/webrtc.go b/webrtc/webrtc.go
index 100d2521..dbdc7a9b 100644
--- a/webrtc/webrtc.go
+++ b/webrtc/webrtc.go
@@ -108,7 +108,6 @@ type WebRTC struct {
connection *webrtc.PeerConnection
encoder *vpxEncoder.VpxEncoder
isConnected bool
- isClosed bool
// for yuvI420 image
ImageChannel chan []byte
InputChannel chan int
@@ -226,7 +225,6 @@ func (w *WebRTC) StopClient() {
w.connection.Close()
}
w.connection = nil
- w.isClosed = true
}
// IsConnected comment
@@ -234,9 +232,6 @@ func (w *WebRTC) IsConnected() bool {
return w.isConnected
}
-func (w *WebRTC) IsClosed() bool {
- return w.isClosed
-}
func (w *WebRTC) startStreaming(vp8Track *webrtc.Track) {
fmt.Println("Start streaming")
@@ -252,7 +247,7 @@ func (w *WebRTC) startStreaming(vp8Track *webrtc.Track) {
// receive frame buffer
go func() {
- for i := 0; w.isConnected; i++ {
+ for w.isConnected {
bs := <-w.encoder.Output
vp8Track.WriteSample(media.Sample{Data: bs, Samples: 1})
}