diff options
author | Matthias P. Braendli <matthias.braendli@mpb.li> | 2013-12-22 16:11:43 +0100 |
---|---|---|
committer | Matthias P. Braendli <matthias.braendli@mpb.li> | 2013-12-24 18:09:27 +0100 |
commit | b0183733ef4c6f08ef8c7b73155268e54ca3f152 (patch) | |
tree | 5aa855d5dc36badbf1b2268bef79db0257146853 /src/inputs/InputBuffered.cpp | |
parent | 7094945ef7ecb8a918dfe3b4619bdc6f239cbb50 (diff) | |
download | dabmux-b0183733ef4c6f08ef8c7b73155268e54ca3f152.tar.gz dabmux-b0183733ef4c6f08ef8c7b73155268e54ca3f152.tar.bz2 dabmux-b0183733ef4c6f08ef8c7b73155268e54ca3f152.zip |
InputBuffered know how to split frames
Diffstat (limited to 'src/inputs/InputBuffered.cpp')
-rw-r--r-- | src/inputs/InputBuffered.cpp | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/src/inputs/InputBuffered.cpp b/src/inputs/InputBuffered.cpp index 9eea2a7..093220b 100644 --- a/src/inputs/InputBuffered.cpp +++ b/src/inputs/InputBuffered.cpp @@ -27,11 +27,13 @@ #include "inputs/Input.h" +#ifdef HAVE_INPUT_FILE #include "TcpLog.h" #include <string> #include <cstring> +#include <iostream> #include <cstdlib> #include <cstdio> #include <fcntl.h> @@ -44,7 +46,7 @@ extern TcpLog etiLog; -int InputBuffered::ReadFrame(void* buffer, int size) +int InputBuffered::ReadFrameFromBuffer(void* buffer, int size) { int retval = 0; bool rc; @@ -115,11 +117,26 @@ bool InputBuffered::FillBuffer() } else { // copy the input frame into the frame_buffer one to one - std::vector<char> frame(m_source_size); - int rc = ReadSource(&frame.front(), m_source_size); + std::vector<char> superframe(m_source_size); + int rc = ReadSource(&superframe.front(), m_source_size); if (rc == m_source_size) { - m_buffer.push_back(frame); + int frame_size = m_source_size/m_framesplit; + std::vector<char> frame(frame_size); + + for (char* framestart = &superframe.front(); + framestart < &superframe[frame_size]; + framestart += frame_size) { + memcpy(&frame.front(), framestart, frame_size); + m_buffer.push_back(frame); + } + + int i = 0; + for (std::list< std::vector<char> >::iterator it = m_buffer.begin(); + it != m_buffer.end(); ++it, i++) + { + cout << "FRAME " << dec << i << " size " << it->size() << endl; + } return true; } else @@ -129,3 +146,5 @@ bool InputBuffered::FillBuffer() } } +#endif // HAVE_INPUT_FILE + |