From 216b3bf41476d03e50b67b09716faa0cc45da979 Mon Sep 17 00:00:00 2001 From: winlin Date: Mon, 13 Apr 2020 09:32:48 +0800 Subject: [PATCH] Create isolate pithy printer for each RTC FD --- trunk/src/app/srs_app_listener.cpp | 2 +- trunk/src/app/srs_app_pithy_print.cpp | 8 ++++---- trunk/src/app/srs_app_pithy_print.hpp | 5 +++-- trunk/src/app/srs_app_rtc_conn.cpp | 2 +- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/trunk/src/app/srs_app_listener.cpp b/trunk/src/app/srs_app_listener.cpp index 3187a3569..2117983be 100755 --- a/trunk/src/app/srs_app_listener.cpp +++ b/trunk/src/app/srs_app_listener.cpp @@ -444,7 +444,7 @@ srs_error_t SrsUdpMuxListener::cycle() { srs_error_t err = srs_success; - SrsPithyPrint* pprint = SrsPithyPrint::create_rtc_recv(); + SrsPithyPrint* pprint = SrsPithyPrint::create_rtc_recv(srs_netfd_fileno(lfd)); SrsAutoFree(SrsPithyPrint, pprint); uint64_t nn_msgs = 0; diff --git a/trunk/src/app/srs_app_pithy_print.cpp b/trunk/src/app/srs_app_pithy_print.cpp index 84c3c854d..58f8bca4a 100644 --- a/trunk/src/app/srs_app_pithy_print.cpp +++ b/trunk/src/app/srs_app_pithy_print.cpp @@ -177,14 +177,14 @@ SrsPithyPrint* SrsPithyPrint::create_rtc_play() return new SrsPithyPrint(SRS_CONSTS_STAGE_RTC_PLAY); } -SrsPithyPrint* SrsPithyPrint::create_rtc_send() +SrsPithyPrint* SrsPithyPrint::create_rtc_send(int fd) { - return new SrsPithyPrint(SRS_CONSTS_STAGE_RTC_SEND); + return new SrsPithyPrint(fd<<16 | SRS_CONSTS_STAGE_RTC_SEND); } -SrsPithyPrint* SrsPithyPrint::create_rtc_recv() +SrsPithyPrint* SrsPithyPrint::create_rtc_recv(int fd) { - return new SrsPithyPrint(SRS_CONSTS_STAGE_RTC_RECV); + return new SrsPithyPrint(fd<<16 | SRS_CONSTS_STAGE_RTC_RECV); } SrsPithyPrint::~SrsPithyPrint() diff --git a/trunk/src/app/srs_app_pithy_print.hpp b/trunk/src/app/srs_app_pithy_print.hpp index 4518b7a7c..ab289e0e7 100644 --- a/trunk/src/app/srs_app_pithy_print.hpp +++ b/trunk/src/app/srs_app_pithy_print.hpp @@ -88,8 +88,9 @@ public: static SrsPithyPrint* create_http_stream(); static SrsPithyPrint* create_http_stream_cache(); static SrsPithyPrint* create_rtc_play(); - static SrsPithyPrint* create_rtc_send(); - static SrsPithyPrint* create_rtc_recv(); + // For RTC sender and receiver, we create printer for each fd. + static SrsPithyPrint* create_rtc_send(int fd); + static SrsPithyPrint* create_rtc_recv(int fd); virtual ~SrsPithyPrint(); private: // Enter the specified stage, return the client id. diff --git a/trunk/src/app/srs_app_rtc_conn.cpp b/trunk/src/app/srs_app_rtc_conn.cpp index c7c03cfd8..757d6b8a7 100644 --- a/trunk/src/app/srs_app_rtc_conn.cpp +++ b/trunk/src/app/srs_app_rtc_conn.cpp @@ -1439,7 +1439,7 @@ srs_error_t SrsUdpMuxSender::cycle() srs_utime_t time_last = srs_get_system_time(); SrsStatistic* stat = SrsStatistic::instance(); - SrsPithyPrint* pprint = SrsPithyPrint::create_rtc_send(); + SrsPithyPrint* pprint = SrsPithyPrint::create_rtc_send(srs_netfd_fileno(lfd)); SrsAutoFree(SrsPithyPrint, pprint); while (true) {