From bd3f31703376e96e07fa103bc9701b4627482606 Mon Sep 17 00:00:00 2001 From: mqh Date: Mon, 24 Aug 2020 09:11:26 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=92=AD=E6=94=BE?= =?UTF-8?q?=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 3 ++- main.go | 9 +++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index f6d5eed..23aad1c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ .idea .vscode -node_modules \ No newline at end of file +node_modules +/.history diff --git a/main.go b/main.go index 362a92e..7ca2583 100644 --- a/main.go +++ b/main.go @@ -240,6 +240,15 @@ func (rtc *WebRTC) GetAnswer() ([]byte, error) { func run() { http.HandleFunc("/webrtc/play", func(w http.ResponseWriter, r *http.Request) { + w.Header().Set("Access-Control-Allow-Credentials", "true") + origin := r.Header["Origin"] + if len(origin) == 0 { + w.Header().Set("Access-Control-Allow-Origin", "*") + } else { + w.Header().Set("Access-Control-Allow-Origin", origin[0]) + } + + w.Header().Set("Content-Type", "application/json") streamPath := r.URL.Query().Get("streamPath") var offer SessionDescription var rtc WebRTC From 0c234bc896a8a70f25dbba0cee4c354789aa87c7 Mon Sep 17 00:00:00 2001 From: mqh Date: Mon, 31 Aug 2020 11:07:11 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E4=BF=AE=E5=A4=8DPeerConnection=E6=9C=AA?= =?UTF-8?q?=E9=87=8A=E6=94=BE=E5=AF=BC=E8=87=B4UDP=E5=8D=A0=E7=94=A8?= =?UTF-8?q?=E6=8C=81=E7=BB=AD=E5=A2=9E=E9=95=BF=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.go | 1 + 1 file changed, 1 insertion(+) diff --git a/main.go b/main.go index 7ca2583..95af9f2 100644 --- a/main.go +++ b/main.go @@ -140,6 +140,7 @@ func (rtc *WebRTC) Play(streamPath string) bool { switch connectionState { case ICEConnectionStateDisconnected: sub.Close() + rtc.Close() case ICEConnectionStateConnected: //rtc.videoTrack = rtc.GetSenders()[0].Track()