Browse Source

修改播放逻辑

v4
mqh 4 years ago
parent
commit
bd3f317033
  1. 3
      .gitignore
  2. 9
      main.go

3
.gitignore

@ -1,3 +1,4 @@
.idea .idea
.vscode .vscode
node_modules node_modules
/.history

9
main.go

@ -240,6 +240,15 @@ func (rtc *WebRTC) GetAnswer() ([]byte, error) {
func run() { func run() {
http.HandleFunc("/webrtc/play", func(w http.ResponseWriter, r *http.Request) { 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") streamPath := r.URL.Query().Get("streamPath")
var offer SessionDescription var offer SessionDescription
var rtc WebRTC var rtc WebRTC

Loading…
Cancel
Save