VirtualBox

source: vbox/trunk/src/VBox/Devices/Audio/AudioTestServiceProtocol.h@ 90778

Last change on this file since 90778 was 89614, checked in by vboxsync, 3 years ago

Audio/ValKit: Implemented support for downloading (guest) test sets. bugref:10008

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 6.6 KB
Line 
1/* $Id: AudioTestServiceProtocol.h 89614 2021-06-11 06:34: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
31RT_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 */
43typedef 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;
53AssertCompileSize(ATSPKTHDR, 16);
54/** Pointer to a packet header. */
55typedef ATSPKTHDR *PATSPKTHDR;
56/** Pointer to a packet header. */
57typedef ATSPKTHDR const *PCATSPKTHDR;
58/** Pointer to a packet header pointer. */
59typedef 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 */
73typedef 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;
82AssertCompileSizeAlignment(ATSPKTREQHOWDY, ATSPKT_ALIGNMENT);
83/** Pointer to a HOWDY request structure. */
84typedef ATSPKTREQHOWDY *PATSPKTREQHOWDY;
85
86/**
87 * The HOWDY reply structure.
88 */
89typedef 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;
98AssertCompileSizeAlignment(ATSPKTREPHOWDY, ATSPKT_ALIGNMENT);
99/** Pointer to a HOWDY reply structure. */
100typedef 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 */
111typedef 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;
118AssertCompileSizeAlignment(ATSPKTREQTSETBEG, ATSPKT_ALIGNMENT);
119/** Pointer to a TSET BEG reply structure. */
120typedef ATSPKTREQTSETBEG *PATSPKTREQTSETBEG;
121
122#define ATSPKT_OPCODE_TESTSET_END "TSET END"
123
124/**
125 * The TSET END (test set end) request structure.
126 */
127typedef 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;
134AssertCompileSizeAlignment(ATSPKTREQTSETEND, ATSPKT_ALIGNMENT);
135/** Pointer to a TSET STA reply structure. */
136typedef ATSPKTREQTSETEND *PATSPKTREQTSETEND;
137
138#define ATSPKT_OPCODE_TESTSET_SEND "TSET SND"
139
140/**
141 * The TSET SND (test set send) request structure.
142 */
143typedef 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;
150AssertCompileSizeAlignment(ATSPKTREQTSETSND, ATSPKT_ALIGNMENT);
151/** Pointer to a ATSPKTREQTSETSND structure. */
152typedef ATSPKTREQTSETSND *PATSPKTREQTSETSND;
153
154#define ATSPKT_OPCODE_TONE_PLAY "TN PLY "
155
156/**
157 * The TN PLY (tone play) request structure.
158 */
159typedef struct ATSPKTREQTONEPLAY
160{
161 /** Embedded packet header. */
162 ATSPKTHDR Hdr;
163 /** Test tone parameters for playback. */
164 AUDIOTESTTONEPARMS ToneParms;
165 uint8_t aPadding[8];
166} ATSPKTREQTONEPLAY;
167AssertCompileSizeAlignment(ATSPKTREQTONEPLAY, ATSPKT_ALIGNMENT);
168/** Pointer to a ATSPKTREQTONEPLAY structure. */
169typedef ATSPKTREQTONEPLAY *PATSPKTREQTONEPLAY;
170
171#define ATSPKT_OPCODE_TONE_RECORD "TN REC "
172
173/**
174 * The TN REC (tone record) request structure.
175 */
176typedef struct ATSPKTREQTONEREC
177{
178 /** Embedded packet header. */
179 ATSPKTHDR Hdr;
180 /** Test tone parameters for playback. */
181 AUDIOTESTTONEPARMS ToneParms;
182 uint8_t aPadding[8];
183} ATSPKTREQTONEREC;
184AssertCompileSizeAlignment(ATSPKTREQTONEREC, ATSPKT_ALIGNMENT);
185/** Pointer to a ATSPKTREQTONEREC structure. */
186typedef ATSPKTREQTONEREC *PATSPKTREQTONEREC;
187
188/* No additional structure for the reply (just standard STATUS packet). */
189
190/**
191 * Checks if the two opcodes match.
192 *
193 * @returns true on match, false on mismatch.
194 * @param pPktHdr The packet header.
195 * @param pszOpcode2 The opcode we're comparing with. Does not have
196 * to be the whole 8 chars long.
197 */
198DECLINLINE(bool) atsIsSameOpcode(PCATSPKTHDR pPktHdr, const char *pszOpcode2)
199{
200 if (pPktHdr->achOpcode[0] != pszOpcode2[0])
201 return false;
202 if (pPktHdr->achOpcode[1] != pszOpcode2[1])
203 return false;
204
205 unsigned i = 2;
206 while ( i < RT_SIZEOFMEMB(ATSPKTHDR, achOpcode)
207 && pszOpcode2[i] != '\0')
208 {
209 if (pPktHdr->achOpcode[i] != pszOpcode2[i])
210 break;
211 i++;
212 }
213
214 if ( i < RT_SIZEOFMEMB(ATSPKTHDR, achOpcode)
215 && pszOpcode2[i] == '\0')
216 {
217 while ( i < RT_SIZEOFMEMB(ATSPKTHDR, achOpcode)
218 && pPktHdr->achOpcode[i] == ' ')
219 i++;
220 }
221
222 return i == RT_SIZEOFMEMB(ATSPKTHDR, achOpcode);
223}
224
225RT_C_DECLS_END
226
227#endif /* !VBOX_INCLUDED_SRC_Audio_AudioTestServiceProtocol_h */
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use