提交 cbf71235 authored 作者: Iñaki Baz Castillo's avatar Iñaki Baz Castillo 提交者: José Luis Millán

Update the libuv's “now” periodically (Fixes #58)

上级 fe79296c
#ifndef MS_DEP_LIBUV_H #ifndef MS_DEP_LIBUV_H
#define MS_DEP_LIBUV_H #define MS_DEP_LIBUV_H
#include "common.h"
#include <uv.h> #include <uv.h>
class DepLibUV class DepLibUV
...@@ -15,6 +16,7 @@ public: ...@@ -15,6 +16,7 @@ public:
private: private:
static uv_loop_t* loop; static uv_loop_t* loop;
static uint32_t timeUpdateCounter;
}; };
/* Inline static methods. */ /* Inline static methods. */
...@@ -25,10 +27,4 @@ uv_loop_t* DepLibUV::GetLoop() ...@@ -25,10 +27,4 @@ uv_loop_t* DepLibUV::GetLoop()
return DepLibUV::loop; return DepLibUV::loop;
} }
inline
uint64_t DepLibUV::GetTime()
{
return uv_now(DepLibUV::loop);
}
#endif #endif
...@@ -8,6 +8,8 @@ ...@@ -8,6 +8,8 @@
/* Static variables. */ /* Static variables. */
uv_loop_t* DepLibUV::loop = nullptr; uv_loop_t* DepLibUV::loop = nullptr;
uint32_t DepLibUV::timeUpdateCounter = 0;
static uint64_t LAST_NOW = 0;
/* Static methods. */ /* Static methods. */
...@@ -21,6 +23,8 @@ void DepLibUV::ClassInit() ...@@ -21,6 +23,8 @@ void DepLibUV::ClassInit()
err = uv_loop_init(DepLibUV::loop); err = uv_loop_init(DepLibUV::loop);
if (err) if (err)
MS_ABORT("libuv initialization failed"); MS_ABORT("libuv initialization failed");
LAST_NOW = uv_now(DepLibUV::loop);
} }
void DepLibUV::ClassDestroy() void DepLibUV::ClassDestroy()
...@@ -52,3 +56,23 @@ void DepLibUV::RunLoop() ...@@ -52,3 +56,23 @@ void DepLibUV::RunLoop()
uv_run(DepLibUV::loop, UV_RUN_DEFAULT); uv_run(DepLibUV::loop, UV_RUN_DEFAULT);
} }
// TODO: Move to inline in the .h file.
uint64_t DepLibUV::GetTime()
{
static uint32_t maxTimeCounter = 32768;
// TODO: Remove.
if (DepLibUV::timeUpdateCounter == 0)
MS_DEBUG_DEV("now - LAST_NOW: %" PRIu64 "ms", uv_now(DepLibUV::loop) - LAST_NOW);
// Update the libuv's concept of “now” every N usages.
if (++DepLibUV::timeUpdateCounter == maxTimeCounter)
{
LAST_NOW = uv_now(DepLibUV::loop);
DepLibUV::timeUpdateCounter = 0;
uv_update_time(DepLibUV::loop);
}
return uv_now(DepLibUV::loop);
}
...@@ -106,7 +106,8 @@ namespace RTC ...@@ -106,7 +106,8 @@ namespace RTC
// Otherwise just return. // Otherwise just return.
else else
{ {
MS_WARN_TAG(rtp, "requested packet range not in the buffer"); // TODO: REMOVE
// MS_WARN_TAG(rtp, "requested packet range not in the buffer");
return; return;
} }
...@@ -160,7 +161,8 @@ namespace RTC ...@@ -160,7 +161,8 @@ namespace RTC
} }
else if (!too_old_packet_found) else if (!too_old_packet_found)
{ {
MS_WARN_TAG(rtp, "ignoring retransmission for too old packet [max_age:%" PRIu32 "ms, packet_age:%" PRIu32 "ms]", MAX_RETRANSMISSION_AGE, diff); // TODO: REMOVE
// MS_WARN_TAG(rtp, "ignoring retransmission for too old packet [max_age:%" PRIu32 "ms, packet_age:%" PRIu32 "ms]", MAX_RETRANSMISSION_AGE, diff);
too_old_packet_found = true; too_old_packet_found = true;
} }
...@@ -194,10 +196,10 @@ namespace RTC ...@@ -194,10 +196,10 @@ namespace RTC
UINT16_TO_BINARY(orig_bitmask), UINT16_TO_BINARY(sent_bitmask)); UINT16_TO_BINARY(orig_bitmask), UINT16_TO_BINARY(sent_bitmask));
} }
// TODO: REMOVE // TODO: REMOVE
else if (first_packet_sent && orig_bitmask && orig_bitmask == sent_bitmask) // else if (first_packet_sent && orig_bitmask && orig_bitmask == sent_bitmask)
{ // {
MS_WARN_TAG(rtcp, "first packet sent and also all the bitmask packets [bitmask:" UINT16_TO_BINARY_PATTERN "]", UINT16_TO_BINARY(orig_bitmask)); // MS_WARN_TAG(rtcp, "first packet sent and also all the bitmask packets [bitmask:" UINT16_TO_BINARY_PATTERN "]", UINT16_TO_BINARY(orig_bitmask));
} // }
// Set the next container element to null. // Set the next container element to null.
container[container_idx] = nullptr; container[container_idx] = nullptr;
......
Markdown 格式
0% 或
您添加了 0 人 到此讨论。请谨慎行事。
请先完成此评论的编辑!
请 注册 或者 后发表评论