正在显示
6 个修改的文件
包含
149 行增加
和
166 行删除
| @@ -787,7 +787,7 @@ vhost all.transcode.srs.com { | @@ -787,7 +787,7 @@ vhost all.transcode.srs.com { | ||
| 787 | output rtmp://127.0.0.1:[port]/[app]?vhost=[vhost]/[stream]_[engine]; | 787 | output rtmp://127.0.0.1:[port]/[app]?vhost=[vhost]/[stream]_[engine]; |
| 788 | } | 788 | } |
| 789 | engine vcopy { | 789 | engine vcopy { |
| 790 | - enabled on; | 790 | + enabled on; |
| 791 | vcodec copy; | 791 | vcodec copy; |
| 792 | acodec libaacplus; | 792 | acodec libaacplus; |
| 793 | abitrate 45; | 793 | abitrate 45; |
| @@ -813,7 +813,7 @@ vhost all.transcode.srs.com { | @@ -813,7 +813,7 @@ vhost all.transcode.srs.com { | ||
| 813 | output rtmp://127.0.0.1:[port]/[app]?vhost=[vhost]/[stream]_[engine]; | 813 | output rtmp://127.0.0.1:[port]/[app]?vhost=[vhost]/[stream]_[engine]; |
| 814 | } | 814 | } |
| 815 | engine copy { | 815 | engine copy { |
| 816 | - enabled on; | 816 | + enabled on; |
| 817 | vcodec copy; | 817 | vcodec copy; |
| 818 | acodec copy; | 818 | acodec copy; |
| 819 | output rtmp://127.0.0.1:[port]/[app]?vhost=[vhost]/[stream]_[engine]; | 819 | output rtmp://127.0.0.1:[port]/[app]?vhost=[vhost]/[stream]_[engine]; |
| @@ -1630,7 +1630,7 @@ SrsConfDirective* SrsConfig::get_forward(string vhost) | @@ -1630,7 +1630,7 @@ SrsConfDirective* SrsConfig::get_forward(string vhost) | ||
| 1630 | return conf->get("forward"); | 1630 | return conf->get("forward"); |
| 1631 | } | 1631 | } |
| 1632 | 1632 | ||
| 1633 | -SrsConfDirective* SrsConfig::get_vhost_on_connect(string vhost) | 1633 | +SrsConfDirective* SrsConfig::get_vhost_http_hooks(string vhost) |
| 1634 | { | 1634 | { |
| 1635 | SrsConfDirective* conf = get_vhost(vhost); | 1635 | SrsConfDirective* conf = get_vhost(vhost); |
| 1636 | 1636 | ||
| @@ -1638,34 +1638,41 @@ SrsConfDirective* SrsConfig::get_vhost_on_connect(string vhost) | @@ -1638,34 +1638,41 @@ SrsConfDirective* SrsConfig::get_vhost_on_connect(string vhost) | ||
| 1638 | return NULL; | 1638 | return NULL; |
| 1639 | } | 1639 | } |
| 1640 | 1640 | ||
| 1641 | - conf = conf->get("http_hooks"); | ||
| 1642 | - if (!conf) { | ||
| 1643 | - return NULL; | 1641 | + return conf->get("http_hooks"); |
| 1642 | +} | ||
| 1643 | + | ||
| 1644 | +bool SrsConfig::get_vhost_http_hooks_enabled(string vhost) | ||
| 1645 | +{ | ||
| 1646 | + SrsConfDirective* conf = get_vhost_http_hooks(vhost); | ||
| 1647 | + | ||
| 1648 | + if (!conf) { | ||
| 1649 | + return false; | ||
| 1644 | } | 1650 | } |
| 1645 | 1651 | ||
| 1646 | SrsConfDirective* enabled = conf->get("enabled"); | 1652 | SrsConfDirective* enabled = conf->get("enabled"); |
| 1647 | if (!enabled || enabled->arg0() != "on") { | 1653 | if (!enabled || enabled->arg0() != "on") { |
| 1648 | - return NULL; | 1654 | + return false; |
| 1649 | } | 1655 | } |
| 1650 | 1656 | ||
| 1651 | - return conf->get("on_connect"); | 1657 | + return true; |
| 1652 | } | 1658 | } |
| 1653 | 1659 | ||
| 1654 | -SrsConfDirective* SrsConfig::get_vhost_on_close(string vhost) | 1660 | +SrsConfDirective* SrsConfig::get_vhost_on_connect(string vhost) |
| 1655 | { | 1661 | { |
| 1656 | - SrsConfDirective* conf = get_vhost(vhost); | 1662 | + SrsConfDirective* conf = get_vhost_http_hooks(vhost); |
| 1657 | 1663 | ||
| 1658 | if (!conf) { | 1664 | if (!conf) { |
| 1659 | return NULL; | 1665 | return NULL; |
| 1660 | } | 1666 | } |
| 1661 | 1667 | ||
| 1662 | - conf = conf->get("http_hooks"); | ||
| 1663 | - if (!conf) { | ||
| 1664 | - return NULL; | ||
| 1665 | - } | ||
| 1666 | - | ||
| 1667 | - SrsConfDirective* enabled = conf->get("enabled"); | ||
| 1668 | - if (!enabled || enabled->arg0() != "on") { | 1668 | + return conf->get("on_connect"); |
| 1669 | +} | ||
| 1670 | + | ||
| 1671 | +SrsConfDirective* SrsConfig::get_vhost_on_close(string vhost) | ||
| 1672 | +{ | ||
| 1673 | + SrsConfDirective* conf = get_vhost_http_hooks(vhost); | ||
| 1674 | + | ||
| 1675 | + if (!conf) { | ||
| 1669 | return NULL; | 1676 | return NULL; |
| 1670 | } | 1677 | } |
| 1671 | 1678 | ||
| @@ -1674,106 +1681,56 @@ SrsConfDirective* SrsConfig::get_vhost_on_close(string vhost) | @@ -1674,106 +1681,56 @@ SrsConfDirective* SrsConfig::get_vhost_on_close(string vhost) | ||
| 1674 | 1681 | ||
| 1675 | SrsConfDirective* SrsConfig::get_vhost_on_publish(string vhost) | 1682 | SrsConfDirective* SrsConfig::get_vhost_on_publish(string vhost) |
| 1676 | { | 1683 | { |
| 1677 | - SrsConfDirective* conf = get_vhost(vhost); | 1684 | + SrsConfDirective* conf = get_vhost_http_hooks(vhost); |
| 1678 | 1685 | ||
| 1679 | if (!conf) { | 1686 | if (!conf) { |
| 1680 | return NULL; | 1687 | return NULL; |
| 1681 | } | 1688 | } |
| 1682 | 1689 | ||
| 1683 | - conf = conf->get("http_hooks"); | ||
| 1684 | - if (!conf) { | ||
| 1685 | - return NULL; | ||
| 1686 | - } | ||
| 1687 | - | ||
| 1688 | - SrsConfDirective* enabled = conf->get("enabled"); | ||
| 1689 | - if (!enabled || enabled->arg0() != "on") { | ||
| 1690 | - return NULL; | ||
| 1691 | - } | ||
| 1692 | - | ||
| 1693 | return conf->get("on_publish"); | 1690 | return conf->get("on_publish"); |
| 1694 | } | 1691 | } |
| 1695 | 1692 | ||
| 1696 | SrsConfDirective* SrsConfig::get_vhost_on_unpublish(string vhost) | 1693 | SrsConfDirective* SrsConfig::get_vhost_on_unpublish(string vhost) |
| 1697 | { | 1694 | { |
| 1698 | - SrsConfDirective* conf = get_vhost(vhost); | 1695 | + SrsConfDirective* conf = get_vhost_http_hooks(vhost); |
| 1699 | 1696 | ||
| 1700 | if (!conf) { | 1697 | if (!conf) { |
| 1701 | return NULL; | 1698 | return NULL; |
| 1702 | } | 1699 | } |
| 1703 | 1700 | ||
| 1704 | - conf = conf->get("http_hooks"); | ||
| 1705 | - if (!conf) { | ||
| 1706 | - return NULL; | ||
| 1707 | - } | ||
| 1708 | - | ||
| 1709 | - SrsConfDirective* enabled = conf->get("enabled"); | ||
| 1710 | - if (!enabled || enabled->arg0() != "on") { | ||
| 1711 | - return NULL; | ||
| 1712 | - } | ||
| 1713 | - | ||
| 1714 | return conf->get("on_unpublish"); | 1701 | return conf->get("on_unpublish"); |
| 1715 | } | 1702 | } |
| 1716 | 1703 | ||
| 1717 | SrsConfDirective* SrsConfig::get_vhost_on_play(string vhost) | 1704 | SrsConfDirective* SrsConfig::get_vhost_on_play(string vhost) |
| 1718 | { | 1705 | { |
| 1719 | - SrsConfDirective* conf = get_vhost(vhost); | 1706 | + SrsConfDirective* conf = get_vhost_http_hooks(vhost); |
| 1720 | 1707 | ||
| 1721 | if (!conf) { | 1708 | if (!conf) { |
| 1722 | return NULL; | 1709 | return NULL; |
| 1723 | } | 1710 | } |
| 1724 | 1711 | ||
| 1725 | - conf = conf->get("http_hooks"); | ||
| 1726 | - if (!conf) { | ||
| 1727 | - return NULL; | ||
| 1728 | - } | ||
| 1729 | - | ||
| 1730 | - SrsConfDirective* enabled = conf->get("enabled"); | ||
| 1731 | - if (!enabled || enabled->arg0() != "on") { | ||
| 1732 | - return NULL; | ||
| 1733 | - } | ||
| 1734 | - | ||
| 1735 | return conf->get("on_play"); | 1712 | return conf->get("on_play"); |
| 1736 | } | 1713 | } |
| 1737 | 1714 | ||
| 1738 | SrsConfDirective* SrsConfig::get_vhost_on_stop(string vhost) | 1715 | SrsConfDirective* SrsConfig::get_vhost_on_stop(string vhost) |
| 1739 | { | 1716 | { |
| 1740 | - SrsConfDirective* conf = get_vhost(vhost); | 1717 | + SrsConfDirective* conf = get_vhost_http_hooks(vhost); |
| 1741 | 1718 | ||
| 1742 | if (!conf) { | 1719 | if (!conf) { |
| 1743 | return NULL; | 1720 | return NULL; |
| 1744 | } | 1721 | } |
| 1745 | 1722 | ||
| 1746 | - conf = conf->get("http_hooks"); | ||
| 1747 | - if (!conf) { | ||
| 1748 | - return NULL; | ||
| 1749 | - } | ||
| 1750 | - | ||
| 1751 | - SrsConfDirective* enabled = conf->get("enabled"); | ||
| 1752 | - if (!enabled || enabled->arg0() != "on") { | ||
| 1753 | - return NULL; | ||
| 1754 | - } | ||
| 1755 | - | ||
| 1756 | return conf->get("on_stop"); | 1723 | return conf->get("on_stop"); |
| 1757 | } | 1724 | } |
| 1758 | 1725 | ||
| 1759 | SrsConfDirective* SrsConfig::get_vhost_on_dvr_hss_reap_flv(string vhost) | 1726 | SrsConfDirective* SrsConfig::get_vhost_on_dvr_hss_reap_flv(string vhost) |
| 1760 | { | 1727 | { |
| 1761 | - SrsConfDirective* conf = get_vhost(vhost); | 1728 | + SrsConfDirective* conf = get_vhost_http_hooks(vhost); |
| 1762 | 1729 | ||
| 1763 | if (!conf) { | 1730 | if (!conf) { |
| 1764 | return NULL; | 1731 | return NULL; |
| 1765 | } | 1732 | } |
| 1766 | 1733 | ||
| 1767 | - conf = conf->get("http_hooks"); | ||
| 1768 | - if (!conf) { | ||
| 1769 | - return NULL; | ||
| 1770 | - } | ||
| 1771 | - | ||
| 1772 | - SrsConfDirective* enabled = conf->get("enabled"); | ||
| 1773 | - if (!enabled || enabled->arg0() != "on") { | ||
| 1774 | - return NULL; | ||
| 1775 | - } | ||
| 1776 | - | ||
| 1777 | return conf->get("on_dvr_hss_reap_flv"); | 1734 | return conf->get("on_dvr_hss_reap_flv"); |
| 1778 | } | 1735 | } |
| 1779 | 1736 |
| @@ -515,8 +515,18 @@ public: | @@ -515,8 +515,18 @@ public: | ||
| 515 | */ | 515 | */ |
| 516 | virtual SrsConfDirective* get_forward(std::string vhost); | 516 | virtual SrsConfDirective* get_forward(std::string vhost); |
| 517 | // http_hooks section | 517 | // http_hooks section |
| 518 | +private: | ||
| 519 | + /** | ||
| 520 | + * get the http_hooks directive of vhost. | ||
| 521 | + */ | ||
| 522 | + virtual SrsConfDirective* get_vhost_http_hooks(std::string vhost); | ||
| 518 | public: | 523 | public: |
| 519 | /** | 524 | /** |
| 525 | + * whether vhost http-hooks enabled. | ||
| 526 | + * @remark, if not enabled, donot callback all http hooks. | ||
| 527 | + */ | ||
| 528 | + virtual bool get_vhost_http_hooks_enabled(std::string vhost); | ||
| 529 | + /** | ||
| 520 | * get the on_connect callbacks of vhost. | 530 | * get the on_connect callbacks of vhost. |
| 521 | * @return the on_connect callback directive, the args is the url to callback. | 531 | * @return the on_connect callback directive, the args is the url to callback. |
| 522 | */ | 532 | */ |
| @@ -371,16 +371,18 @@ int SrsDvrPlan::on_dvr_hss_reap_flv() | @@ -371,16 +371,18 @@ int SrsDvrPlan::on_dvr_hss_reap_flv() | ||
| 371 | int ret = ERROR_SUCCESS; | 371 | int ret = ERROR_SUCCESS; |
| 372 | 372 | ||
| 373 | #ifdef SRS_AUTO_HTTP_CALLBACK | 373 | #ifdef SRS_AUTO_HTTP_CALLBACK |
| 374 | - // HTTP: on_dvr_hss_reap_flv | ||
| 375 | - SrsConfDirective* on_dvr_hss_reap_flv = _srs_config->get_vhost_on_dvr_hss_reap_flv(_req->vhost); | ||
| 376 | - if (!on_dvr_hss_reap_flv) { | ||
| 377 | - srs_info("ignore the empty http callback: on_dvr_hss_reap_flv"); | ||
| 378 | - return ret; | ||
| 379 | - } | ||
| 380 | - | ||
| 381 | - for (int i = 0; i < (int)on_dvr_hss_reap_flv->args.size(); i++) { | ||
| 382 | - std::string url = on_dvr_hss_reap_flv->args.at(i); | ||
| 383 | - SrsHttpHooks::on_dvr_hss_reap_flv(url, _req, segment); | 374 | + if (!_srs_config->get_vhost_http_hooks_enabled(_req->vhost)) { |
| 375 | + // HTTP: on_dvr_hss_reap_flv | ||
| 376 | + SrsConfDirective* on_dvr_hss_reap_flv = _srs_config->get_vhost_on_dvr_hss_reap_flv(_req->vhost); | ||
| 377 | + if (!on_dvr_hss_reap_flv) { | ||
| 378 | + srs_info("ignore the empty http callback: on_dvr_hss_reap_flv"); | ||
| 379 | + return ret; | ||
| 380 | + } | ||
| 381 | + | ||
| 382 | + for (int i = 0; i < (int)on_dvr_hss_reap_flv->args.size(); i++) { | ||
| 383 | + std::string url = on_dvr_hss_reap_flv->args.at(i); | ||
| 384 | + SrsHttpHooks::on_dvr_hss_reap_flv(url, _req, segment); | ||
| 385 | + } | ||
| 384 | } | 386 | } |
| 385 | #endif | 387 | #endif |
| 386 | 388 | ||
| @@ -641,16 +643,18 @@ int SrsDvrHssPlan::on_dvr_hss_reap_flv_header(string path) | @@ -641,16 +643,18 @@ int SrsDvrHssPlan::on_dvr_hss_reap_flv_header(string path) | ||
| 641 | int ret = ERROR_SUCCESS; | 643 | int ret = ERROR_SUCCESS; |
| 642 | 644 | ||
| 643 | #ifdef SRS_AUTO_HTTP_CALLBACK | 645 | #ifdef SRS_AUTO_HTTP_CALLBACK |
| 644 | - // HTTP: on_dvr_hss_reap_flv_header | ||
| 645 | - SrsConfDirective* on_dvr_hss_reap_flv = _srs_config->get_vhost_on_dvr_hss_reap_flv(_req->vhost); | ||
| 646 | - if (!on_dvr_hss_reap_flv) { | ||
| 647 | - srs_info("ignore the empty http callback: on_dvr_hss_reap_flv"); | ||
| 648 | - return ret; | ||
| 649 | - } | ||
| 650 | - | ||
| 651 | - for (int i = 0; i < (int)on_dvr_hss_reap_flv->args.size(); i++) { | ||
| 652 | - std::string url = on_dvr_hss_reap_flv->args.at(i); | ||
| 653 | - SrsHttpHooks::on_dvr_hss_reap_flv_header(url, _req, path); | 646 | + if (!_srs_config->get_vhost_http_hooks_enabled(_req->vhost)) { |
| 647 | + // HTTP: on_dvr_hss_reap_flv_header | ||
| 648 | + SrsConfDirective* on_dvr_hss_reap_flv = _srs_config->get_vhost_on_dvr_hss_reap_flv(_req->vhost); | ||
| 649 | + if (!on_dvr_hss_reap_flv) { | ||
| 650 | + srs_info("ignore the empty http callback: on_dvr_hss_reap_flv"); | ||
| 651 | + return ret; | ||
| 652 | + } | ||
| 653 | + | ||
| 654 | + for (int i = 0; i < (int)on_dvr_hss_reap_flv->args.size(); i++) { | ||
| 655 | + std::string url = on_dvr_hss_reap_flv->args.at(i); | ||
| 656 | + SrsHttpHooks::on_dvr_hss_reap_flv_header(url, _req, path); | ||
| 657 | + } | ||
| 654 | } | 658 | } |
| 655 | #endif | 659 | #endif |
| 656 | 660 |
| @@ -984,20 +984,22 @@ int SrsRtmpConn::http_hooks_on_connect() | @@ -984,20 +984,22 @@ int SrsRtmpConn::http_hooks_on_connect() | ||
| 984 | int ret = ERROR_SUCCESS; | 984 | int ret = ERROR_SUCCESS; |
| 985 | 985 | ||
| 986 | #ifdef SRS_AUTO_HTTP_CALLBACK | 986 | #ifdef SRS_AUTO_HTTP_CALLBACK |
| 987 | - // HTTP: on_connect | ||
| 988 | - SrsConfDirective* on_connect = _srs_config->get_vhost_on_connect(req->vhost); | ||
| 989 | - if (!on_connect) { | ||
| 990 | - srs_info("ignore the empty http callback: on_connect"); | ||
| 991 | - return ret; | ||
| 992 | - } | ||
| 993 | - | ||
| 994 | - int connection_id = _srs_context->get_id(); | ||
| 995 | - for (int i = 0; i < (int)on_connect->args.size(); i++) { | ||
| 996 | - std::string url = on_connect->args.at(i); | ||
| 997 | - if ((ret = SrsHttpHooks::on_connect(url, connection_id, ip, req)) != ERROR_SUCCESS) { | ||
| 998 | - srs_error("hook client on_connect failed. url=%s, ret=%d", url.c_str(), ret); | 987 | + if (!_srs_config->get_vhost_http_hooks_enabled(req->vhost)) { |
| 988 | + // HTTP: on_connect | ||
| 989 | + SrsConfDirective* on_connect = _srs_config->get_vhost_on_connect(req->vhost); | ||
| 990 | + if (!on_connect) { | ||
| 991 | + srs_info("ignore the empty http callback: on_connect"); | ||
| 999 | return ret; | 992 | return ret; |
| 1000 | } | 993 | } |
| 994 | + | ||
| 995 | + int connection_id = _srs_context->get_id(); | ||
| 996 | + for (int i = 0; i < (int)on_connect->args.size(); i++) { | ||
| 997 | + std::string url = on_connect->args.at(i); | ||
| 998 | + if ((ret = SrsHttpHooks::on_connect(url, connection_id, ip, req)) != ERROR_SUCCESS) { | ||
| 999 | + srs_error("hook client on_connect failed. url=%s, ret=%d", url.c_str(), ret); | ||
| 1000 | + return ret; | ||
| 1001 | + } | ||
| 1002 | + } | ||
| 1001 | } | 1003 | } |
| 1002 | #endif | 1004 | #endif |
| 1003 | 1005 | ||
| @@ -1007,18 +1009,20 @@ int SrsRtmpConn::http_hooks_on_connect() | @@ -1007,18 +1009,20 @@ int SrsRtmpConn::http_hooks_on_connect() | ||
| 1007 | void SrsRtmpConn::http_hooks_on_close() | 1009 | void SrsRtmpConn::http_hooks_on_close() |
| 1008 | { | 1010 | { |
| 1009 | #ifdef SRS_AUTO_HTTP_CALLBACK | 1011 | #ifdef SRS_AUTO_HTTP_CALLBACK |
| 1010 | - // whatever the ret code, notify the api hooks. | ||
| 1011 | - // HTTP: on_close | ||
| 1012 | - SrsConfDirective* on_close = _srs_config->get_vhost_on_close(req->vhost); | ||
| 1013 | - if (!on_close) { | ||
| 1014 | - srs_info("ignore the empty http callback: on_close"); | ||
| 1015 | - return; | ||
| 1016 | - } | ||
| 1017 | - | ||
| 1018 | - int connection_id = _srs_context->get_id(); | ||
| 1019 | - for (int i = 0; i < (int)on_close->args.size(); i++) { | ||
| 1020 | - std::string url = on_close->args.at(i); | ||
| 1021 | - SrsHttpHooks::on_close(url, connection_id, ip, req); | 1012 | + if (!_srs_config->get_vhost_http_hooks_enabled(req->vhost)) { |
| 1013 | + // whatever the ret code, notify the api hooks. | ||
| 1014 | + // HTTP: on_close | ||
| 1015 | + SrsConfDirective* on_close = _srs_config->get_vhost_on_close(req->vhost); | ||
| 1016 | + if (!on_close) { | ||
| 1017 | + srs_info("ignore the empty http callback: on_close"); | ||
| 1018 | + return; | ||
| 1019 | + } | ||
| 1020 | + | ||
| 1021 | + int connection_id = _srs_context->get_id(); | ||
| 1022 | + for (int i = 0; i < (int)on_close->args.size(); i++) { | ||
| 1023 | + std::string url = on_close->args.at(i); | ||
| 1024 | + SrsHttpHooks::on_close(url, connection_id, ip, req); | ||
| 1025 | + } | ||
| 1022 | } | 1026 | } |
| 1023 | #endif | 1027 | #endif |
| 1024 | } | 1028 | } |
| @@ -1027,21 +1031,23 @@ int SrsRtmpConn::http_hooks_on_publish() | @@ -1027,21 +1031,23 @@ int SrsRtmpConn::http_hooks_on_publish() | ||
| 1027 | { | 1031 | { |
| 1028 | int ret = ERROR_SUCCESS; | 1032 | int ret = ERROR_SUCCESS; |
| 1029 | 1033 | ||
| 1030 | -#ifdef SRS_AUTO_HTTP_CALLBACK | ||
| 1031 | - // HTTP: on_publish | ||
| 1032 | - SrsConfDirective* on_publish = _srs_config->get_vhost_on_publish(req->vhost); | ||
| 1033 | - if (!on_publish) { | ||
| 1034 | - srs_info("ignore the empty http callback: on_publish"); | ||
| 1035 | - return ret; | ||
| 1036 | - } | ||
| 1037 | - | ||
| 1038 | - int connection_id = _srs_context->get_id(); | ||
| 1039 | - for (int i = 0; i < (int)on_publish->args.size(); i++) { | ||
| 1040 | - std::string url = on_publish->args.at(i); | ||
| 1041 | - if ((ret = SrsHttpHooks::on_publish(url, connection_id, ip, req)) != ERROR_SUCCESS) { | ||
| 1042 | - srs_error("hook client on_publish failed. url=%s, ret=%d", url.c_str(), ret); | 1034 | +#ifdef SRS_AUTO_HTTP_CALLBACK |
| 1035 | + if (!_srs_config->get_vhost_http_hooks_enabled(req->vhost)) { | ||
| 1036 | + // HTTP: on_publish | ||
| 1037 | + SrsConfDirective* on_publish = _srs_config->get_vhost_on_publish(req->vhost); | ||
| 1038 | + if (!on_publish) { | ||
| 1039 | + srs_info("ignore the empty http callback: on_publish"); | ||
| 1043 | return ret; | 1040 | return ret; |
| 1044 | } | 1041 | } |
| 1042 | + | ||
| 1043 | + int connection_id = _srs_context->get_id(); | ||
| 1044 | + for (int i = 0; i < (int)on_publish->args.size(); i++) { | ||
| 1045 | + std::string url = on_publish->args.at(i); | ||
| 1046 | + if ((ret = SrsHttpHooks::on_publish(url, connection_id, ip, req)) != ERROR_SUCCESS) { | ||
| 1047 | + srs_error("hook client on_publish failed. url=%s, ret=%d", url.c_str(), ret); | ||
| 1048 | + return ret; | ||
| 1049 | + } | ||
| 1050 | + } | ||
| 1045 | } | 1051 | } |
| 1046 | #endif | 1052 | #endif |
| 1047 | 1053 | ||
| @@ -1051,18 +1057,20 @@ int SrsRtmpConn::http_hooks_on_publish() | @@ -1051,18 +1057,20 @@ int SrsRtmpConn::http_hooks_on_publish() | ||
| 1051 | void SrsRtmpConn::http_hooks_on_unpublish() | 1057 | void SrsRtmpConn::http_hooks_on_unpublish() |
| 1052 | { | 1058 | { |
| 1053 | #ifdef SRS_AUTO_HTTP_CALLBACK | 1059 | #ifdef SRS_AUTO_HTTP_CALLBACK |
| 1054 | - // whatever the ret code, notify the api hooks. | ||
| 1055 | - // HTTP: on_unpublish | ||
| 1056 | - SrsConfDirective* on_unpublish = _srs_config->get_vhost_on_unpublish(req->vhost); | ||
| 1057 | - if (!on_unpublish) { | ||
| 1058 | - srs_info("ignore the empty http callback: on_unpublish"); | ||
| 1059 | - return; | ||
| 1060 | - } | ||
| 1061 | - | ||
| 1062 | - int connection_id = _srs_context->get_id(); | ||
| 1063 | - for (int i = 0; i < (int)on_unpublish->args.size(); i++) { | ||
| 1064 | - std::string url = on_unpublish->args.at(i); | ||
| 1065 | - SrsHttpHooks::on_unpublish(url, connection_id, ip, req); | 1060 | + if (!_srs_config->get_vhost_http_hooks_enabled(req->vhost)) { |
| 1061 | + // whatever the ret code, notify the api hooks. | ||
| 1062 | + // HTTP: on_unpublish | ||
| 1063 | + SrsConfDirective* on_unpublish = _srs_config->get_vhost_on_unpublish(req->vhost); | ||
| 1064 | + if (!on_unpublish) { | ||
| 1065 | + srs_info("ignore the empty http callback: on_unpublish"); | ||
| 1066 | + return; | ||
| 1067 | + } | ||
| 1068 | + | ||
| 1069 | + int connection_id = _srs_context->get_id(); | ||
| 1070 | + for (int i = 0; i < (int)on_unpublish->args.size(); i++) { | ||
| 1071 | + std::string url = on_unpublish->args.at(i); | ||
| 1072 | + SrsHttpHooks::on_unpublish(url, connection_id, ip, req); | ||
| 1073 | + } | ||
| 1066 | } | 1074 | } |
| 1067 | #endif | 1075 | #endif |
| 1068 | } | 1076 | } |
| @@ -1071,21 +1079,23 @@ int SrsRtmpConn::http_hooks_on_play() | @@ -1071,21 +1079,23 @@ int SrsRtmpConn::http_hooks_on_play() | ||
| 1071 | { | 1079 | { |
| 1072 | int ret = ERROR_SUCCESS; | 1080 | int ret = ERROR_SUCCESS; |
| 1073 | 1081 | ||
| 1074 | -#ifdef SRS_AUTO_HTTP_CALLBACK | ||
| 1075 | - // HTTP: on_play | ||
| 1076 | - SrsConfDirective* on_play = _srs_config->get_vhost_on_play(req->vhost); | ||
| 1077 | - if (!on_play) { | ||
| 1078 | - srs_info("ignore the empty http callback: on_play"); | ||
| 1079 | - return ret; | ||
| 1080 | - } | ||
| 1081 | - | ||
| 1082 | - int connection_id = _srs_context->get_id(); | ||
| 1083 | - for (int i = 0; i < (int)on_play->args.size(); i++) { | ||
| 1084 | - std::string url = on_play->args.at(i); | ||
| 1085 | - if ((ret = SrsHttpHooks::on_play(url, connection_id, ip, req)) != ERROR_SUCCESS) { | ||
| 1086 | - srs_error("hook client on_play failed. url=%s, ret=%d", url.c_str(), ret); | 1082 | +#ifdef SRS_AUTO_HTTP_CALLBACK |
| 1083 | + if (!_srs_config->get_vhost_http_hooks_enabled(req->vhost)) { | ||
| 1084 | + // HTTP: on_play | ||
| 1085 | + SrsConfDirective* on_play = _srs_config->get_vhost_on_play(req->vhost); | ||
| 1086 | + if (!on_play) { | ||
| 1087 | + srs_info("ignore the empty http callback: on_play"); | ||
| 1087 | return ret; | 1088 | return ret; |
| 1088 | } | 1089 | } |
| 1090 | + | ||
| 1091 | + int connection_id = _srs_context->get_id(); | ||
| 1092 | + for (int i = 0; i < (int)on_play->args.size(); i++) { | ||
| 1093 | + std::string url = on_play->args.at(i); | ||
| 1094 | + if ((ret = SrsHttpHooks::on_play(url, connection_id, ip, req)) != ERROR_SUCCESS) { | ||
| 1095 | + srs_error("hook client on_play failed. url=%s, ret=%d", url.c_str(), ret); | ||
| 1096 | + return ret; | ||
| 1097 | + } | ||
| 1098 | + } | ||
| 1089 | } | 1099 | } |
| 1090 | #endif | 1100 | #endif |
| 1091 | 1101 | ||
| @@ -1095,18 +1105,20 @@ int SrsRtmpConn::http_hooks_on_play() | @@ -1095,18 +1105,20 @@ int SrsRtmpConn::http_hooks_on_play() | ||
| 1095 | void SrsRtmpConn::http_hooks_on_stop() | 1105 | void SrsRtmpConn::http_hooks_on_stop() |
| 1096 | { | 1106 | { |
| 1097 | #ifdef SRS_AUTO_HTTP_CALLBACK | 1107 | #ifdef SRS_AUTO_HTTP_CALLBACK |
| 1098 | - // whatever the ret code, notify the api hooks. | ||
| 1099 | - // HTTP: on_stop | ||
| 1100 | - SrsConfDirective* on_stop = _srs_config->get_vhost_on_stop(req->vhost); | ||
| 1101 | - if (!on_stop) { | ||
| 1102 | - srs_info("ignore the empty http callback: on_stop"); | ||
| 1103 | - return; | ||
| 1104 | - } | ||
| 1105 | - | ||
| 1106 | - int connection_id = _srs_context->get_id(); | ||
| 1107 | - for (int i = 0; i < (int)on_stop->args.size(); i++) { | ||
| 1108 | - std::string url = on_stop->args.at(i); | ||
| 1109 | - SrsHttpHooks::on_stop(url, connection_id, ip, req); | 1108 | + if (!_srs_config->get_vhost_http_hooks_enabled(req->vhost)) { |
| 1109 | + // whatever the ret code, notify the api hooks. | ||
| 1110 | + // HTTP: on_stop | ||
| 1111 | + SrsConfDirective* on_stop = _srs_config->get_vhost_on_stop(req->vhost); | ||
| 1112 | + if (!on_stop) { | ||
| 1113 | + srs_info("ignore the empty http callback: on_stop"); | ||
| 1114 | + return; | ||
| 1115 | + } | ||
| 1116 | + | ||
| 1117 | + int connection_id = _srs_context->get_id(); | ||
| 1118 | + for (int i = 0; i < (int)on_stop->args.size(); i++) { | ||
| 1119 | + std::string url = on_stop->args.at(i); | ||
| 1120 | + SrsHttpHooks::on_stop(url, connection_id, ip, req); | ||
| 1121 | + } | ||
| 1110 | } | 1122 | } |
| 1111 | #endif | 1123 | #endif |
| 1112 | 1124 |
此 diff 太大无法显示。
-
请 注册 或 登录 后发表评论