mfreerdp-server and rdpsnd server fixes

This commit is contained in:
C-o-r-E 2013-03-08 12:36:38 -05:00
parent 84d00035d7
commit 989232dc41
3 changed files with 93 additions and 9 deletions

View File

@ -391,6 +391,9 @@ void rdpsnd_recv_server_audio_formats_pdu(rdpsndPlugin* rdpsnd, STREAM* s)
format->data = (BYTE*) malloc(format->cbSize);
stream_read(s, format->data, format->cbSize);
}
printf("server supports the following audio formats:");
rdpsnd_print_audio_formats(rdpsnd->ServerFormats, wNumberOfFormats);
rdpsnd_select_supported_audio_formats(rdpsnd);

View File

@ -132,6 +132,17 @@ static BOOL rdpsnd_server_send_formats(rdpsnd_server* rdpsnd, STREAM* s)
return TRUE;
}
static void rdpsnd_server_recv_waveconfirm(rdpsnd_server* rdpsnd, STREAM* s)
{
//unhandled for now
UINT16 timestamp = 0;
BYTE confirmBlockNum = 0;
stream_read_UINT16(s, timestamp);
stream_read_BYTE(s, confirmBlockNum);
stream_seek_BYTE(s); // padding
}
static void rdpsnd_server_recv_quality_mode(rdpsnd_server* rdpsnd, STREAM* s)
{
UINT16 quality;
@ -185,7 +196,7 @@ static BOOL rdpsnd_server_recv_formats(rdpsnd_server* rdpsnd, STREAM* s)
return FALSE;
}*/
//winpr_HexDump(s->p, 18);
winpr_HexDump(s->p, 18);
stream_read_UINT16(s, rdpsnd->context.client_formats[i].wFormatTag);
stream_read_UINT16(s, rdpsnd->context.client_formats[i].nChannels);
@ -280,6 +291,10 @@ static void* rdpsnd_server_thread_func(void* arg)
switch (msgType)
{
case SNDC_WAVECONFIRM:
rdpsnd_server_recv_waveconfirm(rdpsnd, s);
break;
case SNDC_QUALITYMODE:
rdpsnd_server_recv_quality_mode(rdpsnd, s);
break;

View File

@ -42,16 +42,30 @@ static const AUDIO_FORMAT audio_formats[] =
{ 0x01, 1, 8000, 2, 16, 0, NULL } /* PCM, 8000 Hz, 1 channels, 16 bits */
};
/*
UINT16 wFormatTag;
UINT16 nChannels;
UINT32 nSamplesPerSec;
UINT32 nAvgBytesPerSec;
UINT16 nBlockAlign;
UINT16 wBitsPerSample;
UINT16 cbSize;
BYTE* data;
*/
static const AUDIO_FORMAT supported_audio_formats[] =
{
{ 0x01, 2, 44100, 4, 16, 0, NULL }, /* PCM, 44100 Hz, 2 channels, 16 bits */
{ WAVE_FORMAT_PCM, 2, 44100, 176400, 4, 16, NULL },
{ WAVE_FORMAT_ALAW, 2, 22050, 44100, 2, 8, NULL }
};
static void mf_peer_rdpsnd_activated(rdpsnd_server_context* context)
{
OSStatus status;
int i;
int i, j;
BOOL formatAgreed = FALSE;
AUDIO_FORMAT* agreedFormat = NULL;
//we should actually loop through the list of client formats here
//and see if we can send the client something that it supports...
@ -67,8 +81,62 @@ static void mf_peer_rdpsnd_activated(rdpsnd_server_context* context)
context->client_formats[i].nBlockAlign,
context->client_formats[i].wBitsPerSample,
context->client_formats[i].cbSize);
for (j = 0; j < context->num_server_formats; j++)
{
if ((context->client_formats[i].wFormatTag == context->server_formats[j].wFormatTag) &&
(context->client_formats[i].nChannels == context->server_formats[j].nChannels) &&
(context->client_formats[i].nSamplesPerSec == context->server_formats[j].nSamplesPerSec))
{
printf("agreed on format!\n");
formatAgreed = TRUE;
agreedFormat = (AUDIO_FORMAT*)&context->server_formats[j];
break;
}
}
if (formatAgreed == TRUE)
break;
}
if (formatAgreed == FALSE)
{
printf("Could not agree on a audio format with the server\n");
return;
}
context->SelectFormat(context, i);
context->SetVolume(context, 0x7FFF, 0x7FFF);
switch (agreedFormat->wFormatTag)
{
case WAVE_FORMAT_ALAW:
recorderState.dataFormat.mFormatID = kAudioFormatDVIIntelIMA;
recorderState.dataFormat.mBitsPerChannel = 16;
break;
case WAVE_FORMAT_PCM:
recorderState.dataFormat.mFormatID = kAudioFormatLinearPCM;
recorderState.dataFormat.mBitsPerChannel = 4;
break;
default:
recorderState.dataFormat.mFormatID = kAudioFormatLinearPCM;
break;
}
recorderState.dataFormat.mSampleRate = 22050.0;
recorderState.dataFormat.mFormatID = kAudioFormatALaw;
recorderState.dataFormat.mFormatFlags = kAudioFormatFlagIsSignedInteger | kAudioFormatFlagsNativeEndian | kAudioFormatFlagIsPacked;;
recorderState.dataFormat.mBytesPerPacket = 4;
recorderState.dataFormat.mFramesPerPacket = 1;
recorderState.dataFormat.mBytesPerFrame = 4;
recorderState.dataFormat.mChannelsPerFrame = 2;
recorderState.dataFormat.mBitsPerChannel = 8;
/*
recorderState.dataFormat.mSampleRate = 44100.0;
recorderState.dataFormat.mFormatID = kAudioFormatLinearPCM;
recorderState.dataFormat.mFormatFlags = kAudioFormatFlagIsSignedInteger | kAudioFormatFlagsNativeEndian | kAudioFormatFlagIsPacked;
@ -77,6 +145,8 @@ static void mf_peer_rdpsnd_activated(rdpsnd_server_context* context)
recorderState.dataFormat.mBytesPerFrame = 4;
recorderState.dataFormat.mChannelsPerFrame = 2;
recorderState.dataFormat.mBitsPerChannel = 16;
*/
recorderState.snd_context = context;
@ -121,10 +191,6 @@ static void mf_peer_rdpsnd_activated(rdpsnd_server_context* context)
recorderState.currentPacket = 0;
recorderState.isRunning = true;
context->SelectFormat(context, 4);
context->SetVolume(context, 0x7FFF, 0x7FFF);
AudioQueueStart (recorderState.queue, NULL);
}
@ -134,8 +200,8 @@ BOOL mf_peer_rdpsnd_init(mfPeerContext* context)
context->rdpsnd = rdpsnd_server_context_new(context->vcm);
context->rdpsnd->data = context;
context->rdpsnd->server_formats = audio_formats;
context->rdpsnd->num_server_formats = sizeof(audio_formats) / sizeof(audio_formats[0]);
context->rdpsnd->server_formats = supported_audio_formats;
context->rdpsnd->num_server_formats = sizeof(supported_audio_formats) / sizeof(supported_audio_formats[0]);
context->rdpsnd->src_format.wFormatTag = 1;
context->rdpsnd->src_format.nChannels = 2;