Browse Source
Merge pull request #4 from ourfor-pp/master
增加跨域处理&&修复UDP占用持续增长的bug
v4
dexter
4 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with
12 additions and
1 deletions
-
.gitignore
-
main.go
|
|
@ -1,3 +1,4 @@ |
|
|
|
.idea |
|
|
|
.vscode |
|
|
|
node_modules |
|
|
|
/.history |
|
|
|
|
|
@ -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()
|
|
|
@ -240,6 +241,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 |
|
|
|