RtpSource: Convert internals partially to std::chrono
This allows us to remove the tvNow() helper method.
This commit is contained in:
parent
28d813b95a
commit
f374b319e0
|
@ -66,7 +66,7 @@ RtpSource::RtpSource(
|
||||||
|
|
||||||
mRtpFactor = mRtpClock;
|
mRtpFactor = mRtpClock;
|
||||||
|
|
||||||
mBaseTimeReal = tvNow();
|
mBaseTimeReal = std::chrono::system_clock::now();
|
||||||
mBaseTimeNtp = {};
|
mBaseTimeNtp = {};
|
||||||
mBaseTimeRtp = rtpTime;
|
mBaseTimeRtp = rtpTime;
|
||||||
|
|
||||||
|
@ -159,12 +159,9 @@ bool RtpSource::updateSeq(uint16_t seq) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void RtpSource::updateJitter( const RtpDataHeader *header ) {
|
void RtpSource::updateJitter( const RtpDataHeader *header ) {
|
||||||
if ( mRtpFactor > 0 ) {
|
if (mRtpFactor > 0) {
|
||||||
timeval now = {};
|
SystemTimePoint now = std::chrono::system_clock::now();
|
||||||
gettimeofday(&now, nullptr);
|
FPSeconds time_diff = std::chrono::duration_cast<FPSeconds>(now - mBaseTimeReal);
|
||||||
|
|
||||||
FPSeconds time_diff =
|
|
||||||
zm::chrono::duration_cast<Microseconds>(now) - zm::chrono::duration_cast<Microseconds>(mBaseTimeReal);
|
|
||||||
|
|
||||||
uint32_t localTimeRtp = mBaseTimeRtp + static_cast<uint32>(time_diff.count() * mRtpFactor);
|
uint32_t localTimeRtp = mBaseTimeRtp + static_cast<uint32>(time_diff.count() * mRtpFactor);
|
||||||
uint32_t packetTransit = localTimeRtp - ntohl(header->timestampN);
|
uint32_t packetTransit = localTimeRtp - ntohl(header->timestampN);
|
||||||
|
@ -202,7 +199,7 @@ void RtpSource::updateRtcpData(
|
||||||
Debug(5, "ntpTime: %ld.%06ld, rtpTime: %x", ntpTime.tv_sec, ntpTime.tv_usec, rtpTime);
|
Debug(5, "ntpTime: %ld.%06ld, rtpTime: %x", ntpTime.tv_sec, ntpTime.tv_usec, rtpTime);
|
||||||
|
|
||||||
if ( mBaseTimeNtp.tv_sec == 0 ) {
|
if ( mBaseTimeNtp.tv_sec == 0 ) {
|
||||||
mBaseTimeReal = tvNow();
|
mBaseTimeReal = std::chrono::system_clock::now();
|
||||||
mBaseTimeNtp = ntpTime;
|
mBaseTimeNtp = ntpTime;
|
||||||
mBaseTimeRtp = rtpTime;
|
mBaseTimeRtp = rtpTime;
|
||||||
} else if ( !mRtpClock ) {
|
} else if ( !mRtpClock ) {
|
||||||
|
|
|
@ -24,6 +24,7 @@
|
||||||
#include "zm_config.h"
|
#include "zm_config.h"
|
||||||
#include "zm_define.h"
|
#include "zm_define.h"
|
||||||
#include "zm_ffmpeg.h"
|
#include "zm_ffmpeg.h"
|
||||||
|
#include "zm_time.h"
|
||||||
#include <condition_variable>
|
#include <condition_variable>
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
@ -68,7 +69,7 @@ private:
|
||||||
// Time keys
|
// Time keys
|
||||||
uint32_t mRtpClock;
|
uint32_t mRtpClock;
|
||||||
uint32_t mRtpFactor;
|
uint32_t mRtpFactor;
|
||||||
struct timeval mBaseTimeReal;
|
SystemTimePoint mBaseTimeReal;
|
||||||
struct timeval mBaseTimeNtp;
|
struct timeval mBaseTimeNtp;
|
||||||
uint32_t mBaseTimeRtp;
|
uint32_t mBaseTimeRtp;
|
||||||
|
|
||||||
|
|
|
@ -23,12 +23,6 @@
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
|
|
||||||
inline struct timeval tvNow() {
|
|
||||||
timeval t = {};
|
|
||||||
gettimeofday(&t, nullptr);
|
|
||||||
return t;
|
|
||||||
}
|
|
||||||
|
|
||||||
typedef std::chrono::microseconds Microseconds;
|
typedef std::chrono::microseconds Microseconds;
|
||||||
typedef std::chrono::milliseconds Milliseconds;
|
typedef std::chrono::milliseconds Milliseconds;
|
||||||
typedef std::chrono::seconds Seconds;
|
typedef std::chrono::seconds Seconds;
|
||||||
|
|
Loading…
Reference in New Issue