slimproto.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. /*
  2. * Squeezelite - lightweight headless squeezebox emulator
  3. *
  4. * (c) Adrian Smith 2012-2015, triode1@btinternet.com
  5. * Ralph Irving 2015-2017, ralph_irving@hotmail.com
  6. *
  7. * This program is free software: you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation, either version 3 of the License, or
  10. * (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  19. *
  20. */
  21. // packet formats for slimproto
  22. #ifndef SUN
  23. #pragma pack(push, 1)
  24. #else
  25. #pragma pack(1)
  26. #endif
  27. // from S:N:Slimproto _hello_handler
  28. struct HELO_packet {
  29. char opcode[4];
  30. u32_t length;
  31. u8_t deviceid;
  32. u8_t revision;
  33. u8_t mac[6];
  34. u8_t uuid[16];
  35. u16_t wlan_channellist;
  36. u32_t bytes_received_H, bytes_received_L;
  37. char lang[2];
  38. // u8_t capabilities[];
  39. };
  40. // S:N:Slimproto _stat_handler
  41. struct STAT_packet {
  42. char opcode[4];
  43. u32_t length;
  44. u32_t event;
  45. u8_t num_crlf;
  46. u8_t mas_initialized;
  47. u8_t mas_mode;
  48. u32_t stream_buffer_size;
  49. u32_t stream_buffer_fullness;
  50. u32_t bytes_received_H;
  51. u32_t bytes_received_L;
  52. u16_t signal_strength;
  53. u32_t jiffies;
  54. u32_t output_buffer_size;
  55. u32_t output_buffer_fullness;
  56. u32_t elapsed_seconds;
  57. u16_t voltage;
  58. u32_t elapsed_milliseconds;
  59. u32_t server_timestamp;
  60. u16_t error_code;
  61. };
  62. // S:N:Slimproto _disco_handler
  63. struct DSCO_packet {
  64. char opcode[4];
  65. u32_t length;
  66. u8_t reason;
  67. };
  68. // S:N:Slimproto _http_response_handler
  69. struct RESP_header {
  70. char opcode[4];
  71. u32_t length;
  72. // char header[] - added in sendRESP
  73. };
  74. // S:N:Slimproto _http_metadata_handler
  75. struct META_header {
  76. char opcode[4];
  77. u32_t length;
  78. // char metadata[]
  79. };
  80. // S:N:Slimproto _http_setting_handler
  81. struct SETD_header {
  82. char opcode[4];
  83. u32_t length;
  84. u8_t id;
  85. // data
  86. };
  87. #if IR
  88. struct IR_packet {
  89. char opcode[4];
  90. u32_t length;
  91. u32_t jiffies;
  92. u8_t format; // ignored by server
  93. u8_t bits; // ignored by server
  94. u32_t ir_code;
  95. };
  96. #endif
  97. // from S:P:Squeezebox stream_s
  98. struct strm_packet {
  99. char opcode[4];
  100. char command;
  101. u8_t autostart;
  102. u8_t format;
  103. u8_t pcm_sample_size;
  104. u8_t pcm_sample_rate;
  105. u8_t pcm_channels;
  106. u8_t pcm_endianness;
  107. u8_t threshold;
  108. u8_t spdif_enable;
  109. u8_t transition_period;
  110. u8_t transition_type;
  111. u8_t flags;
  112. u8_t output_threshold;
  113. u8_t slaves;
  114. u32_t replay_gain;
  115. u16_t server_port;
  116. u32_t server_ip;
  117. //char request_string[];
  118. };
  119. // S:P:Squeezebox2
  120. struct aude_packet {
  121. char opcode[4];
  122. u8_t enable_spdif;
  123. u8_t enable_dac;
  124. };
  125. // S:P:Squeezebox2
  126. struct audg_packet {
  127. char opcode[4];
  128. u32_t old_gainL; // unused
  129. u32_t old_gainR; // unused
  130. u8_t adjust;
  131. u8_t preamp; // unused
  132. u32_t gainL;
  133. u32_t gainR;
  134. // squence ids - unused
  135. };
  136. // S:P:Squeezebox2
  137. struct cont_packet {
  138. char opcode[4];
  139. u32_t metaint;
  140. u8_t loop;
  141. // guids we don't use
  142. };
  143. // S:C:Commands
  144. struct serv_packet {
  145. char opcode[4];
  146. u32_t server_ip;
  147. // possible sync group
  148. };
  149. // S:P:Squeezebox2
  150. struct setd_packet {
  151. char opcode[4];
  152. u8_t id;
  153. char data[];
  154. };
  155. // codec open - this is an extension to slimproto to allow the server to read the header and then return decode params
  156. struct codc_packet {
  157. char opcode[4];
  158. u8_t format;
  159. u8_t pcm_sample_size;
  160. u8_t pcm_sample_rate;
  161. u8_t pcm_channels;
  162. u8_t pcm_endianness;
  163. };
  164. // initially Boom
  165. struct audo_packet {
  166. char opcode[4];
  167. u8_t config;
  168. };
  169. #ifndef SUN
  170. #pragma pack(pop)
  171. #else
  172. #pragma pack()
  173. #endif