1 | /* $Id: AudioTestServiceInternal.h 89541 2021-06-07 09:26:07Z 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 |
|
---|
29 | RT_C_DECLS_BEGIN
|
---|
30 |
|
---|
31 | /** Opaque ATS transport layer specific client data. */
|
---|
32 | typedef struct ATSTRANSPORTCLIENT *PATSTRANSPORTCLIENT;
|
---|
33 | typedef PATSTRANSPORTCLIENT *PPATSTRANSPORTCLIENT;
|
---|
34 |
|
---|
35 | /** Opaque ATS transport specific instance data. */
|
---|
36 | typedef struct ATSTRANSPORTINST *PATSTRANSPORTINST;
|
---|
37 | typedef PATSTRANSPORTINST *PPATSTRANSPORTINST;
|
---|
38 |
|
---|
39 | /**
|
---|
40 | * Transport layer descriptor.
|
---|
41 | */
|
---|
42 | typedef struct ATSTRANSPORT
|
---|
43 | {
|
---|
44 | /** The name. */
|
---|
45 | char szName[16];
|
---|
46 | /** The description. */
|
---|
47 | const char *pszDesc;
|
---|
48 |
|
---|
49 | /**
|
---|
50 | * Initializes the transport layer.
|
---|
51 | *
|
---|
52 | * @returns IPRT status code. On errors, the transport layer shall call
|
---|
53 | * RTMsgError to display the error details to the user.
|
---|
54 | * @param pThis The transport instance.
|
---|
55 | * @param pszBindAddr Bind address. Empty means any address.
|
---|
56 | * @param uBindPort Bind port. If set to 0, ATS_DEFAULT_PORT is being used.
|
---|
57 | */
|
---|
58 | DECLR3CALLBACKMEMBER(int, pfnInit, (PATSTRANSPORTINST pThis, const char *pszBindAddr, uint32_t uBindPort));
|
---|
59 |
|
---|
60 | /**
|
---|
61 | * Terminate the transport layer, closing and freeing resources.
|
---|
62 | *
|
---|
63 | * On errors, the transport layer shall call RTMsgError to display the error
|
---|
64 | * details to the user.
|
---|
65 | *
|
---|
66 | * @param pThis The transport instance.
|
---|
67 | */
|
---|
68 | DECLR3CALLBACKMEMBER(void, pfnTerm, (PATSTRANSPORTINST pThis));
|
---|
69 |
|
---|
70 | /**
|
---|
71 | * Waits for a new client to connect and returns the client specific data on
|
---|
72 | * success.
|
---|
73 | */
|
---|
74 | DECLR3CALLBACKMEMBER(int, pfnWaitForConnect, (PATSTRANSPORTINST pThis, PPATSTRANSPORTCLIENT ppClientNew));
|
---|
75 |
|
---|
76 | /**
|
---|
77 | * Polls for incoming packets.
|
---|
78 | *
|
---|
79 | * @returns true if there are pending packets, false if there isn't.
|
---|
80 | * @param pThis The transport instance.
|
---|
81 | * @param pClient The client to poll for data.
|
---|
82 | */
|
---|
83 | DECLR3CALLBACKMEMBER(bool, pfnPollIn, (PATSTRANSPORTINST pThis, PATSTRANSPORTCLIENT pClient));
|
---|
84 |
|
---|
85 | /**
|
---|
86 | * Adds any pollable handles to the poll set.
|
---|
87 | *
|
---|
88 | * @returns IPRT status code.
|
---|
89 | * @param pThis The transport instance.
|
---|
90 | * @param hPollSet The poll set to add them to.
|
---|
91 | * @param pClient The transport client structure.
|
---|
92 | * @param idStart The handle ID to start at.
|
---|
93 | */
|
---|
94 | DECLR3CALLBACKMEMBER(int, pfnPollSetAdd, (PATSTRANSPORTINST pThis, RTPOLLSET hPollSet, PATSTRANSPORTCLIENT pClient, uint32_t idStart));
|
---|
95 |
|
---|
96 | /**
|
---|
97 | * Removes the given client frmo the given pollset.
|
---|
98 | *
|
---|
99 | * @returns IPRT status code.
|
---|
100 | * @param pThis The transport instance.
|
---|
101 | * @param hPollSet The poll set to remove from.
|
---|
102 | * @param pClient The transport client structure.
|
---|
103 | * @param idStart The handle ID to remove.
|
---|
104 | */
|
---|
105 | DECLR3CALLBACKMEMBER(int, pfnPollSetRemove, (PATSTRANSPORTINST pThis, RTPOLLSET hPollSet, PATSTRANSPORTCLIENT pClient, uint32_t idStart));
|
---|
106 |
|
---|
107 | /**
|
---|
108 | * Receives an incoming packet.
|
---|
109 | *
|
---|
110 | * This will block until the data becomes available or we're interrupted by a
|
---|
111 | * signal or something.
|
---|
112 | *
|
---|
113 | * @returns IPRT status code. On error conditions other than VERR_INTERRUPTED,
|
---|
114 | * the current operation will be aborted when applicable. When
|
---|
115 | * interrupted, the transport layer will store the data until the next
|
---|
116 | * receive call.
|
---|
117 | *
|
---|
118 | * @param pThis The transport instance.
|
---|
119 | * @param pClient The transport client structure.
|
---|
120 | * @param ppPktHdr Where to return the pointer to the packet we've
|
---|
121 | * read. This is allocated from the heap using
|
---|
122 | * RTMemAlloc (w/ ATSPKT_ALIGNMENT) and must be
|
---|
123 | * free by calling RTMemFree.
|
---|
124 | */
|
---|
125 | DECLR3CALLBACKMEMBER(int, pfnRecvPkt, (PATSTRANSPORTINST pThis, PATSTRANSPORTCLIENT pClient, PPATSPKTHDR ppPktHdr));
|
---|
126 |
|
---|
127 | /**
|
---|
128 | * Sends an outgoing packet.
|
---|
129 | *
|
---|
130 | * This will block until the data has been written.
|
---|
131 | *
|
---|
132 | * @returns IPRT status code.
|
---|
133 | * @retval VERR_INTERRUPTED if interrupted before anything was sent.
|
---|
134 | *
|
---|
135 | * @param pThis The transport instance.
|
---|
136 | * @param pClient The transport client structure.
|
---|
137 | * @param pPktHdr The packet to send. The size is given by
|
---|
138 | * aligning the size in the header by
|
---|
139 | * ATSPKT_ALIGNMENT.
|
---|
140 | */
|
---|
141 | DECLR3CALLBACKMEMBER(int, pfnSendPkt, (PATSTRANSPORTINST pThis, PATSTRANSPORTCLIENT pClient, PCATSPKTHDR pPktHdr));
|
---|
142 |
|
---|
143 | /**
|
---|
144 | * Sends a babble packet and disconnects the client (if applicable).
|
---|
145 | *
|
---|
146 | * @param pThis The transport instance.
|
---|
147 | * @param pClient The transport client structure.
|
---|
148 | * @param pPktHdr The packet to send. The size is given by
|
---|
149 | * aligning the size in the header by
|
---|
150 | * ATSPKT_ALIGNMENT.
|
---|
151 | * @param cMsSendTimeout The send timeout measured in milliseconds.
|
---|
152 | */
|
---|
153 | DECLR3CALLBACKMEMBER(void, pfnBabble, (PATSTRANSPORTINST pThis, PATSTRANSPORTCLIENT pClient, PCATSPKTHDR pPktHdr, RTMSINTERVAL cMsSendTimeout));
|
---|
154 |
|
---|
155 | /**
|
---|
156 | * Notification about a client HOWDY.
|
---|
157 | *
|
---|
158 | * @param pThis The transport instance.
|
---|
159 | * @param pClient The transport client structure.
|
---|
160 | */
|
---|
161 | DECLR3CALLBACKMEMBER(void, pfnNotifyHowdy, (PATSTRANSPORTINST pThis, PATSTRANSPORTCLIENT pClient));
|
---|
162 |
|
---|
163 | /**
|
---|
164 | * Notification about a client BYE.
|
---|
165 | *
|
---|
166 | * For connection oriented transport layers, it would be good to disconnect the
|
---|
167 | * client at this point.
|
---|
168 | *
|
---|
169 | * @param pThis The transport instance.
|
---|
170 | * @param pClient The transport client structure.
|
---|
171 | */
|
---|
172 | DECLR3CALLBACKMEMBER(void, pfnNotifyBye, (PATSTRANSPORTINST pThis, PATSTRANSPORTCLIENT pClient));
|
---|
173 |
|
---|
174 | /**
|
---|
175 | * Notification about a REBOOT or SHUTDOWN.
|
---|
176 | *
|
---|
177 | * For connection oriented transport layers, stop listening for and
|
---|
178 | * accepting at this point.
|
---|
179 | *
|
---|
180 | * @param pThis The transport instance.
|
---|
181 | */
|
---|
182 | DECLR3CALLBACKMEMBER(void, pfnNotifyReboot, (PATSTRANSPORTINST pThis));
|
---|
183 |
|
---|
184 | /** Non-zero end marker. */
|
---|
185 | uint32_t u32EndMarker;
|
---|
186 | } ATSTRANSPORT;
|
---|
187 | /** Pointer to a const transport layer descriptor. */
|
---|
188 | typedef const struct ATSTRANSPORT *PCATSTRANSPORT;
|
---|
189 |
|
---|
190 |
|
---|
191 | extern ATSTRANSPORT const g_TcpTransport;
|
---|
192 |
|
---|
193 | RT_C_DECLS_END
|
---|
194 |
|
---|
195 | #endif /* !VBOX_INCLUDED_SRC_Audio_AudioTestServiceInternal_h */
|
---|
196 |
|
---|