mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
Fix #910, Support HTTP FLV with HTTP callback. 3.0.39
This commit is contained in:
commit
1cc72df134
7 changed files with 106 additions and 6 deletions
|
@ -184,6 +184,7 @@ Please select according to languages:
|
||||||
|
|
||||||
### V3 changes
|
### V3 changes
|
||||||
|
|
||||||
|
* v3.0, 2018-08-11, For [#910][bug #910], Support HTTP FLV with HTTP callback. 3.0.39
|
||||||
* v3.0, 2018-08-05, Refine HTTP-FLV latency, support realtime mode.3.0.38
|
* v3.0, 2018-08-05, Refine HTTP-FLV latency, support realtime mode.3.0.38
|
||||||
* v3.0, 2018-08-05, Fix [#1087][bug #1087], Ignore iface without address. 3.0.37
|
* v3.0, 2018-08-05, Fix [#1087][bug #1087], Ignore iface without address. 3.0.37
|
||||||
* v3.0, 2018-08-04, For [#1110][bug #1110], Support params in http callback. 3.0.36
|
* v3.0, 2018-08-04, For [#1110][bug #1110], Support params in http callback. 3.0.36
|
||||||
|
@ -229,6 +230,7 @@ Please select according to languages:
|
||||||
|
|
||||||
### V2 changes
|
### V2 changes
|
||||||
|
|
||||||
|
* v2.0, 2018-08-11, For [#910][bug #910], Support HTTP FLV with HTTP callback. 2.0.254
|
||||||
* v2.0, 2018-08-11, For [#1110][bug #1110], Refine params in http callback. 2.0.253
|
* v2.0, 2018-08-11, For [#1110][bug #1110], Refine params in http callback. 2.0.253
|
||||||
* v2.0, 2018-08-05, Refine HTTP-FLV latency, support realtime mode. 2.0.252
|
* v2.0, 2018-08-05, Refine HTTP-FLV latency, support realtime mode. 2.0.252
|
||||||
* v2.0, 2018-08-04, For [#1110][bug #1110], Support params in http callback. 2.0.251
|
* v2.0, 2018-08-04, For [#1110][bug #1110], Support params in http callback. 2.0.251
|
||||||
|
@ -1443,6 +1445,7 @@ Winlin
|
||||||
[bug #1119]: https://github.com/ossrs/srs/issues/1119
|
[bug #1119]: https://github.com/ossrs/srs/issues/1119
|
||||||
[bug #1031]: https://github.com/ossrs/srs/issues/1031
|
[bug #1031]: https://github.com/ossrs/srs/issues/1031
|
||||||
[bug #1110]: https://github.com/ossrs/srs/issues/1110
|
[bug #1110]: https://github.com/ossrs/srs/issues/1110
|
||||||
|
[bug #910]: https://github.com/ossrs/srs/issues/910
|
||||||
[bug #xxxxxxxxxx]: https://github.com/ossrs/srs/issues/xxxxxxxxxx
|
[bug #xxxxxxxxxx]: https://github.com/ossrs/srs/issues/xxxxxxxxxx
|
||||||
|
|
||||||
[bug #735]: https://github.com/ossrs/srs/issues/735
|
[bug #735]: https://github.com/ossrs/srs/issues/735
|
||||||
|
|
|
@ -54,10 +54,11 @@ using namespace std;
|
||||||
#include <srs_app_server.hpp>
|
#include <srs_app_server.hpp>
|
||||||
#include <srs_app_statistic.hpp>
|
#include <srs_app_statistic.hpp>
|
||||||
#include <srs_app_recv_thread.hpp>
|
#include <srs_app_recv_thread.hpp>
|
||||||
|
#include <srs_app_http_hooks.hpp>
|
||||||
|
|
||||||
SrsBufferCache::SrsBufferCache(SrsSource* s, SrsRequest* r)
|
SrsBufferCache::SrsBufferCache(SrsSource* s, SrsRequest* r)
|
||||||
{
|
{
|
||||||
req = r->copy();
|
req = r->copy()->as_http();
|
||||||
source = s;
|
source = s;
|
||||||
queue = new SrsMessageQueue(true);
|
queue = new SrsMessageQueue(true);
|
||||||
trd = new SrsSTCoroutine("http-stream", this);
|
trd = new SrsSTCoroutine("http-stream", this);
|
||||||
|
@ -466,7 +467,7 @@ SrsLiveStream::SrsLiveStream(SrsSource* s, SrsRequest* r, SrsBufferCache* c)
|
||||||
{
|
{
|
||||||
source = s;
|
source = s;
|
||||||
cache = c;
|
cache = c;
|
||||||
req = r->copy();
|
req = r->copy()->as_http();
|
||||||
}
|
}
|
||||||
|
|
||||||
SrsLiveStream::~SrsLiveStream()
|
SrsLiveStream::~SrsLiveStream()
|
||||||
|
@ -476,9 +477,10 @@ SrsLiveStream::~SrsLiveStream()
|
||||||
|
|
||||||
srs_error_t SrsLiveStream::update(SrsSource* s, SrsRequest* r)
|
srs_error_t SrsLiveStream::update(SrsSource* s, SrsRequest* r)
|
||||||
{
|
{
|
||||||
srs_freep(req);
|
|
||||||
source = s;
|
source = s;
|
||||||
req = r->copy();
|
|
||||||
|
srs_freep(req);
|
||||||
|
req = r->copy()->as_http();
|
||||||
|
|
||||||
return srs_success;
|
return srs_success;
|
||||||
}
|
}
|
||||||
|
@ -487,6 +489,21 @@ srs_error_t SrsLiveStream::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage
|
||||||
{
|
{
|
||||||
srs_error_t err = srs_success;
|
srs_error_t err = srs_success;
|
||||||
|
|
||||||
|
if ((err = http_hooks_on_play()) != srs_success) {
|
||||||
|
return srs_error_wrap(err, "http hook");
|
||||||
|
}
|
||||||
|
|
||||||
|
err = do_serve_http(w, r);
|
||||||
|
|
||||||
|
http_hooks_on_stop();
|
||||||
|
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
|
srs_error_t SrsLiveStream::do_serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r)
|
||||||
|
{
|
||||||
|
srs_error_t err = srs_success;
|
||||||
|
|
||||||
string enc_desc;
|
string enc_desc;
|
||||||
ISrsBufferEncoder* enc = NULL;
|
ISrsBufferEncoder* enc = NULL;
|
||||||
|
|
||||||
|
@ -641,6 +658,69 @@ srs_error_t SrsLiveStream::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
srs_error_t SrsLiveStream::http_hooks_on_play()
|
||||||
|
{
|
||||||
|
srs_error_t err = srs_success;
|
||||||
|
|
||||||
|
if (!_srs_config->get_vhost_http_hooks_enabled(req->vhost)) {
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
|
// the http hooks will cause context switch,
|
||||||
|
// so we must copy all hooks for the on_connect may freed.
|
||||||
|
// @see https://github.com/ossrs/srs/issues/475
|
||||||
|
vector<string> hooks;
|
||||||
|
|
||||||
|
if (true) {
|
||||||
|
SrsConfDirective* conf = _srs_config->get_vhost_on_play(req->vhost);
|
||||||
|
|
||||||
|
if (!conf) {
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
|
hooks = conf->args;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < (int)hooks.size(); i++) {
|
||||||
|
std::string url = hooks.at(i);
|
||||||
|
if ((err = SrsHttpHooks::on_play(url, req)) != srs_success) {
|
||||||
|
return srs_error_wrap(err, "rtmp on_play %s", url.c_str());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SrsLiveStream::http_hooks_on_stop()
|
||||||
|
{
|
||||||
|
if (!_srs_config->get_vhost_http_hooks_enabled(req->vhost)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// the http hooks will cause context switch,
|
||||||
|
// so we must copy all hooks for the on_connect may freed.
|
||||||
|
// @see https://github.com/ossrs/srs/issues/475
|
||||||
|
vector<string> hooks;
|
||||||
|
|
||||||
|
if (true) {
|
||||||
|
SrsConfDirective* conf = _srs_config->get_vhost_on_stop(req->vhost);
|
||||||
|
|
||||||
|
if (!conf) {
|
||||||
|
srs_info("ignore the empty http callback: on_stop");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
hooks = conf->args;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < (int)hooks.size(); i++) {
|
||||||
|
std::string url = hooks.at(i);
|
||||||
|
SrsHttpHooks::on_stop(url, req);
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
srs_error_t SrsLiveStream::streaming_send_messages(ISrsBufferEncoder* enc, SrsSharedPtrMessage** msgs, int nb_msgs)
|
srs_error_t SrsLiveStream::streaming_send_messages(ISrsBufferEncoder* enc, SrsSharedPtrMessage** msgs, int nb_msgs)
|
||||||
{
|
{
|
||||||
srs_error_t err = srs_success;
|
srs_error_t err = srs_success;
|
||||||
|
@ -786,7 +866,7 @@ srs_error_t SrsHttpStreamServer::http_mount(SrsSource* s, SrsRequest* r)
|
||||||
srs_freep(tmpl->req);
|
srs_freep(tmpl->req);
|
||||||
|
|
||||||
tmpl->source = s;
|
tmpl->source = s;
|
||||||
tmpl->req = r->copy();
|
tmpl->req = r->copy()->as_http();
|
||||||
|
|
||||||
sflvs[sid] = entry;
|
sflvs[sid] = entry;
|
||||||
|
|
||||||
|
|
|
@ -228,6 +228,9 @@ public:
|
||||||
public:
|
public:
|
||||||
virtual srs_error_t serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r);
|
virtual srs_error_t serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r);
|
||||||
private:
|
private:
|
||||||
|
virtual srs_error_t do_serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r);
|
||||||
|
virtual srs_error_t http_hooks_on_play();
|
||||||
|
virtual void http_hooks_on_stop();
|
||||||
virtual srs_error_t streaming_send_messages(ISrsBufferEncoder* enc, SrsSharedPtrMessage** msgs, int nb_msgs);
|
virtual srs_error_t streaming_send_messages(ISrsBufferEncoder* enc, SrsSharedPtrMessage** msgs, int nb_msgs);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,7 @@
|
||||||
// current release version
|
// current release version
|
||||||
#define VERSION_MAJOR 3
|
#define VERSION_MAJOR 3
|
||||||
#define VERSION_MINOR 0
|
#define VERSION_MINOR 0
|
||||||
#define VERSION_REVISION 38
|
#define VERSION_REVISION 39
|
||||||
|
|
||||||
// generated by configure, only macros.
|
// generated by configure, only macros.
|
||||||
#include <srs_auto_headers.hpp>
|
#include <srs_auto_headers.hpp>
|
||||||
|
|
|
@ -113,6 +113,11 @@ void srs_discovery_tc_url(string tcUrl, string& schema, string& host, string& vh
|
||||||
vhost = host;
|
vhost = host;
|
||||||
srs_vhost_resolve(vhost, app, param);
|
srs_vhost_resolve(vhost, app, param);
|
||||||
srs_vhost_resolve(vhost, stream, param);
|
srs_vhost_resolve(vhost, stream, param);
|
||||||
|
|
||||||
|
// Ignore when the param only contains the default vhost.
|
||||||
|
if (param == "?vhost="SRS_CONSTS_RTMP_DEFAULT_VHOST) {
|
||||||
|
param = "";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void srs_parse_query_string(string q, map<string,string>& query)
|
void srs_parse_query_string(string q, map<string,string>& query)
|
||||||
|
|
|
@ -1624,6 +1624,12 @@ void SrsRequest::strip()
|
||||||
stream = srs_string_trim_start(stream, "/");
|
stream = srs_string_trim_start(stream, "/");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SrsRequest* SrsRequest::as_http()
|
||||||
|
{
|
||||||
|
schema = "http";
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
SrsResponse::SrsResponse()
|
SrsResponse::SrsResponse()
|
||||||
{
|
{
|
||||||
stream_id = SRS_DEFAULT_SID;
|
stream_id = SRS_DEFAULT_SID;
|
||||||
|
|
|
@ -602,6 +602,9 @@ public:
|
||||||
* strip url, user must strip when update the url.
|
* strip url, user must strip when update the url.
|
||||||
*/
|
*/
|
||||||
virtual void strip();
|
virtual void strip();
|
||||||
|
public:
|
||||||
|
// Transform it as HTTP request.
|
||||||
|
virtual SrsRequest* as_http();
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue