summaryrefslogtreecommitdiffstats
path: root/src/input/Udp.cpp
diff options
context:
space:
mode:
authorMatthias P. Braendli <matthias.braendli@mpb.li>2019-08-27 11:02:23 +0200
committerMatthias P. Braendli <matthias.braendli@mpb.li>2019-08-27 11:02:23 +0200
commit0298076eea4f92685f9a01974261da41c2a01e5b (patch)
treef72831cd212da64c1a3ea124bb9b590ced8558f2 /src/input/Udp.cpp
parentcac39dedee89d62ebf5d0135b84ccaa2e387a7cb (diff)
downloaddabmux-0298076eea4f92685f9a01974261da41c2a01e5b.tar.gz
dabmux-0298076eea4f92685f9a01974261da41c2a01e5b.tar.bz2
dabmux-0298076eea4f92685f9a01974261da41c2a01e5b.zip
EDI input: add new buffer management
Diffstat (limited to 'src/input/Udp.cpp')
-rw-r--r--src/input/Udp.cpp18
1 files changed, 13 insertions, 5 deletions
diff --git a/src/input/Udp.cpp b/src/input/Udp.cpp
index b909c5a..5ddc366 100644
--- a/src/input/Udp.cpp
+++ b/src/input/Udp.cpp
@@ -86,7 +86,7 @@ void Udp::openUdpSocket(const std::string& endpoint)
etiLog.level(info) << "Opened UDP port " << address << ":" << port;
}
-int Udp::readFrame(uint8_t* buffer, size_t size)
+size_t Udp::readFrame(uint8_t *buffer, size_t size)
{
// Regardless of buffer contents, try receiving data.
auto packet = m_sock.receive(32768);
@@ -97,12 +97,19 @@ int Udp::readFrame(uint8_t* buffer, size_t size)
// in any case write the buffer
if (m_buffer.size() >= (size_t)size) {
std::copy(m_buffer.begin(), m_buffer.begin() + size, buffer);
+ return size;
}
else {
memset(buffer, 0x0, size);
+ return 0;
}
+}
- return size;
+size_t Udp::readFrame(uint8_t *buffer, size_t size, uint32_t seconds, uint32_t tsta)
+{
+ // Maybe there's a way to carry timestamps, but we don't need it.
+ memset(buffer, 0x0, size);
+ return 0;
}
int Udp::setBitrate(int bitrate)
@@ -278,7 +285,7 @@ void Sti_d_Rtp::receive_packet()
}
}
-int Sti_d_Rtp::readFrame(uint8_t* buffer, size_t size)
+size_t Sti_d_Rtp::readFrame(uint8_t *buffer, size_t size)
{
// Make sure we fill faster than we consume in case there
// are pending packets.
@@ -287,19 +294,20 @@ int Sti_d_Rtp::readFrame(uint8_t* buffer, size_t size)
if (m_queue.empty()) {
memset(buffer, 0x0, size);
+ return 0;
}
else if (m_queue.front().size() != size) {
etiLog.level(warn) << "Invalid input data size for STI " << m_name <<
" : RX " << m_queue.front().size() << " expected " << size;
memset(buffer, 0x0, size);
m_queue.pop_front();
+ return 0;
}
else {
copy(m_queue.front().begin(), m_queue.front().end(), buffer);
m_queue.pop_front();
+ return size;
}
-
- return 0;
}
}