1
0
Fork 0
mirror of https://github.com/ossrs/srs.git synced 2025-03-09 15:49:59 +00:00

Enhance HLS: support http callback on_play/stop, support statistic (#2578)

* Enhance HLS: support http callback on_play/stop, support statistic

* make code readable

* make code readable

* rename secret
This commit is contained in:
Haibo Chen 2021-09-23 13:31:45 +08:00 committed by winlin
parent 46adcfb6c9
commit 36b813b971
7 changed files with 277 additions and 5 deletions

View file

@ -143,6 +143,11 @@ string mock_http_response2(int status, string content)
return ss.str();
}
bool is_string_contain(string substr, string str)
{
return (string::npos != str.find(substr));
}
class MockFileReaderFactory : public ISrsFileReaderFactory
{
public:
@ -1183,6 +1188,42 @@ VOID TEST(ProtocolHTTPTest, VodStreamHandlers)
HELPER_ASSERT_SUCCESS(h.serve_http(&w, &r));
__MOCK_HTTP_EXPECT_STREQ(200, "Hello, world!", w);
}
// should return "hls_ctx"
if (true) {
SrsHttpMuxEntry e;
e.pattern = "/";
SrsVodStream h("/tmp");
h.set_fs_factory(new MockFileReaderFactory("Hello, world!"));
h.set_path_check(_mock_srs_path_always_exists);
h.entry = &e;
MockResponseWriter w;
SrsHttpMessage r(NULL, NULL);
HELPER_ASSERT_SUCCESS(r.set_url("/index.m3u8", false));
HELPER_ASSERT_SUCCESS(h.serve_http(&w, &r));
__MOCK_HTTP_EXPECT_STRCT(200, "index.m3u8?hls_ctx=", w);
}
// should return "hls_ctx"
if (true) {
SrsHttpMuxEntry e;
e.pattern = "/";
SrsVodStream h("/tmp");
h.set_fs_factory(new MockFileReaderFactory("Hello, world!"));
h.set_path_check(_mock_srs_path_always_exists);
h.entry = &e;
MockResponseWriter w;
SrsHttpMessage r(NULL, NULL);
HELPER_ASSERT_SUCCESS(r.set_url("/index.m3u8?hls_ctx=123456", false));
HELPER_ASSERT_SUCCESS(h.serve_http(&w, &r));
__MOCK_HTTP_EXPECT_STRCT(200, "index.m3u8?hls_ctx=123456", w);
}
}
VOID TEST(ProtocolHTTPTest, BasicHandlers)