diff options
author | vboxsync <vboxsync@cfe28804-0f27-0410-a406-dd0f0b0b656f> | 2021-05-19 15:05:29 +0000 |
---|---|---|
committer | vboxsync <vboxsync@cfe28804-0f27-0410-a406-dd0f0b0b656f> | 2021-05-19 15:05:29 +0000 |
commit | 7f1c879f4efed7a662dee7675cf5ddee80defe30 (patch) | |
tree | a4b87044221c7c2cef5d84c3209fb5706db49fbb /src/VBox/Devices/Audio/AudioTestServiceProtocol.h | |
parent | 4fe2f531a37b853d339d8b81a9ddb250f8ed7c4b (diff) | |
download | VirtualBox-svn-7f1c879f4efed7a662dee7675cf5ddee80defe30.tar.gz |
Audio/ValKit: Started working on the audio test execution service (ATS). bugref:10008
git-svn-id: https://www.virtualbox.org/svn/vbox/trunk@89174 cfe28804-0f27-0410-a406-dd0f0b0b656f
Diffstat (limited to 'src/VBox/Devices/Audio/AudioTestServiceProtocol.h')
-rw-r--r-- | src/VBox/Devices/Audio/AudioTestServiceProtocol.h | 222 |
1 files changed, 222 insertions, 0 deletions
diff --git a/src/VBox/Devices/Audio/AudioTestServiceProtocol.h b/src/VBox/Devices/Audio/AudioTestServiceProtocol.h new file mode 100644 index 00000000000..dd7b787163b --- /dev/null +++ b/src/VBox/Devices/Audio/AudioTestServiceProtocol.h @@ -0,0 +1,222 @@ +/* $Id$ */ +/** @file + * AudioTestServiceProtocol - Audio test execution server, Protocol Header. + */ + +/* + * Copyright (C) 2021 Oracle Corporation + * + * This file is part of VirtualBox Open Source Edition (OSE), as + * available from http://www.virtualbox.org. This file is free software; + * you can redistribute it and/or modify it under the terms of the GNU + * General Public License (GPL) as published by the Free Software + * Foundation, in version 2 as it comes in the "COPYING" file of the + * VirtualBox OSE distribution. VirtualBox OSE is distributed in the + * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind. + * + * The contents of this file may alternatively be used under the terms + * of the Common Development and Distribution License Version 1.0 + * (CDDL) only, as it comes in the "COPYING.CDDL" file of the + * VirtualBox OSE distribution, in which case the provisions of the + * CDDL are applicable instead of those of the GPL. + * + * You may elect to license modified versions of this file under the + * terms and conditions of either the GPL or the CDDL or both. + */ + +#ifndef VBOX_INCLUDED_SRC_AudioTestServiceProtocol_h +#define VBOX_INCLUDED_SRC_AudioTestServiceProtocol_h +#ifndef RT_WITHOUT_PRAGMA_ONCE +# pragma once +#endif + +#include <iprt/cdefs.h> +#include <iprt/list.h> + +#include <VBox/vmm/pdmaudioifs.h> + +#include "AudioTest.h" + +RT_C_DECLS_BEGIN + +/** + * Common Packet header (for requests and replies). + */ +typedef struct ATSPKTHDR +{ + /** The unpadded packet length. This include this header. */ + uint32_t cb; + /** The CRC-32 for the packet starting from the opcode field. 0 if the packet + * hasn't been CRCed. */ + uint32_t uCrc32; + /** Packet opcode, an unterminated ASCII string. */ + uint8_t achOpcode[8]; +} ATSPKTHDR; +AssertCompileSize(ATSPKTHDR, 16); +/** Pointer to a packet header. */ +typedef ATSPKTHDR *PATSPKTHDR; +/** Pointer to a packet header. */ +typedef ATSPKTHDR const *PCATSPKTHDR; +/** Pointer to a packet header pointer. */ +typedef PATSPKTHDR *PPATSPKTHDR; + +/** Packet alignment. */ +#define ATSPKT_ALIGNMENT 16 +/** Max packet size. */ +#define ATSPKT_MAX_SIZE _256K + +/** + * Status packet. + */ +typedef struct ATSPKTSTS +{ + /** Embedded common packet header. */ + ATSPKTHDR Hdr; + /** The IPRT status code of the request. */ + int32_t rcReq; + /** Size of the optional status message following this structure - + * only for errors. */ + uint32_t cchStsMsg; + /** Padding - reserved. */ + uint8_t au8Padding[8]; +} ATSPKTSTS; +AssertCompileSizeAlignment(ATSPKTSTS, ATSPKT_ALIGNMENT); +/** Pointer to a status packet header. */ +typedef ATSPKTSTS *PATSPKTSTS; + +#define ATSPKT_OPCODE_HOWDY "HOWDY " + +/** 32bit protocol version consisting of a 16bit major and 16bit minor part. */ +#define ATS_PROTOCOL_VS (ATS_PROTOCOL_VS_MAJOR | ATS_PROTOCOL_VS_MINOR) +/** The major version part of the protocol version. */ +#define ATS_PROTOCOL_VS_MAJOR (1 << 16) +/** The minor version part of the protocol version. */ +#define ATS_PROTOCOL_VS_MINOR (0) + +/** + * The HOWDY request structure. + */ +typedef struct ATSPKTREQHOWDY +{ + /** Embedded packet header. */ + ATSPKTHDR Hdr; + /** Version of the protocol the client wants to use. */ + uint32_t uVersion; + /** Alignment. */ + uint8_t au8Padding[12]; +} ATSPKTREQHOWDY; +AssertCompileSizeAlignment(ATSPKTREQHOWDY, ATSPKT_ALIGNMENT); +/** Pointer to a HOWDY request structure. */ +typedef ATSPKTREQHOWDY *PATSPKTREQHOWDY; + +/** + * The HOWDY reply structure. + */ +typedef struct ATSPKTREPHOWDY +{ + /** Status packet. */ + ATSPKTSTS Sts; + /** Version to use for the established connection. */ + uint32_t uVersion; + /** Padding - reserved. */ + uint8_t au8Padding[12]; +} ATSPKTREPHOWDY; +AssertCompileSizeAlignment(ATSPKTREPHOWDY, ATSPKT_ALIGNMENT); +/** Pointer to a HOWDY reply structure. */ +typedef ATSPKTREPHOWDY *PATSPKTREPHOWDY; + +#define ATSPKT_OPCODE_BYE "BYE " + +/* No additional structures for BYE. */ + +#define ATSPKT_OPCODE_TONE_PLAY "TNPLY " + +/** + * The TONE PLAY request structure. + */ +typedef struct ATSPKTREQTONEPLAY +{ + /** Embedded packet header. */ + ATSPKTHDR Hdr; + AUDIOTESTTONEPARMS Parms; + /** Packet opcode, an unterminated ASCII string. */ + uint8_t achOpcode[8]; + /** Packet opcode, an unterminated ASCII string. */ + uint8_t au8Padding[2]; +} ATSPKTREQTONEPLAY; +//AssertCompileSizeAlignment(ATSPKTREQTONEPLAY, ATSPKT_ALIGNMENT); +/** Pointer to a ATSPKTREQTONEPLAY structure. */ +typedef ATSPKTREQTONEPLAY *PATSPKTREQTONEPLAY; + +/* No additional structure for the reply (just standard STATUS packet). */ + +/** + * Checks if the two opcodes match. + * + * @returns true on match, false on mismatch. + * @param pPktHdr The packet header. + * @param pszOpcode2 The opcode we're comparing with. Does not have + * to be the whole 8 chars long. + */ +DECLINLINE(bool) atsIsSameOpcode(PCATSPKTHDR pPktHdr, const char *pszOpcode2) +{ + if (pPktHdr->achOpcode[0] != pszOpcode2[0]) + return false; + if (pPktHdr->achOpcode[1] != pszOpcode2[1]) + return false; + + unsigned i = 2; + while ( i < RT_SIZEOFMEMB(ATSPKTHDR, achOpcode) + && pszOpcode2[i] != '\0') + { + if (pPktHdr->achOpcode[i] != pszOpcode2[i]) + break; + i++; + } + + if ( i < RT_SIZEOFMEMB(ATSPKTHDR, achOpcode) + && pszOpcode2[i] == '\0') + { + while ( i < RT_SIZEOFMEMB(ATSPKTHDR, achOpcode) + && pPktHdr->achOpcode[i] == ' ') + i++; + } + + return i == RT_SIZEOFMEMB(ATSPKTHDR, achOpcode); +} + +/** + * Converts a ATS request packet from host to network byte ordering. + * + * @returns nothing. + * @param pPktHdr The packet to convert. + */ +DECLHIDDEN(void) atsProtocolReqH2N(PATSPKTHDR pPktHdr); + +/** + * Converts a ATS request packet from network to host byte ordering. + * + * @returns nothing. + * @param pPktHdr The packet to convert. + */ +DECLHIDDEN(void) atsProtocolReqN2H(PATSPKTHDR pPktHdr); + +/** + * Converts a ATS reply packet from host to network byte ordering. + * + * @returns nothing. + * @param pPktHdr The packet to convert. + */ +DECLHIDDEN(void) atsProtocolRepH2N(PATSPKTHDR pPktHdr); + +/** + * Converts a ATS reply packet from network to host byte ordering. + * + * @returns nothing. + * @param pPktHdr The packet to convert. + */ +DECLHIDDEN(void) atsProtocolRepN2H(PATSPKTHDR pPktHdr); + +RT_C_DECLS_END + +#endif /* !VBOX_INCLUDED_SRC_AudioTestServiceProtocol_h */ |