@@ -54,12 +54,9 @@ void VideoWorker::run()
5454 continue ;
5555 }
5656
57- /* timestamp fix, can be removed if solved
58- int64_t nal_ts = stream.pack[stream.packCount - 1].timestamp;
59- struct timeval encoder_time;
60- encoder_time.tv_sec = nal_ts / 1000000;
61- encoder_time.tv_usec = nal_ts % 1000000;
62- */
57+
58+ struct timeval monotonic_time;
59+ WorkerUtils::getMonotonicTimeOfDay (&monotonic_time);
6360
6461 for (uint32_t i = 0 ; i < stream.packCount ; ++i)
6562 {
@@ -76,12 +73,9 @@ void VideoWorker::run()
7673 uint8_t *start = (uint8_t *) stream.pack [i].virAddr ;
7774 uint8_t *end = (uint8_t *) stream.pack [i].virAddr + stream.pack [i].length ;
7875#endif
79- H264NALUnit nalu;
8076
81- /* timestamp fix, can be removed if solved
82- nalu.imp_ts = stream.pack[i].timestamp;
83- nalu.time = encoder_time;
84- */
77+ H264NALUnit nalu;
78+ nalu.time = monotonic_time;
8579
8680 // We use start+4 because the encoder inserts 4-byte MPEG
8781 // 'startcodes' at the beginning of each NAL. Live555 complains
@@ -155,7 +149,7 @@ void VideoWorker::run()
155149
156150 IMP_Encoder_ReleaseStream (encChn, &stream);
157151
158- ms = WorkerUtils::tDiffInMs (&global_video[encChn]->stream ->stats .ts );
152+ ms = WorkerUtils::getMonotonicTimeDiffInMs (&global_video[encChn]->stream ->stats .ts );
159153 if (ms > 1000 )
160154 {
161155 /* currently we write into osd and stream stats,
@@ -168,7 +162,7 @@ void VideoWorker::run()
168162
169163 fps = 0 ;
170164 bps = 0 ;
171- gettimeofday (&global_video[encChn]->stream ->stats .ts , NULL );
165+ WorkerUtils::getMonotonicTimeOfDay (&global_video[encChn]->stream ->stats .ts );
172166 global_video[encChn]->stream ->osd .stats .ts = global_video[encChn]
173167 ->stream ->stats .ts ;
174168 /*
0 commit comments