audin.h (3828B)
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 29typedef struct _audin_server_context audin_server_context; 30 31typedef BOOL (*psAudinServerChannelIdAssigned)(audin_server_context* context, UINT32 channelId); 32 33typedef UINT (*psAudinServerSelectFormat)(audin_server_context* context, 34 size_t client_format_index); 35typedef BOOL (*psAudinServerOpen)(audin_server_context* context); 36typedef BOOL (*psAudinServerIsOpen)(audin_server_context* context); 37typedef BOOL (*psAudinServerClose)(audin_server_context* context); 38 39typedef UINT (*psAudinServerOpening)(audin_server_context* context); 40typedef UINT (*psAudinServerOpenResult)(audin_server_context* context, UINT32 result); 41typedef UINT (*psAudinServerReceiveSamples)(audin_server_context* context, 42 const AUDIO_FORMAT* format, wStream* buf, 43 size_t nframes); 44 45struct _audin_server_context 46{ 47 HANDLE vcm; 48 49 /* Server self-defined pointer. */ 50 void* data; 51 52 /* Server supported formats. Set by server. */ 53 AUDIO_FORMAT* server_formats; 54 size_t num_server_formats; 55 56 /* Server destination PCM audio format. Set by server. */ 57 AUDIO_FORMAT* dst_format; 58 59 /* Server preferred frames per packet. */ 60 int frames_per_packet; 61 62 /* Client supported formats. */ 63 AUDIO_FORMAT* client_formats; 64 size_t num_client_formats; 65 SSIZE_T selected_client_format; 66 67 /*** APIs called by the server. ***/ 68 /** 69 * Choose the audio format to be received. The index argument is an index into 70 * the client_formats array and must be smaller than num_client_formats. 71 */ 72 psAudinServerSelectFormat SelectFormat; 73 /** 74 * Open the audio input stream. 75 */ 76 psAudinServerOpen Open; 77 78 psAudinServerIsOpen IsOpen; 79 80 /** 81 * Close the audio stream. 82 */ 83 psAudinServerClose Close; 84 85 /*** Callbacks registered by the server. ***/ 86 /** 87 * It's ready to open the audio input stream. The server should examine client 88 * formats and call SelectFormat to choose the desired one in this callback. 89 */ 90 psAudinServerOpening Opening; 91 /** 92 * Client replied HRESULT of the open operation. 93 */ 94 psAudinServerOpenResult OpenResult; 95 /** 96 * Receive audio samples. Actual bytes in the buffer is: 97 * nframes * dst_format.nBitsPerSample * dst_format.nChannels / 8 98 * Note that this callback is called from a different thread context so the 99 * server must be careful of thread synchronization. 100 */ 101 psAudinServerReceiveSamples ReceiveSamples; 102 103 rdpContext* rdpcontext; 104 105 /** 106 * Callback, when the channel got its id assigned. 107 */ 108 psAudinServerChannelIdAssigned ChannelIdAssigned; 109}; 110 111#ifdef __cplusplus 112extern "C" 113{ 114#endif 115 116 FREERDP_API audin_server_context* audin_server_context_new(HANDLE vcm); 117 FREERDP_API void audin_server_context_free(audin_server_context* context); 118 119#ifdef __cplusplus 120} 121#endif 122 123#endif /* FREERDP_CHANNEL_AUDIN_SERVER_H */