VirtualBox

source: vbox/trunk/src/VBox/Devices/Audio/AudioTestService.h@ 92208

Last change on this file since 92208 was 90918, checked in by vboxsync, 3 years ago

Audio/Validation Kit: Simplified ATS init / destruction handling. bugref:10008

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 7.7 KB
Line 
1/* $Id: AudioTestService.h 90918 2021-08-26 15:29:25Z vboxsync $ */
2/** @file
3 * AudioTestService - Audio test execution server, Public 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_AudioTestService_h
19#define VBOX_INCLUDED_SRC_Audio_AudioTestService_h
20#ifndef RT_WITHOUT_PRAGMA_ONCE
21# pragma once
22#endif
23
24#include <iprt/tcp.h>
25
26#include "AudioTestServiceInternal.h"
27
28extern const PCATSTRANSPORT g_apTransports[];
29extern const size_t g_cTransports;
30
31/** Default TCP/IP bind port the guest ATS (Audio Test Service) is listening on. */
32#define ATS_TCP_DEF_BIND_PORT_GUEST 6042
33/** Default TCP/IP bind port the host ATS is listening on. */
34#define ATS_TCP_DEF_BIND_PORT_HOST 6052
35/** Default TCP/IP ATS bind port the ValidationKit Audio Driver ATS is listening on. */
36#define ATS_TCP_DEF_BIND_PORT_VALKIT 6062
37/** Default TCP/IP port the guest ATS is connecting to. */
38#define ATS_TCP_DEF_CONNECT_PORT_GUEST ATS_TCP_DEF_BIND_PORT_HOST
39/** Default TCP/IP port the host ATS is connecting to the guest (needs NAT port forwarding). */
40#define ATS_TCP_DEF_CONNECT_PORT_HOST_PORT_FWD 6072
41/** Default TCP/IP port the host ATS is connecting to. */
42#define ATS_TCP_DEF_CONNECT_PORT_VALKIT ATS_TCP_DEF_BIND_PORT_VALKIT
43/** Default TCP/IP address the host is connecting to. */
44#define ATS_TCP_DEF_CONNECT_HOST_ADDR_STR "127.0.0.1"
45/** Default TCP/IP address the guest ATS connects to when
46 * running in client mode (reversed mode, needed for NATed VMs). */
47#define ATS_TCP_DEF_CONNECT_GUEST_STR "10.0.2.2"
48
49/**
50 * Structure for keeping an Audio Test Service (ATS) callback table.
51 */
52typedef struct ATSCALLBACKS
53{
54 /**
55 * Tells the implementation that a new client connected. Optional.
56 *
57 * @param pvUser User-supplied pointer to context data. Optional.
58 */
59 DECLR3CALLBACKMEMBER(int, pfnHowdy, (void const *pvUser));
60
61 /**
62 * Tells the implementation that a client disconnected. Optional.
63 *
64 * @param pvUser User-supplied pointer to context data. Optional.
65 */
66 DECLR3CALLBACKMEMBER(int, pfnBye, (void const *pvUser));
67
68 /**
69 * Begins a test set. Optional.
70 *
71 * @returns VBox status code.
72 * @param pvUser User-supplied pointer to context data. Optional.
73 * @param pszTag Tag of test set to begin.
74 */
75 DECLR3CALLBACKMEMBER(int, pfnTestSetBegin, (void const *pvUser, const char *pszTag));
76
77 /**
78 * Ends the current test set. Optional.
79 *
80 * @returns VBox status code.
81 * @param pvUser User-supplied pointer to context data. Optional.
82 * @param pszTag Tag of test set to end.
83 */
84 DECLR3CALLBACKMEMBER(int, pfnTestSetEnd, (void const *pvUser, const char *pszTag));
85
86 /**
87 * Marks the begin of sending a test set. Optional.
88 *
89 * @returns VBox status code.
90 * @param pvUser User-supplied pointer to context data. Optional.
91 * @param pszTag Tag of test set to begin sending.
92 */
93 DECLR3CALLBACKMEMBER(int, pfnTestSetSendBegin, (void const *pvUser, const char *pszTag));
94
95 /**
96 * Reads data from a test set for sending it.
97 *
98 * @returns VBox status code.
99 * @param pvUser User-supplied pointer to context data. Optional.
100 * @param pszTag Tag of test set to begin sending.
101 * @param pvBuf Where to store the read test set data.
102 * @param cbBuf Size of \a pvBuf (in bytes).
103 * @param pcbRead Where to return the amount of read data in bytes. Optional and can be NULL.
104 */
105 DECLR3CALLBACKMEMBER(int, pfnTestSetSendRead, (void const *pvUser, const char *pszTag, void *pvBuf, size_t cbBuf, size_t *pcbRead));
106
107 /**
108 * Marks the end of sending a test set. Optional.
109 *
110 * @returns VBox status code.
111 * @param pvUser User-supplied pointer to context data. Optional.
112 * @param pszTag Tag of test set to end sending.
113 */
114 DECLR3CALLBACKMEMBER(int, pfnTestSetSendEnd, (void const *pvUser, const char *pszTag));
115
116 /**
117 * Plays a test tone.
118 *
119 * @returns VBox status code.
120 * @param pvUser User-supplied pointer to context data. Optional.
121 * @param pToneParms Tone parameters to use for playback.
122 */
123 DECLR3CALLBACKMEMBER(int, pfnTonePlay, (void const *pvUser, PAUDIOTESTTONEPARMS pToneParms));
124
125 /**
126 * Records a test tone.
127 *
128 * @returns VBox status code.
129 * @param pvUser User-supplied pointer to context data. Optional.
130 * @param pToneParms Tone parameters to use for recording.
131 */
132 DECLR3CALLBACKMEMBER(int, pfnToneRecord, (void const *pvUser, PAUDIOTESTTONEPARMS pToneParms));
133
134 /** Pointer to opaque user-provided context data. */
135 void const *pvUser;
136} ATSCALLBACKS;
137/** Pointer to a const ATS callbacks table. */
138typedef const struct ATSCALLBACKS *PCATSCALLBACKS;
139
140/**
141 * Structure for keeping an Audio Test Service (ATS) instance.
142 */
143typedef struct ATSSERVER
144{
145 /** Pointer to the selected transport layer. */
146 PCATSTRANSPORT pTransport;
147 /** Pointer to the transport instance. */
148 PATSTRANSPORTINST pTransportInst;
149 /** The callbacks table. */
150 ATSCALLBACKS Callbacks;
151 /** Whether server is in started state or not. */
152 bool volatile fStarted;
153 /** Whether to terminate or not. */
154 bool volatile fTerminate;
155 /** The main thread's poll set to handle new clients. */
156 RTPOLLSET hPollSet;
157 /** Pipe for communicating with the serving thread about new clients. - read end */
158 RTPIPE hPipeR;
159 /** Pipe for communicating with the serving thread about new clients. - write end */
160 RTPIPE hPipeW;
161 /** Main thread waiting for connections. */
162 RTTHREAD hThreadMain;
163 /** Thread serving connected clients. */
164 RTTHREAD hThreadServing;
165 /** Critical section protecting the list of new clients. */
166 RTCRITSECT CritSectClients;
167 /** List of new clients waiting to be picked up by the client worker thread. */
168 RTLISTANCHOR LstClientsNew;
169} ATSSERVER;
170/** Pointer to an Audio Test Service (ATS) instance. */
171typedef ATSSERVER *PATSSERVER;
172
173int AudioTestSvcInit(PATSSERVER pThis, PCATSCALLBACKS pCallbacks);
174int AudioTestSvcDestroy(PATSSERVER pThis);
175int AudioTestSvcHandleOption(PATSSERVER pThis, int ch, PCRTGETOPTUNION pVal);
176int AudioTestSvcStart(PATSSERVER pThis);
177int AudioTestSvcStop(PATSSERVER pThis);
178
179/**
180 * Enumeration for the server connection mode.
181 * Only applies to certain transport implementation like TCP/IP.
182 */
183typedef enum ATSCONNMODE
184{
185 /** Both: Uses parallel client and server connection methods (via threads). */
186 ATSCONNMODE_BOTH = 0,
187 /** Client only: Connects to a server. */
188 ATSCONNMODE_CLIENT,
189 /** Server only: Listens for new incoming client connections. */
190 ATSCONNMODE_SERVER,
191 /** 32bit hack. */
192 ATSCONNMODE_32BIT_HACK = 0x7fffffff
193} ATSCONNMODE;
194
195/** TCP/IP options for the ATS server.
196 * @todo Make this more abstract later. */
197enum ATSTCPOPT
198{
199 ATSTCPOPT_CONN_MODE = 5000,
200 ATSTCPOPT_BIND_ADDRESS,
201 ATSTCPOPT_BIND_PORT,
202 ATSTCPOPT_CONNECT_ADDRESS,
203 ATSTCPOPT_CONNECT_PORT
204};
205
206#endif /* !VBOX_INCLUDED_SRC_Audio_AudioTestService_h */
207
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette