fix bug
某种情况下,当客户端全部断开后,边缘服务器回源线程(EdgeIngester/EdgeForwarder)没有被断开。
正在显示
1 个修改的文件
包含
14 行增加
和
22 行删除
trunk/src/app/srs_app_rtmp_conn.cpp
100644 → 100755
@@ -455,14 +455,6 @@ int SrsRtmpConn::stream_service_cycle() | @@ -455,14 +455,6 @@ int SrsRtmpConn::stream_service_cycle() | ||
455 | case SrsRtmpConnPlay: { | 455 | case SrsRtmpConnPlay: { |
456 | srs_verbose("start to play stream %s.", req->stream.c_str()); | 456 | srs_verbose("start to play stream %s.", req->stream.c_str()); |
457 | 457 | ||
458 | - if (vhost_is_edge) { | ||
459 | - // notice edge to start for the first client. | ||
460 | - if ((ret = source->on_edge_start_play()) != ERROR_SUCCESS) { | ||
461 | - srs_error("notice edge start play stream failed. ret=%d", ret); | ||
462 | - return ret; | ||
463 | - } | ||
464 | - } | ||
465 | - | ||
466 | // response connection start play | 458 | // response connection start play |
467 | if ((ret = rtmp->start_play(res->stream_id)) != ERROR_SUCCESS) { | 459 | if ((ret = rtmp->start_play(res->stream_id)) != ERROR_SUCCESS) { |
468 | srs_error("start to play stream failed. ret=%d", ret); | 460 | srs_error("start to play stream failed. ret=%d", ret); |
@@ -482,13 +474,6 @@ int SrsRtmpConn::stream_service_cycle() | @@ -482,13 +474,6 @@ int SrsRtmpConn::stream_service_cycle() | ||
482 | case SrsRtmpConnFMLEPublish: { | 474 | case SrsRtmpConnFMLEPublish: { |
483 | srs_verbose("FMLE start to publish stream %s.", req->stream.c_str()); | 475 | srs_verbose("FMLE start to publish stream %s.", req->stream.c_str()); |
484 | 476 | ||
485 | - if (vhost_is_edge) { | ||
486 | - if ((ret = source->on_edge_start_publish()) != ERROR_SUCCESS) { | ||
487 | - srs_error("notice edge start publish stream failed. ret=%d", ret); | ||
488 | - return ret; | ||
489 | - } | ||
490 | - } | ||
491 | - | ||
492 | if ((ret = rtmp->start_fmle_publish(res->stream_id)) != ERROR_SUCCESS) { | 477 | if ((ret = rtmp->start_fmle_publish(res->stream_id)) != ERROR_SUCCESS) { |
493 | srs_error("start to publish stream failed. ret=%d", ret); | 478 | srs_error("start to publish stream failed. ret=%d", ret); |
494 | return ret; | 479 | return ret; |
@@ -511,13 +496,6 @@ int SrsRtmpConn::stream_service_cycle() | @@ -511,13 +496,6 @@ int SrsRtmpConn::stream_service_cycle() | ||
511 | case SrsRtmpConnFlashPublish: { | 496 | case SrsRtmpConnFlashPublish: { |
512 | srs_verbose("flash start to publish stream %s.", req->stream.c_str()); | 497 | srs_verbose("flash start to publish stream %s.", req->stream.c_str()); |
513 | 498 | ||
514 | - if (vhost_is_edge) { | ||
515 | - if ((ret = source->on_edge_start_publish()) != ERROR_SUCCESS) { | ||
516 | - srs_error("notice edge start publish stream failed. ret=%d", ret); | ||
517 | - return ret; | ||
518 | - } | ||
519 | - } | ||
520 | - | ||
521 | if ((ret = rtmp->start_flash_publish(res->stream_id)) != ERROR_SUCCESS) { | 499 | if ((ret = rtmp->start_flash_publish(res->stream_id)) != ERROR_SUCCESS) { |
522 | srs_error("flash start to publish stream failed. ret=%d", ret); | 500 | srs_error("flash start to publish stream failed. ret=%d", ret); |
523 | return ret; | 501 | return ret; |
@@ -597,6 +575,14 @@ int SrsRtmpConn::playing(SrsSource* source) | @@ -597,6 +575,14 @@ int SrsRtmpConn::playing(SrsSource* source) | ||
597 | SrsAutoFree(SrsConsumer, consumer); | 575 | SrsAutoFree(SrsConsumer, consumer); |
598 | srs_verbose("consumer created success."); | 576 | srs_verbose("consumer created success."); |
599 | 577 | ||
578 | + if (_srs_config->get_vhost_is_edge(req->vhost)) { | ||
579 | + // notice edge to start for the first client. | ||
580 | + if ((ret = source->on_edge_start_play()) != ERROR_SUCCESS) { | ||
581 | + srs_error("notice edge start play stream failed. ret=%d", ret); | ||
582 | + return ret; | ||
583 | + } | ||
584 | + } | ||
585 | + | ||
600 | // use isolate thread to recv, | 586 | // use isolate thread to recv, |
601 | // @see: https://github.com/simple-rtmp-server/srs/issues/217 | 587 | // @see: https://github.com/simple-rtmp-server/srs/issues/217 |
602 | SrsQueueRecvThread trd(consumer, rtmp, SRS_PERF_MW_SLEEP); | 588 | SrsQueueRecvThread trd(consumer, rtmp, SRS_PERF_MW_SLEEP); |
@@ -875,6 +861,12 @@ int SrsRtmpConn::do_publishing(SrsSource* source, SrsPublishRecvThread* trd) | @@ -875,6 +861,12 @@ int SrsRtmpConn::do_publishing(SrsSource* source, SrsPublishRecvThread* trd) | ||
875 | } | 861 | } |
876 | srs_verbose("hls on_publish success."); | 862 | srs_verbose("hls on_publish success."); |
877 | } | 863 | } |
864 | + else { | ||
865 | + if ((ret = source->on_edge_start_publish()) != ERROR_SUCCESS) { | ||
866 | + srs_error("notice edge start publish stream failed. ret=%d", ret); | ||
867 | + return ret; | ||
868 | + } | ||
869 | + } | ||
878 | 870 | ||
879 | // start isolate recv thread. | 871 | // start isolate recv thread. |
880 | if ((ret = trd->start()) != ERROR_SUCCESS) { | 872 | if ((ret = trd->start()) != ERROR_SUCCESS) { |
-
请 注册 或 登录 后发表评论