正在显示
5 个修改的文件
包含
26 行增加
和
3 行删除
| @@ -557,6 +557,12 @@ int SrsHlsMuxer::segment_open(int64_t segment_start_dts) | @@ -557,6 +557,12 @@ int SrsHlsMuxer::segment_open(int64_t segment_start_dts) | ||
| 557 | current->uri += hls_entry_prefix; | 557 | current->uri += hls_entry_prefix; |
| 558 | if (!hls_entry_prefix.empty() && !srs_string_ends_with(hls_entry_prefix, "/")) { | 558 | if (!hls_entry_prefix.empty() && !srs_string_ends_with(hls_entry_prefix, "/")) { |
| 559 | current->uri += "/"; | 559 | current->uri += "/"; |
| 560 | + | ||
| 561 | + // add the http dir to uri. | ||
| 562 | + string http_dir = srs_path_dirname(m3u8_url); | ||
| 563 | + if (!http_dir.empty()) { | ||
| 564 | + current->uri += http_dir + "/"; | ||
| 565 | + } | ||
| 560 | } | 566 | } |
| 561 | current->uri += ts_url; | 567 | current->uri += ts_url; |
| 562 | 568 |
| @@ -39,6 +39,7 @@ using namespace std; | @@ -39,6 +39,7 @@ using namespace std; | ||
| 39 | #include <srs_kernel_utility.hpp> | 39 | #include <srs_kernel_utility.hpp> |
| 40 | #include <srs_app_http_conn.hpp> | 40 | #include <srs_app_http_conn.hpp> |
| 41 | #include <srs_protocol_amf0.hpp> | 41 | #include <srs_protocol_amf0.hpp> |
| 42 | +#include <srs_app_utility.hpp> | ||
| 42 | 43 | ||
| 43 | #define SRS_HTTP_RESPONSE_OK SRS_XSTR(ERROR_SUCCESS) | 44 | #define SRS_HTTP_RESPONSE_OK SRS_XSTR(ERROR_SUCCESS) |
| 44 | 45 | ||
| @@ -315,6 +316,12 @@ int SrsHttpHooks::on_hls(int cid, string url, SrsRequest* req, string file, stri | @@ -315,6 +316,12 @@ int SrsHttpHooks::on_hls(int cid, string url, SrsRequest* req, string file, stri | ||
| 315 | int client_id = cid; | 316 | int client_id = cid; |
| 316 | std::string cwd = _srs_config->cwd(); | 317 | std::string cwd = _srs_config->cwd(); |
| 317 | 318 | ||
| 319 | + // the ts_url is under the same dir of m3u8_url. | ||
| 320 | + string prefix = srs_path_dirname(m3u8_url); | ||
| 321 | + if (!prefix.empty() && !srs_string_is_http(ts_url)) { | ||
| 322 | + ts_url = prefix + "/" + ts_url; | ||
| 323 | + } | ||
| 324 | + | ||
| 318 | SrsJsonObject* obj = SrsJsonAny::object(); | 325 | SrsJsonObject* obj = SrsJsonAny::object(); |
| 319 | SrsAutoFree(SrsJsonObject, obj); | 326 | SrsAutoFree(SrsJsonObject, obj); |
| 320 | 327 | ||
| @@ -358,7 +365,7 @@ int SrsHttpHooks::on_hls_notify(int cid, std::string url, SrsRequest* req, std:: | @@ -358,7 +365,7 @@ int SrsHttpHooks::on_hls_notify(int cid, std::string url, SrsRequest* req, std:: | ||
| 358 | int client_id = cid; | 365 | int client_id = cid; |
| 359 | std::string cwd = _srs_config->cwd(); | 366 | std::string cwd = _srs_config->cwd(); |
| 360 | 367 | ||
| 361 | - if (srs_string_starts_with(ts_url, "http://") || srs_string_starts_with(ts_url, "https://")) { | 368 | + if (srs_string_is_http(ts_url)) { |
| 362 | url = ts_url; | 369 | url = ts_url; |
| 363 | } | 370 | } |
| 364 | 371 |
| @@ -29,6 +29,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | @@ -29,6 +29,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
| 29 | #include <arpa/inet.h> | 29 | #include <arpa/inet.h> |
| 30 | #include <signal.h> | 30 | #include <signal.h> |
| 31 | #include <sys/wait.h> | 31 | #include <sys/wait.h> |
| 32 | +#include <math.h> | ||
| 32 | 33 | ||
| 33 | #ifdef SRS_OSX | 34 | #ifdef SRS_OSX |
| 34 | #include <sys/sysctl.h> | 35 | #include <sys/sysctl.h> |
| @@ -47,6 +48,7 @@ using namespace std; | @@ -47,6 +48,7 @@ using namespace std; | ||
| 47 | #include <srs_protocol_json.hpp> | 48 | #include <srs_protocol_json.hpp> |
| 48 | #include <srs_kernel_buffer.hpp> | 49 | #include <srs_kernel_buffer.hpp> |
| 49 | #include <srs_protocol_amf0.hpp> | 50 | #include <srs_protocol_amf0.hpp> |
| 51 | +#include <srs_kernel_utility.hpp> | ||
| 50 | 52 | ||
| 51 | // the longest time to wait for a process to quit. | 53 | // the longest time to wait for a process to quit. |
| 52 | #define SRS_PROCESS_QUIT_TIMEOUT_MS 1000 | 54 | #define SRS_PROCESS_QUIT_TIMEOUT_MS 1000 |
| @@ -1340,6 +1342,11 @@ string srs_get_peer_ip(int fd) | @@ -1340,6 +1342,11 @@ string srs_get_peer_ip(int fd) | ||
| 1340 | return ip; | 1342 | return ip; |
| 1341 | } | 1343 | } |
| 1342 | 1344 | ||
| 1345 | +bool srs_string_is_http(string url) | ||
| 1346 | +{ | ||
| 1347 | + return srs_string_starts_with(url, "http://", "https://"); | ||
| 1348 | +} | ||
| 1349 | + | ||
| 1343 | bool srs_is_digit_number(const string& str) | 1350 | bool srs_is_digit_number(const string& str) |
| 1344 | { | 1351 | { |
| 1345 | if (str.empty()) { | 1352 | if (str.empty()) { |
| @@ -662,6 +662,9 @@ extern int srs_get_local_port(int fd); | @@ -662,6 +662,9 @@ extern int srs_get_local_port(int fd); | ||
| 662 | // where peer ip is the client public ip which connected to server. | 662 | // where peer ip is the client public ip which connected to server. |
| 663 | extern std::string srs_get_peer_ip(int fd); | 663 | extern std::string srs_get_peer_ip(int fd); |
| 664 | 664 | ||
| 665 | +// whether the url is starts with http:// or https:// | ||
| 666 | +extern bool srs_string_is_http(std::string url); | ||
| 667 | + | ||
| 665 | // whether string is digit number | 668 | // whether string is digit number |
| 666 | // is_digit("1234567890") === true | 669 | // is_digit("1234567890") === true |
| 667 | // is_digit("0123456789") === false | 670 | // is_digit("0123456789") === false |
| @@ -460,7 +460,7 @@ int SrsIngestSrsInput::parseM3u8(SrsHttpUri* url, double& td, double& duration) | @@ -460,7 +460,7 @@ int SrsIngestSrsInput::parseM3u8(SrsHttpUri* url, double& td, double& duration) | ||
| 460 | std::string m3u8_url = body.substr(0, pos); | 460 | std::string m3u8_url = body.substr(0, pos); |
| 461 | body = body.substr(pos + 1); | 461 | body = body.substr(pos + 1); |
| 462 | 462 | ||
| 463 | - if (!srs_string_starts_with(m3u8_url, "http://")) { | 463 | + if (!srs_string_is_http(m3u8_url)) { |
| 464 | m3u8_url = srs_path_dirname(url->get_url()) + "/" + m3u8_url; | 464 | m3u8_url = srs_path_dirname(url->get_url()) + "/" + m3u8_url; |
| 465 | } | 465 | } |
| 466 | srs_trace("parse sub m3u8, url=%s", m3u8_url.c_str()); | 466 | srs_trace("parse sub m3u8, url=%s", m3u8_url.c_str()); |
| @@ -594,7 +594,7 @@ int SrsIngestSrsInput::SrsTsPiece::fetch(string m3u8) | @@ -594,7 +594,7 @@ int SrsIngestSrsInput::SrsTsPiece::fetch(string m3u8) | ||
| 594 | SrsHttpClient client; | 594 | SrsHttpClient client; |
| 595 | 595 | ||
| 596 | std::string ts_url = url; | 596 | std::string ts_url = url; |
| 597 | - if (!srs_string_starts_with(ts_url, "http://")) { | 597 | + if (!srs_string_is_http(ts_url)) { |
| 598 | ts_url = srs_path_dirname(m3u8) + "/" + url; | 598 | ts_url = srs_path_dirname(m3u8) + "/" + url; |
| 599 | } | 599 | } |
| 600 | 600 |
-
请 注册 或 登录 后发表评论