cscg24-guacamole

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

rdpsnd.h (4026B)


      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_CHANNELS_RDPSND_H
     21#define GUAC_RDP_CHANNELS_RDPSND_H
     22
     23#include "channels/common-svc.h"
     24
     25#include <freerdp/freerdp.h>
     26#include <guacamole/client.h>
     27
     28/**
     29 * The maximum number of PCM formats to accept during the initial RDPSND
     30 * handshake with the RDP server.
     31 */
     32#define GUAC_RDP_MAX_FORMATS 16
     33
     34/**
     35 * Abstract representation of a PCM format, including the sample rate, number
     36 * of channels, and bits per sample.
     37 */
     38typedef struct guac_rdpsnd_pcm_format {
     39
     40    /**
     41     * The sample rate of this PCM format.
     42     */
     43    int rate;
     44
     45    /**
     46     * The number off channels used by this PCM format. This will typically
     47     * be 1 or 2.
     48     */
     49    int channels;
     50
     51    /**
     52     * The number of bits per sample within this PCM format. This should be
     53     * either 8 or 16.
     54     */
     55    int bps;
     56
     57} guac_rdpsnd_pcm_format;
     58
     59/**
     60 * Structure representing the current state of the Guacamole RDPSND plugin for
     61 * FreeRDP.
     62 */
     63typedef struct guac_rdpsnd {
     64
     65    /**
     66     * The block number of the last SNDC_WAVE (WaveInfo) PDU received.
     67     */
     68    int waveinfo_block_number;
     69
     70    /**
     71     * Whether the next PDU coming is a SNDWAVE (Wave) PDU. Wave PDUs do not
     72     * have headers, and are indicated by the receipt of a WaveInfo PDU.
     73     */
     74    int next_pdu_is_wave;
     75
     76    /**
     77     * The wave data received within the last SNDC_WAVE (WaveInfo) PDU.
     78     */
     79    unsigned char initial_wave_data[4];
     80
     81    /**
     82     * The size, in bytes, of the wave data in the coming Wave PDU, if any.
     83     * This does not include the initial wave data received within the last
     84     * SNDC_WAVE (WaveInfo) PDU, which is always the first four bytes of the
     85     * actual wave data block.
     86     */
     87    int incoming_wave_size;
     88
     89    /**
     90     * The last received server timestamp.
     91     */
     92    int server_timestamp;
     93
     94    /**
     95     * All formats agreed upon by server and client during the initial format
     96     * exchange. All of these formats will be PCM, which is the only format
     97     * guaranteed to be supported (based on the official RDP documentation).
     98     */
     99    guac_rdpsnd_pcm_format formats[GUAC_RDP_MAX_FORMATS];
    100
    101    /**
    102     * The total number of formats.
    103     */
    104    int format_count;
    105
    106} guac_rdpsnd;
    107
    108/**
    109 * Initializes audio output support for RDP and handling of the RDPSND channel.
    110 * If failures occur, messages noting the specifics of those failures will be
    111 * logged, and the RDP side of audio output support will not be functional.
    112 *
    113 * This MUST be called within the PreConnect callback of the freerdp instance
    114 * for RDPSND support to be loaded.
    115 *
    116 * @param context
    117 *     The rdpContext associated with the FreeRDP side of the RDP connection.
    118 */
    119void guac_rdpsnd_load_plugin(rdpContext* context);
    120
    121/**
    122 * Handler which is invoked when the RDPSND channel is connected to the RDP
    123 * server.
    124 */
    125guac_rdp_common_svc_connect_handler guac_rdpsnd_process_connect;
    126
    127/**
    128 * Handler which is invoked when the RDPSND channel has received data from the
    129 * RDP server.
    130 */
    131guac_rdp_common_svc_receive_handler guac_rdpsnd_process_receive;
    132
    133/**
    134 * Handler which is invoked when the RDPSND channel has disconnected and is
    135 * about to be freed.
    136 */
    137guac_rdp_common_svc_terminate_handler guac_rdpsnd_process_terminate;
    138
    139#endif
    140