1 | /* $Id: AudioTestServiceProtocol.h 91197 2021-09-10 10:57:13Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * AudioTestServiceProtocol - Audio test execution server, Protocol Header.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2021 Oracle Corporation
|
---|
8 | *
|
---|
9 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
10 | * available from http://www.virtualbox.org. This file is free software;
|
---|
11 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
12 | * General Public License (GPL) as published by the Free Software
|
---|
13 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
14 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
15 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
16 | */
|
---|
17 |
|
---|
18 | #ifndef VBOX_INCLUDED_SRC_Audio_AudioTestServiceProtocol_h
|
---|
19 | #define VBOX_INCLUDED_SRC_Audio_AudioTestServiceProtocol_h
|
---|
20 | #ifndef RT_WITHOUT_PRAGMA_ONCE
|
---|
21 | # pragma once
|
---|
22 | #endif
|
---|
23 |
|
---|
24 | #include <iprt/cdefs.h>
|
---|
25 | #include <iprt/list.h>
|
---|
26 |
|
---|
27 | #include <VBox/vmm/pdmaudioifs.h>
|
---|
28 |
|
---|
29 | #include "AudioTest.h"
|
---|
30 |
|
---|
31 | RT_C_DECLS_BEGIN
|
---|
32 |
|
---|
33 | /** Maximum length (in bytes) an opcode can have. */
|
---|
34 | #define ATSPKT_OPCODE_MAX_LEN 8
|
---|
35 | /** Packet alignment. */
|
---|
36 | #define ATSPKT_ALIGNMENT 16
|
---|
37 | /** Max packet size. */
|
---|
38 | #define ATSPKT_MAX_SIZE _256K
|
---|
39 |
|
---|
40 | /**
|
---|
41 | * Common Packet header (for requests and replies).
|
---|
42 | */
|
---|
43 | typedef struct ATSPKTHDR
|
---|
44 | {
|
---|
45 | /** The unpadded packet length. This include this header. */
|
---|
46 | uint32_t cb;
|
---|
47 | /** The CRC-32 for the packet starting from the opcode field. 0 if the packet
|
---|
48 | * hasn't been CRCed. */
|
---|
49 | uint32_t uCrc32;
|
---|
50 | /** Packet opcode, an unterminated ASCII string. */
|
---|
51 | uint8_t achOpcode[ATSPKT_OPCODE_MAX_LEN];
|
---|
52 | } ATSPKTHDR;
|
---|
53 | AssertCompileSize(ATSPKTHDR, 16);
|
---|
54 | /** Pointer to a packet header. */
|
---|
55 | typedef ATSPKTHDR *PATSPKTHDR;
|
---|
56 | /** Pointer to a packet header. */
|
---|
57 | typedef ATSPKTHDR const *PCATSPKTHDR;
|
---|
58 | /** Pointer to a packet header pointer. */
|
---|
59 | typedef PATSPKTHDR *PPATSPKTHDR;
|
---|
60 |
|
---|
61 | #define ATSPKT_OPCODE_HOWDY "HOWDY "
|
---|
62 |
|
---|
63 | /** 32bit protocol version consisting of a 16bit major and 16bit minor part. */
|
---|
64 | #define ATS_PROTOCOL_VS (ATS_PROTOCOL_VS_MAJOR | ATS_PROTOCOL_VS_MINOR)
|
---|
65 | /** The major version part of the protocol version. */
|
---|
66 | #define ATS_PROTOCOL_VS_MAJOR (1 << 16)
|
---|
67 | /** The minor version part of the protocol version. */
|
---|
68 | #define ATS_PROTOCOL_VS_MINOR (0)
|
---|
69 |
|
---|
70 | /**
|
---|
71 | * The HOWDY request structure.
|
---|
72 | */
|
---|
73 | typedef struct ATSPKTREQHOWDY
|
---|
74 | {
|
---|
75 | /** Embedded packet header. */
|
---|
76 | ATSPKTHDR Hdr;
|
---|
77 | /** Version of the protocol the client wants to use. */
|
---|
78 | uint32_t uVersion;
|
---|
79 | /** Alignment. */
|
---|
80 | uint8_t au8Padding[12];
|
---|
81 | } ATSPKTREQHOWDY;
|
---|
82 | AssertCompileSizeAlignment(ATSPKTREQHOWDY, ATSPKT_ALIGNMENT);
|
---|
83 | /** Pointer to a HOWDY request structure. */
|
---|
84 | typedef ATSPKTREQHOWDY *PATSPKTREQHOWDY;
|
---|
85 |
|
---|
86 | /**
|
---|
87 | * The HOWDY reply structure.
|
---|
88 | */
|
---|
89 | typedef struct ATSPKTREPHOWDY
|
---|
90 | {
|
---|
91 | /** Packet header. */
|
---|
92 | ATSPKTHDR Hdr;
|
---|
93 | /** Version to use for the established connection. */
|
---|
94 | uint32_t uVersion;
|
---|
95 | /** Padding - reserved. */
|
---|
96 | uint8_t au8Padding[12];
|
---|
97 | } ATSPKTREPHOWDY;
|
---|
98 | AssertCompileSizeAlignment(ATSPKTREPHOWDY, ATSPKT_ALIGNMENT);
|
---|
99 | /** Pointer to a HOWDY reply structure. */
|
---|
100 | typedef ATSPKTREPHOWDY *PATSPKTREPHOWDY;
|
---|
101 |
|
---|
102 | #define ATSPKT_OPCODE_BYE "BYE "
|
---|
103 |
|
---|
104 | /* No additional structures for BYE. */
|
---|
105 |
|
---|
106 | #define ATSPKT_OPCODE_TESTSET_BEGIN "TSET BEG"
|
---|
107 |
|
---|
108 | /**
|
---|
109 | * The TSET BEG (test set begin) request structure.
|
---|
110 | */
|
---|
111 | typedef struct ATSPKTREQTSETBEG
|
---|
112 | {
|
---|
113 | /** Embedded packet header. */
|
---|
114 | ATSPKTHDR Hdr;
|
---|
115 | /** Audio test set tag to use. */
|
---|
116 | char szTag[AUDIOTEST_TAG_MAX];
|
---|
117 | } ATSPKTREQTSETBEG;
|
---|
118 | AssertCompileSizeAlignment(ATSPKTREQTSETBEG, ATSPKT_ALIGNMENT);
|
---|
119 | /** Pointer to a TSET BEG reply structure. */
|
---|
120 | typedef ATSPKTREQTSETBEG *PATSPKTREQTSETBEG;
|
---|
121 |
|
---|
122 | #define ATSPKT_OPCODE_TESTSET_END "TSET END"
|
---|
123 |
|
---|
124 | /**
|
---|
125 | * The TSET END (test set end) request structure.
|
---|
126 | */
|
---|
127 | typedef struct ATSPKTREQTSETEND
|
---|
128 | {
|
---|
129 | /** Embedded packet header. */
|
---|
130 | ATSPKTHDR Hdr;
|
---|
131 | /** Audio test set tag to use. */
|
---|
132 | char szTag[AUDIOTEST_TAG_MAX];
|
---|
133 | } ATSPKTREQTSETEND;
|
---|
134 | AssertCompileSizeAlignment(ATSPKTREQTSETEND, ATSPKT_ALIGNMENT);
|
---|
135 | /** Pointer to a TSET STA reply structure. */
|
---|
136 | typedef ATSPKTREQTSETEND *PATSPKTREQTSETEND;
|
---|
137 |
|
---|
138 | #define ATSPKT_OPCODE_TESTSET_SEND "TSET SND"
|
---|
139 |
|
---|
140 | /**
|
---|
141 | * The TSET SND (test set send) request structure.
|
---|
142 | */
|
---|
143 | typedef struct ATSPKTREQTSETSND
|
---|
144 | {
|
---|
145 | /** Embedded packet header. */
|
---|
146 | ATSPKTHDR Hdr;
|
---|
147 | /** Audio test set tag to use. */
|
---|
148 | char szTag[AUDIOTEST_TAG_MAX];
|
---|
149 | } ATSPKTREQTSETSND;
|
---|
150 | AssertCompileSizeAlignment(ATSPKTREQTSETSND, ATSPKT_ALIGNMENT);
|
---|
151 | /** Pointer to a ATSPKTREQTSETSND structure. */
|
---|
152 | typedef ATSPKTREQTSETSND *PATSPKTREQTSETSND;
|
---|
153 |
|
---|
154 | #define ATSPKT_OPCODE_TONE_PLAY "TN PLY "
|
---|
155 |
|
---|
156 | /**
|
---|
157 | * The TN PLY (tone play) request structure.
|
---|
158 | */
|
---|
159 | typedef struct ATSPKTREQTONEPLAY
|
---|
160 | {
|
---|
161 | /** Embedded packet header. */
|
---|
162 | ATSPKTHDR Hdr;
|
---|
163 | /** Test tone parameters for playback. */
|
---|
164 | AUDIOTESTTONEPARMS ToneParms;
|
---|
165 | #if ARCH_BITS == 64
|
---|
166 | uint8_t aPadding[8];
|
---|
167 | #else
|
---|
168 | # ifdef RT_OS_WINDOWS
|
---|
169 | uint8_t aPadding[4];
|
---|
170 | # else
|
---|
171 | uint8_t aPadding[12];
|
---|
172 | # endif
|
---|
173 | #endif
|
---|
174 | } ATSPKTREQTONEPLAY;
|
---|
175 | AssertCompileSizeAlignment(ATSPKTREQTONEPLAY, ATSPKT_ALIGNMENT);
|
---|
176 | /** Pointer to a ATSPKTREQTONEPLAY structure. */
|
---|
177 | typedef ATSPKTREQTONEPLAY *PATSPKTREQTONEPLAY;
|
---|
178 |
|
---|
179 | #define ATSPKT_OPCODE_TONE_RECORD "TN REC "
|
---|
180 |
|
---|
181 | /**
|
---|
182 | * The TN REC (tone record) request structure.
|
---|
183 | */
|
---|
184 | typedef struct ATSPKTREQTONEREC
|
---|
185 | {
|
---|
186 | /** Embedded packet header. */
|
---|
187 | ATSPKTHDR Hdr;
|
---|
188 | /** Test tone parameters for playback. */
|
---|
189 | AUDIOTESTTONEPARMS ToneParms;
|
---|
190 | #if ARCH_BITS == 64
|
---|
191 | uint8_t aPadding[8];
|
---|
192 | #else
|
---|
193 | # ifdef RT_OS_WINDOWS
|
---|
194 | uint8_t aPadding[4];
|
---|
195 | # else
|
---|
196 | uint8_t aPadding[12];
|
---|
197 | # endif
|
---|
198 | #endif
|
---|
199 | } ATSPKTREQTONEREC;
|
---|
200 | AssertCompileSizeAlignment(ATSPKTREQTONEREC, ATSPKT_ALIGNMENT);
|
---|
201 | /** Pointer to a ATSPKTREQTONEREC structure. */
|
---|
202 | typedef ATSPKTREQTONEREC *PATSPKTREQTONEREC;
|
---|
203 |
|
---|
204 | /* No additional structure for the reply (just standard STATUS packet). */
|
---|
205 |
|
---|
206 | /**
|
---|
207 | * The failure reply structure.
|
---|
208 | */
|
---|
209 | typedef struct ATSPKTREPFAIL
|
---|
210 | {
|
---|
211 | /** Embedded packet header. */
|
---|
212 | ATSPKTHDR Hdr;
|
---|
213 | /** Error code (IPRT-style). */
|
---|
214 | int rc;
|
---|
215 | /** Error description. */
|
---|
216 | char ach[256];
|
---|
217 | } ATSPKTREPFAIL;
|
---|
218 | /** Pointer to a ATSPKTREPFAIL structure. */
|
---|
219 | typedef ATSPKTREPFAIL *PATSPKTREPFAIL;
|
---|
220 |
|
---|
221 | /**
|
---|
222 | * Checks if the two opcodes match.
|
---|
223 | *
|
---|
224 | * @returns true on match, false on mismatch.
|
---|
225 | * @param pPktHdr The packet header.
|
---|
226 | * @param pszOpcode2 The opcode we're comparing with. Does not have
|
---|
227 | * to be the whole 8 chars long.
|
---|
228 | */
|
---|
229 | DECLINLINE(bool) atsIsSameOpcode(PCATSPKTHDR pPktHdr, const char *pszOpcode2)
|
---|
230 | {
|
---|
231 | if (pPktHdr->achOpcode[0] != pszOpcode2[0])
|
---|
232 | return false;
|
---|
233 | if (pPktHdr->achOpcode[1] != pszOpcode2[1])
|
---|
234 | return false;
|
---|
235 |
|
---|
236 | unsigned i = 2;
|
---|
237 | while ( i < RT_SIZEOFMEMB(ATSPKTHDR, achOpcode)
|
---|
238 | && pszOpcode2[i] != '\0')
|
---|
239 | {
|
---|
240 | if (pPktHdr->achOpcode[i] != pszOpcode2[i])
|
---|
241 | break;
|
---|
242 | i++;
|
---|
243 | }
|
---|
244 |
|
---|
245 | if ( i < RT_SIZEOFMEMB(ATSPKTHDR, achOpcode)
|
---|
246 | && pszOpcode2[i] == '\0')
|
---|
247 | {
|
---|
248 | while ( i < RT_SIZEOFMEMB(ATSPKTHDR, achOpcode)
|
---|
249 | && pPktHdr->achOpcode[i] == ' ')
|
---|
250 | i++;
|
---|
251 | }
|
---|
252 |
|
---|
253 | return i == RT_SIZEOFMEMB(ATSPKTHDR, achOpcode);
|
---|
254 | }
|
---|
255 |
|
---|
256 | RT_C_DECLS_END
|
---|
257 |
|
---|
258 | #endif /* !VBOX_INCLUDED_SRC_Audio_AudioTestServiceProtocol_h */
|
---|