Skip to content

Commit

Permalink
2023.09.02: Enable CORS and timestamp in HLS. v5.8.30
Browse files Browse the repository at this point in the history
  • Loading branch information
winlinvip committed Sep 2, 2023
1 parent a3eee03 commit cc72962
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 11 deletions.
2 changes: 1 addition & 1 deletion platform/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ func initPlatform(ctx context.Context) error {
}

// Run only once for a special version.
bootRelease := "v28"
bootRelease := "v202328"
if firstRun, err := rdb.HGet(ctx, SRS_FIRST_BOOT, bootRelease).Result(); err != nil && err != redis.Nil {
return errors.Wrapf(err, "hget %v %v", SRS_FIRST_BOOT, bootRelease)
} else if firstRun == "" {
Expand Down
2 changes: 1 addition & 1 deletion platform/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ func handleHTTPService(ctx context.Context, handler *http.ServeMux) error {
}
if strings.HasSuffix(r.URL.Path, ".ts") {
httpAllowCORS(w, r)
w.Header().Set("Cache-Control", fmt.Sprintf("public, max-age=%v", 300))
w.Header().Set("Cache-Control", fmt.Sprintf("public, max-age=%v", 600))
hlsFileServer.ServeHTTP(w, r)
return
}
Expand Down
8 changes: 2 additions & 6 deletions platform/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,7 @@ func srsGenerateConfig(ctx context.Context) error {
" hls_window 60;",
" hls_path ./objs/nginx/html;",
" hls_m3u8_file [app]/[stream].m3u8;",
" hls_ts_file [app]/[stream]-[seq].ts;",
" hls_ts_file [app]/[stream]-[seq]-[timestamp].ts;",
" hls_wait_keyframe on;",
" hls_dispose 10;",
}
Expand Down Expand Up @@ -1248,12 +1248,8 @@ func Authenticate(ctx context.Context, apiSecret, token string, header http.Head
}

// httpAllowCORS allow CORS for HTTP request.
// Note that we always enable CROS because we enable HTTP cache.
func httpAllowCORS(w http.ResponseWriter, r *http.Request) {
// Ignore if no CORS required.
if r.Header.Get("Origin") == "" {
return
}

// SRS does not need cookie or credentials, so we disable CORS credentials, and use * for CORS origin,
// headers, expose headers and methods.
w.Header().Set("Access-Control-Allow-Origin", "*")
Expand Down
2 changes: 1 addition & 1 deletion platform/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
package main

// The version for platform.
const version = "v5.8.28"
const version = "v5.8.30"
2 changes: 1 addition & 1 deletion scripts/setup-aapanel/info.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"title": "SRS Stack",
"name": "srs_stack",
"ps": "SRS is a simple, high efficiency and realtime video server, supports RTMP, WebRTC, HLS, HTTP-FLV, and SRT.",
"versions": "5.8.28",
"versions": "5.8.30",
"checks": "/www/server/panel/plugin/srs_stack",
"author": "Winlin",
"home": "https://github.com/ossrs/srs-stack"
Expand Down
2 changes: 1 addition & 1 deletion scripts/setup-bt/info.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"title": "SRS音视频服务器",
"name": "srs_stack",
"ps": "直播和WebRTC音视频能力,支持RTMP、WebRTC、HLS、HTTP-FLV、SRT、MPEG-DASH和GB28181等常用协议",
"versions": "5.8.28",
"versions": "5.8.30",
"checks": "/www/server/panel/plugin/srs_stack",
"author": "Winlin",
"home": "https://github.com/ossrs/srs-stack"
Expand Down

0 comments on commit cc72962

Please sign in to comment.