1 /** 2 * FreeRDP: A Remote Desktop Protocol Implementation 3 * Server Audio Input Virtual Channel 4 * 5 * Copyright 2012 Vic Lee 6 * Copyright 2015 Thincast Technologies GmbH 7 * Copyright 2015 DI (FH) Martin Haimberger <martin.haimberger@thincast.com> 8 * 9 * Licensed under the Apache License, Version 2.0 (the "License"); 10 * you may not use this file except in compliance with the License. 11 * You may obtain a copy of the License at 12 * 13 * http://www.apache.org/licenses/LICENSE-2.0 14 * 15 * Unless required by applicable law or agreed to in writing, software 16 * distributed under the License is distributed on an "AS IS" BASIS, 17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 * See the License for the specific language governing permissions and 19 * limitations under the License. 20 */ 21 22 #ifndef FREERDP_CHANNEL_AUDIN_SERVER_H 23 #define FREERDP_CHANNEL_AUDIN_SERVER_H 24 25 #include <freerdp/codec/audio.h> 26 #include <freerdp/channels/wtsvc.h> 27 #include <freerdp/channels/rdpsnd.h> 28 29 typedef struct _audin_server_context audin_server_context; 30 31 typedef UINT (*psAudinServerSelectFormat)(audin_server_context* context, 32 size_t client_format_index); 33 typedef BOOL (*psAudinServerOpen)(audin_server_context* context); 34 typedef BOOL (*psAudinServerIsOpen)(audin_server_context* context); 35 typedef BOOL (*psAudinServerClose)(audin_server_context* context); 36 37 typedef UINT (*psAudinServerOpening)(audin_server_context* context); 38 typedef UINT (*psAudinServerOpenResult)(audin_server_context* context, UINT32 result); 39 typedef UINT (*psAudinServerReceiveSamples)(audin_server_context* context, 40 const AUDIO_FORMAT* format, wStream* buf, 41 size_t nframes); 42 43 struct _audin_server_context 44 { 45 HANDLE vcm; 46 47 /* Server self-defined pointer. */ 48 void* data; 49 50 /* Server supported formats. Set by server. */ 51 AUDIO_FORMAT* server_formats; 52 size_t num_server_formats; 53 54 /* Server destination PCM audio format. Set by server. */ 55 AUDIO_FORMAT* dst_format; 56 57 /* Server preferred frames per packet. */ 58 int frames_per_packet; 59 60 /* Client supported formats. */ 61 AUDIO_FORMAT* client_formats; 62 size_t num_client_formats; 63 SSIZE_T selected_client_format; 64 65 /*** APIs called by the server. ***/ 66 /** 67 * Choose the audio format to be received. The index argument is an index into 68 * the client_formats array and must be smaller than num_client_formats. 69 */ 70 psAudinServerSelectFormat SelectFormat; 71 /** 72 * Open the audio input stream. 73 */ 74 psAudinServerOpen Open; 75 76 psAudinServerIsOpen IsOpen; 77 78 /** 79 * Close the audio stream. 80 */ 81 psAudinServerClose Close; 82 83 /*** Callbacks registered by the server. ***/ 84 /** 85 * It's ready to open the audio input stream. The server should examine client 86 * formats and call SelectFormat to choose the desired one in this callback. 87 */ 88 psAudinServerOpening Opening; 89 /** 90 * Client replied HRESULT of the open operation. 91 */ 92 psAudinServerOpenResult OpenResult; 93 /** 94 * Receive audio samples. Actual bytes in the buffer is: 95 * nframes * dst_format.nBitsPerSample * dst_format.nChannels / 8 96 * Note that this callback is called from a different thread context so the 97 * server must be careful of thread synchronization. 98 */ 99 psAudinServerReceiveSamples ReceiveSamples; 100 101 rdpContext* rdpcontext; 102 }; 103 104 #ifdef __cplusplus 105 extern "C" 106 { 107 #endif 108 109 FREERDP_API audin_server_context* audin_server_context_new(HANDLE vcm); 110 FREERDP_API void audin_server_context_free(audin_server_context* context); 111 112 #ifdef __cplusplus 113 } 114 #endif 115 116 #endif /* FREERDP_CHANNEL_AUDIN_SERVER_H */ 117