VirtualBox

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

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

Audio/ValKit: Use different ATS TCP/IP ports for each use case so that's easier to follow what is what. bugref:10008

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 6.8 KB
Line 
1/* $Id: AudioTestService.h 90768 2021-08-20 18:15:49Z 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 * Begins a test set. Optional.
56 *
57 * @returns VBox status code.
58 * @param pvUser User-supplied pointer to context data. Optional.
59 * @param pszTag Tag of test set to begin.
60 */
61 DECLR3CALLBACKMEMBER(int, pfnTestSetBegin, (void const *pvUser, const char *pszTag));
62
63 /**
64 * Ends the current test set. Optional.
65 *
66 * @returns VBox status code.
67 * @param pvUser User-supplied pointer to context data. Optional.
68 * @param pszTag Tag of test set to end.
69 */
70 DECLR3CALLBACKMEMBER(int, pfnTestSetEnd, (void const *pvUser, const char *pszTag));
71
72 /**
73 * Marks the begin of sending a test set. Optional.
74 *
75 * @returns VBox status code.
76 * @param pvUser User-supplied pointer to context data. Optional.
77 * @param pszTag Tag of test set to begin sending.
78 */
79 DECLR3CALLBACKMEMBER(int, pfnTestSetSendBegin, (void const *pvUser, const char *pszTag));
80
81 /**
82 * Reads data from a test set for sending it.
83 *
84 * @returns VBox status code.
85 * @param pvUser User-supplied pointer to context data. Optional.
86 * @param pszTag Tag of test set to begin sending.
87 * @param pvBuf Where to store the read test set data.
88 * @param cbBuf Size of \a pvBuf (in bytes).
89 * @param pcbRead Where to return the amount of read data in bytes. Optional and can be NULL.
90 */
91 DECLR3CALLBACKMEMBER(int, pfnTestSetSendRead, (void const *pvUser, const char *pszTag, void *pvBuf, size_t cbBuf, size_t *pcbRead));
92
93 /**
94 * Marks the end of sending a test set. Optional.
95 *
96 * @returns VBox status code.
97 * @param pvUser User-supplied pointer to context data. Optional.
98 * @param pszTag Tag of test set to end sending.
99 */
100 DECLR3CALLBACKMEMBER(int, pfnTestSetSendEnd, (void const *pvUser, const char *pszTag));
101
102 /**
103 * Plays a test tone.
104 *
105 * @returns VBox status code.
106 * @param pvUser User-supplied pointer to context data. Optional.
107 * @param pToneParms Tone parameters to use for playback.
108 */
109 DECLR3CALLBACKMEMBER(int, pfnTonePlay, (void const *pvUser, PAUDIOTESTTONEPARMS pToneParms));
110
111 /**
112 * Records a test tone.
113 *
114 * @returns VBox status code.
115 * @param pvUser User-supplied pointer to context data. Optional.
116 * @param pToneParms Tone parameters to use for recording.
117 */
118 DECLR3CALLBACKMEMBER(int, pfnToneRecord, (void const *pvUser, PAUDIOTESTTONEPARMS pToneParms));
119
120 /** Pointer to opaque user-provided context data. */
121 void const *pvUser;
122} ATSCALLBACKS;
123/** Pointer to a const ATS callbacks table. */
124typedef const struct ATSCALLBACKS *PCATSCALLBACKS;
125
126/**
127 * Structure for keeping an Audio Test Service (ATS) instance.
128 */
129typedef struct ATSSERVER
130{
131 /** Pointer to the selected transport layer. */
132 PCATSTRANSPORT pTransport;
133 /** Pointer to the transport instance. */
134 PATSTRANSPORTINST pTransportInst;
135 /** The callbacks table. */
136 ATSCALLBACKS Callbacks;
137 /** Whether server is in started state or not. */
138 bool volatile fStarted;
139 /** Whether to terminate or not. */
140 bool volatile fTerminate;
141 /** The main thread's poll set to handle new clients. */
142 RTPOLLSET hPollSet;
143 /** Pipe for communicating with the serving thread about new clients. - read end */
144 RTPIPE hPipeR;
145 /** Pipe for communicating with the serving thread about new clients. - write end */
146 RTPIPE hPipeW;
147 /** Main thread waiting for connections. */
148 RTTHREAD hThreadMain;
149 /** Thread serving connected clients. */
150 RTTHREAD hThreadServing;
151 /** Critical section protecting the list of new clients. */
152 RTCRITSECT CritSectClients;
153 /** List of new clients waiting to be picked up by the client worker thread. */
154 RTLISTANCHOR LstClientsNew;
155} ATSSERVER;
156/** Pointer to an Audio Test Service (ATS) instance. */
157typedef ATSSERVER *PATSSERVER;
158
159int AudioTestSvcCreate(PATSSERVER pThis);
160int AudioTestSvcInit(PATSSERVER pThis, PCATSCALLBACKS pCallbacks);
161int AudioTestSvcDestroy(PATSSERVER pThis);
162int AudioTestSvcHandleOption(PATSSERVER pThis, int ch, PCRTGETOPTUNION pVal);
163int AudioTestSvcStart(PATSSERVER pThis);
164int AudioTestSvcShutdown(PATSSERVER pThis);
165
166/** TCP/IP options for the ATS server.
167 * @todo Make this more abstract later. */
168enum ATSTCPOPT
169{
170 ATSTCPOPT_MODE = 5000,
171 ATSTCPOPT_BIND_ADDRESS,
172 ATSTCPOPT_BIND_PORT,
173 ATSTCPOPT_CONNECT_ADDRESS,
174 ATSTCPOPT_CONNECT_PORT
175};
176
177#endif /* !VBOX_INCLUDED_SRC_Audio_AudioTestService_h */
178
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use