allow the user to adjust the frame timeout length when using frame timing at the bridge; ensure audio frames aren't greater then x2 the size of an expected audio frame;

r05a04_dev
Bryan Biedenkapp 4 days ago
parent 78cb47dce1
commit a5c0fbad58

@ -99,6 +99,8 @@ network:
# (This allows the sending source to send audio as fast as it wants. This should not be used in combination # (This allows the sending source to send audio as fast as it wants. This should not be used in combination
# with 'udpRTPFrames'.) # with 'udpRTPFrames'.)
udpFrameTiming: false udpFrameTiming: false
# Amount of time (ms) to wait for UDP audio frames before missing a audio frame.
udpFrameTimeout: 40
# #
# Traffic Encryption Key (TEK) Configuration # Traffic Encryption Key (TEK) Configuration

@ -173,6 +173,7 @@ HostBridge::HostBridge(const std::string& confFile) :
m_udpUseULaw(false), m_udpUseULaw(false),
m_udpUsrp(false), m_udpUsrp(false),
m_udpFrameTiming(false), m_udpFrameTiming(false),
m_udpFrameTimeout(40U),
m_udpFrameCnt(0U), m_udpFrameCnt(0U),
m_tekAlgoId(P25DEF::ALGO_UNENCRYPT), m_tekAlgoId(P25DEF::ALGO_UNENCRYPT),
m_tekKeyId(0U), m_tekKeyId(0U),
@ -1041,6 +1042,7 @@ bool HostBridge::createNetwork()
m_udpReceiveAddress = networkConf["udpReceiveAddress"].as<std::string>(); m_udpReceiveAddress = networkConf["udpReceiveAddress"].as<std::string>();
m_udpUsrp = networkConf["udpUsrp"].as<bool>(false); m_udpUsrp = networkConf["udpUsrp"].as<bool>(false);
m_udpFrameTiming = networkConf["udpFrameTiming"].as<bool>(false); m_udpFrameTiming = networkConf["udpFrameTiming"].as<bool>(false);
m_udpFrameTimeout = (uint16_t)networkConf["udpFrameTimeout"].as<uint32_t>(40U);
if (m_udpUsrp) { if (m_udpUsrp) {
m_udpMetadata = false; // USRP disables metadata due to USRP always having metadata m_udpMetadata = false; // USRP disables metadata due to USRP always having metadata
@ -1209,6 +1211,9 @@ bool HostBridge::createNetwork()
} }
LogInfo(" UDP Audio USRP: %s", m_udpUsrp ? "yes" : "no"); LogInfo(" UDP Audio USRP: %s", m_udpUsrp ? "yes" : "no");
LogInfo(" UDP Frame Timing: %s", m_udpFrameTiming ? "yes" : "no"); LogInfo(" UDP Frame Timing: %s", m_udpFrameTiming ? "yes" : "no");
if (m_udpFrameTiming) {
LogInfo(" UDP Frame Timeout: %u ms", m_udpFrameTimeout);
}
} }
LogInfo(" Traffic Encrypted: %s", tekEnable ? "yes" : "no"); LogInfo(" Traffic Encrypted: %s", tekEnable ? "yes" : "no");
@ -1307,6 +1312,11 @@ void HostBridge::processUDPAudio()
return; return;
} }
if (length > AUDIO_SAMPLES_LENGTH_BYTES * 2U) {
LogWarning(LOG_NET, "UDP audio packet too large (%d bytes), dropping", length);
return;
}
// is the recieved audio frame *at least* raw PCM length of 320 bytes? // is the recieved audio frame *at least* raw PCM length of 320 bytes?
if (!m_udpUseULaw && length < AUDIO_SAMPLES_LENGTH_BYTES) if (!m_udpUseULaw && length < AUDIO_SAMPLES_LENGTH_BYTES)
return; return;
@ -1405,6 +1415,7 @@ void HostBridge::processUDPAudio()
} }
req->dstId = m_dstId; req->dstId = m_dstId;
m_udpPackets.push_back(req); m_udpPackets.push_back(req);
} }
} }
@ -2118,7 +2129,7 @@ void* HostBridge::threadUDPAudioProcess(void* arg)
stopWatch.start(); stopWatch.start();
ulong64_t lastFrameTime = 0U; ulong64_t lastFrameTime = 0U;
Timer frameTimeout = Timer(1000U, 0U, 22U); Timer frameTimeout = Timer(1000U, 0U, bridge->m_udpFrameTimeout);
while (!g_killed) { while (!g_killed) {
if (!HostBridge::s_running) { if (!HostBridge::s_running) {
@ -2133,6 +2144,8 @@ void* HostBridge::threadUDPAudioProcess(void* arg)
// don't consider frame timeouts for RTP or USRP UDP streams (these will be properly timed anyway, we hope) // don't consider frame timeouts for RTP or USRP UDP streams (these will be properly timed anyway, we hope)
if (!bridge->m_udpRTPFrames && !bridge->m_udpUsrp) { if (!bridge->m_udpRTPFrames && !bridge->m_udpUsrp) {
frameTimeout.clock(ms); frameTimeout.clock(ms);
if (frameTimeout.isRunning() && bridge->m_udpPackets.size() > 0)
frameTimeout.start(); // clock the frame timeout timer
if (frameTimeout.isRunning() && frameTimeout.hasExpired()) { if (frameTimeout.isRunning() && frameTimeout.hasExpired()) {
frameTimeout.stop(); frameTimeout.stop();
bridge->padSilenceAudio(bridge->m_udpSrcId, bridge->m_udpDstId); bridge->padSilenceAudio(bridge->m_udpSrcId, bridge->m_udpDstId);

@ -164,6 +164,7 @@ private:
bool m_udpUseULaw; bool m_udpUseULaw;
bool m_udpUsrp; bool m_udpUsrp;
bool m_udpFrameTiming; bool m_udpFrameTiming;
uint32_t m_udpFrameTimeout;
uint32_t m_udpFrameCnt; uint32_t m_udpFrameCnt;
uint8_t m_tekAlgoId; uint8_t m_tekAlgoId;

Loading…
Cancel
Save

Powered by TurnKey Linux.