43 |
{ |
{ |
44 |
STREAM s; |
STREAM s; |
45 |
|
|
46 |
s = channel_init(rdpsnd_channel, size+4); |
s = channel_init(rdpsnd_channel, size + 4); |
47 |
out_uint16_le(s, type); |
out_uint16_le(s, type); |
48 |
out_uint16_le(s, size); |
out_uint16_le(s, size); |
49 |
return s; |
return s; |
54 |
{ |
{ |
55 |
#ifdef RDPSND_DEBUG |
#ifdef RDPSND_DEBUG |
56 |
printf("RDPSND send:\n"); |
printf("RDPSND send:\n"); |
57 |
hexdump(s->channel_hdr+8, s->end-s->channel_hdr-8); |
hexdump(s->channel_hdr + 8, s->end - s->channel_hdr - 8); |
58 |
#endif |
#endif |
59 |
|
|
60 |
channel_send(s, rdpsnd_channel); |
channel_send(s, rdpsnd_channel); |
61 |
} |
} |
62 |
|
|
63 |
void rdpsnd_send_completion(uint16 tick, uint8 packet_index) |
void |
64 |
|
rdpsnd_send_completion(uint16 tick, uint8 packet_index) |
65 |
{ |
{ |
66 |
STREAM s; |
STREAM s; |
67 |
|
|
68 |
s = rdpsnd_init_packet(RDPSND_COMPLETION, 4); |
s = rdpsnd_init_packet(RDPSND_COMPLETION, 4); |
69 |
out_uint16_le(s, tick+50); |
out_uint16_le(s, tick + 50); |
70 |
out_uint8(s, packet_index); |
out_uint8(s, packet_index); |
71 |
out_uint8(s, 0); |
out_uint8(s, 0); |
72 |
s_mark_end(s); |
s_mark_end(s); |
80 |
WAVEFORMATEX *format; |
WAVEFORMATEX *format; |
81 |
STREAM out; |
STREAM out; |
82 |
BOOL device_available = False; |
BOOL device_available = False; |
83 |
|
int readcnt; |
84 |
|
int discardcnt; |
85 |
|
|
86 |
in_uint8s(in, 14); /* flags, volume, pitch, UDP port */ |
in_uint8s(in, 14); /* flags, volume, pitch, UDP port */ |
87 |
in_uint16_le(in, in_format_count); |
in_uint16_le(in, in_format_count); |
94 |
} |
} |
95 |
|
|
96 |
format_count = 0; |
format_count = 0; |
97 |
if (s_check_rem(in, 18*in_format_count)) |
if (s_check_rem(in, 18 * in_format_count)) |
98 |
{ |
{ |
99 |
for (i = 0; i < in_format_count; i++) |
for (i = 0; i < in_format_count; i++) |
100 |
{ |
{ |
107 |
in_uint16_le(in, format->wBitsPerSample); |
in_uint16_le(in, format->wBitsPerSample); |
108 |
in_uint16_le(in, format->cbSize); |
in_uint16_le(in, format->cbSize); |
109 |
|
|
110 |
|
/* read in the buffer of unknown use */ |
111 |
|
readcnt = format->cbSize; |
112 |
|
discardcnt = 0; |
113 |
|
if (format->cbSize > MAX_CBSIZE) |
114 |
|
{ |
115 |
|
fprintf(stderr, "cbSize too large for buffer: %d\n", |
116 |
|
format->cbSize); |
117 |
|
readcnt = MAX_CBSIZE; |
118 |
|
discardcnt = format->cbSize - MAX_CBSIZE; |
119 |
|
} |
120 |
|
in_uint8a(in, format->cb, readcnt); |
121 |
|
in_uint8s(in, discardcnt); |
122 |
|
|
123 |
if (device_available && wave_out_format_supported(format)) |
if (device_available && wave_out_format_supported(format)) |
124 |
{ |
{ |
125 |
format_count++; |
format_count++; |
129 |
} |
} |
130 |
} |
} |
131 |
|
|
132 |
out = rdpsnd_init_packet(RDPSND_NEGOTIATE | 0x200, 20 + 18*format_count); |
out = rdpsnd_init_packet(RDPSND_NEGOTIATE | 0x200, 20 + 18 * format_count); |
133 |
out_uint32_le(out, 3); /* flags */ |
out_uint32_le(out, 3); /* flags */ |
134 |
out_uint32(out, 0xffffffff); /* volume */ |
out_uint32(out, 0xffffffff); /* volume */ |
135 |
out_uint32(out, 0); /* pitch */ |
out_uint32(out, 0); /* pitch */ |
136 |
out_uint16(out, 0); /* UDP port */ |
out_uint16(out, 0); /* UDP port */ |
137 |
|
|
138 |
out_uint16_le(out, format_count); |
out_uint16_le(out, format_count); |
139 |
out_uint8(out, 0x95); /* pad? */ |
out_uint8(out, 0x95); /* pad? */ |
140 |
out_uint16_le(out, 2); /* status */ |
out_uint16_le(out, 2); /* status */ |
141 |
out_uint8(out, 0x77); /* pad? */ |
out_uint8(out, 0x77); /* pad? */ |
142 |
|
|
143 |
for (i = 0; i < format_count; i++) |
for (i = 0; i < format_count; i++) |
144 |
{ |
{ |
149 |
out_uint32_le(out, format->nAvgBytesPerSec); |
out_uint32_le(out, format->nAvgBytesPerSec); |
150 |
out_uint16_le(out, format->nBlockAlign); |
out_uint16_le(out, format->nBlockAlign); |
151 |
out_uint16_le(out, format->wBitsPerSample); |
out_uint16_le(out, format->wBitsPerSample); |
152 |
out_uint16(out, 0); /* cbSize */ |
out_uint16(out, 0); /* cbSize */ |
153 |
} |
} |
154 |
|
|
155 |
s_mark_end(out); |
s_mark_end(out); |
185 |
|
|
186 |
#ifdef RDPSND_DEBUG |
#ifdef RDPSND_DEBUG |
187 |
printf("RDPSND recv:\n"); |
printf("RDPSND recv:\n"); |
188 |
hexdump(s->p, s->end-s->p); |
hexdump(s->p, s->end - s->p); |
189 |
#endif |
#endif |
190 |
|
|
191 |
if (awaiting_data_packet) |
if (awaiting_data_packet) |
220 |
} |
} |
221 |
|
|
222 |
in_uint8(s, type); |
in_uint8(s, type); |
223 |
in_uint8s(s, 1); /* unknown? */ |
in_uint8s(s, 1); /* unknown? */ |
224 |
in_uint16_le(s, datalen); |
in_uint16_le(s, datalen); |
225 |
|
|
226 |
switch (type) |
switch (type) |
227 |
{ |
{ |
228 |
case RDPSND_WRITE: |
case RDPSND_WRITE: |
229 |
in_uint16_le(s, tick); |
in_uint16_le(s, tick); |
230 |
in_uint16_le(s, format); |
in_uint16_le(s, format); |
231 |
in_uint8(s, packet_index); |
in_uint8(s, packet_index); |
232 |
awaiting_data_packet = True; |
awaiting_data_packet = True; |
233 |
break; |
break; |
234 |
case RDPSND_CLOSE: |
case RDPSND_CLOSE: |
235 |
wave_out_close(); |
wave_out_close(); |
236 |
device_open = False; |
device_open = False; |
237 |
break; |
break; |
238 |
case RDPSND_NEGOTIATE: |
case RDPSND_NEGOTIATE: |
239 |
rdpsnd_process_negotiate(s); |
rdpsnd_process_negotiate(s); |
240 |
break; |
break; |
241 |
case RDPSND_UNKNOWN6: |
case RDPSND_UNKNOWN6: |
242 |
rdpsnd_process_unknown6(s); |
rdpsnd_process_unknown6(s); |
243 |
break; |
break; |
244 |
case RDPSND_SET_VOLUME: |
case RDPSND_SET_VOLUME: |
245 |
in_uint32(s, volume); |
in_uint32(s, volume); |
246 |
if ( device_open ) |
if (device_open) |
247 |
{ |
{ |
248 |
wave_out_volume((volume & 0xffff), (volume & 0xffff0000) >> 16); |
wave_out_volume((volume & 0xffff), (volume & 0xffff0000) >> 16); |
249 |
} |
} |
250 |
break; |
break; |
251 |
default: |
default: |
252 |
unimpl("RDPSND packet type %d\n", type); |
unimpl("RDPSND packet type %d\n", type); |
253 |
break; |
break; |
254 |
} |
} |
255 |
} |
} |
256 |
|
|