HLS fmp4 support hls_ctx.

pull/4159/head
Jacob Su 6 months ago
parent bf029ed564
commit 96cd36afd4

@ -11,12 +11,16 @@ http_server {
listen 8080;
dir ./objs/nginx/html;
}
http_api {
enabled on;
listen 1985;
}
vhost __defaultVhost__ {
hls {
enabled on;
hls_use_fmp4 on;
hls_path ./objs/nginx/html;
hls_fragment 10;
hls_window 60;
hls_fragment 2;
hls_window 10;
}
}

@ -989,6 +989,7 @@ public:
// Whether enable hls_ctx
virtual bool get_hls_ctx_enabled(std::string vhost);
// Whether enable session for ts file.
// The ts file including .ts file for MPEG-ts segment, .m4s file and init.mp4 file for fmp4 segment.
virtual bool get_hls_ts_ctx_enabled(std::string vhost);
// hds section
private:

@ -74,6 +74,7 @@ protected:
virtual srs_error_t serve_mp4_stream(ISrsHttpResponseWriter* w, ISrsHttpMessage* r, std::string fullpath, int64_t start, int64_t end);
// Support HLS streaming with pseudo session id.
virtual srs_error_t serve_m3u8_ctx(ISrsHttpResponseWriter* w, ISrsHttpMessage* r, std::string fullpath);
// the ts file including: .ts .m4s init.mp4
virtual srs_error_t serve_ts_ctx(ISrsHttpResponseWriter* w, ISrsHttpMessage* r, std::string fullpath);
};

@ -405,12 +405,14 @@ srs_error_t SrsHttpFileServer::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMes
// use vod stream for .flv/.fhv
if (srs_string_ends_with(fullpath, ".flv") || srs_string_ends_with(fullpath, ".fhv")) {
return serve_flv_file(w, r, fullpath);
} else if (srs_string_ends_with(fullpath, ".mp4")) {
return serve_mp4_file(w, r, fullpath);
} else if (srs_string_ends_with(upath, ".m3u8")) {
return serve_m3u8_file(w, r, fullpath);
} else if (srs_string_ends_with(upath, ".ts")) {
} else if (srs_string_ends_with(upath, ".ts") ||
srs_string_ends_with(upath, ".m4s") ||
srs_path_basename(upath) == "init.mp4") {
return serve_ts_file(w, r, fullpath);
} else if (srs_string_ends_with(fullpath, ".mp4")) {
return serve_mp4_file(w, r, fullpath);
}
// serve common static file.

@ -352,6 +352,7 @@ private:
virtual srs_error_t serve_flv_file(ISrsHttpResponseWriter* w, ISrsHttpMessage* r, std::string fullpath);
virtual srs_error_t serve_mp4_file(ISrsHttpResponseWriter* w, ISrsHttpMessage* r, std::string fullpath);
virtual srs_error_t serve_m3u8_file(ISrsHttpResponseWriter* w, ISrsHttpMessage* r, std::string fullpath);
// the ts file including: .ts .m4s init.mp4
virtual srs_error_t serve_ts_file(ISrsHttpResponseWriter* w, ISrsHttpMessage* r, std::string fullpath);
protected:
// When access flv file with x.flv?start=xxx
@ -371,6 +372,7 @@ protected:
// Remark 2:
// If use two same "hls_ctx" in different requests, SRS cannot detect so that they will be treated as one.
virtual srs_error_t serve_m3u8_ctx(ISrsHttpResponseWriter* w, ISrsHttpMessage* r, std::string fullpath);
// the ts file including: .ts .m4s init.mp4
virtual srs_error_t serve_ts_ctx(ISrsHttpResponseWriter* w, ISrsHttpMessage* r, std::string fullpath);
protected:
// Copy the fs to response writer in size bytes.

Loading…
Cancel
Save