Skip to content

Commit

Permalink
investingating test
Browse files Browse the repository at this point in the history
  • Loading branch information
nclack committed Mar 1, 2024
1 parent a1a519d commit 5348277
Showing 1 changed file with 32 additions and 9 deletions.
41 changes: 32 additions & 9 deletions tests/one-video-stream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,16 +62,22 @@ main()
&props.video[0].camera.identifier));
DEVOK(device_manager_select(dm,
DeviceKind_Storage,
SIZED("Zarr") - 1,
SIZED("tiff") - 1,
&props.video[0].storage.identifier));

storage_properties_init(&props.video[0].storage.settings,
0,
SIZED("out.zarr"),
SIZED("out.tiff"),
0,
0,
{ 0 });

// avoid initing w zero shape
props.video[0].camera.settings.shape = {
.x = 14192,
.y = 10640,
};

OK(acquire_configure(runtime, &props));

AcquirePropertyMetadata metadata = { 0 };
Expand Down Expand Up @@ -104,24 +110,25 @@ main()
OK(acquire_start(runtime));
{
uint64_t nframes = 0;
VideoFrame *beg, *end, *cur;

while (nframes < props.video[0].max_frame_count) {
struct clock throttle;
clock_init(&throttle);
EXPECT(clock_cmp_now(&clock) < 0,
"Timeout at %f ms",
clock_toc_ms(&clock) + time_limit_ms);
VideoFrame *beg, *end, *cur;
OK(acquire_map_read(runtime, 0, &beg, &end));
for (cur = beg; cur < end; cur = next(cur)) {
LOG("stream %d counting frame w id %d", 0, cur->frame_id);
LOG("stream %d counting frame w id %d (nframes = %d)", 0, cur->frame_id, nframes);
CHECK(cur->shape.dims.width ==
props.video[0].camera.settings.shape.x);
CHECK(cur->shape.dims.height ==
props.video[0].camera.settings.shape.y);
++nframes;
}
{
uint32_t n = consumed_bytes(beg, end);
uint32_t n = (uint32_t)consumed_bytes(beg, end);
OK(acquire_unmap_read(runtime, 0, n));
if (n)
LOG("stream %d consumed bytes %d", 0, n);
Expand All @@ -132,15 +139,31 @@ main()
0,
nframes,
-1e-3 * clock_toc_ms(&clock));

if (acquire_get_state(runtime) != DeviceState_Running)
break;
}

do {
OK(acquire_map_read(runtime, 0, &beg, &end));
for (cur = beg; cur < end; cur = next(cur)) {
LOG("[Flush] stream %d counting frame w id %d", 0, cur->frame_id);
CHECK(cur->shape.dims.width ==
props.video[0].camera.settings.shape.x);
CHECK(cur->shape.dims.height ==
props.video[0].camera.settings.shape.y);
++nframes;
}
{
uint32_t n = (uint32_t) consumed_bytes(beg, end);
OK(acquire_unmap_read(runtime, 0, n));
if (n)
LOG("[Flush] stream %d consumed bytes %d", 0, n);
}
} while (beg != end);

CHECK(nframes == props.video[0].max_frame_count);
}

OK(acquire_stop(runtime));

OK(acquire_abort(runtime));
OK(acquire_shutdown(runtime));
return 0;
} catch (const std::runtime_error& e) {
Expand Down

0 comments on commit 5348277

Please sign in to comment.