Raw ↗
+ +
2da5fe7 OpenAVX v0.2.0 - High-performance open-standard IP audio and video transport suite
saifmukhtar · 2026-11-24
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 * include/avx_wire.h - Wire protocol framing and profile definitions
7 */
8  
9 #ifndef AVX_WIRE_H
10 #define AVX_WIRE_H
11  
12 #include <stdint.h>
13 #include <stdbool.h>
14 #include <stddef.h>
15 #include "openavx.h"
16  
17 #ifdef __cplusplus
18 extern "C" {
19 #endif
20  
21 /* Native OpenAVX Protocol Defaults */
22 #define OAVX_WIRE_MAGIC_VIDEO 0x56585641 /* 'AVXV' */
23 #define OAVX_WIRE_MAGIC_AUDIO 0x41585641 /* 'AVXA' */
24 #define OAVX_WIRE_MAGIC_AUDIO_COMP 0x4F585641 /* 'AVXO' */
25 #define OAVX_WIRE_MAGIC_METADATA 0x4D585641 /* 'AVXM' */
26 #define OAVX_WIRE_MAGIC_UDP 0x55585641 /* 'AVXU' */
27 #define OAVX_WIRE_DEFAULT_PORT 7960
28 #define OAVX_WIRE_MDNS_SERVICE "_openavx._tcp.local"
29 #define OAVX_WIRE_HANDSHAKE_TAG "oavx_stream"
30 #define OAVX_WIRE_TALLY_TAG "oavx_tally"
31 #define OAVX_WIRE_COLOR_INFO_TAG "oavx_color_info"
32 #define OAVX_WIRE_PTZ_TAG "oavx_ptz"
33 #define OAVX_WIRE_RECORD_TAG "oavx_record"
34  
35 #ifndef OAVX_WIRE_PROFILE_DEFINED
36 #define OAVX_WIRE_PROFILE_DEFINED
37 typedef struct oavx_wire_profile {
38 uint32_t magic_video;
39 uint32_t magic_audio;
40 uint32_t magic_metadata;
41 uint32_t magic_udp;
42 uint32_t compat_magic_video;
43 uint32_t compat_magic_audio;
44 uint32_t compat_magic_metadata;
45 uint32_t compat_magic_udp;
46 uint16_t base_port;
47 const char* mdns_service;
48 const char* handshake_tag;
49 const char* tally_tag;
50 const char* color_info_tag;
51 const char* ptz_tag;
52 const char* record_tag;
53 } oavx_wire_profile_t;
54 #endif
55  
56 /* Return pointer to default native OpenAVX profile */
57 OPENAVX_API const oavx_wire_profile_t* avx_wire_get_default_profile(void);
58  
59 /* Return pointer to active profile (process-wide fallback) */
60 OPENAVX_API const oavx_wire_profile_t* avx_wire_get_active_profile(void);
61  
62 /* Set process-wide active wire profile (e.g. called by compatibility layer) */
63 OPENAVX_API void avx_wire_set_active_profile(const oavx_wire_profile_t* profile);
64  
65 /* Encode a DNS-SD service string (e.g. "_openavx._tcp.local") into DNS label wire format */
66 OPENAVX_API size_t avx_wire_encode_dns_service(const char* service_str, uint8_t* out_buf, size_t max_len);
67  
68 /* Scan packet for matching DNS service label sequence */
69 OPENAVX_API bool avx_wire_match_service(const uint8_t* pkt, size_t pkt_len, const char* service_str, size_t* out_offset);
70  
71 #ifdef __cplusplus
72 }
73 #endif
74  
75 #endif /* AVX_WIRE_H */