webrtc中 的方法:
static webrtc::Clock * pwebrtc_clock = webrtc::Clock::GetRealTimeClock();
webrtc::NtpTime nNtpTiem = pwebrtc_clock->CurrentNtpTime();
uint32_t nNtpTimeSec = nNtpTiem.seconds();
1900 - 1970 经过的 秒数:
constexpr int64_t kNtpJan1970Sec = 2208988800;
也有通过本机时间获取,可以参考之我之前写的 VLC 获取 NTP time;
下面是windwos 通过网络 获取 NTP time 的方法:
参考:https://www.cnblogs.com/findumars/p/5928698.html
#include <WinSock.h>
#pragma comment (lib,"Ws2_32")
uint64_t get_ntp_time()
{
WORD wVersionRequested;
WSADATA wsaData;
// 初始化版本
wVersionRequested = MAKEWORD( 1, 1 );
if (0!=WSAStartup(wVersionRequested, &am