Home of the Squeezebox™ & Transporter® network music players.
Page 3 of 6 FirstFirst 12345 ... LastLast
Results 21 to 30 of 55
  1. #21
    Senior Member
    Join Date
    Jan 2011
    Location
    Germany
    Posts
    217
    Quote Originally Posted by philippe_44 View Post
    one other thing: do you plan to have a virtual player for the whole hue bridge or per lamp?
    Up to now I am planning with one virtual player per hue bridge exposed to LMS.

    Background: The communication has to happen with the hue bridge which is actually steering the lamps. I also think that this would keep the number of virtual players low as one lamp for a disco would be ridiculous.

  2. #22
    Senior Member
    Join Date
    May 2008
    Location
    Canada
    Posts
    2,956
    Quote Originally Posted by chincheta0815 View Post
    Up to now I am planning with one virtual player per hue bridge exposed to LMS.

    Background: The communication has to happen with the hue bridge which is actually steering the lamps. I also think that this would keep the number of virtual players low as one lamp for a disco would be ridiculous.
    I have the new version raop+upnp discovering Hue and working fine as a virtual player but ... the compilation of all that on Solaris is a true nightmare. I'm not sure I'll be able to do much more. Getting libupnp to compile was already painful but now even libsoxr is a mess (while it works on Windows, OSX and all Linux flavors). Maybe it's my gcc toolchain under SunOS, but it's seems to be a fair bit of work
    Last edited by philippe_44; 2017-04-20 at 22:46.
    LMS 7.7, 7.8 and 7.9 - 5xRadio, 3xBoom, 4xDuet, 1xTouch, 1 SB2. Sonos PLAY:3, PLAY:5, Marantz NR1603, JBL OnBeat, XBoxOne, XBMC, Foobar2000, ShairPortW, JRiver 21, 2xChromecast Audio, Chromecast v1 and v2, , Pi B3, B2, Pi B+, 2xPi A+, Odroid-C1, Odroid-C2, Cubie2, Yamaha WX-010, AppleTV 4, Airport Express

  3. #23
    Senior Member
    Join Date
    Jan 2011
    Location
    Germany
    Posts
    217
    Quote Originally Posted by philippe_44 View Post
    I have the new version raop+upnp discovering Hue and working fine as a virtual player but ... the compilation of all that on Solaris is a true nightmare. I'm not sure I'll be able to do much more. Getting libupnp to compile was already painful but now even libsoxr is a mess (while it works on Windows, OSX and all Linux flavors). Maybe it's my gcc toolchain under SunOS, but it's seems to be a fair bit of work
    For getting libupnp to compile on Solaris flavours I can provide you with the configure-command I use. This compiled libupnp very well. The most important thing was to use "-D_POSIX_PTHREAD_SEMANTICS -D_REENTRANT -D__EXTENSIONS__" is guess, but I can provide you with the complete log if you are interested.

    As for the simple sox I was able to compile some base version of that also for usage as a sox binary in LMS.
    I will have a look and provide you with some info.

    In all cases I did not get the squeeze2upmp bridge to compile with dyanmics libs... Maybe the Makefiles in my repo will help you? (https://github.com/chincheta0815/Hue...Makefile.sunos and https://github.com/chincheta0815/Hue...ation/Makefile)

    Ah, and use "gcc" and "gmake"! On Oracle Solaris you might sometimes run into the issue that the system uses sun's "cc" and a different "make".

    An question that might be very dump: Is it actually necessary to use all roap libs (faad, mad, libsoxr) as I only need a pcm stream?
    Last edited by chincheta0815; 2017-04-20 at 23:58.

  4. #24
    Senior Member
    Join Date
    May 2008
    Location
    Canada
    Posts
    2,956

    How to best send asynchronous HTTP client requests in C?

    My version of libupnp also failed on some regex for libtool to extract only certain symbols that I had do change manually and some macro definition. But soxr is royal pain due to partial definition of length-specific integers accros different files in the compiler library. So sometimes you have to include your version, sometimes you can't. I need to figure that out properly tomorrow then do mad, flac and faad ...

    Okay, now I need to ask you the question why Solaris?
    Last edited by philippe_44; 2017-04-21 at 00:06.
    LMS 7.7, 7.8 and 7.9 - 5xRadio, 3xBoom, 4xDuet, 1xTouch, 1 SB2. Sonos PLAY:3, PLAY:5, Marantz NR1603, JBL OnBeat, XBoxOne, XBMC, Foobar2000, ShairPortW, JRiver 21, 2xChromecast Audio, Chromecast v1 and v2, , Pi B3, B2, Pi B+, 2xPi A+, Odroid-C1, Odroid-C2, Cubie2, Yamaha WX-010, AppleTV 4, Airport Express

  5. #25
    Senior Member
    Join Date
    Jan 2011
    Location
    Germany
    Posts
    217
    Quote Originally Posted by philippe_44 View Post
    My version of libupnp also failed on some regex for libtool to extract only certain symbols that I had do change manually and some macro definition. But soxr is royal pain due to partial definition of length-specific integers accros different files in the compiler library. So sometimes you have to include your version, sometimes you can't. I need to figure that out properly tomorrow then do mad, flac and faad ...

    Okay, now I need to ask you the question why Solaris?
    I can provide you with the static libs of libupnp if you want... The same could hold for flac, faad and mad. Concerning soxr: I did not try that so far, just sox.

    The thing with solaris:
    I run OmniOS which relies on gcc components.
    The reason is that I once did everything with zfs, wrote service manifests etc.
    And another issue was that Linux once shooted my hd controller due to an update.
    The controller driver wasn't there anymore...

    Up to now I never had big pain with SunOS, although I have to admit it is quite specific... ;o)

    If I can help you with compiling just let me now.
    Maybe it is also poassible to leave out some libs as the plugin should only output something for visualization...

  6. #26
    Senior Member
    Join Date
    May 2008
    Location
    Canada
    Posts
    2,956
    Quote Originally Posted by chincheta0815 View Post
    I can provide you with the static libs of libupnp if you want... The same could hold for flac, faad and mad. Concerning soxr: I did not try that so far, just sox.

    The thing with solaris:
    I run OmniOS which relies on gcc components.
    The reason is that I once did everything with zfs, wrote service manifests etc.
    And another issue was that Linux once shooted my hd controller due to an update.
    The controller driver wasn't there anymore...

    Up to now I never had big pain with SunOS, although I have to admit it is quite specific... ;o)

    If I can help you with compiling just let me now.
    Maybe it is also poassible to leave out some libs as the plugin should only output something for visualization...
    I got that sorted out now. You should find everything here https://www.dropbox.com/sh/i1iidptn5...6a-V010ba?dl=0. It includes all libraries and makefiles for the helper and a LMS Perl part. I tested all that quickly, it works on Windows and SunOS, so I assume the rest is fine (the Perl part also works). Hue bridge are discovered, players are created and songs can be "played". It's an hybrid of my UPnP and AirPlay bridges. It behaves much closer to a full squeezelite and accepts mp3,pcm,flac,aac and decodes them so that you can process them (the upnp bridge does not do that, it just transfers whatever it receives to the player).

    In file squeeze2hue.c you have a "PlayerThread" where you can build all the communication with the Hue bridge and lamps. It receives control messages (PLAY, PAUSE, STOP, VOLUME ...) from the slimproto callback, so you can spend all the time you want in that thread when you receive a message, blocking is not an issue

    I've not backported what you've developped, sorry, but that all that was already a large piece of work. Still, what you've done should easy be integrated in "PlayerThread" as all the HueBridge detection/virtual player creation is functionnal, you don't need to backport anything there

    In file output_hue.c you have access to a buffer of PCM audio (always converted to 44.1KHz, 16bits) so whenever you'll be willing to add some dsp effects using raw samples, you should do that there.

    There is version that uses shared libraries for the audio processing (mp3,flac,aac) and a statically linked one. This is probably the one you want to use, I've not tried the dynamically loaded one and the .so names are probably wrong

    There are probably bugs remaining, more than you want

    Good luck !
    LMS 7.7, 7.8 and 7.9 - 5xRadio, 3xBoom, 4xDuet, 1xTouch, 1 SB2. Sonos PLAY:3, PLAY:5, Marantz NR1603, JBL OnBeat, XBoxOne, XBMC, Foobar2000, ShairPortW, JRiver 21, 2xChromecast Audio, Chromecast v1 and v2, , Pi B3, B2, Pi B+, 2xPi A+, Odroid-C1, Odroid-C2, Cubie2, Yamaha WX-010, AppleTV 4, Airport Express

  7. #27
    Senior Member
    Join Date
    Jan 2011
    Location
    Germany
    Posts
    217
    Quote Originally Posted by philippe_44 View Post
    I got that sorted out now. You should find everything here https://www.dropbox.com/sh/i1iidptn5...6a-V010ba?dl=0. It includes all libraries and makefiles for the helper and a LMS Perl part. I tested all that quickly, it works on Windows and SunOS, so I assume the rest is fine (the Perl part also works). Hue bridge are discovered, players are created and songs can be "played". It's an hybrid of my UPnP and AirPlay bridges. It behaves much closer to a full squeezelite and accepts mp3,pcm,flac,aac and decodes them so that you can process them (the upnp bridge does not do that, it just transfers whatever it receives to the player).
    Hi philippe,

    thank you very, very much! That really helps me a lot. Especially my understanding of how the plugin works will grow and it already did - I hope I will let you know about all important progress I make. For now I got the hue switching on and off - I got it steered! Next step asides working functions into the plugin framework will also be the handling of the hue configuration (getting the number of lamps from the bridge, write their info into structures, etc. -> will be a next hard learning phase in terms of C). But: I understand all everytime more!

    Quote Originally Posted by philippe_44 View Post
    In file squeeze2hue.c you have a "PlayerThread" where you can build all the communication with the Hue bridge and lamps. It receives control messages (PLAY, PAUSE, STOP, VOLUME ...) from the slimproto callback, so you can spend all the time you want in that thread when you receive a message, blocking is not an issue
    Just to make sure: When the STOP is received, I can send a "turn the blinking out message" to the hue and wait for the "okay, sorry for annoying" from the bridge. The "here-is-the-music-please-enlighten-me" will be done after a PLAY is received and I will have to do a kind of "HuePlayer" (approx. same as roap-player) that converts the sound stream from the slimtiny to hue commands.

    Quote Originally Posted by philippe_44 View Post
    I've not backported what you've developped, sorry, but that all that was already a large piece of work. Still, what you've done should easy be integrated in "PlayerThread" as all the HueBridge detection/virtual player creation is functionnal, you don't need to backport anything there
    That is really not an issue as my stuff is changing too much for the moment...

    Quote Originally Posted by philippe_44 View Post
    In file output_hue.c you have access to a buffer of PCM audio (always converted to 44.1KHz, 16bits) so whenever you'll be willing to add some dsp effects using raw samples, you should do that there.
    That would probably be the place where I have to hook in the "music-to-light-steering" converter. I have to work on a concept for that...

    Quote Originally Posted by philippe_44 View Post
    There is version that uses shared libraries for the audio processing (mp3,flac,aac) and a statically linked one. This is probably the one you want to use, I've not tried the dynamically loaded one and the .so names are probably wrong
    Well, the static one is okay. Linking dynamically caused problems...

    Quote Originally Posted by philippe_44 View Post
    There are probably bugs remaining, more than you want
    I like surprises and easter eggs. Might be your revenge to my code

    Quote Originally Posted by philippe_44 View Post
    Good luck !
    Something I will definitely need

    Question: Do you like to sneak into the code sometimes without know me that you do? Then I would do a github repo of just the LMS-to-Hue folder (same pattern as you use for your plugins, all files, different pattern or not at all?). I ask, as there are a lot of files that are "yours" and you still remain the "owner" of the framework. I do not want to misuse your trust as I really appreciate your help and work.
    LMS-7.9@solaris. 2x Radio, 2x Duet, 1x Chromecast v1, ShairTunes, 1x Philips Hue System

  8. #28
    Senior Member
    Join Date
    May 2008
    Location
    Canada
    Posts
    2,956
    Quote Originally Posted by chincheta0815 View Post
    Hi philippe,
    Just to make sure: When the STOP is received, I can send a "turn the blinking out message" to the hue and wait for the "okay, sorry for annoying" from the bridge. The "here-is-the-music-please-enlighten-me" will be done after a PLAY is received and I will have to do a kind of "HuePlayer" (approx. same as roap-player) that converts the sound stream from the slimtiny to hue commands.
    I'm not sure to understand.

    The "PlayerThread" receives commands from LMS like PLAY, PAUSE, STOP, VOLUME. In that thread, you can send any command to the HueBridge/Lamps without worrying about being blocking, as far as slimproto is concerned. Of course, if you spend a lot in that thread handling one LMS commands, all others will be queued.

    After receiving the "PLAY" command in that thread, then the PCM buffers will start to be filled in output_hue_thread (output_hue.c). Here, you can do tweak the light effects depending on some complex audio analysis (frames are in ctx->output.buf). If you don't do anything, the audio will just be consumed
    Code:
    		if (ctx->output.buf_frames) {
    				usleep((FRAMES_PER_BLOCK * 1000000) / 44100);
    
    				// current block is a track start, set the value
    				if (ctx->output.detect_start_time) {
    					ctx->output.detect_start_time = false;
    					ctx->output.track_start_time = gettime_ms();
    					LOG_INFO("[%p]: track actual start time:%u (gap:%d)", ctx, ctx->output.track_start_time,
    										(s32_t) (ctx->output.track_start_time - ctx->output.start_at));
    				}
    
    				ctx->output.buf_frames = 0;
    				ran = true;
    			}
    But as a first development step, in the "PlayerThread" you can start some effect as soon as you receive "PLAY" (okay, the string is "CONNECT"), stop it when you receive "STOP" or "PAUSE" and do also variation when the metadata (genre?) is collected. I would ignore the audio analysis piece (output_hue_thread) piece for now

    I like surprises and easter eggs. Might be your revenge to my code


    Question: Do you like to sneak into the code sometimes without know me that you do? Then I would do a github repo of just the LMS-to-Hue folder (same pattern as you use for your plugins, all files, different pattern or not at all?). I ask, as there are a lot of files that are "yours" and you still remain the "owner" of the framework. I do not want to misuse your trust as I really appreciate your help and work.
    It's really your code now. If you want me to test at some points, a github repository with the "LMS-to-Hue" structure is all I need (nothing above). It will allow me to offer some contribution potentially, but you really should have control, not me. I mean that we all have our own preferences and what's the most important is that you feel confortable with the code, it's logic and structure, so any change that helps this is good, even if it is cosmetic or just organizational.

    Bear in mind that my main development environment is Windows
    Last edited by philippe_44; 2017-04-22 at 22:04.
    LMS 7.7, 7.8 and 7.9 - 5xRadio, 3xBoom, 4xDuet, 1xTouch, 1 SB2. Sonos PLAY:3, PLAY:5, Marantz NR1603, JBL OnBeat, XBoxOne, XBMC, Foobar2000, ShairPortW, JRiver 21, 2xChromecast Audio, Chromecast v1 and v2, , Pi B3, B2, Pi B+, 2xPi A+, Odroid-C1, Odroid-C2, Cubie2, Yamaha WX-010, AppleTV 4, Airport Express

  9. #29
    Senior Member
    Join Date
    Jan 2011
    Location
    Germany
    Posts
    217
    Quote Originally Posted by philippe_44 View Post
    I'm not sure to understand.
    For the "blocking" questions: I am concerned about the sockets blocking my netowork communication not the thread blocking the program...

    The thing is:
    - The socket is opened.
    - I can send the request, the lamp switches on or off.
    - The send closes.
    - Then I want to get the bridges response...

    The response is coming in fragmented. There is no content-length header in the response... I get sometimes the whole message sometimes only parts... Then as always I have some issues with strcat, memory alloc, core dumps, etc.

    A response header would look like:
    Code:
    HTTP/1.1 200 OK
    Response is:
    Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
    Pragma: no-cache
    Expires: Mon, 1 Aug 2011 09:00:00 GMT
    Connection: close
    Access-Control-Max-Age: 3600
    Access-Control-Allow-Origin: *
    Access-Control-Allow-Credentials: true
    Access-Control-Allow-Methods: POST, GET, OPTIONS, PUT, DELETE, HEAD
    Access-Control-Allow-Headers: Content-Type
    Content-type: application/json
    
    [{"success":{"/lights/2/state/on":true}}]
    How is it possible to grab that in a while loop? I got it so far that the loop shows all of the characters, but I can't get them into one char...
    Code:
    char response[2];
            int br;
            while( (br = recv(huebridge->sock, response, sizeof(response)-1, 0) ) > 0) {
                response[br] = '\0';
                printf("Response is:\n%s", response);
            }
    That piece of code simply get's the message in single chars... But how can I concat them without a segfault to the final message into "char message[message_length]" for further processing? Do you know a place where I could get some example code? All I found was concerned with general example which are a little bit too abstract for understanding... In perl this part was way simpler...
    LMS-7.9@solaris. 2x Radio, 2x Duet, 1x Chromecast v1, ShairTunes, 1x Philips Hue System

  10. #30
    Senior Member
    Join Date
    May 2008
    Location
    Canada
    Posts
    2,956
    Quote Originally Posted by chincheta0815 View Post
    For the "blocking" questions: I am concerned about the sockets blocking my netowork communication not the thread blocking the program...
    If you mean your general machine network communication being blocked, that you should not worry, it does not happen
    The thing is:
    - The socket is opened.
    - I can send the request, the lamp switches on or off.
    - The send closes.
    - Then I want to get the bridges response...

    The response is coming in fragmented. There is no content-length header in the response... I get sometimes the whole message sometimes only parts... Then as always I have some issues with strcat, memory alloc, core dumps, etc.
    It's not great if the Hue bridge does not provide content-length (on non-chunked transfer) but I think it's still acceptable according to https://www.w3.org/Protocols/rfc2616...c4.html#sec4.4 (I think but I'm not HTTP expert).
    I would also have expected the whole response to be in one recv but ... you could do something like (I've not compiled it, it's lazy pseudo-code)
    Code:
    #define RSP_LEN 2048;
    
    bool somefunc(void) {
    	int len = 0, wait = 100;
    	char response[RSP_LEN];
    	
    	while (wait-- && len < RSP_LEN - 1) {
    		fd_set rfds;
    		struct timeval timeout = {0, 10000};
    		
    		FD_ZERO(&rfds);
    		FD_SET(huebridge->sock, &rfds);
    				
    		if (select(huebridge->sock + 1, &rfds, NULL, NULL, &timeout) < 0) {
    			// socket has closed, which seems to be what you are expecting with Hue bridge
    			break;
    		}
    		
    		if (FD_ISSET(huebridge->sock, &rfds)) {
    			int n;
    			
    			// something usefull received
    			n = recv(huebridge->sock, response + len, RSP_LEN - len - 1, 0);
    			
    			if (n < 0) {
    				// oops ... should not happen
    				break;
    			}
    			
    			len += n;
                            // still, you should try here to see that you have not received all you need by parsing "response", detecting empty line for start of body and content-length if any, then break
    		}	
    	}
    	
    	if (!wait) {
    		// timeout occured
    	}
    	
    	if (len && len < RSP_LEN)
                   response[len] = '\0';
                   // proceed with response
    	} else {
                   // nothing or too many bytes received
            }
    
            // do what you need to do to close the socket
    
    }
    It's not very clean and, as pippin said, if the hue bridge is acting too weird, then better use something like libcurl or a library that handles everything for you (I was not expecting that)
    Last edited by philippe_44; 2017-04-23 at 14:01.
    LMS 7.7, 7.8 and 7.9 - 5xRadio, 3xBoom, 4xDuet, 1xTouch, 1 SB2. Sonos PLAY:3, PLAY:5, Marantz NR1603, JBL OnBeat, XBoxOne, XBMC, Foobar2000, ShairPortW, JRiver 21, 2xChromecast Audio, Chromecast v1 and v2, , Pi B3, B2, Pi B+, 2xPi A+, Odroid-C1, Odroid-C2, Cubie2, Yamaha WX-010, AppleTV 4, Airport Express

Posting Permissions

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