static void wts_read_drdynvc_create_response(rdpPeerChannel* channel, STREAM* s, uint32 length) { uint32 CreationStatus; if (length < 4) return; stream_read_uint32(s, CreationStatus); if ((sint32)CreationStatus < 0) { DEBUG_DVC("ChannelId %d creation failed (%d)", channel->channel_id, (sint32)CreationStatus); channel->dvc_open_state = DVC_OPEN_STATE_FAILED; } else { DEBUG_DVC("ChannelId %d creation succeeded", channel->channel_id); channel->dvc_open_state = DVC_OPEN_STATE_SUCCEEDED; } wait_obj_set(channel->receive_event); }
static int rdpei_on_close(IWTSVirtualChannelCallback* pChannelCallback) { RDPEI_CHANNEL_CALLBACK* callback = (RDPEI_CHANNEL_CALLBACK*) pChannelCallback; DEBUG_DVC(""); free(callback); return 0; }
static void drdynvc_process_connect(rdpSvcPlugin* plugin) { drdynvcPlugin* drdynvc = (drdynvcPlugin*)plugin; DEBUG_DVC("connecting"); drdynvc->channel_mgr = dvcman_new(drdynvc); dvcman_load_plugin(drdynvc->channel_mgr, svc_plugin_get_data(plugin)); dvcman_init(drdynvc->channel_mgr); }
static int echo_on_close(IWTSVirtualChannelCallback* pChannelCallback) { ECHO_CHANNEL_CALLBACK* callback = (ECHO_CHANNEL_CALLBACK*) pChannelCallback; DEBUG_DVC(""); free(callback); return 0; }
static int drdynvc_process_data(drdynvcPlugin* drdynvc, int Sp, int cbChId, STREAM* s) { uint32 ChannelId; ChannelId = drdynvc_read_variable_uint(s, cbChId); DEBUG_DVC("ChannelId=%d", ChannelId); return dvcman_receive_channel_data(drdynvc->channel_mgr, ChannelId, stream_get_tail(s), stream_get_left(s)); }
static int echo_plugin_terminated(IWTSPlugin* pPlugin) { ECHO_PLUGIN* echo = (ECHO_PLUGIN*) pPlugin; DEBUG_DVC(""); free(echo); return 0; }
static void dump_callbacks(void) { wListDictionaryItem *cur; DEBUG_DVC("Dumping all currently registered callbacks"); if (!cb_dict) { DEBUG_DVC("cb_dict=NULL"); return; } cur = cb_dict->head; while (cur) { DEBUG_DVC("cb_dict %s:%p", cur->key, cur->value); cur = cur->next; } }
static int drdynvc_process_data(drdynvcPlugin* drdynvc, int Sp, int cbChId, wStream* s) { UINT32 ChannelId; ChannelId = drdynvc_read_variable_uint(s, cbChId); DEBUG_DVC("ChannelId=%d", ChannelId); return dvcman_receive_channel_data(drdynvc->channel_mgr, ChannelId, Stream_Pointer(s), Stream_GetRemainingLength(s)); }
static int drdynvc_process_close_request(drdynvcPlugin* drdynvc, int Sp, int cbChId, STREAM* data_in) { uint32 ChannelId; ChannelId = drdynvc_read_variable_uint(data_in, cbChId); DEBUG_DVC("ChannelId=%d", ChannelId); dvcman_close_channel(drdynvc->channel_mgr, ChannelId); return 0; }
static int rdpei_plugin_terminated(IWTSPlugin* pPlugin) { RDPEI_PLUGIN* echo = (RDPEI_PLUGIN*) pPlugin; DEBUG_DVC(""); free(echo); return 0; }
static void drdynvc_process_terminate(rdpSvcPlugin* plugin) { drdynvcPlugin* drdynvc = (drdynvcPlugin*)plugin; DEBUG_DVC("terminating"); if (drdynvc->channel_mgr != NULL) dvcman_free(drdynvc->channel_mgr); xfree(drdynvc); }
static boolean tsmf_pulse_play(ITSMFAudioDevice* audio, uint8* data, uint32 data_size) { TSMFPulseAudioDevice* pulse = (TSMFPulseAudioDevice*) audio; uint8* src; int len; int ret; DEBUG_DVC("data_size %d", data_size); if (pulse->stream) { pa_threaded_mainloop_lock(pulse->mainloop); src = data; while (data_size > 0) { while ((len = pa_stream_writable_size(pulse->stream)) == 0) { DEBUG_DVC("waiting"); pa_threaded_mainloop_wait(pulse->mainloop); } if (len < 0) break; if (len > data_size) len = data_size; ret = pa_stream_write(pulse->stream, src, len, NULL, 0LL, PA_SEEK_RELATIVE); if (ret < 0) { DEBUG_DVC("pa_stream_write failed (%d)", pa_context_errno(pulse->context)); break; } src += len; data_size -= len; } pa_threaded_mainloop_unlock(pulse->mainloop); } xfree(data); return true; }
int tsmf_ifman_set_topology_request(TSMF_IFMAN* ifman) { DEBUG_DVC(""); Stream_EnsureRemainingCapacity(ifman->output, 8); Stream_Write_UINT32(ifman->output, 1); /* TopologyReady */ Stream_Write_UINT32(ifman->output, 0); /* Result */ ifman->output_interface_id = TSMF_INTERFACE_DEFAULT | STREAM_ID_STUB; return 0; }
static void audin_alsa_close(IAudinDevice* device) { AudinALSADevice* alsa = (AudinALSADevice*) device; DEBUG_DVC(""); freerdp_thread_stop(alsa->thread); alsa->receive = NULL; alsa->user_data = NULL; }
static void audin_alsa_open(IAudinDevice* device, AudinReceive receive, void* user_data) { AudinALSADevice* alsa = (AudinALSADevice*) device; DEBUG_DVC(""); alsa->receive = receive; alsa->user_data = user_data; freerdp_thread_start(alsa->thread, audin_alsa_thread_func, alsa); }
static void wts_read_drdynvc_create_response(rdpPeerChannel* channel, wStream* s, UINT32 length) { UINT32 CreationStatus; if (length < 4) return; Stream_Read_UINT32(s, CreationStatus); if ((INT32) CreationStatus < 0) { DEBUG_DVC("ChannelId %d creation failed (%d)", channel->channelId, (INT32) CreationStatus); channel->dvc_open_state = DVC_OPEN_STATE_FAILED; } else { DEBUG_DVC("ChannelId %d creation succeeded", channel->channelId); channel->dvc_open_state = DVC_OPEN_STATE_SUCCEEDED; } }
static int dvcman_close_channel_iface(IWTSVirtualChannel *pChannel) { DVCMAN_CHANNEL *channel = (DVCMAN_CHANNEL *) pChannel; DVCMAN *dvcman = channel->dvcman; assert(channel); assert(dvcman); DEBUG_DVC("id=%d", channel->channel_id); ArrayList_Remove(dvcman->channels, channel); dvcman_channel_free(channel); return 1; }
static int drdynvc_process_data(drdynvcPlugin* drdynvc, int Sp, int cbChId, STREAM* data_in, int in_length) { int pos; uint32 ChannelId; ChannelId = drdynvc_read_variable_uint(data_in, cbChId); pos = stream_get_pos(data_in); DEBUG_DVC("ChannelId=%d", ChannelId); return dvcman_receive_channel_data(drdynvc->channel_mgr, ChannelId, stream_get_tail(data_in), in_length - pos); }
static int tsmf_plugin_terminated(IWTSPlugin* pPlugin) { TSMF_PLUGIN* tsmf = (TSMF_PLUGIN*) pPlugin; DEBUG_DVC(""); if (tsmf->listener_callback) xfree(tsmf->listener_callback); xfree(tsmf); return 0; }
static void audin_pulse_set_format(IAudinDevice* device, audinFormat* format, uint32 FramesPerPacket) { int bs; pa_sample_spec sample_spec = { 0 }; AudinPulseDevice* pulse = (AudinPulseDevice*) device; if (!pulse->context) return; if (FramesPerPacket > 0) { pulse->frames_per_packet = FramesPerPacket; } sample_spec.rate = format->nSamplesPerSec; sample_spec.channels = format->nChannels; switch (format->wFormatTag) { case 1: /* PCM */ switch (format->wBitsPerSample) { case 8: sample_spec.format = PA_SAMPLE_U8; break; case 16: sample_spec.format = PA_SAMPLE_S16LE; break; } break; case 6: /* A-LAW */ sample_spec.format = PA_SAMPLE_ALAW; break; case 7: /* U-LAW */ sample_spec.format = PA_SAMPLE_ULAW; break; case 0x11: /* IMA ADPCM */ sample_spec.format = PA_SAMPLE_S16LE; bs = (format->nBlockAlign - 4 * format->nChannels) * 4; pulse->frames_per_packet = (pulse->frames_per_packet * format->nChannels * 2 / bs + 1) * bs / (format->nChannels * 2); DEBUG_DVC("aligned FramesPerPacket=%d", pulse->frames_per_packet); break; } pulse->sample_spec = sample_spec; pulse->format = format->wFormatTag; pulse->block_size = format->nBlockAlign; }
static int tsmf_plugin_initialize(IWTSPlugin* pPlugin, IWTSVirtualChannelManager* pChannelMgr) { TSMF_PLUGIN* tsmf = (TSMF_PLUGIN*) pPlugin; DEBUG_DVC(""); tsmf->listener_callback = xnew(TSMF_LISTENER_CALLBACK); tsmf->listener_callback->iface.OnNewChannelConnection = tsmf_on_new_channel_connection; tsmf->listener_callback->plugin = pPlugin; tsmf->listener_callback->channel_mgr = pChannelMgr; return pChannelMgr->CreateListener(pChannelMgr, "TSMF", 0, (IWTSListenerCallback*) tsmf->listener_callback, NULL); }
static int drdynvc_process_create_request(drdynvcPlugin* drdynvc, int Sp, int cbChId, wStream* s) { int pos; int status; UINT32 ChannelId; wStream* data_out; ChannelId = drdynvc_read_variable_uint(s, cbChId); pos = Stream_GetPosition(s); DEBUG_DVC("ChannelId=%d ChannelName=%s", ChannelId, Stream_Pointer(s)); status = dvcman_create_channel(drdynvc->channel_mgr, ChannelId, (char*) Stream_Pointer(s)); data_out = Stream_New(NULL, pos + 4); Stream_Write_UINT8(data_out, 0x10 | cbChId); Stream_SetPosition(s, 1); Stream_Copy(data_out, s, pos - 1); if (status == 0) { DEBUG_DVC("channel created"); Stream_Write_UINT32(data_out, 0); } else { DEBUG_DVC("no listener"); Stream_Write_UINT32(data_out, (UINT32)(-1)); } status = svc_plugin_send((rdpSvcPlugin*) drdynvc, data_out); if (status != CHANNEL_RC_OK) { DEBUG_WARN("VirtualChannelWrite failed %d", status); return 1; } return 0; }
static int drdynvc_process_create_request(drdynvcPlugin* drdynvc, int Sp, int cbChId, STREAM* s) { int pos; int error; UINT32 ChannelId; STREAM* data_out; ChannelId = drdynvc_read_variable_uint(s, cbChId); pos = stream_get_pos(s); DEBUG_DVC("ChannelId=%d ChannelName=%s", ChannelId, stream_get_tail(s)); error = dvcman_create_channel(drdynvc->channel_mgr, ChannelId, (char*) stream_get_tail(s)); data_out = stream_new(pos + 4); stream_write_BYTE(data_out, 0x10 | cbChId); stream_set_pos(s, 1); stream_copy(data_out, s, pos - 1); if (error == 0) { DEBUG_DVC("channel created"); stream_write_UINT32(data_out, 0); } else { DEBUG_DVC("no listener"); stream_write_UINT32(data_out, (UINT32)(-1)); } error = svc_plugin_send((rdpSvcPlugin*) drdynvc, data_out); if (error != CHANNEL_RC_OK) { DEBUG_WARN("VirtualChannelWrite failed %d", error); return 1; } return 0; }
int tsmf_ifman_rim_exchange_capability_request(TSMF_IFMAN* ifman) { UINT32 CapabilityValue; Stream_Read_UINT32(ifman->input, CapabilityValue); DEBUG_DVC("server CapabilityValue %d", CapabilityValue); Stream_EnsureRemainingCapacity(ifman->output, 8); Stream_Write_UINT32(ifman->output, 1); /* CapabilityValue */ Stream_Write_UINT32(ifman->output, 0); /* Result */ return 0; }
int tsmf_ifman_on_playback_rate_changed(TSMF_IFMAN * ifman) { DEBUG_DVC(""); Stream_EnsureRemainingCapacity(ifman->output, 16); Stream_Write_UINT32(ifman->output, CLIENT_EVENT_NOTIFICATION); /* FunctionId */ Stream_Write_UINT32(ifman->output, 0); /* StreamId */ Stream_Write_UINT32(ifman->output, TSMM_CLIENT_EVENT_MONITORCHANGED); /* EventId */ Stream_Write_UINT32(ifman->output, 0); /* cbData */ ifman->output_interface_id = TSMF_INTERFACE_CLIENT_NOTIFICATIONS | STREAM_ID_PROXY; return 0; }
static int dvcman_close_channel_iface(IWTSVirtualChannel* pChannel) { DVCMAN_CHANNEL* channel = (DVCMAN_CHANNEL*)pChannel; DVCMAN* dvcman = channel->dvcman; DEBUG_DVC("id=%d", channel->channel_id); if (list_remove(dvcman->channels, channel) == NULL) DEBUG_WARN("channel not found"); dvcman_channel_free(channel); return 1; }
static void wts_read_drdynvc_capabilities_response(rdpPeerChannel* channel, uint32 length) { uint16 Version; if (length < 3) return; stream_seek_uint8(channel->receive_data); /* Pad (1 byte) */ stream_read_uint16(channel->receive_data, Version); DEBUG_DVC("Version: %d", Version); channel->vcm->drdynvc_state = DRDYNVC_STATE_READY; }
void tsmf_stream_set_format(TSMF_STREAM* stream, const char* name, wStream* s) { TS_AM_MEDIA_TYPE mediatype; if (stream->decoder) { DEBUG_WARN("duplicated call"); return; } tsmf_codec_parse_media_type(&mediatype, s); if (mediatype.MajorType == TSMF_MAJOR_TYPE_VIDEO) { DEBUG_DVC("video width %d height %d bit_rate %d frame_rate %f codec_data %d", mediatype.Width, mediatype.Height, mediatype.BitRate, (double) mediatype.SamplesPerSecond.Numerator / (double) mediatype.SamplesPerSecond.Denominator, mediatype.ExtraDataSize); } else if (mediatype.MajorType == TSMF_MAJOR_TYPE_AUDIO) { DEBUG_DVC("audio channel %d sample_rate %d bits_per_sample %d codec_data %d", mediatype.Channels, mediatype.SamplesPerSecond.Numerator, mediatype.BitsPerSample, mediatype.ExtraDataSize); stream->sample_rate = mediatype.SamplesPerSecond.Numerator; stream->channels = mediatype.Channels; stream->bits_per_sample = mediatype.BitsPerSample; if (stream->bits_per_sample == 0) stream->bits_per_sample = 16; } stream->major_type = mediatype.MajorType; stream->width = mediatype.Width; stream->height = mediatype.Height; stream->decoder = tsmf_load_decoder(name, &mediatype); }
int tsmf_ifman_on_sample(TSMF_IFMAN* ifman) { TSMF_PRESENTATION* presentation; TSMF_STREAM* stream; UINT32 StreamId; UINT64 SampleStartTime; UINT64 SampleEndTime; UINT64 ThrottleDuration; UINT32 SampleExtensions; UINT32 cbData; Stream_Seek(ifman->input, 16); Stream_Read_UINT32(ifman->input, StreamId); Stream_Seek_UINT32(ifman->input); /* numSample */ Stream_Read_UINT64(ifman->input, SampleStartTime); Stream_Read_UINT64(ifman->input, SampleEndTime); Stream_Read_UINT64(ifman->input, ThrottleDuration); Stream_Seek_UINT32(ifman->input); /* SampleFlags */ Stream_Read_UINT32(ifman->input, SampleExtensions); Stream_Read_UINT32(ifman->input, cbData); DEBUG_DVC("MessageId %d StreamId %d SampleStartTime %d SampleEndTime %d " "ThrottleDuration %d SampleExtensions %d cbData %d", ifman->message_id, StreamId, (int)SampleStartTime, (int)SampleEndTime, (int)ThrottleDuration, SampleExtensions, cbData); presentation = tsmf_presentation_find_by_id(ifman->presentation_id); if (presentation == NULL) { DEBUG_WARN("unknown presentation id"); return 1; } stream = tsmf_stream_find_by_id(presentation, StreamId); if (stream == NULL) { DEBUG_WARN("unknown stream id"); return 1; } tsmf_stream_push_sample(stream, ifman->channel_callback, ifman->message_id, SampleStartTime, SampleEndTime, ThrottleDuration, SampleExtensions, cbData, Stream_Pointer(ifman->input)); ifman->output_pending = TRUE; return 0; }
static void wts_read_drdynvc_capabilities_response(rdpPeerChannel* channel, UINT32 length) { UINT16 Version; if (length < 3) return; Stream_Seek_UINT8(channel->receiveData); /* Pad (1 byte) */ Stream_Read_UINT16(channel->receiveData, Version); DEBUG_DVC("Version: %d", Version); channel->vcm->drdynvc_state = DRDYNVC_STATE_READY; }