From e9832ac723c8d6681707639dd074ea4eb568974c Mon Sep 17 00:00:00 2001 From: Thulinma Date: Mon, 3 Feb 2020 16:34:05 +0100 Subject: [PATCH] Added stats entry for RTSP pull input --- src/input/input_rtsp.cpp | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/src/input/input_rtsp.cpp b/src/input/input_rtsp.cpp index c0b338bb..23964e06 100755 --- a/src/input/input_rtsp.cpp +++ b/src/input/input_rtsp.cpp @@ -180,16 +180,44 @@ namespace Mist{ } std::string InputRTSP::streamMainLoop(){ + IPC::sharedClient statsPage = IPC::sharedClient(SHM_STATISTICS, STAT_EX_SIZE, true); + uint64_t startTime = Util::epoch(); uint64_t lastPing = Util::bootSecs(); + uint64_t lastSecs = 0; while (config->is_active && nProxy.userClient.isAlive() && parsePacket()){ handleUDP(); // keep going nProxy.userClient.keepAlive(); - if (Util::bootSecs() - lastPing > 30){ + uint64_t currSecs = Util::bootSecs(); + if (currSecs - lastPing > 30){ sendCommand("GET_PARAMETER", url.getUrl(), ""); lastPing = Util::bootSecs(); } + if (lastSecs != currSecs){ + if (!statsPage.getData()){ + statsPage = IPC::sharedClient(SHM_STATISTICS, STAT_EX_SIZE, true); + } + if (statsPage.getData()){ + if (!statsPage.isAlive()){ + config->is_active = false; + statsPage.finish(); + return "received shutdown request from controller"; + } + uint64_t now = Util::epoch(); + IPC::statExchange tmpEx(statsPage.getData()); + tmpEx.now(now); + tmpEx.crc(getpid()); + tmpEx.streamName(streamName); + tmpEx.connector("INPUT"); + tmpEx.up(tcpCon.dataUp()); + tmpEx.down(tcpCon.dataDown()); + tmpEx.time(now - startTime); + tmpEx.lastSecond(0); + statsPage.keepAlive(); + } + } } + statsPage.finish(); if (!tcpCon){return "TCP connection closed";} if (!config->is_active){return "received deactivate signal";} if (!nProxy.userClient.isAlive()){return "buffer shutdown";}