+ +
2da5fe7 OpenAVX v0.2.0 - High-performance open-standard IP audio and video transport suite
saifmukhtar · 2026-11-24
main
| 1 | /* |
| 2 | * SPDX-License-Identifier: AGPL-3.0-or-later WITH Classpath-exception-2.0 |
| 3 | * Copyright (c) 2026 Saif Mukhtar |
| 4 | * |
| 5 | * OpenAVX - Open Audio-Video eXchange |
| 6 | * test/openavx_test.c - Basic Smoke & Integrity Test |
| 7 | */ |
| 8 | |
| 9 | #include "openavx.h" |
| 10 | #include <stdio.h> |
| 11 | #include <stdlib.h> |
| 12 | #include <assert.h> |
| 13 | |
| 14 | int main(void) { |
| 15 | printf("==========================================\n"); |
| 16 | printf(" OpenAVX Native Foundation Test (oavx_*)\n"); |
| 17 | printf("==========================================\n\n"); |
| 18 | |
| 19 | printf("[*] 1. Initializing OpenAVX Context Engine...\n"); |
| 20 | oavx_context_t *ctx = oavx_context_create(); |
| 21 | assert(ctx != NULL); |
| 22 | printf("[+] oavx_context_create succeeded: %p\n", (void*)ctx); |
| 23 | |
| 24 | printf("[*] 2. Querying version and CPU support...\n"); |
| 25 | const char* version = oavx_version(); |
| 26 | printf("[+] oavx_version: %s\n", version); |
| 27 | assert(version != NULL); |
| 28 | |
| 29 | bool cpu_ok = oavx_is_supported_cpu(); |
| 30 | printf("[+] oavx_is_supported_cpu: %s\n", cpu_ok ? "YES" : "NO"); |
| 31 | assert(cpu_ok); |
| 32 | |
| 33 | printf("[*] 3. Testing Discovery Session...\n"); |
| 34 | oavx_discovery_t *disc = oavx_discovery_create(ctx, "public"); |
| 35 | assert(disc != NULL); |
| 36 | printf("[+] Discovery instance created: %p\n", (void*)disc); |
| 37 | |
| 38 | oavx_endpoint_t sources[64]; |
| 39 | size_t num_sources = oavx_discovery_get_sources(disc, sources, 64); |
| 40 | printf("[+] Current discovered sources: %zu\n", num_sources); |
| 41 | |
| 42 | oavx_discovery_destroy(disc); |
| 43 | printf("[+] Discovery instance destroyed\n"); |
| 44 | |
| 45 | printf("[*] 4. Testing Transmit Stream...\n"); |
| 46 | oavx_stream_config_t send_settings = { |
| 47 | .name = "OpenAVX (Test Channel)", |
| 48 | .groups = "public", |
| 49 | .direction = OAVX_DIR_TRANSMIT, |
| 50 | .clock_sync = true |
| 51 | }; |
| 52 | oavx_stream_t *tx = oavx_stream_open(ctx, &send_settings); |
| 53 | assert(tx != NULL); |
| 54 | printf("[+] Transmit stream created: %p\n", (void*)tx); |
| 55 | |
| 56 | oavx_tally_t tally = {0}; |
| 57 | bool tally_ok = oavx_stream_get_tally(tx, &tally, 100); |
| 58 | assert(tally_ok); |
| 59 | printf("[+] Stream tally queried: flags=0x%x (program=%d, preview=%d)\n", |
| 60 | tally.flags, (tally.flags & OAVX_TALLY_PROGRAM) != 0, (tally.flags & OAVX_TALLY_PREVIEW) != 0); |
| 61 | |
| 62 | oavx_stream_close(tx); |
| 63 | printf("[+] Transmit stream closed\n"); |
| 64 | |
| 65 | printf("[*] 5. Testing Receive Stream...\n"); |
| 66 | oavx_stream_config_t recv_settings = { |
| 67 | .name = "OpenAVX (Receiver Test)", |
| 68 | .endpoint = "127.0.0.1:7960", |
| 69 | .direction = OAVX_DIR_RECEIVE, |
| 70 | .color_format = OAVX_COLOR_FORMAT_BGRX_BGRA, |
| 71 | .bandwidth = OAVX_BANDWIDTH_HIGHEST, |
| 72 | .clock_sync = false |
| 73 | }; |
| 74 | oavx_stream_t *rx = oavx_stream_open(ctx, &recv_settings); |
| 75 | assert(rx != NULL); |
| 76 | printf("[+] Receive stream created: %p\n", (void*)rx); |
| 77 | |
| 78 | oavx_stream_close(rx); |
| 79 | printf("[+] Receive stream closed\n"); |
| 80 | |
| 81 | printf("[*] 6. Destroying OpenAVX context engine...\n"); |
| 82 | oavx_context_destroy(ctx); |
| 83 | printf("[+] oavx_context_destroy completed cleanly!\n"); |
| 84 | |
| 85 | printf("\n[PASS] openavx_test\n"); |
| 86 | return 0; |
| 87 | } |