VirtualBox

source: vbox/trunk/src/VBox/Devices/Audio/AudioTestServiceInternal.h@ 91024

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

Audio/Validation Kit: Trying to resolve the connection issues by checking whether clients were connected in reverse mode or not. This would otherwise end up in connecting more and more clients without any real use. See comments. ​bugref:10008

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 10.0 KB
Line 
1/* $Id: AudioTestServiceInternal.h 91024 2021-08-31 09:56:26Z vboxsync $ */
2/** @file
3 * AudioTestService - Audio test execution server, Internal 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_AudioTestServiceInternal_h
19#define VBOX_INCLUDED_SRC_Audio_AudioTestServiceInternal_h
20#ifndef RT_WITHOUT_PRAGMA_ONCE
21# pragma once
22#endif
23
24#include <iprt/getopt.h>
25#include <iprt/stream.h>
26
27#include "AudioTestServiceProtocol.h"
28
29RT_C_DECLS_BEGIN
30
31/** Opaque ATS transport layer specific client data. */
32typedef struct ATSTRANSPORTCLIENT *PATSTRANSPORTCLIENT;
33typedef PATSTRANSPORTCLIENT *PPATSTRANSPORTCLIENT;
34
35/** Opaque ATS transport specific instance data. */
36typedef struct ATSTRANSPORTINST *PATSTRANSPORTINST;
37typedef PATSTRANSPORTINST *PPATSTRANSPORTINST;
38
39/**
40 * Transport layer descriptor.
41 */
42typedef struct ATSTRANSPORT
43{
44 /** The name. */
45 char szName[16];
46 /** The description. */
47 const char *pszDesc;
48 /** Pointer to an array of options. */
49 PCRTGETOPTDEF paOpts;
50 /** The number of options in the array. */
51 size_t cOpts;
52
53 /**
54 * Print the usage information for this transport layer.
55 *
56 * @param pStream The stream to print the usage info to.
57 *
58 * @remarks This is only required if TXSTRANSPORT::cOpts is greater than 0.
59 */
60 DECLR3CALLBACKMEMBER(void, pfnUsage,(PRTSTREAM pStream));
61
62 /**
63 * Creates a transport instance.
64 *
65 * @returns IPRT status code. On errors, the transport layer shall call
66 * RTMsgError to display the error details to the user.
67 * @param ppThis Where to return the created transport instance on success.
68 */
69 DECLR3CALLBACKMEMBER(int, pfnCreate, (PPATSTRANSPORTINST ppThis));
70
71 /**
72 * Destroys a transport instance.
73 *
74 * On errors, the transport layer shall call RTMsgError to display the error
75 * details to the user.
76 *
77 * @returns IPRT status code. On errors, the transport layer shall call
78 * RTMsgError to display the error details to the user.
79 * @param pThis The transport instance.
80 * The pointer will be invalid on return.
81 */
82 DECLR3CALLBACKMEMBER(int, pfnDestroy, (PATSTRANSPORTINST pThis));
83
84 /**
85 * Handle an option.
86 *
87 * When encountering an options that is not part of the base options, we'll call
88 * this method for each transport layer until one handles it.
89 *
90 * @retval VINF_SUCCESS if handled.
91 * @retval VERR_TRY_AGAIN if not handled.
92 * @retval VERR_INVALID_PARAMETER if we should exit with a non-zero status.
93 *
94 * @param pThis Transport instance to set options for.
95 * @param ch The short option value.
96 * @param pVal Pointer to the value union.
97 *
98 * @remarks This is only required if TXSTRANSPORT::cOpts is greater than 0.
99 */
100 DECLR3CALLBACKMEMBER(int, pfnOption,(PATSTRANSPORTINST pThis, int ch, PCRTGETOPTUNION pVal));
101
102 /**
103 * Starts a transport instance.
104 *
105 * @returns IPRT status code. On errors, the transport layer shall call
106 * RTMsgError to display the error details to the user.
107 * @param pThis Transport instance to initialize.
108 */
109 DECLR3CALLBACKMEMBER(int, pfnStart, (PATSTRANSPORTINST pThis));
110
111 /**
112 * Terminate a transport instance, closing and freeing resources.
113 *
114 * On errors, the transport layer shall call RTMsgError to display the error
115 * details to the user.
116 *
117 * @param pThis The transport instance.
118 */
119 DECLR3CALLBACKMEMBER(void, pfnTerm, (PATSTRANSPORTINST pThis));
120
121 /**
122 * Waits for a new client to connect and returns the client specific data on
123 * success.
124 *
125 * @returns VBox status code.
126 * @param pThis The transport instance.
127 * @param msTimeout Timeout (in ms) waiting for a connection to be established.
128 * Use RT_INDEFINITE_WAIT to wait indefinitely.
129 * This might or might not be supported by the specific transport implementation.
130 * @param pfFromServer Returns \c true if the returned client is from a remote server (called a reverse connection),
131 * or \c false if not (regular client). Optional and can be NULL.
132 * @param ppClientNew Where to return the allocated client on success.
133 */
134 DECLR3CALLBACKMEMBER(int, pfnWaitForConnect, (PATSTRANSPORTINST pThis, RTMSINTERVAL msTimeout, bool *pfFromServer, PPATSTRANSPORTCLIENT ppClientNew));
135
136 /**
137 * Polls for incoming packets.
138 *
139 * @returns true if there are pending packets, false if there isn't.
140 * @param pThis The transport instance.
141 * @param pClient The client to poll for data.
142 */
143 DECLR3CALLBACKMEMBER(bool, pfnPollIn, (PATSTRANSPORTINST pThis, PATSTRANSPORTCLIENT pClient));
144
145 /**
146 * Adds any pollable handles to the poll set.
147 *
148 * @returns IPRT status code.
149 * @param pThis The transport instance.
150 * @param hPollSet The poll set to add them to.
151 * @param pClient The transport client structure.
152 * @param idStart The handle ID to start at.
153 */
154 DECLR3CALLBACKMEMBER(int, pfnPollSetAdd, (PATSTRANSPORTINST pThis, RTPOLLSET hPollSet, PATSTRANSPORTCLIENT pClient, uint32_t idStart));
155
156 /**
157 * Removes the given client frmo the given pollset.
158 *
159 * @returns IPRT status code.
160 * @param pThis The transport instance.
161 * @param hPollSet The poll set to remove from.
162 * @param pClient The transport client structure.
163 * @param idStart The handle ID to remove.
164 */
165 DECLR3CALLBACKMEMBER(int, pfnPollSetRemove, (PATSTRANSPORTINST pThis, RTPOLLSET hPollSet, PATSTRANSPORTCLIENT pClient, uint32_t idStart));
166
167 /**
168 * Receives an incoming packet.
169 *
170 * This will block until the data becomes available or we're interrupted by a
171 * signal or something.
172 *
173 * @returns IPRT status code. On error conditions other than VERR_INTERRUPTED,
174 * the current operation will be aborted when applicable. When
175 * interrupted, the transport layer will store the data until the next
176 * receive call.
177 *
178 * @param pThis The transport instance.
179 * @param pClient The transport client structure.
180 * @param ppPktHdr Where to return the pointer to the packet we've
181 * read. This is allocated from the heap using
182 * RTMemAlloc (w/ ATSPKT_ALIGNMENT) and must be
183 * free by calling RTMemFree.
184 */
185 DECLR3CALLBACKMEMBER(int, pfnRecvPkt, (PATSTRANSPORTINST pThis, PATSTRANSPORTCLIENT pClient, PPATSPKTHDR ppPktHdr));
186
187 /**
188 * Sends an outgoing packet.
189 *
190 * This will block until the data has been written.
191 *
192 * @returns IPRT status code.
193 * @retval VERR_INTERRUPTED if interrupted before anything was sent.
194 *
195 * @param pThis The transport instance.
196 * @param pClient The transport client structure.
197 * @param pPktHdr The packet to send. The size is given by
198 * aligning the size in the header by
199 * ATSPKT_ALIGNMENT.
200 */
201 DECLR3CALLBACKMEMBER(int, pfnSendPkt, (PATSTRANSPORTINST pThis, PATSTRANSPORTCLIENT pClient, PCATSPKTHDR pPktHdr));
202
203 /**
204 * Sends a babble packet and disconnects the client (if applicable).
205 *
206 * @param pThis The transport instance.
207 * @param pClient The transport client structure.
208 * @param pPktHdr The packet to send. The size is given by
209 * aligning the size in the header by
210 * ATSPKT_ALIGNMENT.
211 * @param cMsSendTimeout The send timeout measured in milliseconds.
212 */
213 DECLR3CALLBACKMEMBER(void, pfnBabble, (PATSTRANSPORTINST pThis, PATSTRANSPORTCLIENT pClient, PCATSPKTHDR pPktHdr, RTMSINTERVAL cMsSendTimeout));
214
215 /**
216 * Notification about a client HOWDY.
217 *
218 * @param pThis The transport instance.
219 * @param pClient The transport client structure.
220 */
221 DECLR3CALLBACKMEMBER(void, pfnNotifyHowdy, (PATSTRANSPORTINST pThis, PATSTRANSPORTCLIENT pClient));
222
223 /**
224 * Notification about a client BYE.
225 *
226 * For connection oriented transport layers, it would be good to disconnect the
227 * client at this point.
228 *
229 * @param pThis The transport instance.
230 * @param pClient The transport client structure.
231 */
232 DECLR3CALLBACKMEMBER(void, pfnNotifyBye, (PATSTRANSPORTINST pThis, PATSTRANSPORTCLIENT pClient));
233
234 /**
235 * Notification about a REBOOT or SHUTDOWN.
236 *
237 * For connection oriented transport layers, stop listening for and
238 * accepting at this point.
239 *
240 * @param pThis The transport instance.
241 */
242 DECLR3CALLBACKMEMBER(void, pfnNotifyReboot, (PATSTRANSPORTINST pThis));
243
244 /** Non-zero end marker. */
245 uint32_t u32EndMarker;
246} ATSTRANSPORT;
247/** Pointer to a const transport layer descriptor. */
248typedef const struct ATSTRANSPORT *PCATSTRANSPORT;
249
250
251extern ATSTRANSPORT const g_TcpTransport;
252
253RT_C_DECLS_END
254
255#endif /* !VBOX_INCLUDED_SRC_Audio_AudioTestServiceInternal_h */
256
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