Ejemplo n.º 1
0
static int snd_record_handle_write(RecordChannel *record_channel, size_t size, void *message)
{
    SpiceMsgcRecordPacket *packet;
    uint32_t write_pos;
    uint32_t* data;
    uint32_t len;
    uint32_t now;

    if (!record_channel) {
        return FALSE;
    }

    packet = (SpiceMsgcRecordPacket *)message;
    size = packet->data_size;

    if (record_channel->mode == SPICE_AUDIO_DATA_MODE_CELT_0_5_1) {
        int celt_err = celt051_decode(record_channel->celt_decoder, packet->data, size,
                                      (celt_int16_t *)record_channel->celt_buf);
        if (celt_err != CELT_OK) {
            spice_printerr("celt decode failed (%d)", celt_err);
            return FALSE;
        }
        data = record_channel->celt_buf;
        size = FRAME_SIZE;
    } else if (record_channel->mode == SPICE_AUDIO_DATA_MODE_RAW) {
        data = (uint32_t *)packet->data;
        size = size >> 2;
        size = MIN(size, RECORD_SAMPLES_SIZE);
    } else {
void PlaybackChannel::handle_celt_data(RedPeer::InMessage* message)
{
    SpiceMsgPlaybackPacket* packet = (SpiceMsgPlaybackPacket*)message->data();
    uint8_t* data = packet->data;
    uint32_t size = packet->data_size;
    celt_int16_t pcm[256 * 2];

    if (celt051_decode(_celt_decoder, data, size, pcm) != CELT_OK) {
        THROW("celt decode failed");
    }
#ifdef WAVE_CAPTURE
    put_wave_data(pcm, _frame_bytes);
    return;
#endif
    if ((_frame_count++ % 1000) == 0) {
        get_client().set_mm_time(packet->time - _wave_player->get_delay_ms());
    }
    _wave_player->write((uint8_t *)pcm);
}