1*bdc29e6aSFrançois RevolEsounD Protocol (Draft) 2*bdc29e6aSFrançois RevolAuthor: ymnk<ymnk@jcraft.com> 3*bdc29e6aSFrançois RevolData: 2000-10-02 4*bdc29e6aSFrançois Revol=============== 5*bdc29e6aSFrançois Revol 6*bdc29e6aSFrançois RevolIntroduction 7*bdc29e6aSFrançois Revol------------ 8*bdc29e6aSFrançois RevolThis document describes the protocol in EsounD system. 9*bdc29e6aSFrançois RevolUnfortunately, any formal description about EsounD had not existed. 10*bdc29e6aSFrançois RevolSo the author has tried to read the source code of EsounD and written this 11*bdc29e6aSFrançois Revoldocument. The author is also the author of JEsd, which is a re-implementation 12*bdc29e6aSFrançois Revolof EsounD in pure Java and this document is based on his knowledge, 13*bdc29e6aSFrançois Revolwhich had gotten in hacking JEsd. 14*bdc29e6aSFrançois Revol 15*bdc29e6aSFrançois Revol 16*bdc29e6aSFrançois RevolConnection Setup 17*bdc29e6aSFrançois Revol---------------- 18*bdc29e6aSFrançois RevolThe esd will wait for the TCP connection requests from EsounD compatible 19*bdc29e6aSFrançois Revolapplications. In the default, esd will listen to the TCP port 16001. 20*bdc29e6aSFrançois RevolThe client must send an initial byte of data to be authorized them-self 21*bdc29e6aSFrançois Revoland to identify the byte order to be employed. 22*bdc29e6aSFrançois RevolFor authorization, client must send 'esd-key', which is a 16 byte data. 23*bdc29e6aSFrançois RevolFor endian-ness, client must send a 4 byte data. 24*bdc29e6aSFrançois RevolIf esd does not detect any error, '1' will be sent back and 25*bdc29e6aSFrançois Revol'0' will be sent back in error. 26*bdc29e6aSFrançois Revol 27*bdc29e6aSFrançois RevolRequests 28*bdc29e6aSFrançois Revol-------- 29*bdc29e6aSFrançois Revol lock: 30*bdc29e6aSFrançois Revol esd-key:ESDKEY 31*bdc29e6aSFrançois Revol w result:BOOLEAN 32*bdc29e6aSFrançois Revol 33*bdc29e6aSFrançois Revol At first, esd will check if the client has the right to lock the device 34*bdc29e6aSFrançois Revol by esd-key. If that client has the right to do so, esd will lock the device 35*bdc29e6aSFrançois Revol and send back true. If not, false will be sent back 36*bdc29e6aSFrançois Revol 37*bdc29e6aSFrançois Revol unlock: 38*bdc29e6aSFrançois Revol esd-key:ESDKEY 39*bdc29e6aSFrançois Revol w result:BOOLEAN 40*bdc29e6aSFrançois Revol 41*bdc29e6aSFrançois Revol At first, esd will check if the client has the right to unlock the device 42*bdc29e6aSFrançois Revol by esd-key. If that client has the right to do so, esd will unlock the 43*bdc29e6aSFrançois Revol device and send back true. If not, false will be sent back 44*bdc29e6aSFrançois Revol 45*bdc29e6aSFrançois Revol ... 46*bdc29e6aSFrançois Revol 47*bdc29e6aSFrançois Revol 48*bdc29e6aSFrançois Revol 49*bdc29e6aSFrançois RevolSyntactic Conventions 50*bdc29e6aSFrançois Revol-------------------- 51*bdc29e6aSFrançois RevolAll numbers are in decimal, unless prefixed with '0x', in which case 52*bdc29e6aSFrançois Revolthey are in hexadecimal(base 16). 53*bdc29e6aSFrançois Revol 54*bdc29e6aSFrançois RevolThe general syntax used to describe data packets is: 55*bdc29e6aSFrançois Revol Name: 56*bdc29e6aSFrançois Revol encoded-form 57*bdc29e6aSFrançois Revol ... 58*bdc29e6aSFrançois Revol encoded-form 59*bdc29e6aSFrançois Revol 60*bdc29e6aSFrançois RevolFor components described in the protocol descriptions as: 61*bdc29e6aSFrançois Revol name: TYPE 62*bdc29e6aSFrançois Revol w name: TYPE 63*bdc29e6aSFrançois Revolthe encode-form are: 64*bdc29e6aSFrançois Revol N TYPE name 65*bdc29e6aSFrançois Revoland 66*bdc29e6aSFrançois Revolw N TYPE name 67*bdc29e6aSFrançois RevolN is the number of bytes in the data stream, and TYPE is the interpretation 68*bdc29e6aSFrançois Revolof those bytes. For example, 69*bdc29e6aSFrançois Revol result: BOOLEAN 70*bdc29e6aSFrançois Revolbecomes: 71*bdc29e6aSFrançois Revol 4 BOOLEAN result 72*bdc29e6aSFrançois Revol 73*bdc29e6aSFrançois RevolFor components with a static numeric value the encode-form is: 74*bdc29e6aSFrançois Revol N value name 75*bdc29e6aSFrançois RevolThe value is always interpreted as a N-byte unsigned integer. 76*bdc29e6aSFrançois Revol 77*bdc29e6aSFrançois Revol 78*bdc29e6aSFrançois RevolData Types 79*bdc29e6aSFrançois Revol---------- 80*bdc29e6aSFrançois Revol CARD8: A single byte unsigned integer. 81*bdc29e6aSFrançois Revol CARD32: 32-bit unsigned integer 82*bdc29e6aSFrançois Revol ARRAY8: A collection of CARD8. 83*bdc29e6aSFrançois Revol ARRAY8(n): This is a ARRAY8, which includes 'n' elements. 84*bdc29e6aSFrançois Revol ENDIAN: This is a ARRAY8(4), which includes 'ENDN' or 'NDNE'. 85*bdc29e6aSFrançois Revol If the first element is 'E', data from clients is in big-endian. 86*bdc29e6aSFrançois Revol BOOLEAN: This is a CARD32 and includes '0' or '1'. '1' means true. 87*bdc29e6aSFrançois Revol ESDKEY: This is a ARRAY8(16), which includes 'esd-key'. 88*bdc29e6aSFrançois Revol ESDNAME: This is a ARRAY8(128), which includes 'esd-name'. 89*bdc29e6aSFrançois Revol ESDSTREAM: This is a infinite ARRAY8. 90*bdc29e6aSFrançois Revol FORMAT: This is a CARD32. Each bits in this data has following semantics, 91*bdc29e6aSFrançois Revol (format&0x000f)==0x0000 8bit data 92*bdc29e6aSFrançois Revol (format&0x000f)==0x0001 16bit data 93*bdc29e6aSFrançois Revol (format&0x00f0)==0x0010 mono 94*bdc29e6aSFrançois Revol (format&0x00f0)==0x0020 stereo 95*bdc29e6aSFrançois Revol (format&0x0f00)==0x0000 stream 96*bdc29e6aSFrançois Revol (format&0x0f00)==0x0100 sample 97*bdc29e6aSFrançois Revol (format&0x0f00)==0x0200 ADPCM 98*bdc29e6aSFrançois Revol (format&0xf000)==0x1000 play 99*bdc29e6aSFrançois Revol (format&0xf000)==0x0000 monitor for streams, stop for samples 100*bdc29e6aSFrançois Revol (format&0xf000)==0x2000 record for streams, loop for samples 101*bdc29e6aSFrançois Revol MODE: This is a CARD32, which is '0', '1', '2' or '3'. 102*bdc29e6aSFrançois Revol 0 ERROR 103*bdc29e6aSFrançois Revol 1 STANDBY 104*bdc29e6aSFrançois Revol 2 AUTOSTANDBY 105*bdc29e6aSFrançois Revol 3 RUNNING 106*bdc29e6aSFrançois Revol 107*bdc29e6aSFrançois Revol 108*bdc29e6aSFrançois RevolPacket Format 109*bdc29e6aSFrançois Revol------------- 110*bdc29e6aSFrançois Revol init: 111*bdc29e6aSFrançois Revol 4 0 opcode 112*bdc29e6aSFrançois Revol 16 ESDKEY esd-key 113*bdc29e6aSFrançois Revol 4 ENDIAN 'ENDN' or 'NDNE' 114*bdc29e6aSFrançois Revol w 4 BOOLEAN 0 or 1 115*bdc29e6aSFrançois Revol 116*bdc29e6aSFrançois Revol 117*bdc29e6aSFrançois Revol lock: 118*bdc29e6aSFrançois Revol 4 1 opcode 119*bdc29e6aSFrançois Revol 16 ESDKEY esd-key 120*bdc29e6aSFrançois Revol 4 ENDIAN unused 121*bdc29e6aSFrançois Revol w 4 BOOLEAN 0 or 1 122*bdc29e6aSFrançois Revol 123*bdc29e6aSFrançois Revol unlock: 124*bdc29e6aSFrançois Revol 4 2 opcode 125*bdc29e6aSFrançois Revol 16 ESDKEY esd-key 126*bdc29e6aSFrançois Revol 4 ENDIAN unused 127*bdc29e6aSFrançois Revol w 4 BOOLEAN 0 or 1 128*bdc29e6aSFrançois Revol 129*bdc29e6aSFrançois Revol stream-play: 130*bdc29e6aSFrançois Revol 4 3 opcode 131*bdc29e6aSFrançois Revol 4 FORMAT format 132*bdc29e6aSFrançois Revol 4 CARD32 rate 133*bdc29e6aSFrançois Revol 128 ESDNAME name 134*bdc29e6aSFrançois Revol ? ESDSTREAM stream of PCM sound 135*bdc29e6aSFrançois Revol 136*bdc29e6aSFrançois Revol//stream-mon: This protocol is not used for the remote esd. 137*bdc29e6aSFrançois Revol// 4 4 opcode 138*bdc29e6aSFrançois Revol// 4 FORMA format 139*bdc29e6aSFrançois Revol// 4 CARD3 rate 140*bdc29e6aSFrançois Revol// 128 ESDNAME name 141*bdc29e6aSFrançois Revol// w ? ESDSTREAM stream of PCM sound 142*bdc29e6aSFrançois Revol 143*bdc29e6aSFrançois Revol stream-mon: 144*bdc29e6aSFrançois Revol 4 5 opcode 145*bdc29e6aSFrançois Revol 4 FORMAT format 146*bdc29e6aSFrançois Revol 4 CARD32 rate 147*bdc29e6aSFrançois Revol 128 ESDNAME name 148*bdc29e6aSFrançois Revol w ? ESDSTREAM stream of PCM sound 149*bdc29e6aSFrançois Revol 150*bdc29e6aSFrançois Revol sample-cache: 151*bdc29e6aSFrançois Revol 4 6 opcode 152*bdc29e6aSFrançois Revol 4 FORMAT format 153*bdc29e6aSFrançois Revol 4 CARD32 rate 154*bdc29e6aSFrançois Revol 4 n size 155*bdc29e6aSFrançois Revol 128 ESDNAME name 156*bdc29e6aSFrançois Revol w 4 CARD32 sample-id 157*bdc29e6aSFrançois Revol n ARRAY8(n) stream of PCM sound 158*bdc29e6aSFrançois Revol w 4 CARD32 sample-id 159*bdc29e6aSFrançois Revol 160*bdc29e6aSFrançois Revol sample-free: 161*bdc29e6aSFrançois Revol 4 7 opcode 162*bdc29e6aSFrançois Revol 4 CARD32 sample-id 163*bdc29e6aSFrançois Revol w 4 CARD32 sample-id 164*bdc29e6aSFrançois Revol 165*bdc29e6aSFrançois Revol sample-play: 166*bdc29e6aSFrançois Revol 4 8 opcode 167*bdc29e6aSFrançois Revol 4 CARD32 sample-id 168*bdc29e6aSFrançois Revol w 4 CARD32 sample-id 169*bdc29e6aSFrançois Revol 170*bdc29e6aSFrançois Revol sample-loop: 171*bdc29e6aSFrançois Revol 4 9 opcode 172*bdc29e6aSFrançois Revol 4 CARD32 sample-id 173*bdc29e6aSFrançois Revol w 4 CARD32 sample-id 174*bdc29e6aSFrançois Revol 175*bdc29e6aSFrançois Revol sample-stop: 176*bdc29e6aSFrançois Revol 4 10 opcode 177*bdc29e6aSFrançois Revol 4 CARD32 sample-id 178*bdc29e6aSFrançois Revol w 4 CARD32 sample-id 179*bdc29e6aSFrançois Revol 180*bdc29e6aSFrançois Revol sample-kill: 181*bdc29e6aSFrançois Revol 4 11 opcode 182*bdc29e6aSFrançois Revol 4 CARD32 sample-id 183*bdc29e6aSFrançois Revol w 4 CARD32 sample-id 184*bdc29e6aSFrançois Revol 185*bdc29e6aSFrançois Revol standby: 186*bdc29e6aSFrançois Revol 4 12 opcode 187*bdc29e6aSFrançois Revol 16 ESDKEY esd-key 188*bdc29e6aSFrançois Revol 4 ENDIAN unused 189*bdc29e6aSFrançois Revol w 4 BOOLEAN 0 or 1 190*bdc29e6aSFrançois Revol 191*bdc29e6aSFrançois Revol resume: 192*bdc29e6aSFrançois Revol 4 13 opcode 193*bdc29e6aSFrançois Revol 16 ESDKEY esd-key 194*bdc29e6aSFrançois Revol 4 ENDIAN unused 195*bdc29e6aSFrançois Revol w 4 BOOLEAN 0 or 1 196*bdc29e6aSFrançois Revol 197*bdc29e6aSFrançois Revol sample-getid: 198*bdc29e6aSFrançois Revol 4 14 opcode 199*bdc29e6aSFrançois Revol 128 ESDNAME name 200*bdc29e6aSFrançois Revol w 4 CARD32 sample-id 201*bdc29e6aSFrançois Revol 202*bdc29e6aSFrançois Revol stream-filter: 203*bdc29e6aSFrançois Revol 4 15 opcode 204*bdc29e6aSFrançois Revol 4 FORMAT format 205*bdc29e6aSFrançois Revol 4 CARD32 rate 206*bdc29e6aSFrançois Revol 128 ESDNAME name 207*bdc29e6aSFrançois Revol w 4 BOOLEAN 0 or 1 208*bdc29e6aSFrançois Revol 209*bdc29e6aSFrançois Revol server-info: 210*bdc29e6aSFrançois Revol 4 16 opcode 211*bdc29e6aSFrançois Revol w 4 CARD32 version 212*bdc29e6aSFrançois Revol w 4 CARD32 rate 213*bdc29e6aSFrançois Revol w 4 FORMAT format 214*bdc29e6aSFrançois Revol 215*bdc29e6aSFrançois Revol server-all-info: 216*bdc29e6aSFrançois Revol 4 17 opcode 217*bdc29e6aSFrançois Revol w 4 CARD32 version 218*bdc29e6aSFrançois Revol w 4 CARD32 rate 219*bdc29e6aSFrançois Revol w 4 FORMAT format 220*bdc29e6aSFrançois Revol w ? STREAMINFO 221*bdc29e6aSFrançois Revol w ? SAMPLEINFO 222*bdc29e6aSFrançois Revol 223*bdc29e6aSFrançois RevolSTREAMINFO: 224*bdc29e6aSFrançois Revol except for last in series 225*bdc29e6aSFrançois Revol w 4 CARD32 id 226*bdc29e6aSFrançois Revol w 16 ESDNAME name 227*bdc29e6aSFrançois Revol w 4 CARD32 rate 228*bdc29e6aSFrançois Revol w 4 CARD32 left-vol-scale 229*bdc29e6aSFrançois Revol w 4 CARD32 right-vol-scale 230*bdc29e6aSFrançois Revol w 4 FORMAT format 231*bdc29e6aSFrançois Revol last in series 232*bdc29e6aSFrançois Revol w 4 CARD32 0 233*bdc29e6aSFrançois Revol w 32 ARRAY8(32) unused 234*bdc29e6aSFrançois Revol 235*bdc29e6aSFrançois Revol 236*bdc29e6aSFrançois RevolSAMPLEINFO: 237*bdc29e6aSFrançois Revol except for last in series 238*bdc29e6aSFrançois Revol w 4 CARD32 id 239*bdc29e6aSFrançois Revol w 16 ESDNAME name 240*bdc29e6aSFrançois Revol w 4 CARD32 rate 241*bdc29e6aSFrançois Revol w 4 CARD32 left-vol-scale 242*bdc29e6aSFrançois Revol w 4 CARD32 right-vol-scale 243*bdc29e6aSFrançois Revol w 4 FORMAT format 244*bdc29e6aSFrançois Revol w 4 CARD32 sample-length 245*bdc29e6aSFrançois Revol last in series 246*bdc29e6aSFrançois Revol w 4 CARD32 0 247*bdc29e6aSFrançois Revol w 36 ARRAY8(36) unused 248*bdc29e6aSFrançois Revol 249*bdc29e6aSFrançois Revol 250*bdc29e6aSFrançois Revol//subscribe: undefined 251*bdc29e6aSFrançois Revol// 4 18 opcode 252*bdc29e6aSFrançois Revol 253*bdc29e6aSFrançois Revol//unsubjcribe: undefined 254*bdc29e6aSFrançois Revol// 4 19 opcode 255*bdc29e6aSFrançois Revol 256*bdc29e6aSFrançois Revol stream-pan: 257*bdc29e6aSFrançois Revol 4 20 opcode 258*bdc29e6aSFrançois Revol 4 CARD32 stream-id 259*bdc29e6aSFrançois Revol 4 CARD32 left-scale 260*bdc29e6aSFrançois Revol 4 CARD32 right-scale 261*bdc29e6aSFrançois Revol w 4 BOOLEAN 0 or 1 262*bdc29e6aSFrançois Revol 263*bdc29e6aSFrançois Revol sample-pan: 264*bdc29e6aSFrançois Revol 4 21 opcode 265*bdc29e6aSFrançois Revol 4 CARD32 sample-id 266*bdc29e6aSFrançois Revol 4 CARD32 left-scale 267*bdc29e6aSFrançois Revol 4 CARD32 right-scale 268*bdc29e6aSFrançois Revol w 4 BOOLEAN 0 or 1 269*bdc29e6aSFrançois Revol 270*bdc29e6aSFrançois Revol 271*bdc29e6aSFrançois Revol standby-mode: 272*bdc29e6aSFrançois Revol 4 22 opcode 273*bdc29e6aSFrançois Revol 4 0 version 274*bdc29e6aSFrançois Revol w 4 MODE mode 275*bdc29e6aSFrançois Revol w 4 BOOLEAN 0 or 1 276*bdc29e6aSFrançois Revol 277*bdc29e6aSFrançois Revol latency: 278*bdc29e6aSFrançois Revol 4 23 opcode 279*bdc29e6aSFrançois Revol w 4 CARD32 latency 280