mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
add utest for config vhosts, transcode/dvr/hls
This commit is contained in:
parent
d612597a8f
commit
2c9e16a9e7
6 changed files with 3222 additions and 1152 deletions
|
@ -787,7 +787,7 @@ vhost all.transcode.srs.com {
|
||||||
output rtmp://127.0.0.1:[port]/[app]?vhost=[vhost]/[stream]_[engine];
|
output rtmp://127.0.0.1:[port]/[app]?vhost=[vhost]/[stream]_[engine];
|
||||||
}
|
}
|
||||||
engine vcopy {
|
engine vcopy {
|
||||||
enabled on;
|
enabled on;
|
||||||
vcodec copy;
|
vcodec copy;
|
||||||
acodec libaacplus;
|
acodec libaacplus;
|
||||||
abitrate 45;
|
abitrate 45;
|
||||||
|
@ -813,7 +813,7 @@ vhost all.transcode.srs.com {
|
||||||
output rtmp://127.0.0.1:[port]/[app]?vhost=[vhost]/[stream]_[engine];
|
output rtmp://127.0.0.1:[port]/[app]?vhost=[vhost]/[stream]_[engine];
|
||||||
}
|
}
|
||||||
engine copy {
|
engine copy {
|
||||||
enabled on;
|
enabled on;
|
||||||
vcodec copy;
|
vcodec copy;
|
||||||
acodec copy;
|
acodec copy;
|
||||||
output rtmp://127.0.0.1:[port]/[app]?vhost=[vhost]/[stream]_[engine];
|
output rtmp://127.0.0.1:[port]/[app]?vhost=[vhost]/[stream]_[engine];
|
||||||
|
|
|
@ -1630,7 +1630,7 @@ SrsConfDirective* SrsConfig::get_forward(string vhost)
|
||||||
return conf->get("forward");
|
return conf->get("forward");
|
||||||
}
|
}
|
||||||
|
|
||||||
SrsConfDirective* SrsConfig::get_vhost_on_connect(string vhost)
|
SrsConfDirective* SrsConfig::get_vhost_http_hooks(string vhost)
|
||||||
{
|
{
|
||||||
SrsConfDirective* conf = get_vhost(vhost);
|
SrsConfDirective* conf = get_vhost(vhost);
|
||||||
|
|
||||||
|
@ -1638,13 +1638,30 @@ SrsConfDirective* SrsConfig::get_vhost_on_connect(string vhost)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
conf = conf->get("http_hooks");
|
return conf->get("http_hooks");
|
||||||
|
}
|
||||||
|
|
||||||
|
bool SrsConfig::get_vhost_http_hooks_enabled(string vhost)
|
||||||
|
{
|
||||||
|
SrsConfDirective* conf = get_vhost_http_hooks(vhost);
|
||||||
|
|
||||||
if (!conf) {
|
if (!conf) {
|
||||||
return NULL;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
SrsConfDirective* enabled = conf->get("enabled");
|
SrsConfDirective* enabled = conf->get("enabled");
|
||||||
if (!enabled || enabled->arg0() != "on") {
|
if (!enabled || enabled->arg0() != "on") {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
SrsConfDirective* SrsConfig::get_vhost_on_connect(string vhost)
|
||||||
|
{
|
||||||
|
SrsConfDirective* conf = get_vhost_http_hooks(vhost);
|
||||||
|
|
||||||
|
if (!conf) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1653,127 +1670,67 @@ SrsConfDirective* SrsConfig::get_vhost_on_connect(string vhost)
|
||||||
|
|
||||||
SrsConfDirective* SrsConfig::get_vhost_on_close(string vhost)
|
SrsConfDirective* SrsConfig::get_vhost_on_close(string vhost)
|
||||||
{
|
{
|
||||||
SrsConfDirective* conf = get_vhost(vhost);
|
SrsConfDirective* conf = get_vhost_http_hooks(vhost);
|
||||||
|
|
||||||
if (!conf) {
|
if (!conf) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
conf = conf->get("http_hooks");
|
|
||||||
if (!conf) {
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
SrsConfDirective* enabled = conf->get("enabled");
|
|
||||||
if (!enabled || enabled->arg0() != "on") {
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
return conf->get("on_close");
|
return conf->get("on_close");
|
||||||
}
|
}
|
||||||
|
|
||||||
SrsConfDirective* SrsConfig::get_vhost_on_publish(string vhost)
|
SrsConfDirective* SrsConfig::get_vhost_on_publish(string vhost)
|
||||||
{
|
{
|
||||||
SrsConfDirective* conf = get_vhost(vhost);
|
SrsConfDirective* conf = get_vhost_http_hooks(vhost);
|
||||||
|
|
||||||
if (!conf) {
|
if (!conf) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
conf = conf->get("http_hooks");
|
|
||||||
if (!conf) {
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
SrsConfDirective* enabled = conf->get("enabled");
|
|
||||||
if (!enabled || enabled->arg0() != "on") {
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
return conf->get("on_publish");
|
return conf->get("on_publish");
|
||||||
}
|
}
|
||||||
|
|
||||||
SrsConfDirective* SrsConfig::get_vhost_on_unpublish(string vhost)
|
SrsConfDirective* SrsConfig::get_vhost_on_unpublish(string vhost)
|
||||||
{
|
{
|
||||||
SrsConfDirective* conf = get_vhost(vhost);
|
SrsConfDirective* conf = get_vhost_http_hooks(vhost);
|
||||||
|
|
||||||
if (!conf) {
|
if (!conf) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
conf = conf->get("http_hooks");
|
|
||||||
if (!conf) {
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
SrsConfDirective* enabled = conf->get("enabled");
|
|
||||||
if (!enabled || enabled->arg0() != "on") {
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
return conf->get("on_unpublish");
|
return conf->get("on_unpublish");
|
||||||
}
|
}
|
||||||
|
|
||||||
SrsConfDirective* SrsConfig::get_vhost_on_play(string vhost)
|
SrsConfDirective* SrsConfig::get_vhost_on_play(string vhost)
|
||||||
{
|
{
|
||||||
SrsConfDirective* conf = get_vhost(vhost);
|
SrsConfDirective* conf = get_vhost_http_hooks(vhost);
|
||||||
|
|
||||||
if (!conf) {
|
if (!conf) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
conf = conf->get("http_hooks");
|
|
||||||
if (!conf) {
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
SrsConfDirective* enabled = conf->get("enabled");
|
|
||||||
if (!enabled || enabled->arg0() != "on") {
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
return conf->get("on_play");
|
return conf->get("on_play");
|
||||||
}
|
}
|
||||||
|
|
||||||
SrsConfDirective* SrsConfig::get_vhost_on_stop(string vhost)
|
SrsConfDirective* SrsConfig::get_vhost_on_stop(string vhost)
|
||||||
{
|
{
|
||||||
SrsConfDirective* conf = get_vhost(vhost);
|
SrsConfDirective* conf = get_vhost_http_hooks(vhost);
|
||||||
|
|
||||||
if (!conf) {
|
if (!conf) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
conf = conf->get("http_hooks");
|
|
||||||
if (!conf) {
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
SrsConfDirective* enabled = conf->get("enabled");
|
|
||||||
if (!enabled || enabled->arg0() != "on") {
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
return conf->get("on_stop");
|
return conf->get("on_stop");
|
||||||
}
|
}
|
||||||
|
|
||||||
SrsConfDirective* SrsConfig::get_vhost_on_dvr_hss_reap_flv(string vhost)
|
SrsConfDirective* SrsConfig::get_vhost_on_dvr_hss_reap_flv(string vhost)
|
||||||
{
|
{
|
||||||
SrsConfDirective* conf = get_vhost(vhost);
|
SrsConfDirective* conf = get_vhost_http_hooks(vhost);
|
||||||
|
|
||||||
if (!conf) {
|
if (!conf) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
conf = conf->get("http_hooks");
|
|
||||||
if (!conf) {
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
SrsConfDirective* enabled = conf->get("enabled");
|
|
||||||
if (!enabled || enabled->arg0() != "on") {
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
return conf->get("on_dvr_hss_reap_flv");
|
return conf->get("on_dvr_hss_reap_flv");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -515,7 +515,17 @@ public:
|
||||||
*/
|
*/
|
||||||
virtual SrsConfDirective* get_forward(std::string vhost);
|
virtual SrsConfDirective* get_forward(std::string vhost);
|
||||||
// http_hooks section
|
// http_hooks section
|
||||||
|
private:
|
||||||
|
/**
|
||||||
|
* get the http_hooks directive of vhost.
|
||||||
|
*/
|
||||||
|
virtual SrsConfDirective* get_vhost_http_hooks(std::string vhost);
|
||||||
public:
|
public:
|
||||||
|
/**
|
||||||
|
* whether vhost http-hooks enabled.
|
||||||
|
* @remark, if not enabled, donot callback all http hooks.
|
||||||
|
*/
|
||||||
|
virtual bool get_vhost_http_hooks_enabled(std::string vhost);
|
||||||
/**
|
/**
|
||||||
* get the on_connect callbacks of vhost.
|
* get the on_connect callbacks of vhost.
|
||||||
* @return the on_connect callback directive, the args is the url to callback.
|
* @return the on_connect callback directive, the args is the url to callback.
|
||||||
|
|
|
@ -371,16 +371,18 @@ int SrsDvrPlan::on_dvr_hss_reap_flv()
|
||||||
int ret = ERROR_SUCCESS;
|
int ret = ERROR_SUCCESS;
|
||||||
|
|
||||||
#ifdef SRS_AUTO_HTTP_CALLBACK
|
#ifdef SRS_AUTO_HTTP_CALLBACK
|
||||||
// HTTP: on_dvr_hss_reap_flv
|
if (!_srs_config->get_vhost_http_hooks_enabled(_req->vhost)) {
|
||||||
SrsConfDirective* on_dvr_hss_reap_flv = _srs_config->get_vhost_on_dvr_hss_reap_flv(_req->vhost);
|
// HTTP: on_dvr_hss_reap_flv
|
||||||
if (!on_dvr_hss_reap_flv) {
|
SrsConfDirective* on_dvr_hss_reap_flv = _srs_config->get_vhost_on_dvr_hss_reap_flv(_req->vhost);
|
||||||
srs_info("ignore the empty http callback: on_dvr_hss_reap_flv");
|
if (!on_dvr_hss_reap_flv) {
|
||||||
return ret;
|
srs_info("ignore the empty http callback: on_dvr_hss_reap_flv");
|
||||||
}
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
for (int i = 0; i < (int)on_dvr_hss_reap_flv->args.size(); i++) {
|
for (int i = 0; i < (int)on_dvr_hss_reap_flv->args.size(); i++) {
|
||||||
std::string url = on_dvr_hss_reap_flv->args.at(i);
|
std::string url = on_dvr_hss_reap_flv->args.at(i);
|
||||||
SrsHttpHooks::on_dvr_hss_reap_flv(url, _req, segment);
|
SrsHttpHooks::on_dvr_hss_reap_flv(url, _req, segment);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -641,16 +643,18 @@ int SrsDvrHssPlan::on_dvr_hss_reap_flv_header(string path)
|
||||||
int ret = ERROR_SUCCESS;
|
int ret = ERROR_SUCCESS;
|
||||||
|
|
||||||
#ifdef SRS_AUTO_HTTP_CALLBACK
|
#ifdef SRS_AUTO_HTTP_CALLBACK
|
||||||
// HTTP: on_dvr_hss_reap_flv_header
|
if (!_srs_config->get_vhost_http_hooks_enabled(_req->vhost)) {
|
||||||
SrsConfDirective* on_dvr_hss_reap_flv = _srs_config->get_vhost_on_dvr_hss_reap_flv(_req->vhost);
|
// HTTP: on_dvr_hss_reap_flv_header
|
||||||
if (!on_dvr_hss_reap_flv) {
|
SrsConfDirective* on_dvr_hss_reap_flv = _srs_config->get_vhost_on_dvr_hss_reap_flv(_req->vhost);
|
||||||
srs_info("ignore the empty http callback: on_dvr_hss_reap_flv");
|
if (!on_dvr_hss_reap_flv) {
|
||||||
return ret;
|
srs_info("ignore the empty http callback: on_dvr_hss_reap_flv");
|
||||||
}
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
for (int i = 0; i < (int)on_dvr_hss_reap_flv->args.size(); i++) {
|
for (int i = 0; i < (int)on_dvr_hss_reap_flv->args.size(); i++) {
|
||||||
std::string url = on_dvr_hss_reap_flv->args.at(i);
|
std::string url = on_dvr_hss_reap_flv->args.at(i);
|
||||||
SrsHttpHooks::on_dvr_hss_reap_flv_header(url, _req, path);
|
SrsHttpHooks::on_dvr_hss_reap_flv_header(url, _req, path);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -984,20 +984,22 @@ int SrsRtmpConn::http_hooks_on_connect()
|
||||||
int ret = ERROR_SUCCESS;
|
int ret = ERROR_SUCCESS;
|
||||||
|
|
||||||
#ifdef SRS_AUTO_HTTP_CALLBACK
|
#ifdef SRS_AUTO_HTTP_CALLBACK
|
||||||
// HTTP: on_connect
|
if (!_srs_config->get_vhost_http_hooks_enabled(req->vhost)) {
|
||||||
SrsConfDirective* on_connect = _srs_config->get_vhost_on_connect(req->vhost);
|
// HTTP: on_connect
|
||||||
if (!on_connect) {
|
SrsConfDirective* on_connect = _srs_config->get_vhost_on_connect(req->vhost);
|
||||||
srs_info("ignore the empty http callback: on_connect");
|
if (!on_connect) {
|
||||||
return ret;
|
srs_info("ignore the empty http callback: on_connect");
|
||||||
}
|
|
||||||
|
|
||||||
int connection_id = _srs_context->get_id();
|
|
||||||
for (int i = 0; i < (int)on_connect->args.size(); i++) {
|
|
||||||
std::string url = on_connect->args.at(i);
|
|
||||||
if ((ret = SrsHttpHooks::on_connect(url, connection_id, ip, req)) != ERROR_SUCCESS) {
|
|
||||||
srs_error("hook client on_connect failed. url=%s, ret=%d", url.c_str(), ret);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int connection_id = _srs_context->get_id();
|
||||||
|
for (int i = 0; i < (int)on_connect->args.size(); i++) {
|
||||||
|
std::string url = on_connect->args.at(i);
|
||||||
|
if ((ret = SrsHttpHooks::on_connect(url, connection_id, ip, req)) != ERROR_SUCCESS) {
|
||||||
|
srs_error("hook client on_connect failed. url=%s, ret=%d", url.c_str(), ret);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -1007,18 +1009,20 @@ int SrsRtmpConn::http_hooks_on_connect()
|
||||||
void SrsRtmpConn::http_hooks_on_close()
|
void SrsRtmpConn::http_hooks_on_close()
|
||||||
{
|
{
|
||||||
#ifdef SRS_AUTO_HTTP_CALLBACK
|
#ifdef SRS_AUTO_HTTP_CALLBACK
|
||||||
// whatever the ret code, notify the api hooks.
|
if (!_srs_config->get_vhost_http_hooks_enabled(req->vhost)) {
|
||||||
// HTTP: on_close
|
// whatever the ret code, notify the api hooks.
|
||||||
SrsConfDirective* on_close = _srs_config->get_vhost_on_close(req->vhost);
|
// HTTP: on_close
|
||||||
if (!on_close) {
|
SrsConfDirective* on_close = _srs_config->get_vhost_on_close(req->vhost);
|
||||||
srs_info("ignore the empty http callback: on_close");
|
if (!on_close) {
|
||||||
return;
|
srs_info("ignore the empty http callback: on_close");
|
||||||
}
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
int connection_id = _srs_context->get_id();
|
int connection_id = _srs_context->get_id();
|
||||||
for (int i = 0; i < (int)on_close->args.size(); i++) {
|
for (int i = 0; i < (int)on_close->args.size(); i++) {
|
||||||
std::string url = on_close->args.at(i);
|
std::string url = on_close->args.at(i);
|
||||||
SrsHttpHooks::on_close(url, connection_id, ip, req);
|
SrsHttpHooks::on_close(url, connection_id, ip, req);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -1028,20 +1032,22 @@ int SrsRtmpConn::http_hooks_on_publish()
|
||||||
int ret = ERROR_SUCCESS;
|
int ret = ERROR_SUCCESS;
|
||||||
|
|
||||||
#ifdef SRS_AUTO_HTTP_CALLBACK
|
#ifdef SRS_AUTO_HTTP_CALLBACK
|
||||||
// HTTP: on_publish
|
if (!_srs_config->get_vhost_http_hooks_enabled(req->vhost)) {
|
||||||
SrsConfDirective* on_publish = _srs_config->get_vhost_on_publish(req->vhost);
|
// HTTP: on_publish
|
||||||
if (!on_publish) {
|
SrsConfDirective* on_publish = _srs_config->get_vhost_on_publish(req->vhost);
|
||||||
srs_info("ignore the empty http callback: on_publish");
|
if (!on_publish) {
|
||||||
return ret;
|
srs_info("ignore the empty http callback: on_publish");
|
||||||
}
|
|
||||||
|
|
||||||
int connection_id = _srs_context->get_id();
|
|
||||||
for (int i = 0; i < (int)on_publish->args.size(); i++) {
|
|
||||||
std::string url = on_publish->args.at(i);
|
|
||||||
if ((ret = SrsHttpHooks::on_publish(url, connection_id, ip, req)) != ERROR_SUCCESS) {
|
|
||||||
srs_error("hook client on_publish failed. url=%s, ret=%d", url.c_str(), ret);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int connection_id = _srs_context->get_id();
|
||||||
|
for (int i = 0; i < (int)on_publish->args.size(); i++) {
|
||||||
|
std::string url = on_publish->args.at(i);
|
||||||
|
if ((ret = SrsHttpHooks::on_publish(url, connection_id, ip, req)) != ERROR_SUCCESS) {
|
||||||
|
srs_error("hook client on_publish failed. url=%s, ret=%d", url.c_str(), ret);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -1051,18 +1057,20 @@ int SrsRtmpConn::http_hooks_on_publish()
|
||||||
void SrsRtmpConn::http_hooks_on_unpublish()
|
void SrsRtmpConn::http_hooks_on_unpublish()
|
||||||
{
|
{
|
||||||
#ifdef SRS_AUTO_HTTP_CALLBACK
|
#ifdef SRS_AUTO_HTTP_CALLBACK
|
||||||
// whatever the ret code, notify the api hooks.
|
if (!_srs_config->get_vhost_http_hooks_enabled(req->vhost)) {
|
||||||
// HTTP: on_unpublish
|
// whatever the ret code, notify the api hooks.
|
||||||
SrsConfDirective* on_unpublish = _srs_config->get_vhost_on_unpublish(req->vhost);
|
// HTTP: on_unpublish
|
||||||
if (!on_unpublish) {
|
SrsConfDirective* on_unpublish = _srs_config->get_vhost_on_unpublish(req->vhost);
|
||||||
srs_info("ignore the empty http callback: on_unpublish");
|
if (!on_unpublish) {
|
||||||
return;
|
srs_info("ignore the empty http callback: on_unpublish");
|
||||||
}
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
int connection_id = _srs_context->get_id();
|
int connection_id = _srs_context->get_id();
|
||||||
for (int i = 0; i < (int)on_unpublish->args.size(); i++) {
|
for (int i = 0; i < (int)on_unpublish->args.size(); i++) {
|
||||||
std::string url = on_unpublish->args.at(i);
|
std::string url = on_unpublish->args.at(i);
|
||||||
SrsHttpHooks::on_unpublish(url, connection_id, ip, req);
|
SrsHttpHooks::on_unpublish(url, connection_id, ip, req);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -1072,20 +1080,22 @@ int SrsRtmpConn::http_hooks_on_play()
|
||||||
int ret = ERROR_SUCCESS;
|
int ret = ERROR_SUCCESS;
|
||||||
|
|
||||||
#ifdef SRS_AUTO_HTTP_CALLBACK
|
#ifdef SRS_AUTO_HTTP_CALLBACK
|
||||||
// HTTP: on_play
|
if (!_srs_config->get_vhost_http_hooks_enabled(req->vhost)) {
|
||||||
SrsConfDirective* on_play = _srs_config->get_vhost_on_play(req->vhost);
|
// HTTP: on_play
|
||||||
if (!on_play) {
|
SrsConfDirective* on_play = _srs_config->get_vhost_on_play(req->vhost);
|
||||||
srs_info("ignore the empty http callback: on_play");
|
if (!on_play) {
|
||||||
return ret;
|
srs_info("ignore the empty http callback: on_play");
|
||||||
}
|
|
||||||
|
|
||||||
int connection_id = _srs_context->get_id();
|
|
||||||
for (int i = 0; i < (int)on_play->args.size(); i++) {
|
|
||||||
std::string url = on_play->args.at(i);
|
|
||||||
if ((ret = SrsHttpHooks::on_play(url, connection_id, ip, req)) != ERROR_SUCCESS) {
|
|
||||||
srs_error("hook client on_play failed. url=%s, ret=%d", url.c_str(), ret);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int connection_id = _srs_context->get_id();
|
||||||
|
for (int i = 0; i < (int)on_play->args.size(); i++) {
|
||||||
|
std::string url = on_play->args.at(i);
|
||||||
|
if ((ret = SrsHttpHooks::on_play(url, connection_id, ip, req)) != ERROR_SUCCESS) {
|
||||||
|
srs_error("hook client on_play failed. url=%s, ret=%d", url.c_str(), ret);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -1095,18 +1105,20 @@ int SrsRtmpConn::http_hooks_on_play()
|
||||||
void SrsRtmpConn::http_hooks_on_stop()
|
void SrsRtmpConn::http_hooks_on_stop()
|
||||||
{
|
{
|
||||||
#ifdef SRS_AUTO_HTTP_CALLBACK
|
#ifdef SRS_AUTO_HTTP_CALLBACK
|
||||||
// whatever the ret code, notify the api hooks.
|
if (!_srs_config->get_vhost_http_hooks_enabled(req->vhost)) {
|
||||||
// HTTP: on_stop
|
// whatever the ret code, notify the api hooks.
|
||||||
SrsConfDirective* on_stop = _srs_config->get_vhost_on_stop(req->vhost);
|
// HTTP: on_stop
|
||||||
if (!on_stop) {
|
SrsConfDirective* on_stop = _srs_config->get_vhost_on_stop(req->vhost);
|
||||||
srs_info("ignore the empty http callback: on_stop");
|
if (!on_stop) {
|
||||||
return;
|
srs_info("ignore the empty http callback: on_stop");
|
||||||
}
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
int connection_id = _srs_context->get_id();
|
int connection_id = _srs_context->get_id();
|
||||||
for (int i = 0; i < (int)on_stop->args.size(); i++) {
|
for (int i = 0; i < (int)on_stop->args.size(); i++) {
|
||||||
std::string url = on_stop->args.at(i);
|
std::string url = on_stop->args.at(i);
|
||||||
SrsHttpHooks::on_stop(url, connection_id, ip, req);
|
SrsHttpHooks::on_stop(url, connection_id, ip, req);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue