Skip to content

Commit

Permalink
change: system_clock uint64 -> uint32
Browse files Browse the repository at this point in the history
  • Loading branch information
ireader committed Jul 28, 2024
1 parent 5e5dc13 commit e7e7f6b
Show file tree
Hide file tree
Showing 15 changed files with 31 additions and 31 deletions.
4 changes: 2 additions & 2 deletions libdash/test/dash-dynamic-test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ static int dash_live_worker(const char* file, dash_playlist_t* dash)
uint32_t timestamp;
uint32_t s_timestamp = 0;
uint32_t diff = 0;
uint64_t clock;
uint32_t clock;

while (1)
{
Expand All @@ -137,7 +137,7 @@ static int dash_live_worker(const char* file, dash_playlist_t* dash)
clock = system_clock(); // timestamp start from 0
while (1 == flv_reader_read(f, &type, &timestamp, &taglen, dash->packet, sizeof(dash->packet)))
{
uint64_t t = system_clock();
uint32_t t = system_clock();
if (clock + timestamp > t && clock + timestamp < t + 3 * 1000)
system_sleep(clock + timestamp - t);
else if (clock + timestamp > t + 3 * 1000)
Expand Down
4 changes: 2 additions & 2 deletions libhls/demo/hls-server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ static int STDCALL hls_server_worker(void* param)
{
int r, type;
size_t taglen;
uint64_t clock;
uint32_t clock;
uint32_t timestamp;
hls_playlist_t* playlist = (hls_playlist_t*)param;

Expand All @@ -138,7 +138,7 @@ static int STDCALL hls_server_worker(void* param)
clock = 0;
while (1 == flv_reader_read(flv, &type, &timestamp, &taglen, playlist->packet, sizeof(playlist->packet)))
{
uint64_t now = system_clock();
uint32_t now = system_clock();
if (0 == clock)
{
clock = now;
Expand Down
2 changes: 1 addition & 1 deletion librtmp/test/rtmp-play-aio-test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ void rtmp_play_aio_test(const char* host, const char* app, const char* stream, c
void* flv = flv_writer_create(file);
aio_connect(host, 1935, 3000, rtmp_onconnect, flv);

// uint64_t clock = system_clock();
// uint32_t clock = system_clock();
while (0 == s_param.code)
{
aio_socket_process(1000);
Expand Down
4 changes: 2 additions & 2 deletions librtmp/test/rtmp-publish-aio-test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ static int STDCALL rtmp_client_push(void* flv)
int r, type;
size_t taglen;
uint32_t timestamp;
uint64_t clock0 = system_clock();
uint32_t clock0 = system_clock();
void* f = flv_reader_create((const char*)flv);

static char packet[2 * 1024 * 1024];
while (0 == s_param.code && 1 == flv_reader_read(f, &type, &timestamp, &taglen, packet, sizeof(packet)))
{
uint64_t t = system_clock();
uint32_t t = system_clock();
if(clock0 + timestamp > t && clock0 + timestamp < t + 3 * 1000)
system_sleep(clock0 + timestamp - t);
else if (t + timestamp > t + 3 * 1000)
Expand Down
4 changes: 2 additions & 2 deletions librtmp/test/rtmp-publish-test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ static void rtmp_client_push(const char* flv, rtmp_client_t* rtmp)
uint32_t timestamp;
uint32_t s_timestamp = 0;
uint32_t diff = 0;
uint64_t clock;
uint32_t clock;

static char packet[2 * 1024 * 1024];
while (1)
Expand All @@ -98,7 +98,7 @@ static void rtmp_client_push(const char* flv, rtmp_client_t* rtmp)
clock = system_clock(); // timestamp start from 0
while (1 == flv_reader_read(f, &type, &timestamp, &taglen, packet, sizeof(packet)))
{
uint64_t t = system_clock();
uint32_t t = system_clock();
if (clock + timestamp > t && clock + timestamp < t + 3 * 1000) // dts skip
system_sleep(clock + timestamp - t);
else if (clock + timestamp > t + 3 * 1000)
Expand Down
8 changes: 4 additions & 4 deletions librtmp/test/rtmp-server-publish-benchmark.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ struct rtmp_raw_packet_t
uint32_t timestamp;
};

static uint64_t s_clock;
static uint32_t s_clock;
static std::vector<rtmp_raw_packet_t> s_pkts;
static rtmp_server_publish_benchmark_t s_servers[N];

Expand Down Expand Up @@ -51,15 +51,15 @@ static void init_packets(const char* filename)
}
}

static void rtmp_server_publish_input(rtmp_server_publish_benchmark_t* rtmp, uint64_t now)
static void rtmp_server_publish_input(rtmp_server_publish_benchmark_t* rtmp, uint32_t now)
{
if (rtmp->i >= s_pkts.size())
return;

for(int i = 0; 1; i++)
{
rtmp_raw_packet_t& pkt = s_pkts[rtmp->i];
if (s_clock + pkt.timestamp > now)
if ((int)(s_clock + pkt.timestamp - now) > 0)
{
if (i > 50) printf("cycle %d\n", i);
return;
Expand All @@ -75,7 +75,7 @@ static int STDCALL rtmp_server_onthread(void* param)
int idx = (int)(intptr_t)param;
while (1)
{
uint64_t now = system_clock();
uint32_t now = system_clock();
for (int i = idx; i < N; i += M)
{
rtmp_server_publish_input(s_servers + i, now);
Expand Down
6 changes: 3 additions & 3 deletions librtmp/test/rtmp-server-vod-aio-test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ static int STDCALL aio_rtmp_server_worker(void* param)
uint32_t timestamp;
uint32_t s_timestamp = 0;
uint32_t diff = 0;
uint64_t clock;
//uint64_t clock0 = system_clock() - 3000; // send more data, open fast
uint32_t clock;
//uint32_t clock0 = system_clock() - 3000; // send more data, open fast
rtmp_server_vod_t* vod = (rtmp_server_vod_t*)param;

while (1)
Expand All @@ -40,7 +40,7 @@ static int STDCALL aio_rtmp_server_worker(void* param)
while (1 == flv_reader_read(f, &type, &timestamp, &taglen, vod->packet, sizeof(vod->packet)))
{
assert(taglen < sizeof(vod->packet));
uint64_t t = system_clock();
uint32_t t = system_clock();
if (clock + timestamp > t && clock + timestamp < t + 3 * 1000)
system_sleep(clock + timestamp - t);
else if (clock + timestamp > t + 3 * 1000)
Expand Down
4 changes: 2 additions & 2 deletions librtmp/test/rtmp-server-vod-test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ static int STDCALL rtmp_server_worker(void* param)
int r, type;
size_t taglen;
uint32_t timestamp;
static uint64_t clock0 = system_clock() - 200; // send more data, open fast
static uint32_t clock0 = system_clock() - 200; // send more data, open fast
void* f = flv_reader_create(s_file);

static unsigned char packet[8 * 1024 * 1024];
while (1 == flv_reader_read(f, &type, &timestamp, &taglen, packet, sizeof(packet)))
{
assert(taglen < sizeof(packet));
uint64_t t = system_clock();
uint32_t t = system_clock();
if (clock0 + timestamp > t && clock0 + timestamp < t + 3 * 1000)
system_sleep(clock0 + timestamp - t);
else if (clock0 + timestamp > t + 3 * 1000)
Expand Down
6 changes: 3 additions & 3 deletions librtp/test/rtp-dump-replay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ void rtp_dump_replay_test(const char* file, const char* peer, int port)
int r;
uint8_t data[1500];
uint32_t clock, clock0;
uint64_t base = 0;
uint32_t base = 0;
struct rtpdump_t* dump;

socket_init();
Expand All @@ -29,7 +29,7 @@ void rtp_dump_replay_test(const char* file, const char* peer, int port)
break;

assert(r >= 0);
uint64_t now = system_clock();
uint32_t now = system_clock();
if (0 == base)
{
base = now;
Expand All @@ -39,7 +39,7 @@ void rtp_dump_replay_test(const char* file, const char* peer, int port)
{
if (now - base < clock - clock0)
{
uint64_t v = (uint64_t)(clock - clock0) - (now - base);
uint32_t v = (uint64_t)(clock - clock0) - (now - base);
if(v < 5000)
system_sleep(v);
}
Expand Down
6 changes: 3 additions & 3 deletions librtsp/test/media/ffmpeg-file-source.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ int FFFileSource::Play()
}

m_status = 1;
uint64_t clock = system_clock();
uint64_t clock = system_time();
for (int i = 0; i < m_count; i++)
{
struct media_t* m = &m_media[i];
Expand Down Expand Up @@ -289,7 +289,7 @@ int FFFileSource::Seek(int64_t pos)
if (-1 != m_media[i].dts_first)
m_media[i].timestamp += m_media[i].dts_last - m_media[i].dts_first + 1;
m_media[i].dts_first = -1;
//SendRTCP(&m_media[i], system_clock());
//SendRTCP(&m_media[i], system_time());
}

m_dts = -1;
Expand Down Expand Up @@ -543,7 +543,7 @@ int FFFileSource::RTPPacket(void* param, const void *packet, int bytes, uint32_t
// Hack: Send an initial RTCP "SR" packet, before the initial RTP packet,
// so that receivers will (likely) be able to get RTCP-synchronized presentation times immediately:
rtp_onsend(m->rtp, packet, bytes/*, time*/);
SendRTCP(m, system_clock());
SendRTCP(m, system_time());

int r = m->transport->Send(false, packet, bytes);
assert(r == (int)bytes);
Expand Down
4 changes: 2 additions & 2 deletions librtsp/test/media/ffmpeg-live-source.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ int FFLiveSource::Play()
}

m_status = 1;
uint64_t clock = system_clock();
uint64_t clock = system_time();
for (int i = 0; i < m_count; i++)
{
struct media_t* m = &m_media[i];
Expand Down Expand Up @@ -750,7 +750,7 @@ int FFLiveSource::RTPPacket(void* param, const void *packet, int bytes, uint32_t
// Hack: Send an initial RTCP "SR" packet, before the initial RTP packet,
// so that receivers will (likely) be able to get RTCP-synchronized presentation times immediately:
rtp_onsend(m->rtp, packet, bytes/*, time*/);
SendRTCP(m, system_clock());
SendRTCP(m, system_time());

int r = m->transport->Send(false, packet, bytes);
assert(r == (int)bytes);
Expand Down
2 changes: 1 addition & 1 deletion librtsp/test/media/mp4-file-source.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ int MP4FileSource::Play()

m_status = 1;
int bytes = 0;
uint64_t clock = system_clock();
uint64_t clock = system_time();
std::shared_ptr<struct avpacket_t> pkt(avpacket_queue_front(m->pkts), avpacket_release);
int64_t dts = pkt->dts < pkt->pts ? pkt->dts : pkt->pts;

Expand Down
2 changes: 1 addition & 1 deletion librtsp/test/media/vod-file-source.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ int VodFileSource::Worker()
r = 0; // 1 -> 0
}

uint64_t now = system_clock();
uint64_t now = system_time();
uint64_t timestamp = 0 == pkt->dts || -1 == pkt->dts ? pkt->pts : pkt->dts;

if (0 == m_clock || now < m_clock || timestamp < m_timestamp)
Expand Down
4 changes: 2 additions & 2 deletions librtsp/test/rtp-streaming-test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ struct rtp_streaming_test_stream_t
struct rtp_streaming_test_t
{
struct rtp_streaming_test_stream_t a, v;
uint64_t clock;
uint32_t clock;
};

static int rtp_encode_packet(void* param, int pid, const void* packet, int bytes, uint32_t timestamp, int /*flags*/)
Expand Down Expand Up @@ -82,7 +82,7 @@ static void onread(void* param, uint32_t track, const void* buffer, size_t bytes
static int64_t a_pts, a_dts;
struct rtp_streaming_test_t* ctx = (struct rtp_streaming_test_t*)param;

uint64_t clock = system_clock();
uint32_t clock = system_clock();
if (clock - ctx->clock + 5 < dts)
system_sleep(dts - (clock - ctx->clock + 5));

Expand Down
2 changes: 1 addition & 1 deletion librtsp/test/rtsp-server-test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ static int rtsp_onplay(void* /*ptr*/, rtsp_server_t* rtsp, const char* uri, cons
// for vlc 2.2.2
MP4FileSource* mp4 = dynamic_cast<MP4FileSource*>(source.get());
if(mp4)
mp4->SendRTCP(system_clock());
mp4->SendRTCP(system_time());

it->second.status = 1;
return rtsp_server_reply_play(rtsp, 200, npt, NULL, rtpinfo);
Expand Down

0 comments on commit e7e7f6b

Please sign in to comment.