diff --git a/README.en.md b/README.en.md index 6f85e67..7754b0e 100644 --- a/README.en.md +++ b/README.en.md @@ -69,6 +69,13 @@ Response Body: `SDP` `/webrtc/test/publish` - `?streamPath=xxx` The streamPath to publish, default is `live/webrtc` - you can add other query parameters to the URL + +### ScreenShare Test Page + +`/webrtc/test/screenshare` +- `?streamPath=xxx` The streamPath to publish, default is `live/webrtc` +- you can add other query parameters to the URL + ### Play Test Page `/webrtc/test/subscribe` diff --git a/README.md b/README.md index 85e6722..ba924c3 100644 --- a/README.md +++ b/README.md @@ -66,6 +66,12 @@ Response Body: `SDP` `/webrtc/test/publish` - 可增加参数`?streamPath=xxx`指定推流地址,默认为`live/webrtc` - 可以增加其他推流参数 + +### 屏幕分享测试 + +`/webrtc/test/screenshare` +- 可增加参数`?streamPath=xxx`指定推流地址,默认为`live/webrtc` +- 可以增加其他推流参数 ### 播放测试页面 `/webrtc/test/subscribe` diff --git a/batcher.go b/batcher.go index a2a025d..d7239ca 100644 --- a/batcher.go +++ b/batcher.go @@ -73,13 +73,13 @@ func (suber *WebRTCBatcher) Signal(msg DataChannelMessage) { sub.WebRTCIO = suber.WebRTCIO if err = WebRTCPlugin.SubscribeExist(streamPath, sub); err == nil { suber.subscribers = append(suber.subscribers, sub) - go func() { + go func(streamPath string) { sub.PlayRTP() - if sub.audioSender != nil { - suber.RemoveTrack(sub.audioSender) + if sub.audio.RTPSender != nil { + suber.RemoveTrack(sub.audio.RTPSender ) } - if sub.videoSender != nil { - suber.RemoveTrack(sub.videoSender) + if sub.video.RTPSender != nil { + suber.RemoveTrack(sub.video.RTPSender) } if sub.DC != nil { sub.DC.Close() @@ -87,7 +87,7 @@ func (suber *WebRTCBatcher) Signal(msg DataChannelMessage) { removeMap["streamPath"] = streamPath b, _ := json.Marshal(removeMap) suber.signalChannel.SendText(string(b)) - }() + }(streamPath) } else { removeMap["streamPath"] = streamPath b, _ := json.Marshal(removeMap) diff --git a/io.go b/io.go index 80523f1..c7c4cfe 100644 --- a/io.go +++ b/io.go @@ -7,6 +7,7 @@ import ( type WebRTCIO struct { *PeerConnection SDP string + // LocalSDP *sdp.SessionDescription } func (IO *WebRTCIO) GetAnswer() (string, error) { @@ -15,10 +16,14 @@ func (IO *WebRTCIO) GetAnswer() (string, error) { if err != nil { return "", err } + // IO.LocalSDP, err = answer.Unmarshal() + // if err != nil { + // return "", err + // } gatherComplete := GatheringCompletePromise(IO.PeerConnection) if err := IO.SetLocalDescription(answer); err != nil { return "", err } <-gatherComplete return IO.LocalDescription().SDP, nil -} \ No newline at end of file +} diff --git a/main.go b/main.go index 73fdea8..e871fca 100644 --- a/main.go +++ b/main.go @@ -230,6 +230,9 @@ func (conf *WebRTCConfig) Push_(w http.ResponseWriter, r *http.Request) { func (conf *WebRTCConfig) Test_Publish(w http.ResponseWriter, r *http.Request) { w.Write(publishHTML) } +func (conf *WebRTCConfig) Test_ScreenShare(w http.ResponseWriter, r *http.Request) { + w.Write(publishHTML) +} func (conf *WebRTCConfig) Test_Subscribe(w http.ResponseWriter, r *http.Request) { w.Write(subscribeHTML) } diff --git a/publish.html b/publish.html index 143fee6..3d646b0 100644 --- a/publish.html +++ b/publish.html @@ -12,6 +12,7 @@ +
   
 
@@ -20,16 +21,29 @@