From ee41aa7cd07f1e97c4fa5bb9856c1fded37826b2 Mon Sep 17 00:00:00 2001 From: Thulinma Date: Fri, 30 Mar 2012 13:20:08 +0200 Subject: [PATCH] Added DTSC rate limiter. Closes #12 --- util/dtsc.cpp | 6 ++++++ util/dtsc.h | 1 + 2 files changed, 7 insertions(+) diff --git a/util/dtsc.cpp b/util/dtsc.cpp index 85e1ce47..a5eb05e3 100644 --- a/util/dtsc.cpp +++ b/util/dtsc.cpp @@ -23,6 +23,12 @@ DTSC::Stream::Stream(unsigned int rbuffers){ buffercount = rbuffers; } +/// Returns the time in milliseconds of the last received packet. +/// This is _not_ the time this packet was received, only the stored time. +unsigned int DTSC::Stream::getTime(){ + return buffers.front().getContentP("time")->NumValue(); +} + /// Attempts to parse a packet from the given std::string buffer. /// Returns true if successful, removing the parsed part from the buffer string. /// Returns false if invalid or not enough data is in the buffer. diff --git a/util/dtsc.h b/util/dtsc.h index 3d690d53..f721e6c4 100644 --- a/util/dtsc.h +++ b/util/dtsc.h @@ -129,6 +129,7 @@ namespace DTSC{ std::string & outPacket(unsigned int num); std::string & outHeader(); Ring * getRing(); + unsigned int getTime(); void dropRing(Ring * ptr); private: std::deque buffers;