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

API: Fix the same 'client_id' error when asynchronous call (#2665) v4.0.179

This commit is contained in:
Haibo Chen 2021-10-16 07:50:47 +08:00 committed by winlin
parent f7c32b45fd
commit 3fc287f7de
4 changed files with 68 additions and 48 deletions

View file

@ -8,6 +8,7 @@ The changelog for SRS.
## SRS 4.0 Changelog
* v4.0, 2021-10-16, Merge [#2665](https://github.com/ossrs/srs/pull/2665): API: Fix the same 'client_id' error when asynchronous call. v4.0.179
* v4.0, 2021-10-13, Merge [#2671](https://github.com/ossrs/srs/pull/2671): SRT: Pes error when mpegts demux in srt. v4.0.178
* v4.0, 2021-10-12, Merge [#2550](https://github.com/ossrs/srs/pull/2550): API use publish params. v4.0.177
* v4.0, 2021-10-12, Merge [#2549](https://github.com/ossrs/srs/pull/2549): Fix duration issue for HLS on_hls. v4.0.176

View file

@ -37,6 +37,7 @@ using namespace std;
#include <srs_app_http_hooks.hpp>
#include <srs_app_statistic.hpp>
#include <srs_app_hybrid.hpp>
#include <srs_service_log.hpp>
#define SRS_CONTEXT_IN_HLS "hls_ctx"
@ -194,6 +195,12 @@ srs_error_t SrsVodStream::serve_m3u8_ctx(ISrsHttpResponseWriter * w, ISrsHttpMes
srs_assert(hr);
SrsRequest* req = hr->to_request(hr->host())->as_http();
// discovery vhost, resolve the vhost from config
SrsConfDirective* parsed_vhost = _srs_config->get_vhost(req->vhost);
if (parsed_vhost) {
req->vhost = parsed_vhost->arg0();
}
SrsAutoFree(SrsRequest, req);
string ctx = hr->query_get(SRS_CONTEXT_IN_HLS);
@ -202,10 +209,6 @@ srs_error_t SrsVodStream::serve_m3u8_ctx(ISrsHttpResponseWriter * w, ISrsHttpMes
return SrsHttpFileServer::serve_m3u8_ctx(w, r, fullpath);
}
if ((err = http_hooks_on_play(req)) != srs_success) {
return srs_error_wrap(err, "HLS: http_hooks_on_play");
}
if (ctx.empty()) {
// make sure unique
do {
@ -213,6 +216,13 @@ srs_error_t SrsVodStream::serve_m3u8_ctx(ISrsHttpResponseWriter * w, ISrsHttpMes
} while (ctx_is_exist(ctx));
}
SrsContextRestore(_srs_context->get_id());
_srs_context->set_id(SrsContextId().set_value(ctx));
if ((err = http_hooks_on_play(req)) != srs_success) {
return srs_error_wrap(err, "HLS: http_hooks_on_play");
}
std::stringstream ss;
ss << "#EXTM3U" << SRS_CONSTS_LF;
ss << "#EXT-X-STREAM-INF:BANDWIDTH=1,AVERAGE-BANDWIDTH=1" << SRS_CONSTS_LF;
@ -339,6 +349,9 @@ srs_error_t SrsVodStream::on_timer(srs_utime_t interval)
SrsRequest* req = it->second.req;
srs_utime_t hls_window = _srs_config->get_hls_window(req->vhost);
if (it->second.request_time + (2 * hls_window) < srs_get_system_time()) {
SrsContextRestore(_srs_context->get_id());
_srs_context->set_id(SrsContextId().set_value(ctx));
http_hooks_on_stop(req);
srs_freep(req);

View file

@ -386,6 +386,9 @@ srs_error_t SrsRtcAsyncCallOnStop::call()
hooks = conf->args;
}
SrsContextRestore(_srs_context->get_id());
_srs_context->set_id(cid);
for (int i = 0; i < (int)hooks.size(); i++) {
std::string url = hooks.at(i);
SrsHttpHooks::on_stop(url, req);
@ -1031,6 +1034,9 @@ srs_error_t SrsRtcAsyncCallOnUnpublish::call()
hooks = conf->args;
}
SrsContextRestore(_srs_context->get_id());
_srs_context->set_id(cid);
for (int i = 0; i < (int)hooks.size(); i++) {
std::string url = hooks.at(i);
SrsHttpHooks::on_unpublish(url, req);

View file

@ -9,6 +9,6 @@
#define VERSION_MAJOR 4
#define VERSION_MINOR 0
#define VERSION_REVISION 178
#define VERSION_REVISION 179
#endif