diff options
| author | Matthias P. Braendli <matthias.braendli@mpb.li> | 2019-12-05 18:02:01 +0100 | 
|---|---|---|
| committer | Matthias P. Braendli <matthias.braendli@mpb.li> | 2019-12-05 18:02:01 +0100 | 
| commit | 7ad4a211a9bcba9c78e6a41e0ad1f20460e8896e (patch) | |
| tree | 15cd910a847ced4ed4a57604c3a0126640567799 /src/AVTInput.cpp | |
| parent | c89b5e3c0d9515f07892af464bd6c60fb3427c36 (diff) | |
| download | ODR-SourceCompanion-7ad4a211a9bcba9c78e6a41e0ad1f20460e8896e.tar.gz ODR-SourceCompanion-7ad4a211a9bcba9c78e6a41e0ad1f20460e8896e.tar.bz2 ODR-SourceCompanion-7ad4a211a9bcba9c78e6a41e0ad1f20460e8896e.zip | |
Add example code for RTP timestamp parsing
Diffstat (limited to 'src/AVTInput.cpp')
| -rw-r--r-- | src/AVTInput.cpp | 24 | 
1 files changed, 22 insertions, 2 deletions
| diff --git a/src/AVTInput.cpp b/src/AVTInput.cpp index d39f2ef..2498e19 100644 --- a/src/AVTInput.cpp +++ b/src/AVTInput.cpp @@ -208,19 +208,39 @@ const uint8_t* AVTInput::_findDABFrameFromUDP(const uint8_t* buf, size_t size,      bool rtp = false;      // RTP Header is optionnal, STI is mandatory -    if (error) -    { +    if (error) {          // Assuming RTP header          if (size-index >= 12) {              uint32_t version = (buf[index] & 0xC0) >> 6;              uint32_t payloadType = (buf[index+1] & 0x7F);              if (version == 2 && payloadType == 34) { +#if 0 +                // If one wants to decode the RTP timestamp, here is some +                // example code. The AVT generates a timestamp which starts +                // at device startup, and is not useful for timing. Proper +                // frame ordering is guaranteed with the DFCT below. +                const uint32_t timestamp = +                    (buf[index+4] << 24) | +                    (buf[index+5] << 16) | +                    (buf[index+6] << 8) | +                    buf[index+7]; + +                using namespace std::chrono; +                const auto now = steady_clock::now().time_since_epoch(); + +                const auto t1 = timestamp / 90 / 24; +                const auto t2 = duration_cast<milliseconds>(now).count() / 24; + +                fprintf(stderr, "RTP TS=%d vs %lld delta %lld\n", t1, t2, t2-t1); +#endif +                  index += 12; // RTP Header length                  error = !_isSTI(buf+index);                  rtp = true;              }          }      } +      if (!error) {          index += 4;          //uint32_t DFS = unpack2(buf+index); | 
