/* v0.4 smoke test publisher — NV12 1920x1080 ring 4, fill каждый slot * с pattern (i % 256), publish, infinite loop. */ #include #include #include #include #include #include int main(int argc, char **argv) { const char *key = argc > 1 ? argv[1] : "smoke"; cuframes_publisher_config_t cfg = {0}; cfg.key = key; cfg.width = 1920; cfg.height = 1080; cfg.format = CUFRAMES_FORMAT_NV12; cfg.ownership = CUFRAMES_OWNERSHIP_LIBRARY; cfg.ring_size = 4; cfg.policy = CUFRAMES_POLICY_DROP_OLDEST; cfg.cuda_device = 0; cuframes_publisher_t *pub = NULL; int r = cuframes_publisher_create(&cfg, &pub); if (r != CUFRAMES_OK) { fprintf(stderr, "publisher create failed: %d (%s)\n", r, cuframes_strerror(r)); return 1; } fprintf(stderr, "publisher 'cuframes-%s' ready (v0.4 VMM)\n", key); cudaStream_t stream; cudaStreamCreate(&stream); int i = 0; while (1) { void *ptr = NULL; r = cuframes_publisher_acquire(pub, &ptr); if (r != CUFRAMES_OK) { fprintf(stderr, "acquire: %d\n", r); break; } uint8_t pattern = (uint8_t)(i & 0xFF); cudaMemsetAsync(ptr, pattern, 1920 * 1080 * 3 / 2, stream); r = cuframes_publisher_publish(pub, stream, (int64_t)cuframes_now_ns()); if (r != CUFRAMES_OK) { fprintf(stderr, "publish: %d\n", r); break; } i++; if (i % 50 == 0) fprintf(stderr, "published %d frames\n", i); struct timespec ts = {.tv_sec = 0, .tv_nsec = 40000000}; /* 25 fps */ nanosleep(&ts, NULL); } cudaStreamDestroy(stream); cuframes_publisher_destroy(pub); return 0; }