From 373620cfc6289d504bcf5a01cef62a5f3abda0be Mon Sep 17 00:00:00 2001 From: KkemChen Date: Thu, 23 May 2024 10:30:11 +0800 Subject: [PATCH 1/5] feat: add broadcast event for player count change (#3562) --- conf/config.ini | 2 ++ src/Common/MediaSource.cpp | 4 ++++ src/Common/config.cpp | 3 +++ src/Common/config.h | 6 ++++++ 4 files changed, 15 insertions(+) diff --git a/conf/config.ini b/conf/config.ini index 89800db2..95d3fa37 100644 --- a/conf/config.ini +++ b/conf/config.ini @@ -126,6 +126,8 @@ wait_track_ready_ms=10000 wait_add_track_ms=3000 #如果track未就绪,我们先缓存帧数据,但是有最大个数限制,防止内存溢出 unready_frame_cache=100 +#是否启用观看人数变化事件广播,置1则启用,置0则关闭 +broadcast_player_count_changed=0 [hls] #hls写文件的buf大小,调整参数可以提高文件io性能 diff --git a/src/Common/MediaSource.cpp b/src/Common/MediaSource.cpp index 8de8202a..039b156a 100644 --- a/src/Common/MediaSource.cpp +++ b/src/Common/MediaSource.cpp @@ -652,6 +652,10 @@ MediaSource::Ptr MediaSource::createFromMP4(const string &schema, const string & /////////////////////////////////////MediaSourceEvent////////////////////////////////////// void MediaSourceEvent::onReaderChanged(MediaSource &sender, int size){ + GET_CONFIG(bool, enable, General::kBroadcastPlayerCountChanged); + if (enable) { + NOTICE_EMIT(BroadcastPlayerCountChangedArgs, Broadcast::kBroadcastPlayerCountChanged, sender.getMediaTuple(), sender.totalReaderCount()); + } if (size || sender.totalReaderCount()) { //还有人观看该视频,不触发关闭事件 _async_close_timer = nullptr; diff --git a/src/Common/config.cpp b/src/Common/config.cpp index 8b7031ae..f2ec0354 100644 --- a/src/Common/config.cpp +++ b/src/Common/config.cpp @@ -64,6 +64,7 @@ const string kBroadcastRtcSctpFailed = "kBroadcastRtcSctpFailed"; const string kBroadcastRtcSctpClosed = "kBroadcastRtcSctpClosed"; const string kBroadcastRtcSctpSend = "kBroadcastRtcSctpSend"; const string kBroadcastRtcSctpReceived = "kBroadcastRtcSctpReceived"; +const string kBroadcastPlayerCountChanged = "kBroadcastPlayerCountChanged"; } // namespace Broadcast @@ -82,6 +83,7 @@ const string kEnableFFmpegLog = GENERAL_FIELD "enable_ffmpeg_log"; const string kWaitTrackReadyMS = GENERAL_FIELD "wait_track_ready_ms"; const string kWaitAddTrackMS = GENERAL_FIELD "wait_add_track_ms"; const string kUnreadyFrameCache = GENERAL_FIELD "unready_frame_cache"; +const string kBroadcastPlayerCountChanged = GENERAL_FIELD "broadcast_player_count_changed"; static onceToken token([]() { mINI::Instance()[kFlowThreshold] = 1024; @@ -96,6 +98,7 @@ static onceToken token([]() { mINI::Instance()[kWaitTrackReadyMS] = 10000; mINI::Instance()[kWaitAddTrackMS] = 3000; mINI::Instance()[kUnreadyFrameCache] = 100; + mINI::Instance()[kBroadcastPlayerCountChanged] = 0; }); } // namespace General diff --git a/src/Common/config.h b/src/Common/config.h index b10fe685..4b6423a5 100644 --- a/src/Common/config.h +++ b/src/Common/config.h @@ -124,6 +124,10 @@ extern const std::string kBroadcastRtcSctpSend; extern const std::string kBroadcastRtcSctpReceived; #define BroadcastRtcSctpReceivedArgs WebRtcTransport& sender, uint16_t &streamId, uint32_t &ppid, const uint8_t *&msg, size_t &len +// 观看人数变化广播 +extern const std::string kBroadcastPlayerCountChanged; +#define BroadcastPlayerCountChangedArgs const MediaTuple& args, const int& count + #define ReloadConfigTag ((void *)(0xFF)) #define RELOAD_KEY(arg, key) \ do { \ @@ -196,6 +200,8 @@ extern const std::string kWaitTrackReadyMS; extern const std::string kWaitAddTrackMS; // 如果track未就绪,我们先缓存帧数据,但是有最大个数限制(100帧时大约4秒),防止内存溢出 extern const std::string kUnreadyFrameCache; +// 是否启用观看人数变化事件广播,置1则启用,置0则关闭 +extern const std::string kBroadcastPlayerCountChanged; } // namespace General namespace Protocol { From f83e287c774398bda3bb0b7bdc7f46d70b4f4401 Mon Sep 17 00:00:00 2001 From: waken <33921191+mc373906408@users.noreply.github.com> Date: Thu, 23 May 2024 17:36:56 +0800 Subject: [PATCH 2/5] =?UTF-8?q?=E4=BF=AE=E5=A4=8DC++17=E6=96=B0=E5=BA=93st?= =?UTF-8?q?d::variant=E5=AF=BC=E8=87=B4=E7=9A=84=E7=BC=96=E8=AF=91?= =?UTF-8?q?=E5=87=BA=E9=94=99=20(#3567)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/WebApi.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/WebApi.cpp b/server/WebApi.cpp index 988b55b5..be1f7a96 100755 --- a/server/WebApi.cpp +++ b/server/WebApi.cpp @@ -1766,7 +1766,7 @@ void installWebApi() { , _session_id(std::move(session_id)) {} ~WebRtcArgsImp() override = default; - variant operator[](const string &key) const override { + toolkit::variant operator[](const string &key) const override { if (key == "url") { return getUrl(); } From 12b71ca41d93a70c80c6b0975a44ae19df7468e1 Mon Sep 17 00:00:00 2001 From: xiongziliang <771730766@qq.com> Date: Sat, 25 May 2024 20:44:58 +0800 Subject: [PATCH 3/5] Update zltoolkit --- 3rdpart/ZLToolKit | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/3rdpart/ZLToolKit b/3rdpart/ZLToolKit index 26d54bbc..1e1a9907 160000 --- a/3rdpart/ZLToolKit +++ b/3rdpart/ZLToolKit @@ -1 +1 @@ -Subproject commit 26d54bbc7b1860a450434dce49bbc8fcbcbae88b +Subproject commit 1e1a990783c6c09452419c0aaa6d72ce02d0202b From 942458480dcffa922b5cf872809f320ed7a6a5cb Mon Sep 17 00:00:00 2001 From: xiongziliang <771730766@qq.com> Date: Sat, 25 May 2024 21:16:57 +0800 Subject: [PATCH 4/5] Demangle backtrace function binary symbols when generated crash logs --- server/System.cpp | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/server/System.cpp b/server/System.cpp index 77578924..1e2c8f57 100644 --- a/server/System.cpp +++ b/server/System.cpp @@ -22,11 +22,12 @@ #include #include -#include "Common/JemallocUtil.h" -#include "Common/macros.h" #include "System.h" +#include "Util/util.h" #include "Util/logger.h" #include "Util/uv_errno.h" +#include "Common/macros.h" +#include "Common/JemallocUtil.h" using namespace std; using namespace toolkit; @@ -66,6 +67,16 @@ static void save_jemalloc_stats() { out.flush(); } +static std::string get_func_symbol(const std::string &symbol) { + size_t pos1 = symbol.find("("); + if (pos1 == string::npos) { + return ""; + } + size_t pos2 = symbol.find("+", pos1); + auto ret = symbol.substr(pos1 + 1, pos2 - pos1 - 1); + return ret; +} + static void sig_crash(int sig) { signal(sig, SIG_DFL); void *array[MAX_STACK_FRAMES]; @@ -78,6 +89,10 @@ static void sig_crash(int sig) { std::string symbol(strings[i]); ref.emplace_back(symbol); #if defined(__linux) || defined(__linux__) + auto func_symbol = get_func_symbol(symbol); + if (!func_symbol.empty()) { + ref.emplace_back(toolkit::demangle(func_symbol.data())); + } static auto addr2line = [](const string &address) { string cmd = StrPrinter << "addr2line -C -f -e " << exePath() << " " << address; return System::execute(cmd); From 3a50c6e06d3a042f88bb843ec4f40f159c52b1ad Mon Sep 17 00:00:00 2001 From: xiongziliang <771730766@qq.com> Date: Sat, 25 May 2024 21:50:25 +0800 Subject: [PATCH 5/5] =?UTF-8?q?=E9=87=8D=E6=96=B0=E6=95=B4=E7=90=86issue?= =?UTF-8?q?=E6=A8=A1=E6=9D=BF=E8=A7=84=E8=8C=83=E8=A6=81=E6=B1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/ISSUE_TEMPLATE/bug.md | 24 +++++++++---- .github/ISSUE_TEMPLATE/compile.md | 4 +-- .github/ISSUE_TEMPLATE/config.yml | 6 ++++ .github/ISSUE_TEMPLATE/feature.md | 6 ++-- .github/ISSUE_TEMPLATE/question.md | 19 ---------- .github/ISSUE_TEMPLATE/requirement.md | 8 ----- .github/workflows/issue_lint.yml | 51 +++++++++++++++++++++++++++ 7 files changed, 79 insertions(+), 39 deletions(-) create mode 100644 .github/ISSUE_TEMPLATE/config.yml delete mode 100644 .github/ISSUE_TEMPLATE/question.md delete mode 100644 .github/ISSUE_TEMPLATE/requirement.md create mode 100644 .github/workflows/issue_lint.yml diff --git a/.github/ISSUE_TEMPLATE/bug.md b/.github/ISSUE_TEMPLATE/bug.md index c57d7a3e..62321514 100644 --- a/.github/ISSUE_TEMPLATE/bug.md +++ b/.github/ISSUE_TEMPLATE/bug.md @@ -20,14 +20,14 @@ assignees: '' * https://docs.github.com/en/get-started/writing-on-github/getting-started-with-writing-and-formatting-on-github/basic-writing-and-formatting-syntax --> -### 现象描述 +## 现象描述 -### 如何复现? +## 如何复现? -### 相关日志或截图 +## 相关日志或截图 -### 相关日志及环境信息 +## 相关日志及环境信息