guacai-messages.h (6987B)
1/* 2 * Licensed to the Apache Software Foundation (ASF) under one 3 * or more contributor license agreements. See the NOTICE file 4 * distributed with this work for additional information 5 * regarding copyright ownership. The ASF licenses this file 6 * to you under the Apache License, Version 2.0 (the 7 * "License"); you may not use this file except in compliance 8 * with the License. You may obtain a copy of the License at 9 * 10 * http://www.apache.org/licenses/LICENSE-2.0 11 * 12 * Unless required by applicable law or agreed to in writing, 13 * software distributed under the License is distributed on an 14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 * KIND, either express or implied. See the License for the 16 * specific language governing permissions and limitations 17 * under the License. 18 */ 19 20#ifndef GUAC_RDP_PLUGINS_GUACAI_MESSAGES_H 21#define GUAC_RDP_PLUGINS_GUACAI_MESSAGES_H 22 23#include "channels/audio-input/audio-buffer.h" 24 25#include <freerdp/dvc.h> 26#include <guacamole/client.h> 27#include <winpr/stream.h> 28#include <winpr/wtypes.h> 29 30/** 31 * The format tag associated with raw wave audio (WAVE_FORMAT_PCM). This format 32 * is required to be supported by all RDP servers. 33 */ 34#define GUAC_RDP_WAVE_FORMAT_PCM 0x01 35 36/** 37 * The message ID associated with the AUDIO_INPUT Version PDU. The Version PDU 38 * is sent by both the client and the server to indicate their version of the 39 * AUDIO_INPUT channel protocol (which must always be 1). 40 */ 41#define GUAC_RDP_MSG_SNDIN_VERSION 0x01 42 43/** 44 * The message ID associated with the AUDIO_INPUT Sound Formats PDU. The 45 * Sound Formats PDU is sent by the client and the server to indicate the 46 * formats of audio supported. 47 */ 48#define GUAC_RDP_MSG_SNDIN_FORMATS 0x02 49 50/** 51 * The message ID associated with the AUDIO_INPUT Open PDU. The Open PDU is 52 * sent by the server to inform the client that the AUDIO_INPUT channel is 53 * now open. 54 */ 55#define GUAC_RDP_MSG_SNDIN_OPEN 0x03 56 57/** 58 * The message ID associated with the AUDIO_INPUT Open Reply PDU. The Open 59 * Reply PDU is sent by the client (after sending a Format Change PDU) to 60 * acknowledge that the AUDIO_INPUT channel is open. 61 */ 62#define GUAC_RDP_MSG_SNDIN_OPEN_REPLY 0x04 63 64/** 65 * The message ID associated with the AUDIO_INPUT Incoming Data PDU. The 66 * Incoming Data PDU is sent by the client to inform the server of incoming 67 * sound format or audio data. 68 */ 69#define GUAC_RDP_MSG_SNDIN_DATA_INCOMING 0x05 70 71/** 72 * The message ID associated with the AUDIO_INPUT Data PDU. The Data PDU is 73 * sent by the client and contains audio data read from the microphone. 74 */ 75#define GUAC_RDP_MSG_SNDIN_DATA 0x06 76 77/** 78 * The message ID associated with the AUDIO_INPUT Format Change PDU. The Format 79 * Change PDU is sent by the client to acknowledge the current sound format, or 80 * by the server to request a different sound format. 81 */ 82#define GUAC_RDP_MSG_SNDIN_FORMATCHANGE 0x07 83 84/** 85 * An AUDIO_INPUT format, analogous to the AUDIO_FORMAT structure defined 86 * within Microsoft's RDP documentation. 87 */ 88typedef struct guac_rdp_ai_format { 89 90 /** 91 * The "format tag" denoting the overall format of audio data received, 92 * such as WAVE_FORMAT_PCM. 93 */ 94 UINT16 tag; 95 96 /** 97 * The number of audio channels. 98 */ 99 UINT16 channels; 100 101 /** 102 * The number of samples per second. 103 */ 104 UINT32 rate; 105 106 /** 107 * The average number of bytes required for one second of audio. 108 */ 109 UINT32 bytes_per_sec; 110 111 /** 112 * The absolute minimum number of bytes required to process audio in this 113 * format. 114 */ 115 UINT16 block_align; 116 117 /** 118 * The number of bits per sample. 119 */ 120 UINT16 bps; 121 122 /** 123 * The size of the arbitrary data block, if any. The meaning of the data 124 * within the arbitrary data block is determined by the format tag. 125 * WAVE_FORMAT_PCM audio has no associated arbitrary data. 126 */ 127 UINT16 data_size; 128 129 /** 130 * Optional arbitrary data whose meaning is determined by the format tag. 131 * WAVE_FORMAT_PCM audio has no associated arbitrary data. 132 */ 133 BYTE* data; 134 135} guac_rdp_ai_format; 136 137/** 138 * Processes a Version PDU received from the RDP server. The Version PDU is 139 * sent by the server to indicate its version of the AUDIO_INPUT channel 140 * protocol (which must always be 1). 141 * 142 * @param client 143 * The guac_client associated with the current RDP connection. 144 * 145 * @param channel 146 * The IWTSVirtualChannel instance associated with the connected 147 * AUDIO_INPUT channel. 148 * 149 * @param stream 150 * The received PDU, with the read position just after the message ID field 151 * common to all AUDIO_INPUT PDUs. 152 */ 153void guac_rdp_ai_process_version(guac_client* client, 154 IWTSVirtualChannel* channel, wStream* stream); 155 156/** 157 * Processes a Sound Formats PDU received from the RDP server. The Sound 158 * Formats PDU is sent by the server to indicate the formats of audio 159 * supported. 160 * 161 * @param client 162 * The guac_client associated with the current RDP connection. 163 * 164 * @param channel 165 * The IWTSVirtualChannel instance associated with the connected 166 * AUDIO_INPUT channel. 167 * 168 * @param stream 169 * The received PDU, with the read position just after the message ID field 170 * common to all AUDIO_INPUT PDUs. 171 */ 172void guac_rdp_ai_process_formats(guac_client* client, 173 IWTSVirtualChannel* channel, wStream* stream); 174 175/** 176 * Processes a Open PDU received from the RDP server. The Open PDU is sent by 177 * the server to inform the client that the AUDIO_INPUT channel is now open. 178 * 179 * @param client 180 * The guac_client associated with the current RDP connection. 181 * 182 * @param channel 183 * The IWTSVirtualChannel instance associated with the connected 184 * AUDIO_INPUT channel. 185 * 186 * @param stream 187 * The received PDU, with the read position just after the message ID field 188 * common to all AUDIO_INPUT PDUs. 189 */ 190void guac_rdp_ai_process_open(guac_client* client, 191 IWTSVirtualChannel* channel, wStream* stream); 192 193/** 194 * Processes a Format Change PDU received from the RDP server. The Format 195 * Change PDU is sent by the server to request a different sound format. 196 * 197 * @param client 198 * The guac_client associated with the current RDP connection. 199 * 200 * @param channel 201 * The IWTSVirtualChannel instance associated with the connected 202 * AUDIO_INPUT channel. 203 * 204 * @param stream 205 * The received PDU, with the read position just after the message ID field 206 * common to all AUDIO_INPUT PDUs. 207 */ 208void guac_rdp_ai_process_formatchange(guac_client* client, 209 IWTSVirtualChannel* channel, wStream* stream); 210 211/** 212 * Audio buffer flush handler which sends audio data along the active audio 213 * input channel using a Data Incoming PDU and Data PDU. The arbitrary data 214 * provided to the handler by the audio buffer implementation is in this case 215 * the IWTSVirtualChannel structure representing the active audio input 216 * channel. 217 */ 218guac_rdp_audio_buffer_flush_handler guac_rdp_ai_flush_packet; 219 220#endif 221