Home of the Squeezebox™ & Transporter® network music players.
Page 1 of 4 123 ... LastLast
Results 1 to 10 of 38
  1. #1
    Junior Member
    Join Date
    Aug 2010
    Posts
    27

    Help me write a custom SqueezeServer

    Yes, this is a big ask. I have a bunch of Squeezebox3's in my house. I like them. I have a *lot* of custom code, using the CLI interface, invested in making them part of my home automation. It all works pretty well. Squeezeboxes are my alarm clock, my music, and they participate in my calendar reminders (my house talks to me), and they pop up caller id information when the phone rings.

    There are features I want, though, that are very much unique to my house and needs and which are never going to be available in SqueezeCenter. Basically, I want total control of the SB3 display at the pixel level, and custom interpretation of the remote control IR. On the other hand, I don't really need the standard Web interface to Squeeze server; I have my own software interface to it. I'd also like something faster than the existing implementation.

    All these things convince me that what I really want to do is write my own custom squeeze server. Yes, I know. It's hard. But it's made simpler by the fact that there are a lot of features in the existing product that I just don't need.

    The problem is, the existing tech documentation does not appear to be in good shape, and what exists, is geared towards writing clients, not servers. I've gleaned enough from the slimproto documentation to have basic control of the SB3 display. What I don't understand is any of the http: stuff, that happens when it's actually time to play music. (I'm a wizard with sockets and C++, but not an expert on music formats and streaming and web pages).

    What I'm not seeing is how the actual music data flows to the SB3 from the server. I get that the server sends a strm command, with an HTTP GET embedded, to the SB3, and the SB3 feeds the GET back to the server, but I don't understand how the actual audio starts flowing. Is there a separate socket involved, or is it all done via port 9000 and magic web page stuff?

    Can someone point me to documentation? I'm fluent in C++ and Python, but not Perl, so clawing through the server sources is a very, very slow process for me.

    TIA. (Yes, I know this is ambitious, but my actual needs are simple and I think I can pull this off if I just know the protocols.)

  2. #2
    Junior Member
    Join Date
    Aug 2010
    Posts
    27
    Come on, folk. There's got to be someone in a developer's forum who can explain how the music bits get from the server to an SB3...

  3. #3
    I've not played around with the software at this level, but surely you could learn a bunch by running WireShark on your Squeezebox Server host & looking at packets. I expect it's as simple as the player making an HTTP GET request and the server sending bits back in the response message body.
    owner of the stuff at https://tuxreborn.netlify.com/
    (which used to reside at www.tux.org/~peterw/)
    Note: The best way to reach me is email or PM, as I don't spend much time on the forums.
    Free plugins: AllQuiet Auto Dim/AutoDisplay BlankSaver ContextMenu DenonSerial
    FuzzyTime KidsPlay KitchenTimer PlayLog PowerCenter/BottleRocket SaverSwitcher
    SettingsManager SleepFade StatusFirst SyncOptions VolumeLock

  4. #4
    Senior Member erland's Avatar
    Join Date
    Dec 2005
    Location
    Sweden
    Posts
    11,042
    If perl is the problem, maybe you can take a look at the small third party server someone started to write in C/C++ here:
    http://forums.slimdevices.com/showthread.php?t=38173

    The Google Code project where the source code is can be found here:
    http://code.google.com/p/squeezed/

    Or if you like to look at the protocol from the client side, it might be worth to look at SoftSqueeze which is written in Java:
    http://softsqueeze.sourceforge.net/

    I suspect you are going to have to dig a bit in code to find what you like, I don't think there are any documentation available besides what you can find on the wiki:
    http://wiki.slimdevices.com/index.ph...otoTCPProtocol

    If you want answers from someone from Logitech, try to post small questions rather than big conceptual questions that takes a lot of time to answer, they usually don't have enough time to answer complicated questions.
    Erland Isaksson (My homepage)
    Developer of many plugins/applets

  5. #5
    Senior Member bluegaspode's Avatar
    Join Date
    Jul 2009
    Location
    Berlin, Germany
    Posts
    3,229
    Quote Originally Posted by ScottM View Post
    What I'm not seeing is how the actual music data flows to the SB3 from the server. I get that the server sends a strm command, with an HTTP GET embedded, to the SB3, and the SB3 feeds the GET back to the server, but I don't understand how the actual audio starts flowing. Is there a separate socket involved, or is it all done via port 9000 and magic web page stuff?
    Behind this GET request is just the actual music file. Typically everything is served under yourserver:9000/stream.mp3 regardless of format.

    So basically you have two Sockets open: one for SlimProto serving fine grained control (start stream, stop stream, 'please reconnect, I have a new stream') and one where the Squeezebox just downloads the actual streamdata. Maybe most complicated on the server side is the progress bar: if you move it the clients just reconnect to the stream.mp3 and get a stream that starts at the specific position.
    Did you know: SqueezePlayer will stream all your music to your Android device. Take your music everywhere!
    Remote Control + Streaming to your iPad? Squeezebox + iPad = SqueezePad
    Want to see a Weather Forecast on your Radio/Touch/Controller ? => why not try my Weather Forecast Applet
    Want to use the Headphones with your Controller ? => why not try my Headphone Switcher Applet

  6. #6
    Senior Member
    Join Date
    Oct 2005
    Location
    Ireland
    Posts
    18,004
    You could also look at the scrawny server which is an attempt at a minimal SBS written in python

    http://sourceforge.net/projects/scrawnyserver/files/

  7. #7
    Junior Member
    Join Date
    Aug 2010
    Posts
    27
    Quote Originally Posted by bluegaspode View Post
    Behind this GET request is just the actual music file. Typically everything is served under yourserver:9000/stream.mp3 regardless of format.

    So basically you have two Sockets open: one for SlimProto serving fine grained control (start stream, stop stream, 'please reconnect, I have a new stream') and one where the Squeezebox just downloads the actual streamdata.
    OK. Based on all these links, I think I'm making progress but I'm not there yet. What I'm trying to ship for now is bare bones 16 bit PCM data, stereo or mono, where each 16 bit is randomly generated. This should get me white noise, and it has the advantage that if I screw up something minor I should still hear something. It looks like I'm delivering the data more or less the right way, but something is missing because all I hear is silence. (I'm using SoftSqueeze 3.7 for testing, and it works fine with my actual SBS, so the error is certainly in my own stuff.)

    See if you can spot my error.

    I get a connection from softSqueeze to my code, on port 3483. It sends me a HELO. I send some display commands (those work), and then send a "strm" with this data:
    buffer[0] = 's'; //start
    buffer[1] = '1'; //autostart
    buffer[2] = 'p'; //p=PCM, f=FLAC, ...
    buffer[3] = '1'; //pcm sample size (1=16 bits)
    buffer[4] = '3'; //sample rate (0=11k)
    buffer[5] = '2'; //mono, stereo (tried both)
    buffer[6] = '0'; //'0' little, 1 big (wav is 0, aiff is 1)
    buffer[7] = 1; //threshold
    buffer[8] = '1'; //SPDIF auto
    buffer[9] = 0; //transisition period seconds
    buffer[10] = '0'; //no transisition
    buffer[11] = 0; //no flags
    buffer[12] = 0; //0.1 secs before play?
    buffer[13] = 0; //reserved
    uintTo4(buffer + 14, 0x79995555); //replay gain, nonzero
    uintTo2(buffer + 18, 9000); //server port
    uintTo4(buffer + 20, 0); //server ip, default to back to me
    followed immediately by
    GET /stream.mp3?player=xxx HTTP/1.0\r\n\r\n

    Softsqueeze obligingly opens a connection to my code at port 9000 and sends that GET text right back. I respond on the new socket with
    HTTP/1.0 200 OK\r\n\r\n
    because I saw that in other code, followed immediately by a few hundred thousand, 16 bit, random binary values. Then I wait a couple seconds and close the socket.

    Back on the original socket, I'm getting back STAT commands, and the contents LOOK promising. I get STAT-c, STAT-h, and then a series of STAT-t with - key point - the 4 byte int "output buffer fullness" [bytes 33..37] value rising, and then falling for a few seconds, and then endlessly 0. I thought that meant I was home free and that output was being fed to and consumed by the audio chain. But there's no sound produced. I get a DSCO and, only very occasionally, a STAT-u.

    What am I missing? 16 bit PCM mono should be the simplest of the simple. Someone point out the blunder (or how to get a clue from SoftSqueeze or some other tool) before I go mad... thanks.

  8. #8
    Senior Member
    Join Date
    Oct 2005
    Location
    Ireland
    Posts
    18,004
    The usual way would be to enable debug logging in Softsqueeze,in SBS and in your server and compare Softsqueeze/SBS logs against Softsqueeze/your server logs.

  9. #9
    Senior Member bluegaspode's Avatar
    Join Date
    Jul 2009
    Location
    Berlin, Germany
    Posts
    3,229
    Looks good - seems your Squeezebox is downloading and playing all data.
    I'd try 0 as replaygain value. The value is interpreted as fixedpoint xxxx.xxxx, so you should either use 0x10000 or a plain 0 (which is interpreted as no replaygain given).
    Did you know: SqueezePlayer will stream all your music to your Android device. Take your music everywhere!
    Remote Control + Streaming to your iPad? Squeezebox + iPad = SqueezePad
    Want to see a Weather Forecast on your Radio/Touch/Controller ? => why not try my Weather Forecast Applet
    Want to use the Headphones with your Controller ? => why not try my Headphone Switcher Applet

  10. #10
    Junior Member
    Join Date
    Aug 2010
    Posts
    27
    Quote Originally Posted by bluegaspode View Post
    Looks good - seems your Squeezebox is downloading and playing all data.
    I'd try 0 as replaygain value. The value is interpreted as fixedpoint xxxx.xxxx, so you should either use 0x10000 or a plain 0 (which is interpreted as no replaygain given).
    No luck here. No value I've tried in there, including 0, has made a difference.

    Looks like it's time to install Wireshark.

    Since I'm frustrated, I'm going to mention the obvious: the documentation of the protocol (http://wiki.slimdevices.com/index.ph...otoTCPProtocol) is beyond a joke. Not simply out of date, but filled with mistakes, unanswered questions and ambiguities. As a document that carries Logitech's logo, it's an embarrassment. A formal description of the protocol is needed; if anyone knows of something better than that page, I'd be thankful.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •