diff --git a/trunk/conf/hls.mp4.conf b/trunk/conf/hls.mp4.conf index b957ca2a26..78b8fa3dde 100644 --- a/trunk/conf/hls.mp4.conf +++ b/trunk/conf/hls.mp4.conf @@ -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; } } diff --git a/trunk/src/app/srs_app_config.hpp b/trunk/src/app/srs_app_config.hpp index c06b3a3941..4c337ffca9 100644 --- a/trunk/src/app/srs_app_config.hpp +++ b/trunk/src/app/srs_app_config.hpp @@ -989,6 +989,7 @@ class SrsConfig // 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: diff --git a/trunk/src/app/srs_app_http_static.hpp b/trunk/src/app/srs_app_http_static.hpp index d4682370d8..9c679acf50 100644 --- a/trunk/src/app/srs_app_http_static.hpp +++ b/trunk/src/app/srs_app_http_static.hpp @@ -74,6 +74,7 @@ class SrsVodStream : public SrsHttpFileServer 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); }; diff --git a/trunk/src/protocol/srs_protocol_http_stack.cpp b/trunk/src/protocol/srs_protocol_http_stack.cpp index b280fca387..c11e4eac3f 100644 --- a/trunk/src/protocol/srs_protocol_http_stack.cpp +++ b/trunk/src/protocol/srs_protocol_http_stack.cpp @@ -405,13 +405,15 @@ 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. return serve_file(w, r, fullpath); diff --git a/trunk/src/protocol/srs_protocol_http_stack.hpp b/trunk/src/protocol/srs_protocol_http_stack.hpp index fcef24401d..90c5a0d09c 100644 --- a/trunk/src/protocol/srs_protocol_http_stack.hpp +++ b/trunk/src/protocol/srs_protocol_http_stack.hpp @@ -352,6 +352,7 @@ class SrsHttpFileServer : public ISrsHttpHandler 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 @@ class SrsHttpFileServer : public ISrsHttpHandler // 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.