cscg24-guacamole

CSCG 2024 Challenge 'Guacamole Mashup'
git clone https://git.sinitax.com/sinitax/cscg24-guacamole
Log | Files | Refs | sfeed.txt

rdpsnd.h (6416B)


      1/**
      2 * FreeRDP: A Remote Desktop Protocol Implementation
      3 * Server Audio 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_RDPSND_SERVER_H
     23#define FREERDP_CHANNEL_RDPSND_SERVER_H
     24
     25#include <freerdp/channels/wtsvc.h>
     26#include <freerdp/channels/rdpsnd.h>
     27
     28typedef struct _rdpsnd_server_context RdpsndServerContext;
     29typedef struct _rdpsnd_server_context rdpsnd_server_context;
     30typedef struct _rdpsnd_server_private RdpsndServerPrivate;
     31
     32typedef UINT (*psRdpsndStart)(RdpsndServerContext* context);
     33typedef UINT (*psRdpsndStop)(RdpsndServerContext* context);
     34
     35typedef BOOL (*psRdpsndChannelIdAssigned)(RdpsndServerContext* context, UINT32 channelId);
     36
     37typedef UINT (*psRdpsndServerInitialize)(RdpsndServerContext* context, BOOL ownThread);
     38typedef UINT (*psRdpsndServerSendFormats)(RdpsndServerContext* context);
     39typedef UINT (*psRdpsndServerSelectFormat)(RdpsndServerContext* context,
     40                                           UINT16 client_format_index);
     41typedef UINT (*psRdpsndServerTraining)(RdpsndServerContext* context, UINT16 timestamp,
     42                                       UINT16 packsize, BYTE* data);
     43typedef UINT (*psRdpsndServerTrainingConfirm)(RdpsndServerContext* context, UINT16 timestamp,
     44                                              UINT16 packsize);
     45typedef UINT (*psRdpsndServerSendSamples)(RdpsndServerContext* context, const void* buf,
     46                                          int nframes, UINT16 wTimestamp);
     47typedef UINT (*psRdpsndServerSendSamples2)(RdpsndServerContext* context, UINT16 formatNo,
     48                                           const void* buf, size_t size, UINT16 timestamp,
     49                                           UINT32 audioTimeStamp);
     50typedef UINT (*psRdpsndServerConfirmBlock)(RdpsndServerContext* context, BYTE confirmBlockNum,
     51                                           UINT16 wtimestamp);
     52typedef UINT (*psRdpsndServerSetVolume)(RdpsndServerContext* context, int left, int right);
     53typedef UINT (*psRdpsndServerClose)(RdpsndServerContext* context);
     54
     55typedef void (*psRdpsndServerActivated)(RdpsndServerContext* context);
     56
     57struct _rdpsnd_server_context
     58{
     59	HANDLE vcm;
     60
     61	psRdpsndStart Start;
     62	psRdpsndStop Stop;
     63
     64	RdpsndServerPrivate* priv;
     65
     66	/* Server self-defined pointer. */
     67	void* data;
     68
     69	/* Server supported formats. Set by server. */
     70	AUDIO_FORMAT* server_formats;
     71	size_t num_server_formats;
     72
     73	/* Server source PCM audio format. Set by server. */
     74	AUDIO_FORMAT* src_format;
     75
     76	/* Server audio latency, or buffer size, in milli-seconds. Set by server. */
     77	int latency;
     78
     79	/* Client supported formats. */
     80	AUDIO_FORMAT* client_formats;
     81	UINT16 num_client_formats;
     82	UINT16 selected_client_format;
     83
     84	/* Last sent audio block number. */
     85	UINT8 block_no;
     86
     87	/*** APIs called by the server. ***/
     88	/**
     89	 * Initialize the channel. The caller should check the return value to see
     90	 * whether the initialization succeed. If not, the "Activated" callback
     91	 * will not be called and the server must not call any API on this context.
     92	 */
     93	psRdpsndServerInitialize Initialize;
     94	/**
     95	 * Choose the audio format to be sent. The index argument is an index into
     96	 * the client_formats array and must be smaller than num_client_formats.
     97	 */
     98	psRdpsndServerSelectFormat SelectFormat;
     99	/**
    100	 * Send audio samples. Actually bytes in the buffer must be:
    101	 * nframes * src_format.nBitsPerSample * src_format.nChannels / 8
    102	 */
    103	psRdpsndServerSendSamples SendSamples;
    104	/**
    105	 * Called when block confirm is received from the client
    106	 */
    107	psRdpsndServerConfirmBlock ConfirmBlock;
    108	/**
    109	 * Set the volume level of the client. Valid range is between 0 and 0xFFFF.
    110	 */
    111	psRdpsndServerSetVolume SetVolume;
    112	/**
    113	 * Close the audio stream.
    114	 */
    115	psRdpsndServerClose Close;
    116
    117	/*** Callbacks registered by the server. ***/
    118	/**
    119	 * The channel has been activated. The server maybe choose audio format and
    120	 * start audio stream from this point. Note that this callback is called
    121	 * from a different thread context so the server must be careful of thread
    122	 * synchronization.
    123	 */
    124	psRdpsndServerActivated Activated;
    125
    126	/**
    127	 *  MS-RDPEA channel version the client announces
    128	 */
    129	UINT16 clientVersion;
    130
    131	rdpContext* rdpcontext;
    132
    133	/* Server to request to use dynamic virtual channel. */
    134	BOOL use_dynamic_virtual_channel;
    135
    136	/* dwFlags in CLIENT_AUDIO_VERSION_AND_FORMATS */
    137	UINT32 capsFlags;
    138	/* dwVolume in CLIENT_AUDIO_VERSION_AND_FORMATS */
    139	UINT32 initialVolume;
    140	/* dwPitch in CLIENT_AUDIO_VERSION_AND_FORMATS */
    141	UINT32 initialPitch;
    142
    143	UINT16 qualityMode;
    144
    145	/**
    146	 * Send server formats and version to the client. Automatically sent, when
    147	 * opening the channel.
    148	 * Also used to restart the protocol after sending the Close PDU.
    149	 */
    150	psRdpsndServerSendFormats SendFormats;
    151	/**
    152	 * Send Training PDU.
    153	 */
    154	psRdpsndServerTraining Training;
    155
    156	/**
    157	 * Send encoded audio samples using a Wave2 PDU.
    158	 * When successful, the block_no member is incremented.
    159	 */
    160	psRdpsndServerSendSamples2 SendSamples2;
    161
    162	/**
    163	 * Called when a TrainingConfirm PDU is received from the client.
    164	 */
    165	psRdpsndServerTrainingConfirm TrainingConfirm;
    166
    167	/**
    168	 * Callback, when the channel got its id assigned.
    169	 * Only called, when use_dynamic_virtual_channel=TRUE.
    170	 */
    171	psRdpsndChannelIdAssigned ChannelIdAssigned;
    172};
    173
    174#ifdef __cplusplus
    175extern "C"
    176{
    177#endif
    178
    179	FREERDP_API RdpsndServerContext* rdpsnd_server_context_new(HANDLE vcm);
    180	FREERDP_API void rdpsnd_server_context_reset(RdpsndServerContext*);
    181	FREERDP_API void rdpsnd_server_context_free(RdpsndServerContext* context);
    182	FREERDP_API HANDLE rdpsnd_server_get_event_handle(RdpsndServerContext* context);
    183	FREERDP_API UINT rdpsnd_server_handle_messages(RdpsndServerContext* context);
    184
    185#ifdef __cplusplus
    186}
    187#endif
    188
    189#endif /* FREERDP_CHANNEL_RDPSND_SERVER_H */