support http hooks: on_connect/close/publish/unpublish/play/stop.
正在显示
2 个修改的文件
包含
35 行增加
和
1 行删除
@@ -88,7 +88,8 @@ vhost dev { | @@ -88,7 +88,8 @@ vhost dev { | ||
88 | #forward 127.0.0.1:19350; | 88 | #forward 127.0.0.1:19350; |
89 | #forward 127.0.0.1:1936; | 89 | #forward 127.0.0.1:1936; |
90 | http_hooks { | 90 | http_hooks { |
91 | - on_connect http://127.0.0.1:8085/api/v1/clients http://localhost:8085/api/v1/clients; | 91 | + enabled on; |
92 | + on_connect http://127.0.0.1:8085/api/v1/clients; | ||
92 | on_close http://127.0.0.1:8085/api/v1/clients; | 93 | on_close http://127.0.0.1:8085/api/v1/clients; |
93 | on_publish http://127.0.0.1:8085/api/v1/streams; | 94 | on_publish http://127.0.0.1:8085/api/v1/streams; |
94 | on_unpublish http://127.0.0.1:8085/api/v1/streams; | 95 | on_unpublish http://127.0.0.1:8085/api/v1/streams; |
@@ -136,6 +137,9 @@ vhost dev { | @@ -136,6 +137,9 @@ vhost dev { | ||
136 | # the http hook callback vhost, srs will invoke the hooks for specified events. | 137 | # the http hook callback vhost, srs will invoke the hooks for specified events. |
137 | vhost hooks.callback.vhost.com { | 138 | vhost hooks.callback.vhost.com { |
138 | http_hooks { | 139 | http_hooks { |
140 | + # whether the http hooks enalbe. | ||
141 | + # default off. | ||
142 | + enabled on; | ||
139 | # when client connect to vhost/app, call the hook, | 143 | # when client connect to vhost/app, call the hook, |
140 | # the request in the POST data string is a object encode by json: | 144 | # the request in the POST data string is a object encode by json: |
141 | # { | 145 | # { |
@@ -575,6 +575,11 @@ SrsConfDirective* SrsConfig::get_vhost_on_connect(std::string vhost) | @@ -575,6 +575,11 @@ SrsConfDirective* SrsConfig::get_vhost_on_connect(std::string vhost) | ||
575 | return NULL; | 575 | return NULL; |
576 | } | 576 | } |
577 | 577 | ||
578 | + SrsConfDirective* enabled = conf->get("enabled"); | ||
579 | + if (!enabled || enabled->arg0() != "on") { | ||
580 | + return NULL; | ||
581 | + } | ||
582 | + | ||
578 | return conf->get("on_connect"); | 583 | return conf->get("on_connect"); |
579 | } | 584 | } |
580 | 585 | ||
@@ -591,6 +596,11 @@ SrsConfDirective* SrsConfig::get_vhost_on_close(std::string vhost) | @@ -591,6 +596,11 @@ SrsConfDirective* SrsConfig::get_vhost_on_close(std::string vhost) | ||
591 | return NULL; | 596 | return NULL; |
592 | } | 597 | } |
593 | 598 | ||
599 | + SrsConfDirective* enabled = conf->get("enabled"); | ||
600 | + if (!enabled || enabled->arg0() != "on") { | ||
601 | + return NULL; | ||
602 | + } | ||
603 | + | ||
594 | return conf->get("on_close"); | 604 | return conf->get("on_close"); |
595 | } | 605 | } |
596 | 606 | ||
@@ -607,6 +617,11 @@ SrsConfDirective* SrsConfig::get_vhost_on_publish(std::string vhost) | @@ -607,6 +617,11 @@ SrsConfDirective* SrsConfig::get_vhost_on_publish(std::string vhost) | ||
607 | return NULL; | 617 | return NULL; |
608 | } | 618 | } |
609 | 619 | ||
620 | + SrsConfDirective* enabled = conf->get("enabled"); | ||
621 | + if (!enabled || enabled->arg0() != "on") { | ||
622 | + return NULL; | ||
623 | + } | ||
624 | + | ||
610 | return conf->get("on_publish"); | 625 | return conf->get("on_publish"); |
611 | } | 626 | } |
612 | 627 | ||
@@ -623,6 +638,11 @@ SrsConfDirective* SrsConfig::get_vhost_on_unpublish(std::string vhost) | @@ -623,6 +638,11 @@ SrsConfDirective* SrsConfig::get_vhost_on_unpublish(std::string vhost) | ||
623 | return NULL; | 638 | return NULL; |
624 | } | 639 | } |
625 | 640 | ||
641 | + SrsConfDirective* enabled = conf->get("enabled"); | ||
642 | + if (!enabled || enabled->arg0() != "on") { | ||
643 | + return NULL; | ||
644 | + } | ||
645 | + | ||
626 | return conf->get("on_unpublish"); | 646 | return conf->get("on_unpublish"); |
627 | } | 647 | } |
628 | 648 | ||
@@ -639,6 +659,11 @@ SrsConfDirective* SrsConfig::get_vhost_on_play(std::string vhost) | @@ -639,6 +659,11 @@ SrsConfDirective* SrsConfig::get_vhost_on_play(std::string vhost) | ||
639 | return NULL; | 659 | return NULL; |
640 | } | 660 | } |
641 | 661 | ||
662 | + SrsConfDirective* enabled = conf->get("enabled"); | ||
663 | + if (!enabled || enabled->arg0() != "on") { | ||
664 | + return NULL; | ||
665 | + } | ||
666 | + | ||
642 | return conf->get("on_play"); | 667 | return conf->get("on_play"); |
643 | } | 668 | } |
644 | 669 | ||
@@ -655,6 +680,11 @@ SrsConfDirective* SrsConfig::get_vhost_on_stop(std::string vhost) | @@ -655,6 +680,11 @@ SrsConfDirective* SrsConfig::get_vhost_on_stop(std::string vhost) | ||
655 | return NULL; | 680 | return NULL; |
656 | } | 681 | } |
657 | 682 | ||
683 | + SrsConfDirective* enabled = conf->get("enabled"); | ||
684 | + if (!enabled || enabled->arg0() != "on") { | ||
685 | + return NULL; | ||
686 | + } | ||
687 | + | ||
658 | return conf->get("on_stop"); | 688 | return conf->get("on_stop"); |
659 | } | 689 | } |
660 | 690 |
-
请 注册 或 登录 后发表评论