VirtualBox

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

Last change on this file since 89805 was 89614, checked in by vboxsync, 4 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.2 KB
Line 
1/* $Id: AudioTestService.h 89614 2021-06-11 06:34:13Z 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 "AudioTestServiceInternal.h"
25
26
27/** Default TCP/IP port the host ATS (Audio Test Service) is running on. */
28#define ATS_TCP_HOST_DEFAULT_PORT 6052
29/** Default TCP/IP address the host ATS (Audio Test Service) is running on. */
30#define ATS_TCP_HOST_DEFAULT_ADDR_STR "127.0.0.1"
31/** Default TCP/IP port the guest ATS (Audio Test Service) is running on. */
32#define ATS_TCP_GUEST_DEFAULT_PORT 6042
33
34/**
35 * Structure for keeping an Audio Test Service (ATS) callback table.
36 */
37typedef struct ATSCALLBACKS
38{
39 /**
40 * Begins a test set. Optional.
41 *
42 * @returns VBox status code.
43 * @param pvUser User-supplied pointer to context data. Optional.
44 * @param pszTag Tag of test set to begin.
45 */
46 DECLR3CALLBACKMEMBER(int, pfnTestSetBegin, (void const *pvUser, const char *pszTag));
47
48 /**
49 * Ends the current test set. Optional.
50 *
51 * @returns VBox status code.
52 * @param pvUser User-supplied pointer to context data. Optional.
53 * @param pszTag Tag of test set to end.
54 */
55 DECLR3CALLBACKMEMBER(int, pfnTestSetEnd, (void const *pvUser, const char *pszTag));
56
57 /**
58 * Marks the begin of sending a test set. Optional.
59 *
60 * @returns VBox status code.
61 * @param pvUser User-supplied pointer to context data. Optional.
62 * @param pszTag Tag of test set to begin sending.
63 */
64 DECLR3CALLBACKMEMBER(int, pfnTestSetSendBegin, (void const *pvUser, const char *pszTag));
65
66 /**
67 * Reads data from a test set for sending it.
68 *
69 * @returns VBox status code.
70 * @param pvUser User-supplied pointer to context data. Optional.
71 * @param pszTag Tag of test set to begin sending.
72 * @param pvBuf Where to store the read test set data.
73 * @param cbBuf Size of \a pvBuf (in bytes).
74 * @param pcbRead Where to return the amount of read data in bytes. Optional and can be NULL.
75 */
76 DECLR3CALLBACKMEMBER(int, pfnTestSetSendRead, (void const *pvUser, const char *pszTag, void *pvBuf, size_t cbBuf, size_t *pcbRead));
77
78 /**
79 * Marks the end of sending a test set. Optional.
80 *
81 * @returns VBox status code.
82 * @param pvUser User-supplied pointer to context data. Optional.
83 * @param pszTag Tag of test set to end sending.
84 */
85 DECLR3CALLBACKMEMBER(int, pfnTestSetSendEnd, (void const *pvUser, const char *pszTag));
86
87 /**
88 * Plays a test tone.
89 *
90 * @returns VBox status code.
91 * @param pvUser User-supplied pointer to context data. Optional.
92 * @param pToneParms Tone parameters to use for playback.
93 */
94 DECLR3CALLBACKMEMBER(int, pfnTonePlay, (void const *pvUser, PAUDIOTESTTONEPARMS pToneParms));
95
96 /**
97 * Records a test tone.
98 *
99 * @returns VBox status code.
100 * @param pvUser User-supplied pointer to context data. Optional.
101 * @param pToneParms Tone parameters to use for recording.
102 */
103 DECLR3CALLBACKMEMBER(int, pfnToneRecord, (void const *pvUser, PAUDIOTESTTONEPARMS pToneParms));
104
105 /** Pointer to opaque user-provided context data. */
106 void const *pvUser;
107} ATSCALLBACKS;
108/** Pointer to a const ATS callbacks table. */
109typedef const struct ATSCALLBACKS *PCATSCALLBACKS;
110
111/**
112 * Structure for keeping Audio Test Service (ATS) transport instance-specific data.
113 *
114 * Currently only TCP/IP is supported.
115 */
116typedef struct ATSTRANSPORTINST
117{
118 /** The addresses to bind to. Empty string means any. */
119 char szTcpBindAddr[256];
120 /** The TCP port to listen to. */
121 uint32_t uTcpBindPort;
122 /** Pointer to the TCP server instance. */
123 PRTTCPSERVER pTcpServer;
124} ATSTRANSPORTINST;
125/** Pointer to an Audio Test Service (ATS) TCP/IP transport instance. */
126typedef ATSTRANSPORTINST *PATSTRANSPORTINSTTCP;
127
128/**
129 * Structure for keeping an Audio Test Service (ATS) instance.
130 */
131typedef struct ATSSERVER
132{
133 /** The selected transport layer. */
134 PCATSTRANSPORT pTransport;
135 /** The transport instance. */
136 ATSTRANSPORTINST TransportInst;
137 /** The callbacks table. */
138 ATSCALLBACKS Callbacks;
139 /** Whether server is in started state or not. */
140 bool volatile fStarted;
141 /** Whether to terminate or not. */
142 bool volatile fTerminate;
143 /** The main thread's poll set to handle new clients. */
144 RTPOLLSET hPollSet;
145 /** Pipe for communicating with the serving thread about new clients. - read end */
146 RTPIPE hPipeR;
147 /** Pipe for communicating with the serving thread about new clients. - write end */
148 RTPIPE hPipeW;
149 /** Main thread waiting for connections. */
150 RTTHREAD hThreadMain;
151 /** Thread serving connected clients. */
152 RTTHREAD hThreadServing;
153 /** Critical section protecting the list of new clients. */
154 RTCRITSECT CritSectClients;
155 /** List of new clients waiting to be picked up by the client worker thread. */
156 RTLISTANCHOR LstClientsNew;
157} ATSSERVER;
158/** Pointer to an Audio Test Service (ATS) instance. */
159typedef ATSSERVER *PATSSERVER;
160
161int AudioTestSvcInit(PATSSERVER pThis, const char *pszBindAddr, uint32_t uBindPort, PCATSCALLBACKS pCallbacks);
162int AudioTestSvcDestroy(PATSSERVER pThis);
163int AudioTestSvcStart(PATSSERVER pThis);
164int AudioTestSvcShutdown(PATSSERVER pThis);
165
166#endif /* !VBOX_INCLUDED_SRC_Audio_AudioTestService_h */
167
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