sfreerdp-server: get rdpsnd channel to initialize

This commit is contained in:
Marc-André Moreau 2012-10-08 16:29:40 -04:00
parent 829723582e
commit 84f88883e9
5 changed files with 34 additions and 12 deletions

View File

@ -373,6 +373,7 @@ static boolean audin_server_open(audin_server_context* context)
if (audin->audin_channel_thread == NULL) if (audin->audin_channel_thread == NULL)
{ {
audin->audin_channel = WTSVirtualChannelOpenEx(context->vcm, "AUDIO_INPUT", WTS_CHANNEL_OPTION_DYNAMIC); audin->audin_channel = WTSVirtualChannelOpenEx(context->vcm, "AUDIO_INPUT", WTS_CHANNEL_OPTION_DYNAMIC);
if (audin->audin_channel == NULL) if (audin->audin_channel == NULL)
return false; return false;

View File

@ -91,12 +91,15 @@ static boolean rdpsnd_server_send_formats(rdpsnd_server* rdpsnd, STREAM* s)
stream_write_uint16(s, rdpsnd->context.server_formats[i].wFormatTag); /* wFormatTag (WAVE_FORMAT_PCM) */ stream_write_uint16(s, rdpsnd->context.server_formats[i].wFormatTag); /* wFormatTag (WAVE_FORMAT_PCM) */
stream_write_uint16(s, rdpsnd->context.server_formats[i].nChannels); /* nChannels */ stream_write_uint16(s, rdpsnd->context.server_formats[i].nChannels); /* nChannels */
stream_write_uint32(s, rdpsnd->context.server_formats[i].nSamplesPerSec); /* nSamplesPerSec */ stream_write_uint32(s, rdpsnd->context.server_formats[i].nSamplesPerSec); /* nSamplesPerSec */
stream_write_uint32(s, rdpsnd->context.server_formats[i].nSamplesPerSec * stream_write_uint32(s, rdpsnd->context.server_formats[i].nSamplesPerSec *
rdpsnd->context.server_formats[i].nChannels * rdpsnd->context.server_formats[i].nChannels *
rdpsnd->context.server_formats[i].wBitsPerSample / 8); /* nAvgBytesPerSec */ rdpsnd->context.server_formats[i].wBitsPerSample / 8); /* nAvgBytesPerSec */
stream_write_uint16(s, rdpsnd->context.server_formats[i].nBlockAlign); /* nBlockAlign */ stream_write_uint16(s, rdpsnd->context.server_formats[i].nBlockAlign); /* nBlockAlign */
stream_write_uint16(s, rdpsnd->context.server_formats[i].wBitsPerSample); /* wBitsPerSample */ stream_write_uint16(s, rdpsnd->context.server_formats[i].wBitsPerSample); /* wBitsPerSample */
stream_write_uint16(s, rdpsnd->context.server_formats[i].cbSize); /* cbSize */ stream_write_uint16(s, rdpsnd->context.server_formats[i].cbSize); /* cbSize */
if (rdpsnd->context.server_formats[i].cbSize > 0) if (rdpsnd->context.server_formats[i].cbSize > 0)
{ {
stream_write(s, rdpsnd->context.server_formats[i].data, rdpsnd->context.server_formats[i].cbSize); stream_write(s, rdpsnd->context.server_formats[i].data, rdpsnd->context.server_formats[i].cbSize);
@ -296,19 +299,20 @@ static void rdpsnd_server_select_format(rdpsnd_server_context* context, int clie
static boolean rdpsnd_server_send_audio_pdu(rdpsnd_server* rdpsnd) static boolean rdpsnd_server_send_audio_pdu(rdpsnd_server* rdpsnd)
{ {
STREAM* s = rdpsnd->rdpsnd_pdu;
rdpsndFormat* format;
int tbytes_per_frame;
uint8* src;
int size; int size;
boolean r;
uint8* src;
int frames; int frames;
int fill_size; int fill_size;
boolean r; rdpsndFormat* format;
int tbytes_per_frame;
STREAM* s = rdpsnd->rdpsnd_pdu;
format = &rdpsnd->context.client_formats[rdpsnd->context.selected_client_format]; format = &rdpsnd->context.client_formats[rdpsnd->context.selected_client_format];
tbytes_per_frame = format->nChannels * rdpsnd->src_bytes_per_sample; tbytes_per_frame = format->nChannels * rdpsnd->src_bytes_per_sample;
if (format->nSamplesPerSec == rdpsnd->context.src_format.nSamplesPerSec && format->nChannels == rdpsnd->context.src_format.nChannels) if ((format->nSamplesPerSec == rdpsnd->context.src_format.nSamplesPerSec) &&
(format->nChannels == rdpsnd->context.src_format.nChannels))
{ {
src = rdpsnd->out_buffer; src = rdpsnd->out_buffer;
frames = rdpsnd->out_pending_frames; frames = rdpsnd->out_pending_frames;
@ -366,6 +370,7 @@ static boolean rdpsnd_server_send_audio_pdu(rdpsnd_server* rdpsnd)
stream_check_size(s, size + fill_size); stream_check_size(s, size + fill_size);
stream_write_uint32(s, 0); /* bPad */ stream_write_uint32(s, 0); /* bPad */
stream_write(s, src + 4, size - 4); stream_write(s, src + 4, size - 4);
if (fill_size > 0) if (fill_size > 0)
stream_write_zero(s, fill_size); stream_write_zero(s, fill_size);
@ -390,8 +395,8 @@ static boolean rdpsnd_server_send_samples(rdpsnd_server_context* context, const
{ {
cframes = MIN(nframes, rdpsnd->out_frames - rdpsnd->out_pending_frames); cframes = MIN(nframes, rdpsnd->out_frames - rdpsnd->out_pending_frames);
cframesize = cframes * rdpsnd->src_bytes_per_frame; cframesize = cframes * rdpsnd->src_bytes_per_frame;
memcpy(rdpsnd->out_buffer + (rdpsnd->out_pending_frames * rdpsnd->src_bytes_per_frame),
buf, cframesize); memcpy(rdpsnd->out_buffer + (rdpsnd->out_pending_frames * rdpsnd->src_bytes_per_frame), buf, cframesize);
buf = (uint8*) buf + cframesize; buf = (uint8*) buf + cframesize;
nframes -= cframes; nframes -= cframes;
rdpsnd->out_pending_frames += cframes; rdpsnd->out_pending_frames += cframes;
@ -466,15 +471,21 @@ void rdpsnd_server_context_free(rdpsnd_server_context* context)
freerdp_thread_stop(rdpsnd->rdpsnd_channel_thread); freerdp_thread_stop(rdpsnd->rdpsnd_channel_thread);
freerdp_thread_free(rdpsnd->rdpsnd_channel_thread); freerdp_thread_free(rdpsnd->rdpsnd_channel_thread);
} }
if (rdpsnd->rdpsnd_channel) if (rdpsnd->rdpsnd_channel)
WTSVirtualChannelClose(rdpsnd->rdpsnd_channel); WTSVirtualChannelClose(rdpsnd->rdpsnd_channel);
if (rdpsnd->rdpsnd_pdu) if (rdpsnd->rdpsnd_pdu)
stream_free(rdpsnd->rdpsnd_pdu); stream_free(rdpsnd->rdpsnd_pdu);
if (rdpsnd->out_buffer) if (rdpsnd->out_buffer)
xfree(rdpsnd->out_buffer); xfree(rdpsnd->out_buffer);
if (rdpsnd->dsp_context) if (rdpsnd->dsp_context)
freerdp_dsp_context_free(rdpsnd->dsp_context); freerdp_dsp_context_free(rdpsnd->dsp_context);
if (rdpsnd->context.client_formats) if (rdpsnd->context.client_formats)
xfree(rdpsnd->context.client_formats); xfree(rdpsnd->context.client_formats);
xfree(rdpsnd); xfree(rdpsnd);
} }

View File

@ -44,7 +44,7 @@ static void sf_peer_rdpsnd_activated(rdpsnd_server_context* context)
printf("RDPSND Activated\n"); printf("RDPSND Activated\n");
} }
void sf_peer_rdpsnd_init(testPeerContext* context) boolean sf_peer_rdpsnd_init(testPeerContext* context)
{ {
context->rdpsnd = rdpsnd_server_context_new(context->vcm); context->rdpsnd = rdpsnd_server_context_new(context->vcm);
context->rdpsnd->data = context; context->rdpsnd->data = context;
@ -59,4 +59,8 @@ void sf_peer_rdpsnd_init(testPeerContext* context)
context->rdpsnd->src_format.wBitsPerSample = 16; context->rdpsnd->src_format.wBitsPerSample = 16;
context->rdpsnd->Activated = sf_peer_rdpsnd_activated; context->rdpsnd->Activated = sf_peer_rdpsnd_activated;
context->rdpsnd->Initialize(context->rdpsnd);
return true;
} }

View File

@ -26,7 +26,7 @@
#include "sfreerdp.h" #include "sfreerdp.h"
void sf_peer_rdpsnd_init(testPeerContext* context); boolean sf_peer_rdpsnd_init(testPeerContext* context);
#endif /* SF_RDPSND_H */ #endif /* SF_RDPSND_H */

View File

@ -482,6 +482,7 @@ boolean tf_peer_post_connect(freerdp_peer* client)
test_peer_load_icon(client); test_peer_load_icon(client);
/* Iterate all channel names requested by the client and activate those supported by the server */ /* Iterate all channel names requested by the client and activate those supported by the server */
for (i = 0; i < client->settings->num_channels; i++) for (i = 0; i < client->settings->num_channels; i++)
{ {
if (client->settings->channels[i].joined) if (client->settings->channels[i].joined)
@ -498,11 +499,16 @@ boolean tf_peer_post_connect(freerdp_peer* client)
tf_debug_channel_thread_func, context); tf_debug_channel_thread_func, context);
} }
} }
else if (strncmp(client->settings->channels[i].name, "rdpsnd", 6) == 0)
{
sf_peer_rdpsnd_init(context); /* Audio Output */
}
} }
} }
/* Dynamic Virtual Channels */
sf_peer_audin_init(context); /* Audio Input */ sf_peer_audin_init(context); /* Audio Input */
sf_peer_rdpsnd_init(context); /* Audio Output */
/* Return false here would stop the execution of the peer mainloop. */ /* Return false here would stop the execution of the peer mainloop. */