vod.go 481 B

123456789101112131415161718192021222324252627
  1. package record
  2. import (
  3. "net/http"
  4. )
  5. func ext(path string) string {
  6. for i := len(path) - 1; i >= 0 && path[i] != '/'; i-- {
  7. if path[i] == '.' {
  8. return path[i:]
  9. }
  10. }
  11. return ""
  12. }
  13. func (conf *RecordConfig) ServeHTTP(w http.ResponseWriter, r *http.Request) {
  14. switch ext(r.URL.Path) {
  15. case ".flv":
  16. conf.Flv.ServeHTTP(w, r)
  17. case ".mp4":
  18. conf.Mp4.ServeHTTP(w, r)
  19. case ".m3u8", ".ts":
  20. conf.Hls.ServeHTTP(w, r)
  21. case ".h264", ".h265":
  22. conf.Raw.ServeHTTP(w, r)
  23. }
  24. }