正在显示
6 个修改的文件
包含
89 行增加
和
199 行删除
| @@ -307,23 +307,6 @@ int SrsEdgeIngester::connect_server() | @@ -307,23 +307,6 @@ int SrsEdgeIngester::connect_server() | ||
| 307 | return ret; | 307 | return ret; |
| 308 | } | 308 | } |
| 309 | 309 | ||
| 310 | -SrsEdgeProxyContext::SrsEdgeProxyContext() | ||
| 311 | -{ | ||
| 312 | - edge_stream_id = 0; | ||
| 313 | - edge_io = NULL; | ||
| 314 | - edge_rtmp = NULL; | ||
| 315 | - edge_stfd = NULL; | ||
| 316 | - | ||
| 317 | - origin_stream_id = 0; | ||
| 318 | - origin_io = NULL; | ||
| 319 | - origin_rtmp = NULL; | ||
| 320 | - origin_stfd = NULL; | ||
| 321 | -} | ||
| 322 | - | ||
| 323 | -SrsEdgeProxyContext::~SrsEdgeProxyContext() | ||
| 324 | -{ | ||
| 325 | -} | ||
| 326 | - | ||
| 327 | SrsEdgeForwarder::SrsEdgeForwarder() | 310 | SrsEdgeForwarder::SrsEdgeForwarder() |
| 328 | { | 311 | { |
| 329 | io = NULL; | 312 | io = NULL; |
| @@ -395,129 +378,30 @@ void SrsEdgeForwarder::stop() | @@ -395,129 +378,30 @@ void SrsEdgeForwarder::stop() | ||
| 395 | srs_freep(io); | 378 | srs_freep(io); |
| 396 | } | 379 | } |
| 397 | 380 | ||
| 398 | -int SrsEdgeForwarder::proxy(SrsEdgeProxyContext* context) | 381 | +int SrsEdgeForwarder::proxy(SrsCommonMessage* msg) |
| 399 | { | 382 | { |
| 400 | int ret = ERROR_SUCCESS; | 383 | int ret = ERROR_SUCCESS; |
| 401 | 384 | ||
| 402 | - context->origin_io = io; | ||
| 403 | - context->origin_rtmp = client; | ||
| 404 | - context->origin_stream_id = stream_id; | ||
| 405 | - context->origin_stfd = stfd; | ||
| 406 | - | ||
| 407 | - context->origin_rtmp->set_recv_timeout(SRS_RECV_TIMEOUT_US); | ||
| 408 | - context->edge_rtmp->set_recv_timeout(SRS_RECV_TIMEOUT_US); | ||
| 409 | - | ||
| 410 | - SrsPithyPrint pithy_print(SRS_STAGE_EDGE); | ||
| 411 | - | ||
| 412 | - pollfd fds[2]; | ||
| 413 | - fds[0].fd = st_netfd_fileno(context->edge_stfd); | ||
| 414 | - fds[0].events = POLLIN; | ||
| 415 | - | ||
| 416 | - fds[1].fd = st_netfd_fileno(context->origin_stfd); | ||
| 417 | - fds[1].events = POLLIN; | ||
| 418 | - | ||
| 419 | - while (true) { | ||
| 420 | - // switch to other st-threads. | ||
| 421 | - st_usleep(0); | ||
| 422 | - | ||
| 423 | - pithy_print.elapse(); | ||
| 424 | - | ||
| 425 | - // pithy print | ||
| 426 | - if (pithy_print.can_print()) { | ||
| 427 | - srs_trace("<- time=%"PRId64", obytes=%"PRId64", ibytes=%"PRId64", okbps=%d, ikbps=%d", | ||
| 428 | - pithy_print.age(), client->get_send_bytes(), client->get_recv_bytes(), client->get_send_kbps(), client->get_recv_kbps()); | ||
| 429 | - } | ||
| 430 | - | ||
| 431 | - fds[0].revents = 0; | ||
| 432 | - fds[1].revents = 0; | ||
| 433 | - | ||
| 434 | - // Upon successful completion, a non-negative value is returned. | ||
| 435 | - // A positive value indicates the total number of OS file descriptors in pds that have events. | ||
| 436 | - // A value of 0 indicates that the call timed out. | ||
| 437 | - // Upon failure, a value of -1 is returned and errno is set to indicate the error | ||
| 438 | - if(st_poll(fds, 2, ST_UTIME_NO_TIMEOUT) <= 0){ | ||
| 439 | - ret = ERROR_RTMP_EDGE_PROXY_PULL; | ||
| 440 | - srs_error("edge wait for st_poll error. ret=%d", ret); | ||
| 441 | - return ret; | ||
| 442 | - } | ||
| 443 | - | ||
| 444 | - // edge active | ||
| 445 | - if(fds[0].revents & POLLIN){ | ||
| 446 | - if((ret = proxy_edge_message(context)) != ERROR_SUCCESS){ | ||
| 447 | - return ret; | ||
| 448 | - } | ||
| 449 | - } | ||
| 450 | - | ||
| 451 | - // origin active | ||
| 452 | - if(fds[1].revents & POLLIN){ | ||
| 453 | - if((ret = proxy_origin_message(context)) != ERROR_SUCCESS){ | ||
| 454 | - return ret; | ||
| 455 | - } | ||
| 456 | - } | ||
| 457 | - } | ||
| 458 | - | ||
| 459 | - return ret; | ||
| 460 | -} | ||
| 461 | - | ||
| 462 | -int SrsEdgeForwarder::proxy_origin_message(SrsEdgeProxyContext* context) | ||
| 463 | -{ | ||
| 464 | - int ret = ERROR_SUCCESS; | ||
| 465 | - | ||
| 466 | - SrsCommonMessage* msg = NULL; | ||
| 467 | - | ||
| 468 | - // process origin message. | ||
| 469 | - ret = context->origin_rtmp->recv_message(&msg); | ||
| 470 | - if (ret != ERROR_SUCCESS && ret != ERROR_SOCKET_TIMEOUT) { | ||
| 471 | - srs_error("forward recv origin server message failed. ret=%d", ret); | ||
| 472 | - return ret; | ||
| 473 | - } | ||
| 474 | - | ||
| 475 | - srs_assert(msg); | ||
| 476 | - | ||
| 477 | - if (msg->size <= 0 | 385 | + // the msg is auto free by source, |
| 386 | + // so we just ignore, or copy then send it. | ||
| 387 | + if (msg->size <= 0 | ||
| 478 | || msg->header.is_set_chunk_size() | 388 | || msg->header.is_set_chunk_size() |
| 479 | || msg->header.is_window_ackledgement_size() | 389 | || msg->header.is_window_ackledgement_size() |
| 480 | || msg->header.is_ackledgement() | 390 | || msg->header.is_ackledgement() |
| 481 | ) { | 391 | ) { |
| 482 | - srs_freep(msg); | ||
| 483 | - return ret; | ||
| 484 | - } | ||
| 485 | - | ||
| 486 | - msg->header.stream_id = context->edge_stream_id; | ||
| 487 | - if ((ret = context->edge_rtmp->send_message(msg)) != ERROR_SUCCESS) { | ||
| 488 | - srs_error("send origin message to client failed. ret=%d", ret); | ||
| 489 | - return ret; | ||
| 490 | - } | ||
| 491 | - | ||
| 492 | - return ret; | ||
| 493 | -} | ||
| 494 | - | ||
| 495 | -int SrsEdgeForwarder::proxy_edge_message(SrsEdgeProxyContext* context) | ||
| 496 | -{ | ||
| 497 | - int ret = ERROR_SUCCESS; | ||
| 498 | - | ||
| 499 | - SrsCommonMessage* msg = NULL; | ||
| 500 | - | ||
| 501 | - // proxy client message to origin | ||
| 502 | - ret = context->edge_rtmp->recv_message(&msg); | ||
| 503 | - if (ret != ERROR_SUCCESS && ret != ERROR_SOCKET_TIMEOUT) { | ||
| 504 | - srs_error("recv client message failed. ret=%d", ret); | ||
| 505 | return ret; | 392 | return ret; |
| 506 | } | 393 | } |
| 507 | 394 | ||
| 508 | - srs_assert(msg); | ||
| 509 | - | ||
| 510 | - if (msg->size <= 0 | ||
| 511 | - || msg->header.is_set_chunk_size() | ||
| 512 | - || msg->header.is_window_ackledgement_size() | ||
| 513 | - || msg->header.is_ackledgement() | ||
| 514 | - ) { | ||
| 515 | - srs_freep(msg); | 395 | + SrsSharedPtrMessage* copy = new SrsSharedPtrMessage(); |
| 396 | + SrsAutoFree(SrsSharedPtrMessage, copy, false); | ||
| 397 | + if ((ret = copy->initialize(msg)) != ERROR_SUCCESS) { | ||
| 398 | + srs_error("initialize the msg failed. ret=%d", ret); | ||
| 516 | return ret; | 399 | return ret; |
| 517 | } | 400 | } |
| 401 | + srs_verbose("initialize shared ptr msg success."); | ||
| 518 | 402 | ||
| 519 | - msg->header.stream_id = context->origin_stream_id; | ||
| 520 | - if ((ret = context->origin_rtmp->send_message(msg)) != ERROR_SUCCESS) { | 403 | + copy->header.stream_id = stream_id; |
| 404 | + if ((ret = client->send_message(copy->copy())) != ERROR_SUCCESS) { | ||
| 521 | srs_error("send client message to origin failed. ret=%d", ret); | 405 | srs_error("send client message to origin failed. ret=%d", ret); |
| 522 | return ret; | 406 | return ret; |
| 523 | } | 407 | } |
| @@ -730,13 +614,18 @@ int SrsPublishEdge::on_client_publish() | @@ -730,13 +614,18 @@ int SrsPublishEdge::on_client_publish() | ||
| 730 | return forwarder->start(); | 614 | return forwarder->start(); |
| 731 | } | 615 | } |
| 732 | 616 | ||
| 733 | -int SrsPublishEdge::on_proxy_publish(SrsEdgeProxyContext* context) | 617 | +int SrsPublishEdge::on_proxy_publish(SrsCommonMessage* msg) |
| 734 | { | 618 | { |
| 735 | - int ret = forwarder->proxy(context); | 619 | + return forwarder->proxy(msg); |
| 620 | +} | ||
| 621 | + | ||
| 622 | +void SrsPublishEdge::on_proxy_unpublish() | ||
| 623 | +{ | ||
| 624 | + if (state == SrsEdgeStatePublish) { | ||
| 625 | + forwarder->stop(); | ||
| 626 | + } | ||
| 736 | 627 | ||
| 737 | SrsEdgeState pstate = state; | 628 | SrsEdgeState pstate = state; |
| 738 | state = SrsEdgeStateInit; | 629 | state = SrsEdgeStateInit; |
| 739 | srs_trace("edge change from %d to state %d (init).", pstate, state); | 630 | srs_trace("edge change from %d to state %d (init).", pstate, state); |
| 740 | - | ||
| 741 | - return ret; | ||
| 742 | } | 631 | } |
| @@ -101,23 +101,6 @@ private: | @@ -101,23 +101,6 @@ private: | ||
| 101 | virtual int process_publish_message(SrsCommonMessage* msg); | 101 | virtual int process_publish_message(SrsCommonMessage* msg); |
| 102 | }; | 102 | }; |
| 103 | 103 | ||
| 104 | -class SrsEdgeProxyContext | ||
| 105 | -{ | ||
| 106 | -public: | ||
| 107 | - int edge_stream_id; | ||
| 108 | - st_netfd_t edge_stfd; | ||
| 109 | - ISrsProtocolReaderWriter* edge_io; | ||
| 110 | - SrsRtmpServer* edge_rtmp; | ||
| 111 | -public: | ||
| 112 | - int origin_stream_id; | ||
| 113 | - st_netfd_t origin_stfd; | ||
| 114 | - ISrsProtocolReaderWriter* origin_io; | ||
| 115 | - SrsRtmpClient* origin_rtmp; | ||
| 116 | -public: | ||
| 117 | - SrsEdgeProxyContext(); | ||
| 118 | - virtual ~SrsEdgeProxyContext(); | ||
| 119 | -}; | ||
| 120 | - | ||
| 121 | /** | 104 | /** |
| 122 | * edge used to forward stream to origin. | 105 | * edge used to forward stream to origin. |
| 123 | */ | 106 | */ |
| @@ -141,10 +124,8 @@ public: | @@ -141,10 +124,8 @@ public: | ||
| 141 | virtual int start(); | 124 | virtual int start(); |
| 142 | virtual void stop(); | 125 | virtual void stop(); |
| 143 | public: | 126 | public: |
| 144 | - virtual int proxy(SrsEdgeProxyContext* context); | 127 | + virtual int proxy(SrsCommonMessage* msg); |
| 145 | private: | 128 | private: |
| 146 | - virtual int proxy_origin_message(SrsEdgeProxyContext* context); | ||
| 147 | - virtual int proxy_edge_message(SrsEdgeProxyContext* context); | ||
| 148 | virtual void close_underlayer_socket(); | 129 | virtual void close_underlayer_socket(); |
| 149 | virtual int connect_server(); | 130 | virtual int connect_server(); |
| 150 | }; | 131 | }; |
| @@ -201,7 +182,11 @@ public: | @@ -201,7 +182,11 @@ public: | ||
| 201 | /** | 182 | /** |
| 202 | * proxy publish stream to edge | 183 | * proxy publish stream to edge |
| 203 | */ | 184 | */ |
| 204 | - virtual int on_proxy_publish(SrsEdgeProxyContext* context); | 185 | + virtual int on_proxy_publish(SrsCommonMessage* msg); |
| 186 | + /** | ||
| 187 | + * proxy unpublish stream to edge. | ||
| 188 | + */ | ||
| 189 | + virtual void on_proxy_unpublish(); | ||
| 205 | }; | 190 | }; |
| 206 | 191 | ||
| 207 | #endif | 192 | #endif |
| @@ -145,7 +145,7 @@ int SrsRtmpConn::do_cycle() | @@ -145,7 +145,7 @@ int SrsRtmpConn::do_cycle() | ||
| 145 | req->app.c_str()); | 145 | req->app.c_str()); |
| 146 | 146 | ||
| 147 | ret = service_cycle(); | 147 | ret = service_cycle(); |
| 148 | - on_close(); | 148 | + http_hooks_on_close(); |
| 149 | 149 | ||
| 150 | return ret; | 150 | return ret; |
| 151 | } | 151 | } |
| @@ -312,14 +312,14 @@ int SrsRtmpConn::stream_service_cycle() | @@ -312,14 +312,14 @@ int SrsRtmpConn::stream_service_cycle() | ||
| 312 | srs_error("start to play stream failed. ret=%d", ret); | 312 | srs_error("start to play stream failed. ret=%d", ret); |
| 313 | return ret; | 313 | return ret; |
| 314 | } | 314 | } |
| 315 | - if ((ret = on_play()) != ERROR_SUCCESS) { | 315 | + if ((ret = http_hooks_on_play()) != ERROR_SUCCESS) { |
| 316 | srs_error("http hook on_play failed. ret=%d", ret); | 316 | srs_error("http hook on_play failed. ret=%d", ret); |
| 317 | return ret; | 317 | return ret; |
| 318 | } | 318 | } |
| 319 | 319 | ||
| 320 | srs_info("start to play stream %s success", req->stream.c_str()); | 320 | srs_info("start to play stream %s success", req->stream.c_str()); |
| 321 | ret = playing(source); | 321 | ret = playing(source); |
| 322 | - on_stop(); | 322 | + http_hooks_on_stop(); |
| 323 | 323 | ||
| 324 | return ret; | 324 | return ret; |
| 325 | } | 325 | } |
| @@ -338,23 +338,23 @@ int SrsRtmpConn::stream_service_cycle() | @@ -338,23 +338,23 @@ int SrsRtmpConn::stream_service_cycle() | ||
| 338 | return ret; | 338 | return ret; |
| 339 | } | 339 | } |
| 340 | 340 | ||
| 341 | - SrsEdgeProxyContext context; | ||
| 342 | - context.edge_io = skt; | ||
| 343 | - context.edge_stream_id = res->stream_id; | ||
| 344 | - context.edge_rtmp = rtmp; | ||
| 345 | - context.edge_stfd = stfd; | ||
| 346 | - if (vhost_is_edge) { | ||
| 347 | - return source->on_edge_proxy_publish(&context); | ||
| 348 | - } | ||
| 349 | - | ||
| 350 | - if ((ret = on_publish()) != ERROR_SUCCESS) { | 341 | + if ((ret = http_hooks_on_publish()) != ERROR_SUCCESS) { |
| 351 | srs_error("http hook on_publish failed. ret=%d", ret); | 342 | srs_error("http hook on_publish failed. ret=%d", ret); |
| 352 | return ret; | 343 | return ret; |
| 353 | } | 344 | } |
| 345 | + | ||
| 354 | srs_info("start to publish stream %s success", req->stream.c_str()); | 346 | srs_info("start to publish stream %s success", req->stream.c_str()); |
| 355 | ret = fmle_publish(source); | 347 | ret = fmle_publish(source); |
| 356 | - source->on_unpublish(); | ||
| 357 | - on_unpublish(); | 348 | + |
| 349 | + // when edge, notice edge to change state. | ||
| 350 | + // when origin, notice all service to unpublish. | ||
| 351 | + if (vhost_is_edge) { | ||
| 352 | + source->on_edge_proxy_unpublish(); | ||
| 353 | + } else { | ||
| 354 | + source->on_unpublish(); | ||
| 355 | + } | ||
| 356 | + | ||
| 357 | + http_hooks_on_unpublish(); | ||
| 358 | return ret; | 358 | return ret; |
| 359 | } | 359 | } |
| 360 | case SrsRtmpConnFlashPublish: { | 360 | case SrsRtmpConnFlashPublish: { |
| @@ -372,23 +372,23 @@ int SrsRtmpConn::stream_service_cycle() | @@ -372,23 +372,23 @@ int SrsRtmpConn::stream_service_cycle() | ||
| 372 | return ret; | 372 | return ret; |
| 373 | } | 373 | } |
| 374 | 374 | ||
| 375 | - SrsEdgeProxyContext context; | ||
| 376 | - context.edge_io = skt; | ||
| 377 | - context.edge_stream_id = res->stream_id; | ||
| 378 | - context.edge_rtmp = rtmp; | ||
| 379 | - context.edge_stfd = stfd; | ||
| 380 | - if (vhost_is_edge) { | ||
| 381 | - return source->on_edge_proxy_publish(&context); | ||
| 382 | - } | ||
| 383 | - | ||
| 384 | - if ((ret = on_publish()) != ERROR_SUCCESS) { | 375 | + if ((ret = http_hooks_on_publish()) != ERROR_SUCCESS) { |
| 385 | srs_error("http hook on_publish failed. ret=%d", ret); | 376 | srs_error("http hook on_publish failed. ret=%d", ret); |
| 386 | return ret; | 377 | return ret; |
| 387 | } | 378 | } |
| 379 | + | ||
| 388 | srs_info("flash start to publish stream %s success", req->stream.c_str()); | 380 | srs_info("flash start to publish stream %s success", req->stream.c_str()); |
| 389 | ret = flash_publish(source); | 381 | ret = flash_publish(source); |
| 390 | - source->on_unpublish(); | ||
| 391 | - on_unpublish(); | 382 | + |
| 383 | + // when edge, notice edge to change state. | ||
| 384 | + // when origin, notice all service to unpublish. | ||
| 385 | + if (vhost_is_edge) { | ||
| 386 | + source->on_edge_proxy_unpublish(); | ||
| 387 | + } else { | ||
| 388 | + source->on_unpublish(); | ||
| 389 | + } | ||
| 390 | + | ||
| 391 | + http_hooks_on_unpublish(); | ||
| 392 | return ret; | 392 | return ret; |
| 393 | } | 393 | } |
| 394 | default: { | 394 | default: { |
| @@ -431,7 +431,7 @@ int SrsRtmpConn::check_vhost() | @@ -431,7 +431,7 @@ int SrsRtmpConn::check_vhost() | ||
| 431 | } | 431 | } |
| 432 | srs_verbose("check refer success."); | 432 | srs_verbose("check refer success."); |
| 433 | 433 | ||
| 434 | - if ((ret = on_connect()) != ERROR_SUCCESS) { | 434 | + if ((ret = http_hooks_on_connect()) != ERROR_SUCCESS) { |
| 435 | return ret; | 435 | return ret; |
| 436 | } | 436 | } |
| 437 | 437 | ||
| @@ -562,6 +562,8 @@ int SrsRtmpConn::fmle_publish(SrsSource* source) | @@ -562,6 +562,8 @@ int SrsRtmpConn::fmle_publish(SrsSource* source) | ||
| 562 | } | 562 | } |
| 563 | srs_verbose("fmle hls on_publish success."); | 563 | srs_verbose("fmle hls on_publish success."); |
| 564 | 564 | ||
| 565 | + bool vhost_is_edge = _srs_config->get_vhost_is_edge(req->vhost); | ||
| 566 | + | ||
| 565 | while (true) { | 567 | while (true) { |
| 566 | // switch to other st-threads. | 568 | // switch to other st-threads. |
| 567 | st_usleep(0); | 569 | st_usleep(0); |
| @@ -604,7 +606,7 @@ int SrsRtmpConn::fmle_publish(SrsSource* source) | @@ -604,7 +606,7 @@ int SrsRtmpConn::fmle_publish(SrsSource* source) | ||
| 604 | } | 606 | } |
| 605 | 607 | ||
| 606 | // video, audio, data message | 608 | // video, audio, data message |
| 607 | - if ((ret = process_publish_message(source, msg)) != ERROR_SUCCESS) { | 609 | + if ((ret = process_publish_message(source, msg, vhost_is_edge)) != ERROR_SUCCESS) { |
| 608 | srs_error("fmle process publish message failed. ret=%d", ret); | 610 | srs_error("fmle process publish message failed. ret=%d", ret); |
| 609 | return ret; | 611 | return ret; |
| 610 | } | 612 | } |
| @@ -632,6 +634,8 @@ int SrsRtmpConn::flash_publish(SrsSource* source) | @@ -632,6 +634,8 @@ int SrsRtmpConn::flash_publish(SrsSource* source) | ||
| 632 | } | 634 | } |
| 633 | srs_verbose("flash hls on_publish success."); | 635 | srs_verbose("flash hls on_publish success."); |
| 634 | 636 | ||
| 637 | + bool vhost_is_edge = _srs_config->get_vhost_is_edge(req->vhost); | ||
| 638 | + | ||
| 635 | while (true) { | 639 | while (true) { |
| 636 | // switch to other st-threads. | 640 | // switch to other st-threads. |
| 637 | st_usleep(0); | 641 | st_usleep(0); |
| @@ -668,7 +672,7 @@ int SrsRtmpConn::flash_publish(SrsSource* source) | @@ -668,7 +672,7 @@ int SrsRtmpConn::flash_publish(SrsSource* source) | ||
| 668 | } | 672 | } |
| 669 | 673 | ||
| 670 | // video, audio, data message | 674 | // video, audio, data message |
| 671 | - if ((ret = process_publish_message(source, msg)) != ERROR_SUCCESS) { | 675 | + if ((ret = process_publish_message(source, msg, vhost_is_edge)) != ERROR_SUCCESS) { |
| 672 | srs_error("flash process publish message failed. ret=%d", ret); | 676 | srs_error("flash process publish message failed. ret=%d", ret); |
| 673 | return ret; | 677 | return ret; |
| 674 | } | 678 | } |
| @@ -677,10 +681,15 @@ int SrsRtmpConn::flash_publish(SrsSource* source) | @@ -677,10 +681,15 @@ int SrsRtmpConn::flash_publish(SrsSource* source) | ||
| 677 | return ret; | 681 | return ret; |
| 678 | } | 682 | } |
| 679 | 683 | ||
| 680 | -int SrsRtmpConn::process_publish_message(SrsSource* source, SrsCommonMessage* msg) | 684 | +int SrsRtmpConn::process_publish_message(SrsSource* source, SrsCommonMessage* msg, bool vhost_is_edge) |
| 681 | { | 685 | { |
| 682 | int ret = ERROR_SUCCESS; | 686 | int ret = ERROR_SUCCESS; |
| 683 | 687 | ||
| 688 | + // for edge, directly proxy message to origin. | ||
| 689 | + if (vhost_is_edge) { | ||
| 690 | + return source->on_edge_proxy_publish(msg); | ||
| 691 | + } | ||
| 692 | + | ||
| 684 | // process audio packet | 693 | // process audio packet |
| 685 | if (msg->header.is_audio()) { | 694 | if (msg->header.is_audio()) { |
| 686 | if ((ret = source->on_audio(msg)) != ERROR_SUCCESS) { | 695 | if ((ret = source->on_audio(msg)) != ERROR_SUCCESS) { |
| @@ -771,7 +780,7 @@ int SrsRtmpConn::process_play_control_msg(SrsConsumer* consumer, SrsCommonMessag | @@ -771,7 +780,7 @@ int SrsRtmpConn::process_play_control_msg(SrsConsumer* consumer, SrsCommonMessag | ||
| 771 | return ret; | 780 | return ret; |
| 772 | } | 781 | } |
| 773 | 782 | ||
| 774 | -int SrsRtmpConn::on_connect() | 783 | +int SrsRtmpConn::http_hooks_on_connect() |
| 775 | { | 784 | { |
| 776 | int ret = ERROR_SUCCESS; | 785 | int ret = ERROR_SUCCESS; |
| 777 | 786 | ||
| @@ -795,7 +804,7 @@ int SrsRtmpConn::on_connect() | @@ -795,7 +804,7 @@ int SrsRtmpConn::on_connect() | ||
| 795 | return ret; | 804 | return ret; |
| 796 | } | 805 | } |
| 797 | 806 | ||
| 798 | -void SrsRtmpConn::on_close() | 807 | +void SrsRtmpConn::http_hooks_on_close() |
| 799 | { | 808 | { |
| 800 | #ifdef SRS_AUTO_HTTP_CALLBACK | 809 | #ifdef SRS_AUTO_HTTP_CALLBACK |
| 801 | // whatever the ret code, notify the api hooks. | 810 | // whatever the ret code, notify the api hooks. |
| @@ -813,7 +822,7 @@ void SrsRtmpConn::on_close() | @@ -813,7 +822,7 @@ void SrsRtmpConn::on_close() | ||
| 813 | #endif | 822 | #endif |
| 814 | } | 823 | } |
| 815 | 824 | ||
| 816 | -int SrsRtmpConn::on_publish() | 825 | +int SrsRtmpConn::http_hooks_on_publish() |
| 817 | { | 826 | { |
| 818 | int ret = ERROR_SUCCESS; | 827 | int ret = ERROR_SUCCESS; |
| 819 | 828 | ||
| @@ -837,7 +846,7 @@ int SrsRtmpConn::on_publish() | @@ -837,7 +846,7 @@ int SrsRtmpConn::on_publish() | ||
| 837 | return ret; | 846 | return ret; |
| 838 | } | 847 | } |
| 839 | 848 | ||
| 840 | -void SrsRtmpConn::on_unpublish() | 849 | +void SrsRtmpConn::http_hooks_on_unpublish() |
| 841 | { | 850 | { |
| 842 | #ifdef SRS_AUTO_HTTP_CALLBACK | 851 | #ifdef SRS_AUTO_HTTP_CALLBACK |
| 843 | // whatever the ret code, notify the api hooks. | 852 | // whatever the ret code, notify the api hooks. |
| @@ -855,7 +864,7 @@ void SrsRtmpConn::on_unpublish() | @@ -855,7 +864,7 @@ void SrsRtmpConn::on_unpublish() | ||
| 855 | #endif | 864 | #endif |
| 856 | } | 865 | } |
| 857 | 866 | ||
| 858 | -int SrsRtmpConn::on_play() | 867 | +int SrsRtmpConn::http_hooks_on_play() |
| 859 | { | 868 | { |
| 860 | int ret = ERROR_SUCCESS; | 869 | int ret = ERROR_SUCCESS; |
| 861 | 870 | ||
| @@ -879,7 +888,7 @@ int SrsRtmpConn::on_play() | @@ -879,7 +888,7 @@ int SrsRtmpConn::on_play() | ||
| 879 | return ret; | 888 | return ret; |
| 880 | } | 889 | } |
| 881 | 890 | ||
| 882 | -void SrsRtmpConn::on_stop() | 891 | +void SrsRtmpConn::http_hooks_on_stop() |
| 883 | { | 892 | { |
| 884 | #ifdef SRS_AUTO_HTTP_CALLBACK | 893 | #ifdef SRS_AUTO_HTTP_CALLBACK |
| 885 | // whatever the ret code, notify the api hooks. | 894 | // whatever the ret code, notify the api hooks. |
| @@ -80,15 +80,15 @@ private: | @@ -80,15 +80,15 @@ private: | ||
| 80 | virtual int playing(SrsSource* source); | 80 | virtual int playing(SrsSource* source); |
| 81 | virtual int fmle_publish(SrsSource* source); | 81 | virtual int fmle_publish(SrsSource* source); |
| 82 | virtual int flash_publish(SrsSource* source); | 82 | virtual int flash_publish(SrsSource* source); |
| 83 | - virtual int process_publish_message(SrsSource* source, SrsCommonMessage* msg); | 83 | + virtual int process_publish_message(SrsSource* source, SrsCommonMessage* msg, bool vhost_is_edge); |
| 84 | virtual int process_play_control_msg(SrsConsumer* consumer, SrsCommonMessage* msg); | 84 | virtual int process_play_control_msg(SrsConsumer* consumer, SrsCommonMessage* msg); |
| 85 | private: | 85 | private: |
| 86 | - virtual int on_connect(); | ||
| 87 | - virtual void on_close(); | ||
| 88 | - virtual int on_publish(); | ||
| 89 | - virtual void on_unpublish(); | ||
| 90 | - virtual int on_play(); | ||
| 91 | - virtual void on_stop(); | 86 | + virtual int http_hooks_on_connect(); |
| 87 | + virtual void http_hooks_on_close(); | ||
| 88 | + virtual int http_hooks_on_publish(); | ||
| 89 | + virtual void http_hooks_on_unpublish(); | ||
| 90 | + virtual int http_hooks_on_play(); | ||
| 91 | + virtual void http_hooks_on_stop(); | ||
| 92 | }; | 92 | }; |
| 93 | 93 | ||
| 94 | #endif | 94 | #endif |
| @@ -1199,9 +1199,14 @@ int SrsSource::on_edge_start_publish() | @@ -1199,9 +1199,14 @@ int SrsSource::on_edge_start_publish() | ||
| 1199 | return publish_edge->on_client_publish(); | 1199 | return publish_edge->on_client_publish(); |
| 1200 | } | 1200 | } |
| 1201 | 1201 | ||
| 1202 | -int SrsSource::on_edge_proxy_publish(SrsEdgeProxyContext* context) | 1202 | +int SrsSource::on_edge_proxy_publish(SrsCommonMessage* msg) |
| 1203 | { | 1203 | { |
| 1204 | - return publish_edge->on_proxy_publish(context); | 1204 | + return publish_edge->on_proxy_publish(msg); |
| 1205 | +} | ||
| 1206 | + | ||
| 1207 | +void SrsSource::on_edge_proxy_unpublish() | ||
| 1208 | +{ | ||
| 1209 | + publish_edge->on_proxy_unpublish(); | ||
| 1205 | } | 1210 | } |
| 1206 | 1211 | ||
| 1207 | int SrsSource::create_forwarders() | 1212 | int SrsSource::create_forwarders() |
| @@ -322,7 +322,9 @@ public: | @@ -322,7 +322,9 @@ public: | ||
| 322 | // for edge, when publish edge stream, check the state | 322 | // for edge, when publish edge stream, check the state |
| 323 | virtual int on_edge_start_publish(); | 323 | virtual int on_edge_start_publish(); |
| 324 | // for edge, proxy the publish | 324 | // for edge, proxy the publish |
| 325 | - virtual int on_edge_proxy_publish(SrsEdgeProxyContext* context); | 325 | + virtual int on_edge_proxy_publish(SrsCommonMessage* msg); |
| 326 | + // for edge, proxy stop publish | ||
| 327 | + virtual void on_edge_proxy_unpublish(); | ||
| 326 | private: | 328 | private: |
| 327 | virtual int create_forwarders(); | 329 | virtual int create_forwarders(); |
| 328 | virtual void destroy_forwarders(); | 330 | virtual void destroy_forwarders(); |
-
请 注册 或 登录 后发表评论