diff --git a/main.go b/main.go index 469fb62..422be8c 100644 --- a/main.go +++ b/main.go @@ -47,7 +47,8 @@ import ( //go:embed publish.html var publishHTML []byte - +//go:embed subscribe.html +var subscribeHTML []byte var ( reg_level = regexp.MustCompile("profile-level-id=(4.+f)") ) @@ -144,7 +145,7 @@ func (conf *WebRTCConfig) Push_(w http.ResponseWriter, r *http.Request) { http.Error(w, err.Error(), http.StatusInternalServerError) return } - // puber.SetIO(puber.PeerConnection) + puber.SetIO(puber.PeerConnection) //TODO: 单PC需要注释掉 puber.OnICECandidate(func(ice *ICECandidate) { if ice != nil { puber.Info(ice.ToJSON().Candidate) @@ -206,7 +207,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_Subscribe(w http.ResponseWriter, r *http.Request) { + w.Write(subscribeHTML) +} var webrtcConfig WebRTCConfig var WebRTCPlugin = engine.InstallPlugin(&webrtcConfig) diff --git a/publish.html b/publish.html index a98f5d7..2b72e8c 100644 --- a/publish.html +++ b/publish.html @@ -12,10 +12,20 @@ +
+
+
+
+
+
+
+
+
+
+
+
+diff --git a/publisher.go b/publisher.go index 45d3c61..750f740 100644 --- a/publisher.go +++ b/publisher.go @@ -1,7 +1,6 @@ package webrtc import ( - "fmt" "time" "github.com/pion/rtcp" @@ -75,7 +74,8 @@ func (puber *WebRTCPublisher) writeRTCP(track *TrackRemote) { select { case <-ticker.C: if rtcpErr := puber.WriteRTCP([]rtcp.Packet{&rtcp.PictureLossIndication{MediaSSRC: uint32(track.SSRC())}}); rtcpErr != nil { - fmt.Println(rtcpErr) + puber.Error("writeRTCP", zap.Error(rtcpErr)) + return } case <-puber.Done(): return diff --git a/subscribe.html b/subscribe.html new file mode 100644 index 0000000..2c6bb4a --- /dev/null +++ b/subscribe.html @@ -0,0 +1,87 @@ + + + +
+ + + +
+ + +
+ + +