diff options
| author | Matthias P. Braendli <matthias.braendli@mpb.li> | 2019-12-04 14:53:54 +0100 | 
|---|---|---|
| committer | Matthias P. Braendli <matthias.braendli@mpb.li> | 2019-12-04 14:53:54 +0100 | 
| commit | c89b5e3c0d9515f07892af464bd6c60fb3427c36 (patch) | |
| tree | 18c7573859606dada82e56d5115cd5d1e71129db /src/OrderedQueue.cpp | |
| parent | 814ec3abaede73ea38c7130333c7bc0a18e05d91 (diff) | |
| download | ODR-SourceCompanion-c89b5e3c0d9515f07892af464bd6c60fb3427c36.tar.gz ODR-SourceCompanion-c89b5e3c0d9515f07892af464bd6c60fb3427c36.tar.bz2 ODR-SourceCompanion-c89b5e3c0d9515f07892af464bd6c60fb3427c36.zip | |
Timestamp arrival of UDP packets
Diffstat (limited to 'src/OrderedQueue.cpp')
| -rw-r--r-- | src/OrderedQueue.cpp | 19 | 
1 files changed, 12 insertions, 7 deletions
| diff --git a/src/OrderedQueue.cpp b/src/OrderedQueue.cpp index eb2cf97..707f0f9 100644 --- a/src/OrderedQueue.cpp +++ b/src/OrderedQueue.cpp @@ -22,6 +22,8 @@  #include <cstdio>  #include <stdint.h> +using namespace std; +  #define DEBUG(fmt, A...)   fprintf(stderr, "OrderedQueue: " fmt, ##A)  //#define DEBUG(x...)  #define ERROR(fmt, A...)   fprintf(stderr, "OrderedQueue: ERROR " fmt, ##A) @@ -32,7 +34,7 @@ OrderedQueue::OrderedQueue(int maxIndex, size_t capacity) :  {  } -void OrderedQueue::push(int32_t index, const uint8_t* buf, size_t size) +void OrderedQueue::push(int32_t index, const uint8_t* buf, size_t size, const timestamp_t& ts)  {      // DEBUG("OrderedQueue::push index=%d\n", index);      index = (index + _maxIndex) % _maxIndex; @@ -52,8 +54,11 @@ void OrderedQueue::push(int32_t index, const uint8_t* buf, size_t size)              DEBUG("Duplicated index=%d\n", index);          } -        OrderedQueueData oqd(size); -        copy(buf, buf + size, oqd.begin()); +        OrderedQueueData oqd; +        oqd.buf.resize(size); +        oqd.capture_timestamp = ts; + +        copy(buf, buf + size, oqd.buf.begin());          _stock[index] = move(oqd);      }      else { @@ -73,9 +78,9 @@ bool OrderedQueue::availableData() const      return _stock.size() > 0;  } -std::vector<uint8_t> OrderedQueue::pop(int32_t *returnedIndex) +OrderedQueueData OrderedQueue::pop(int32_t *returnedIndex)  { -    OrderedQueueData buf; +    OrderedQueueData oqd;      uint32_t gap = 0;      if (_stock.size() > 0) { @@ -83,7 +88,7 @@ std::vector<uint8_t> OrderedQueue::pop(int32_t *returnedIndex)          bool found = false;          while (not found) {              try { -                buf = move(_stock.at(nextIndex)); +                oqd = move(_stock.at(nextIndex));                  _stock.erase(nextIndex);                  _lastIndexPop = nextIndex;                  if (returnedIndex) *returnedIndex = _lastIndexPop; @@ -108,6 +113,6 @@ std::vector<uint8_t> OrderedQueue::pop(int32_t *returnedIndex)          DEBUG("index jump of %d\n", gap);      } -    return buf; +    return oqd;  } | 
