dtchat: keep the call-level sync test on an explicit timestamp (T7.5)
Video frames are timestamped by wall clock now, so test_video_packet can no longer make the old frame-count timestamps by sending quickly. dc_call_send_video_at() takes the timestamp as an argument (dc_call_send_video passes the elapsed time since the call began), and the test sends 0/66/132 ms after 200 ms of decoded audio: the first two are dropped, the third renders with offset -68 ms and two drops. Standalone and in-tree (43 ok/0 bad) green.
This commit is contained in:
1 parent
2ac8536ef9
commit
233048237b
3 files changed
+20
-5
No files matched your search
@@ -490,6 +490,11 @@ int dc_call_audio_out(DcMediaCall *call, int16_t *pcm);
|
||||
/* one encoded frame out (fragmented) and the completed frames in */
|
||||
int dc_call_send_video(DcMediaCall *call, uint16_t frame_id,
|
||||
const unsigned char *frame, size_t len, int keyframe);
|
||||
/* the same with a caller-chosen timestamp (the send path uses the elapsed
|
||||
* time since the call began; a test or a recording can say when the frame
|
||||
* belongs) */
|
||||
int dc_call_send_video_at(DcMediaCall *call, uint32_t ts, uint16_t frame_id,
|
||||
const unsigned char *frame, size_t len, int keyframe);
|
||||
/* 1: a decoded I420 frame to render (DC_VIDEO_W x DC_VIDEO_H), 0: nothing
|
||||
* complete or not decodable yet, -1: a frame was dropped because it was more
|
||||
* than DC_SYNC_LATE_MS behind the audio (or OUT is too small) */
|
||||
|
||||
@@ -547,6 +547,17 @@ dc_call_audio_out(DcMediaCall *call, int16_t *pcm)
|
||||
int
|
||||
dc_call_send_video(DcMediaCall *call, uint16_t frame_id,
|
||||
const unsigned char *frame, size_t len, int keyframe)
|
||||
{
|
||||
if (call == NULL)
|
||||
return -1;
|
||||
return dc_call_send_video_at(call,
|
||||
(uint32_t)(dc_loop_now_ms() - call->video_start), frame_id, frame,
|
||||
len, keyframe);
|
||||
}
|
||||
|
||||
int
|
||||
dc_call_send_video_at(DcMediaCall *call, uint32_t ts, uint16_t frame_id,
|
||||
const unsigned char *frame, size_t len, int keyframe)
|
||||
{
|
||||
unsigned char fragment[DC_MEDIA_MAX_PAYLOAD];
|
||||
unsigned char packet[DC_MEDIA_MAX_PAYLOAD + 64];
|
||||
@@ -569,8 +580,7 @@ dc_call_send_video(DcMediaCall *call, uint16_t frame_id,
|
||||
* timestamp is when the frame is sent, not a frame count: a pump
|
||||
* that runs slower than the nominal frame rate must not make the
|
||||
* stream drift behind the sound */
|
||||
plen = dc_media_seal(&call->snd, DC_MEDIA_VIDEO,
|
||||
(uint32_t)(dc_loop_now_ms() - call->video_start), fragment,
|
||||
plen = dc_media_seal(&call->snd, DC_MEDIA_VIDEO, ts, fragment,
|
||||
flen, packet, sizeof(packet));
|
||||
if (plen == 0)
|
||||
return -1;
|
||||
|
||||
@@ -262,15 +262,15 @@ main(void)
|
||||
for (i = 0; i < 10; i++) {
|
||||
CHECK(dc_call_audio_out(d, pcm) == 1);
|
||||
}
|
||||
CHECK(dc_call_send_video(c, 1, frame, 1000, 0) == 0);
|
||||
CHECK(dc_call_send_video_at(c, 0, 1, frame, 1000, 0) == 0);
|
||||
(void)dc_call_drain(d);
|
||||
CHECK(dc_call_video_packet(d, got, sizeof(got), &len, &keyframe,
|
||||
&frame_id) == -1);
|
||||
CHECK(dc_call_send_video(c, 2, frame, 1000, 0) == 0);
|
||||
CHECK(dc_call_send_video_at(c, 66, 2, frame, 1000, 0) == 0);
|
||||
(void)dc_call_drain(d);
|
||||
CHECK(dc_call_video_packet(d, got, sizeof(got), &len, &keyframe,
|
||||
&frame_id) == -1);
|
||||
CHECK(dc_call_send_video(c, 3, frame, 1000, 0) == 0);
|
||||
CHECK(dc_call_send_video_at(c, 132, 3, frame, 1000, 0) == 0);
|
||||
(void)dc_call_drain(d);
|
||||
CHECK(dc_call_video_packet(d, got, sizeof(got), &len, &keyframe,
|
||||
&frame_id) == 1);
|
||||
|
||||
Reference in new issue
Block a user