mirror of https://github.com/gwuhaolin/livego.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
40 lines
692 B
40 lines
692 B
package rtsp |
|
|
|
import ( |
|
"net" |
|
"net/http" |
|
|
|
"github.com/gwuhaolin/livego/av" |
|
) |
|
|
|
type Server struct { |
|
handler av.Handler |
|
} |
|
|
|
type stream struct { |
|
Key string `json:"key"` |
|
Id string `json:"id"` |
|
} |
|
|
|
type streams struct { |
|
Publishers []stream `json:"publishers"` |
|
Players []stream `json:"players"` |
|
} |
|
|
|
func NewServer(h av.Handler) *Server { |
|
return &Server{ |
|
handler: h, |
|
} |
|
} |
|
|
|
func (server *Server) Serve(l net.Listener) error { |
|
mux := http.NewServeMux() |
|
mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { |
|
server.handleConn(w, r) |
|
}) |
|
mux.HandleFunc("/streams", func(w http.ResponseWriter, r *http.Request) { |
|
server.getStream(w, r) |
|
}) |
|
http.Serve(l, mux) |
|
return nil |
|
}
|
|
|