winlin

call http api when dvr got keyframe

@@ -96,6 +96,8 @@ vhost dvr.srs.com { @@ -96,6 +96,8 @@ vhost dvr.srs.com {
96 # dvr RTMP stream to file, 96 # dvr RTMP stream to file,
97 # start to record to file when encoder publish, 97 # start to record to file when encoder publish,
98 # reap flv according by specified dvr_plan. 98 # reap flv according by specified dvr_plan.
  99 + # http callbacks:
  100 + # @see http callback on_dvr_keyframe on http_hooks section.
99 dvr { 101 dvr {
100 # whether enabled dvr features 102 # whether enabled dvr features
101 # default: off 103 # default: off
@@ -320,6 +322,19 @@ vhost hooks.callback.srs.com { @@ -320,6 +322,19 @@ vhost hooks.callback.srs.com {
320 # support multiple api hooks, format: 322 # support multiple api hooks, format:
321 # on_stop http://xxx/api0 http://xxx/api1 http://xxx/apiN 323 # on_stop http://xxx/api0 http://xxx/api1 http://xxx/apiN
322 on_stop http://127.0.0.1:8085/api/v1/sessions http://localhost:8085/api/v1/sessions; 324 on_stop http://127.0.0.1:8085/api/v1/sessions http://localhost:8085/api/v1/sessions;
  325 + # when dvr got an keyframe, call the hook,
  326 + # the request in the POST data string is a object encode by json:
  327 + # {
  328 + # "action": "on_dvr_keyframe",
  329 + # "vhost": "video.test.com", "app": "live",
  330 + # "stream": "livestream"
  331 + # }
  332 + # if valid, the hook must return HTTP code 200(Stauts OK) and response
  333 + # an int value specifies the error code(0 corresponding to success):
  334 + # 0
  335 + # support multiple api hooks, format:
  336 + # on_stop http://xxx/api0 http://xxx/api1 http://xxx/apiN
  337 + on_dvr_keyframe http://127.0.0.1:8085/api/v1/dvrs http://localhost:8085/api/v1/dvrs;
323 } 338 }
324 } 339 }
325 340
@@ -1560,6 +1560,27 @@ SrsConfDirective* SrsConfig::get_vhost_on_stop(string vhost) @@ -1560,6 +1560,27 @@ SrsConfDirective* SrsConfig::get_vhost_on_stop(string vhost)
1560 return conf->get("on_stop"); 1560 return conf->get("on_stop");
1561 } 1561 }
1562 1562
  1563 +SrsConfDirective* SrsConfig::get_vhost_on_dvr_keyframe(string vhost)
  1564 +{
  1565 + SrsConfDirective* conf = get_vhost(vhost);
  1566 +
  1567 + if (!conf) {
  1568 + return NULL;
  1569 + }
  1570 +
  1571 + conf = conf->get("http_hooks");
  1572 + if (!conf) {
  1573 + return NULL;
  1574 + }
  1575 +
  1576 + SrsConfDirective* enabled = conf->get("enabled");
  1577 + if (!enabled || enabled->arg0() != "on") {
  1578 + return NULL;
  1579 + }
  1580 +
  1581 + return conf->get("on_dvr_keyframe");
  1582 +}
  1583 +
1563 bool SrsConfig::get_vhost_enabled(string vhost) 1584 bool SrsConfig::get_vhost_enabled(string vhost)
1564 { 1585 {
1565 SrsConfDirective* vhost_conf = get_vhost(vhost); 1586 SrsConfDirective* vhost_conf = get_vhost(vhost);
@@ -173,6 +173,7 @@ public: @@ -173,6 +173,7 @@ public:
173 virtual SrsConfDirective* get_vhost_on_unpublish(std::string vhost); 173 virtual SrsConfDirective* get_vhost_on_unpublish(std::string vhost);
174 virtual SrsConfDirective* get_vhost_on_play(std::string vhost); 174 virtual SrsConfDirective* get_vhost_on_play(std::string vhost);
175 virtual SrsConfDirective* get_vhost_on_stop(std::string vhost); 175 virtual SrsConfDirective* get_vhost_on_stop(std::string vhost);
  176 + virtual SrsConfDirective* get_vhost_on_dvr_keyframe(std::string vhost);
176 virtual bool get_gop_cache(std::string vhost); 177 virtual bool get_gop_cache(std::string vhost);
177 virtual bool get_atc(std::string vhost); 178 virtual bool get_atc(std::string vhost);
178 virtual double get_queue_length(std::string vhost); 179 virtual double get_queue_length(std::string vhost);
@@ -37,6 +37,8 @@ using namespace std; @@ -37,6 +37,8 @@ using namespace std;
37 #include <srs_core_autofree.hpp> 37 #include <srs_core_autofree.hpp>
38 #include <srs_kernel_stream.hpp> 38 #include <srs_kernel_stream.hpp>
39 #include <srs_kernel_utility.hpp> 39 #include <srs_kernel_utility.hpp>
  40 +#include <srs_app_http_hooks.hpp>
  41 +#include <srs_app_codec.hpp>
40 42
41 SrsFileStream::SrsFileStream() 43 SrsFileStream::SrsFileStream()
42 { 44 {
@@ -364,34 +366,6 @@ int SrsDvrPlan::on_publish() @@ -364,34 +366,6 @@ int SrsDvrPlan::on_publish()
364 return ret; 366 return ret;
365 } 367 }
366 368
367 -int SrsDvrPlan::flv_open(string stream, string path)  
368 -{  
369 - int ret = ERROR_SUCCESS;  
370 -  
371 - if ((ret = fs->open(path)) != ERROR_SUCCESS) {  
372 - srs_error("open file stream for file %s failed. ret=%d", path.c_str(), ret);  
373 - return ret;  
374 - }  
375 -  
376 - if ((ret = enc->initialize(fs)) != ERROR_SUCCESS) {  
377 - srs_error("initialize enc by fs for file %s failed. ret=%d", path.c_str(), ret);  
378 - return ret;  
379 - }  
380 -  
381 - if ((ret = enc->write_header()) != ERROR_SUCCESS) {  
382 - srs_error("write flv header for file %s failed. ret=%d", path.c_str(), ret);  
383 - return ret;  
384 - }  
385 -  
386 - srs_trace("dvr stream %s to file %s", stream.c_str(), path.c_str());  
387 - return ret;  
388 -}  
389 -  
390 -int SrsDvrPlan::flv_close()  
391 -{  
392 - return fs->close();  
393 -}  
394 -  
395 int SrsDvrPlan::on_meta_data(SrsOnMetaDataPacket* metadata) 369 int SrsDvrPlan::on_meta_data(SrsOnMetaDataPacket* metadata)
396 { 370 {
397 int ret = ERROR_SUCCESS; 371 int ret = ERROR_SUCCESS;
@@ -459,6 +433,16 @@ int SrsDvrPlan::on_video(SrsSharedPtrMessage* video) @@ -459,6 +433,16 @@ int SrsDvrPlan::on_video(SrsSharedPtrMessage* video)
459 return ret; 433 return ret;
460 } 434 }
461 435
  436 +#ifdef SRS_AUTO_HTTP_CALLBACK
  437 + bool is_key_frame = SrsCodec::video_is_keyframe((int8_t*)payload, size);
  438 + srs_verbose("dvr video is key: %d", is_key_frame);
  439 + if (is_key_frame) {
  440 + if ((ret = on_dvr_keyframe()) != ERROR_SUCCESS) {
  441 + return ret;
  442 + }
  443 + }
  444 +#endif
  445 +
462 if ((ret = on_video_msg(video)) != ERROR_SUCCESS) { 446 if ((ret = on_video_msg(video)) != ERROR_SUCCESS) {
463 return ret; 447 return ret;
464 } 448 }
@@ -466,6 +450,29 @@ int SrsDvrPlan::on_video(SrsSharedPtrMessage* video) @@ -466,6 +450,29 @@ int SrsDvrPlan::on_video(SrsSharedPtrMessage* video)
466 return ret; 450 return ret;
467 } 451 }
468 452
  453 +int SrsDvrPlan::flv_open(string stream, string path)
  454 +{
  455 + int ret = ERROR_SUCCESS;
  456 +
  457 + if ((ret = fs->open(path)) != ERROR_SUCCESS) {
  458 + srs_error("open file stream for file %s failed. ret=%d", path.c_str(), ret);
  459 + return ret;
  460 + }
  461 +
  462 + if ((ret = enc->initialize(fs)) != ERROR_SUCCESS) {
  463 + srs_error("initialize enc by fs for file %s failed. ret=%d", path.c_str(), ret);
  464 + return ret;
  465 + }
  466 +
  467 + if ((ret = enc->write_header()) != ERROR_SUCCESS) {
  468 + srs_error("write flv header for file %s failed. ret=%d", path.c_str(), ret);
  469 + return ret;
  470 + }
  471 +
  472 + srs_trace("dvr stream %s to file %s", stream.c_str(), path.c_str());
  473 + return ret;
  474 +}
  475 +
469 int SrsDvrPlan::on_audio_msg(SrsSharedPtrMessage* /*audio*/) 476 int SrsDvrPlan::on_audio_msg(SrsSharedPtrMessage* /*audio*/)
470 { 477 {
471 int ret = ERROR_SUCCESS; 478 int ret = ERROR_SUCCESS;
@@ -478,6 +485,32 @@ int SrsDvrPlan::on_video_msg(SrsSharedPtrMessage* /*video*/) @@ -478,6 +485,32 @@ int SrsDvrPlan::on_video_msg(SrsSharedPtrMessage* /*video*/)
478 return ret; 485 return ret;
479 } 486 }
480 487
  488 +int SrsDvrPlan::flv_close()
  489 +{
  490 + return fs->close();
  491 +}
  492 +
  493 +int SrsDvrPlan::on_dvr_keyframe()
  494 +{
  495 + int ret = ERROR_SUCCESS;
  496 +
  497 +#ifdef SRS_AUTO_HTTP_CALLBACK
  498 + // HTTP: on_dvr_keyframe
  499 + SrsConfDirective* on_dvr_keyframe = _srs_config->get_vhost_on_dvr_keyframe(_req->vhost);
  500 + if (!on_dvr_keyframe) {
  501 + srs_info("ignore the empty http callback: on_dvr_keyframe");
  502 + return ret;
  503 + }
  504 +
  505 + for (int i = 0; i < (int)on_dvr_keyframe->args.size(); i++) {
  506 + std::string url = on_dvr_keyframe->args.at(i);
  507 + SrsHttpHooks::on_dvr_keyframe(url, _req);
  508 + }
  509 +#endif
  510 +
  511 + return ret;
  512 +}
  513 +
481 SrsDvrPlan* SrsDvrPlan::create_plan(string vhost) 514 SrsDvrPlan* SrsDvrPlan::create_plan(string vhost)
482 { 515 {
483 std::string plan = _srs_config->get_dvr_plan(vhost); 516 std::string plan = _srs_config->get_dvr_plan(vhost);
@@ -146,6 +146,8 @@ protected: @@ -146,6 +146,8 @@ protected:
146 virtual int on_audio_msg(SrsSharedPtrMessage* audio); 146 virtual int on_audio_msg(SrsSharedPtrMessage* audio);
147 virtual int on_video_msg(SrsSharedPtrMessage* video); 147 virtual int on_video_msg(SrsSharedPtrMessage* video);
148 virtual int flv_close(); 148 virtual int flv_close();
  149 +private:
  150 + virtual int on_dvr_keyframe();
149 public: 151 public:
150 static SrsDvrPlan* create_plan(std::string vhost); 152 static SrsDvrPlan* create_plan(std::string vhost);
151 }; 153 };
@@ -55,7 +55,7 @@ SrsHttpClient::~SrsHttpClient() @@ -55,7 +55,7 @@ SrsHttpClient::~SrsHttpClient()
55 srs_freep(parser); 55 srs_freep(parser);
56 } 56 }
57 57
58 -int SrsHttpClient::post(SrsHttpUri* uri, std::string req, std::string& res) 58 +int SrsHttpClient::post(SrsHttpUri* uri, string req, string& res)
59 { 59 {
60 res = ""; 60 res = "";
61 61
@@ -183,7 +183,7 @@ SrsHttpHooks::~SrsHttpHooks() @@ -183,7 +183,7 @@ SrsHttpHooks::~SrsHttpHooks()
183 { 183 {
184 } 184 }
185 185
186 -int SrsHttpHooks::on_connect(std::string url, int client_id, std::string ip, SrsRequest* req) 186 +int SrsHttpHooks::on_connect(string url, int client_id, string ip, SrsRequest* req)
187 { 187 {
188 int ret = ERROR_SUCCESS; 188 int ret = ERROR_SUCCESS;
189 189
@@ -236,7 +236,7 @@ int SrsHttpHooks::on_connect(std::string url, int client_id, std::string ip, Srs @@ -236,7 +236,7 @@ int SrsHttpHooks::on_connect(std::string url, int client_id, std::string ip, Srs
236 return ret; 236 return ret;
237 } 237 }
238 238
239 -void SrsHttpHooks::on_close(std::string url, int client_id, std::string ip, SrsRequest* req) 239 +void SrsHttpHooks::on_close(string url, int client_id, string ip, SrsRequest* req)
240 { 240 {
241 int ret = ERROR_SUCCESS; 241 int ret = ERROR_SUCCESS;
242 242
@@ -289,7 +289,7 @@ void SrsHttpHooks::on_close(std::string url, int client_id, std::string ip, SrsR @@ -289,7 +289,7 @@ void SrsHttpHooks::on_close(std::string url, int client_id, std::string ip, SrsR
289 return; 289 return;
290 } 290 }
291 291
292 -int SrsHttpHooks::on_publish(std::string url, int client_id, std::string ip, SrsRequest* req) 292 +int SrsHttpHooks::on_publish(string url, int client_id, string ip, SrsRequest* req)
293 { 293 {
294 int ret = ERROR_SUCCESS; 294 int ret = ERROR_SUCCESS;
295 295
@@ -343,7 +343,7 @@ int SrsHttpHooks::on_publish(std::string url, int client_id, std::string ip, Srs @@ -343,7 +343,7 @@ int SrsHttpHooks::on_publish(std::string url, int client_id, std::string ip, Srs
343 return ret; 343 return ret;
344 } 344 }
345 345
346 -void SrsHttpHooks::on_unpublish(std::string url, int client_id, std::string ip, SrsRequest* req) 346 +void SrsHttpHooks::on_unpublish(string url, int client_id, string ip, SrsRequest* req)
347 { 347 {
348 int ret = ERROR_SUCCESS; 348 int ret = ERROR_SUCCESS;
349 349
@@ -397,7 +397,7 @@ void SrsHttpHooks::on_unpublish(std::string url, int client_id, std::string ip, @@ -397,7 +397,7 @@ void SrsHttpHooks::on_unpublish(std::string url, int client_id, std::string ip,
397 return; 397 return;
398 } 398 }
399 399
400 -int SrsHttpHooks::on_play(std::string url, int client_id, std::string ip, SrsRequest* req) 400 +int SrsHttpHooks::on_play(string url, int client_id, string ip, SrsRequest* req)
401 { 401 {
402 int ret = ERROR_SUCCESS; 402 int ret = ERROR_SUCCESS;
403 403
@@ -451,7 +451,7 @@ int SrsHttpHooks::on_play(std::string url, int client_id, std::string ip, SrsReq @@ -451,7 +451,7 @@ int SrsHttpHooks::on_play(std::string url, int client_id, std::string ip, SrsReq
451 return ret; 451 return ret;
452 } 452 }
453 453
454 -void SrsHttpHooks::on_stop(std::string url, int client_id, std::string ip, SrsRequest* req) 454 +void SrsHttpHooks::on_stop(string url, int client_id, string ip, SrsRequest* req)
455 { 455 {
456 int ret = ERROR_SUCCESS; 456 int ret = ERROR_SUCCESS;
457 457
@@ -505,4 +505,54 @@ void SrsHttpHooks::on_stop(std::string url, int client_id, std::string ip, SrsRe @@ -505,4 +505,54 @@ void SrsHttpHooks::on_stop(std::string url, int client_id, std::string ip, SrsRe
505 return; 505 return;
506 } 506 }
507 507
  508 +void SrsHttpHooks::on_dvr_keyframe(string url, SrsRequest* req)
  509 +{
  510 + int ret = ERROR_SUCCESS;
  511 +
  512 + SrsHttpUri uri;
  513 + if ((ret = uri.initialize(url)) != ERROR_SUCCESS) {
  514 + srs_warn("http uri parse on_dvr_keyframe url failed, ignored. "
  515 + "url=%s, ret=%d", url.c_str(), ret);
  516 + return;
  517 + }
  518 +
  519 + /**
  520 + {
  521 + "action": "on_dvr_keyframe",
  522 + "vhost": "video.test.com", "app": "live",
  523 + "stream": "livestream"
  524 + }
  525 + */
  526 + std::stringstream ss;
  527 + ss << JOBJECT_START
  528 + << JFIELD_STR("action", "on_dvr_keyframe") << JFIELD_CONT
  529 + << JFIELD_STR("vhost", req->vhost) << JFIELD_CONT
  530 + << JFIELD_STR("app", req->app) << JFIELD_CONT
  531 + << JFIELD_STR("stream", req->stream)
  532 + << JOBJECT_END;
  533 + std::string data = ss.str();
  534 + std::string res;
  535 +
  536 + SrsHttpClient http;
  537 + if ((ret = http.post(&uri, data, res)) != ERROR_SUCCESS) {
  538 + srs_warn("http post on_dvr_keyframe uri failed, ignored. "
  539 + "url=%s, request=%s, response=%s, ret=%d",
  540 + url.c_str(), data.c_str(), res.c_str(), ret);
  541 + return;
  542 + }
  543 +
  544 + if (res.empty() || res != SRS_HTTP_RESPONSE_OK) {
  545 + ret = ERROR_HTTP_DATA_INVLIAD;
  546 + srs_warn("http hook on_dvr_keyframe validate failed, ignored. "
  547 + "res=%s, ret=%d", res.c_str(), ret);
  548 + return;
  549 + }
  550 +
  551 + srs_trace("http hook on_dvr_keyframe success. "
  552 + "url=%s, request=%s, response=%s, ret=%d",
  553 + url.c_str(), data.c_str(), res.c_str(), ret);
  554 +
  555 + return;
  556 +}
  557 +
508 #endif 558 #endif
@@ -71,8 +71,9 @@ private: @@ -71,8 +71,9 @@ private:
71 */ 71 */
72 class SrsHttpHooks 72 class SrsHttpHooks
73 { 73 {
74 -public: 74 +private:
75 SrsHttpHooks(); 75 SrsHttpHooks();
  76 +public:
76 virtual ~SrsHttpHooks(); 77 virtual ~SrsHttpHooks();
77 public: 78 public:
78 /** 79 /**
@@ -82,14 +83,14 @@ public: @@ -82,14 +83,14 @@ public:
82 * ignore if empty. 83 * ignore if empty.
83 * @return valid failed or connect to the url failed. 84 * @return valid failed or connect to the url failed.
84 */ 85 */
85 - virtual int on_connect(std::string url, int client_id, std::string ip, SrsRequest* req); 86 + static int on_connect(std::string url, int client_id, std::string ip, SrsRequest* req);
86 /** 87 /**
87 * on_close hook, when client disconnect to srs, where client is valid by on_connect. 88 * on_close hook, when client disconnect to srs, where client is valid by on_connect.
88 * @param client_id the id of client on server. 89 * @param client_id the id of client on server.
89 * @param url the api server url, to process the event. 90 * @param url the api server url, to process the event.
90 * ignore if empty. 91 * ignore if empty.
91 */ 92 */
92 - virtual void on_close(std::string url, int client_id, std::string ip, SrsRequest* req); 93 + static void on_close(std::string url, int client_id, std::string ip, SrsRequest* req);
93 /** 94 /**
94 * on_publish hook, when client(encoder) start to publish stream 95 * on_publish hook, when client(encoder) start to publish stream
95 * @param client_id the id of client on server. 96 * @param client_id the id of client on server.
@@ -97,14 +98,14 @@ public: @@ -97,14 +98,14 @@ public:
97 * ignore if empty. 98 * ignore if empty.
98 * @return valid failed or connect to the url failed. 99 * @return valid failed or connect to the url failed.
99 */ 100 */
100 - virtual int on_publish(std::string url, int client_id, std::string ip, SrsRequest* req); 101 + static int on_publish(std::string url, int client_id, std::string ip, SrsRequest* req);
101 /** 102 /**
102 * on_unpublish hook, when client(encoder) stop publish stream. 103 * on_unpublish hook, when client(encoder) stop publish stream.
103 * @param client_id the id of client on server. 104 * @param client_id the id of client on server.
104 * @param url the api server url, to process the event. 105 * @param url the api server url, to process the event.
105 * ignore if empty. 106 * ignore if empty.
106 */ 107 */
107 - virtual void on_unpublish(std::string url, int client_id, std::string ip, SrsRequest* req); 108 + static void on_unpublish(std::string url, int client_id, std::string ip, SrsRequest* req);
108 /** 109 /**
109 * on_play hook, when client start to play stream. 110 * on_play hook, when client start to play stream.
110 * @param client_id the id of client on server. 111 * @param client_id the id of client on server.
@@ -112,14 +113,21 @@ public: @@ -112,14 +113,21 @@ public:
112 * ignore if empty. 113 * ignore if empty.
113 * @return valid failed or connect to the url failed. 114 * @return valid failed or connect to the url failed.
114 */ 115 */
115 - virtual int on_play(std::string url, int client_id, std::string ip, SrsRequest* req); 116 + static int on_play(std::string url, int client_id, std::string ip, SrsRequest* req);
116 /** 117 /**
117 * on_stop hook, when client stop to play the stream. 118 * on_stop hook, when client stop to play the stream.
118 * @param client_id the id of client on server. 119 * @param client_id the id of client on server.
119 * @param url the api server url, to process the event. 120 * @param url the api server url, to process the event.
120 * ignore if empty. 121 * ignore if empty.
121 */ 122 */
122 - virtual void on_stop(std::string url, int client_id, std::string ip, SrsRequest* req); 123 + static void on_stop(std::string url, int client_id, std::string ip, SrsRequest* req);
  124 +public:
  125 + /**
  126 + * on_dvr_keyframe hook, when dvr get keyframe.
  127 + * @param url the api server url, to process the event.
  128 + * ignore if empty.
  129 + */
  130 + static void on_dvr_keyframe(std::string url, SrsRequest* req);
123 }; 131 };
124 132
125 #endif 133 #endif
@@ -68,9 +68,6 @@ SrsRtmpConn::SrsRtmpConn(SrsServer* srs_server, st_netfd_t client_stfd) @@ -68,9 +68,6 @@ SrsRtmpConn::SrsRtmpConn(SrsServer* srs_server, st_netfd_t client_stfd)
68 skt = new SrsSocket(client_stfd); 68 skt = new SrsSocket(client_stfd);
69 rtmp = new SrsRtmpServer(skt); 69 rtmp = new SrsRtmpServer(skt);
70 refer = new SrsRefer(); 70 refer = new SrsRefer();
71 -#ifdef SRS_AUTO_HTTP_CALLBACK  
72 - http_hooks = new SrsHttpHooks();  
73 -#endif  
74 bandwidth = new SrsBandwidth(); 71 bandwidth = new SrsBandwidth();
75 duration = 0; 72 duration = 0;
76 73
@@ -86,9 +83,6 @@ SrsRtmpConn::~SrsRtmpConn() @@ -86,9 +83,6 @@ SrsRtmpConn::~SrsRtmpConn()
86 srs_freep(rtmp); 83 srs_freep(rtmp);
87 srs_freep(skt); 84 srs_freep(skt);
88 srs_freep(refer); 85 srs_freep(refer);
89 -#ifdef SRS_AUTO_HTTP_CALLBACK  
90 - srs_freep(http_hooks);  
91 -#endif  
92 srs_freep(bandwidth); 86 srs_freep(bandwidth);
93 } 87 }
94 88
@@ -730,7 +724,7 @@ int SrsRtmpConn::on_connect() @@ -730,7 +724,7 @@ int SrsRtmpConn::on_connect()
730 { 724 {
731 int ret = ERROR_SUCCESS; 725 int ret = ERROR_SUCCESS;
732 726
733 -#ifdef SRS_AUTO_HTTP_CALLBACK 727 +#ifdef SRS_AUTO_HTTP_CALLBACK
734 // HTTP: on_connect 728 // HTTP: on_connect
735 SrsConfDirective* on_connect = _srs_config->get_vhost_on_connect(req->vhost); 729 SrsConfDirective* on_connect = _srs_config->get_vhost_on_connect(req->vhost);
736 if (!on_connect) { 730 if (!on_connect) {
@@ -740,7 +734,7 @@ int SrsRtmpConn::on_connect() @@ -740,7 +734,7 @@ int SrsRtmpConn::on_connect()
740 734
741 for (int i = 0; i < (int)on_connect->args.size(); i++) { 735 for (int i = 0; i < (int)on_connect->args.size(); i++) {
742 std::string url = on_connect->args.at(i); 736 std::string url = on_connect->args.at(i);
743 - if ((ret = http_hooks->on_connect(url, connection_id, ip, req)) != ERROR_SUCCESS) { 737 + if ((ret = SrsHttpHooks::on_connect(url, connection_id, ip, req)) != ERROR_SUCCESS) {
744 srs_error("hook client on_connect failed. url=%s, ret=%d", url.c_str(), ret); 738 srs_error("hook client on_connect failed. url=%s, ret=%d", url.c_str(), ret);
745 return ret; 739 return ret;
746 } 740 }
@@ -763,7 +757,7 @@ void SrsRtmpConn::on_close() @@ -763,7 +757,7 @@ void SrsRtmpConn::on_close()
763 757
764 for (int i = 0; i < (int)on_close->args.size(); i++) { 758 for (int i = 0; i < (int)on_close->args.size(); i++) {
765 std::string url = on_close->args.at(i); 759 std::string url = on_close->args.at(i);
766 - http_hooks->on_close(url, connection_id, ip, req); 760 + SrsHttpHooks::on_close(url, connection_id, ip, req);
767 } 761 }
768 #endif 762 #endif
769 } 763 }
@@ -782,7 +776,7 @@ int SrsRtmpConn::on_publish() @@ -782,7 +776,7 @@ int SrsRtmpConn::on_publish()
782 776
783 for (int i = 0; i < (int)on_publish->args.size(); i++) { 777 for (int i = 0; i < (int)on_publish->args.size(); i++) {
784 std::string url = on_publish->args.at(i); 778 std::string url = on_publish->args.at(i);
785 - if ((ret = http_hooks->on_publish(url, connection_id, ip, req)) != ERROR_SUCCESS) { 779 + if ((ret = SrsHttpHooks::on_publish(url, connection_id, ip, req)) != ERROR_SUCCESS) {
786 srs_error("hook client on_publish failed. url=%s, ret=%d", url.c_str(), ret); 780 srs_error("hook client on_publish failed. url=%s, ret=%d", url.c_str(), ret);
787 return ret; 781 return ret;
788 } 782 }
@@ -805,7 +799,7 @@ void SrsRtmpConn::on_unpublish() @@ -805,7 +799,7 @@ void SrsRtmpConn::on_unpublish()
805 799
806 for (int i = 0; i < (int)on_unpublish->args.size(); i++) { 800 for (int i = 0; i < (int)on_unpublish->args.size(); i++) {
807 std::string url = on_unpublish->args.at(i); 801 std::string url = on_unpublish->args.at(i);
808 - http_hooks->on_unpublish(url, connection_id, ip, req); 802 + SrsHttpHooks::on_unpublish(url, connection_id, ip, req);
809 } 803 }
810 #endif 804 #endif
811 } 805 }
@@ -824,7 +818,7 @@ int SrsRtmpConn::on_play() @@ -824,7 +818,7 @@ int SrsRtmpConn::on_play()
824 818
825 for (int i = 0; i < (int)on_play->args.size(); i++) { 819 for (int i = 0; i < (int)on_play->args.size(); i++) {
826 std::string url = on_play->args.at(i); 820 std::string url = on_play->args.at(i);
827 - if ((ret = http_hooks->on_play(url, connection_id, ip, req)) != ERROR_SUCCESS) { 821 + if ((ret = SrsHttpHooks::on_play(url, connection_id, ip, req)) != ERROR_SUCCESS) {
828 srs_error("hook client on_play failed. url=%s, ret=%d", url.c_str(), ret); 822 srs_error("hook client on_play failed. url=%s, ret=%d", url.c_str(), ret);
829 return ret; 823 return ret;
830 } 824 }
@@ -847,7 +841,7 @@ void SrsRtmpConn::on_stop() @@ -847,7 +841,7 @@ void SrsRtmpConn::on_stop()
847 841
848 for (int i = 0; i < (int)on_stop->args.size(); i++) { 842 for (int i = 0; i < (int)on_stop->args.size(); i++) {
849 std::string url = on_stop->args.at(i); 843 std::string url = on_stop->args.at(i);
850 - http_hooks->on_stop(url, connection_id, ip, req); 844 + SrsHttpHooks::on_stop(url, connection_id, ip, req);
851 } 845 }
852 #endif 846 #endif
853 847
@@ -58,9 +58,6 @@ private: @@ -58,9 +58,6 @@ private:
58 SrsSocket* skt; 58 SrsSocket* skt;
59 SrsRtmpServer* rtmp; 59 SrsRtmpServer* rtmp;
60 SrsRefer* refer; 60 SrsRefer* refer;
61 -#ifdef SRS_AUTO_HTTP_CALLBACK  
62 - SrsHttpHooks* http_hooks;  
63 -#endif  
64 SrsBandwidth* bandwidth; 61 SrsBandwidth* bandwidth;
65 // elapse duration in ms 62 // elapse duration in ms
66 // for live play duration, for instance, rtmpdump to record. 63 // for live play duration, for instance, rtmpdump to record.