/[rdesktop]/sourceforge.net/rdesktop/trunk/rdpsnd.c
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /sourceforge.net/rdesktop/trunk/rdpsnd.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 493 by stargo, Tue Oct 14 07:53:10 2003 UTC revision 499 by astrand, Wed Oct 15 14:01:32 2003 UTC
# Line 43  rdpsnd_init_packet(uint16 type, uint16 s Line 43  rdpsnd_init_packet(uint16 type, uint16 s
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;
# Line 54  rdpsnd_send(STREAM s) Line 54  rdpsnd_send(STREAM 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);
# Line 93  rdpsnd_process_negotiate(STREAM in) Line 94  rdpsnd_process_negotiate(STREAM in)
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                  {                  {
# Line 111  rdpsnd_process_negotiate(STREAM in) Line 112  rdpsnd_process_negotiate(STREAM in)
112                          discardcnt = 0;                          discardcnt = 0;
113                          if (format->cbSize > MAX_CBSIZE)                          if (format->cbSize > MAX_CBSIZE)
114                          {                          {
115                                  fprintf(stderr, "cbSize too large for buffer: %d\n", format->cbSize);                                  fprintf(stderr, "cbSize too large for buffer: %d\n",
116                                            format->cbSize);
117                                  readcnt = MAX_CBSIZE;                                  readcnt = MAX_CBSIZE;
118                                  discardcnt = format->cbSize - MAX_CBSIZE;                                  discardcnt = format->cbSize - MAX_CBSIZE;
119                          }                          }
# Line 127  rdpsnd_process_negotiate(STREAM in) Line 129  rdpsnd_process_negotiate(STREAM in)
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          {          {
# Line 147  rdpsnd_process_negotiate(STREAM in) Line 149  rdpsnd_process_negotiate(STREAM in)
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);
# Line 183  rdpsnd_process(STREAM s) Line 185  rdpsnd_process(STREAM s)
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)
# Line 218  rdpsnd_process(STREAM s) Line 220  rdpsnd_process(STREAM s)
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    

Legend:
Removed from v.493  
changed lines
  Added in v.499

  ViewVC Help
Powered by ViewVC 1.1.26