Register Guidelines E-Books Search Today's Posts Mark Forums Read

Go Back   MobileRead Forums > E-Book Readers > Amazon Kindle > Kindle Developer's Corner

Notices

Reply
 
Thread Tools Search this Thread
Old 01-31-2011, 07:06 AM   #1
dent
Junior Member
dent began at the beginning.
 
Posts: 8
Karma: 10
Join Date: Jan 2011
Device: kindle 3
cross-compiling gstreamer for the kindle3

hi all,

I'm interested in playing mp3/asf streams over the network (for streaming live bbc and various mp3 podcasts for example). After toying with mplayer, vlc, deadbeef and being slightly overwhelmed by their dependencies (ok, deadbeef is not so bad) I came acrosss gstreamer and its crazy modular pipeline, which is already on the kindle. great!

Predictably the kindle's playbin module only supports playing from files.
Code:
gst-launch playbin uri=file:///path/to/file.mp3
works fine on the kindle. using uri=http://foo.com/bla.mp3 results in the following error:
No URI handler for http

I used NiLuJe's invaluable x-compile logs to get a working cross compile toolchain (managed to compile and run netcat with the -e option so it seems to work--more on that in another post). Thanks NiLuJe!!. I have my build environment installed in a vbox guest running ubuntu maverick.

I downloaded amazon's sources to make sure I had the right versions and set about compiling gstreamer-0.10.17.
After some battling I managed to get alsa-lib-1.0.13, glib-2.22, libxml2-2.7.8 (NOT an amazon source but gstreamer complained it needed it before configure would complete to I obliged). Whether any of these will actually work on the kindle remains to be seen

At some point in the gstreamer build process it dies with this error:
Code:
arm-kindle-linux-gnueabi-gcc -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -fno-stack-protector -U_FORTIFY_SOURCE -o .libs/gst-xmllaunch-0.10 -pthread gst_xmllaunch_0.10-gst-launch.o  -L/home/kindle/lib ../gst/.libs/libgstreamer-0.10.so /home/kindle/lib/libgobject-2.0.so /home/kindle/lib/libgthread-2.0.so /home/kindle/lib/libgmodule-2.0.so /home/kindle/lib/libglib-2.0.so -lrt  -Wl,--rpath -Wl,/home/kindle/lib
gst_xmllaunch_0.10-gst-launch.o: In function `main':
/home/dent/build/gstreamer/gstreamer-0.10.17/tools/gst-launch.c:662: undefined reference to `g_malloc0_n'
../gst/.libs/libgstreamer-0.10.so: undefined reference to `g_realloc_n'
../gst/.libs/libgstreamer-0.10.so: undefined reference to `g_malloc_n'
collect2: ld returned 1 exit status
make[2]: *** [gst-xmllaunch-0.10] Error 1
make[2]: Leaving directory `/home/dent/build/gstreamer/gstreamer-0.10.17/tools'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/home/dent/build/gstreamer/gstreamer-0.10.17'
make: *** [all] Error 2
Now, I'm comfortable enough tinkering with software but have very little experience cross-compiling (so far).

It looks like gstreamer-0.10.17/tools/gst-launch.c is using g_malloc0_n in a few places. Looking at glib's docs though I see that that function (and g_realloc_n and g_malloc_n) were introduced in glib-2.24. So it seems reasonable my cross compiled glib-2.22 doesn't define them as confirmed by:
Code:
nm /home/kindle/lib/libglib-2.0.so.0 | grep g_malloc
0003e750 t IA__g_malloc
0003e6b0 t IA__g_malloc0
0003e750 T g_malloc
0003e6b0 T g_malloc0
Finally, my question
Does this mean:
  1. it's not possible to cross compile gstreamer-0.10.17 against glib-2.22. This seems unlikely as it begs the question, why has amazon distributed those particular versions?
  2. Having glib-2.26 on my host maverick system is what's triggering this and building on an older ubuntu/debian with glib-2.22 would be better? I don't see why that *should* be the case? The compilation process should only be paying attention to includes and libs in /home/kindle, right?
  3. Something completely unrelated

For reference, i configured gstreamer with:
Code:
CFLAGS="-fno-stack-protector -U_FORTIFY_SOURCE" CXXFLAGS="-fno-stack-protector -U_FORTIFY_SOURCE" CPPFLAGS=-I/home/kindle/include LDFLAGS=-L/home/kindle/lib ./configure --prefix=/home/kindle --build=i686-linux-gnu --host=arm-kindle-linux-gnueabi --disable-nls --disable-examples --disable-valgrind --disable-failing-tests --without-libiconv-prefix --without-libintl-prefix
Any help/tips for moving forwards greatly appreciated. Cheers!

dent

Last edited by dent; 01-31-2011 at 02:42 PM. Reason: fix typo
dent is offline   Reply With Quote
Old 01-31-2011, 11:51 PM   #2
Elleo
Junior Member
Elleo began at the beginning.
 
Posts: 5
Karma: 12
Join Date: Nov 2010
Location: Aberystwyth, UK
Device: Kindle 3 (3G)
Someone else ran into this problem in ##kindle (on irc.freenode.net) a few days ago, as I recall the issue was that it was picking up the host environment's include files because pkg-config was still looking in the normal places for its configuration files. The fix was simply to point PKG_CONFIG_PATH and PKG_CONFIG_LIBDIR to the pkgconfig directory in the cross-compilation environment.

Last edited by Elleo; 02-01-2011 at 12:29 AM. Reason: Added detail for ##kindle
Elleo is offline   Reply With Quote
 
Advertisement
Old 02-01-2011, 04:05 PM   #3
dent
Junior Member
dent began at the beginning.
 
Posts: 8
Karma: 10
Join Date: Jan 2011
Device: kindle 3
Thanks a lot for the pointer Elleo, I'll have a look into it and report back

As a quick workaround, I managed to stream bbcworld using

Code:
wget -O - http://mp32.bbc.streamuk.com | gst-launch playbin uri=fd://0
dent is offline   Reply With Quote
Old 02-02-2011, 06:01 PM   #4
alethiophile
Member
alethiophile can differentiate black from dark navy bluealethiophile can differentiate black from dark navy bluealethiophile can differentiate black from dark navy bluealethiophile can differentiate black from dark navy bluealethiophile can differentiate black from dark navy bluealethiophile can differentiate black from dark navy bluealethiophile can differentiate black from dark navy bluealethiophile can differentiate black from dark navy bluealethiophile can differentiate black from dark navy bluealethiophile can differentiate black from dark navy bluealethiophile can differentiate black from dark navy blue
 
Posts: 10
Karma: 13156
Join Date: Feb 2011
Device: Kindle Paperwhite
Out of curiosity, where do you get the Kindle cross-compiler? I haven't been able to find it elsewhere.
alethiophile is offline   Reply With Quote
Old 02-02-2011, 06:31 PM   #5
Acorn
Enthusiast
Acorn began at the beginning.
 
Posts: 33
Karma: 10
Join Date: Oct 2010
Device: Kindle 3
http://info.iet.unipi.it/~luigi/kindle/ I think
Acorn is offline   Reply With Quote
Old 02-02-2011, 07:17 PM   #6
alethiophile
Member
alethiophile can differentiate black from dark navy bluealethiophile can differentiate black from dark navy bluealethiophile can differentiate black from dark navy bluealethiophile can differentiate black from dark navy bluealethiophile can differentiate black from dark navy bluealethiophile can differentiate black from dark navy bluealethiophile can differentiate black from dark navy bluealethiophile can differentiate black from dark navy bluealethiophile can differentiate black from dark navy bluealethiophile can differentiate black from dark navy bluealethiophile can differentiate black from dark navy blue
 
Posts: 10
Karma: 13156
Join Date: Feb 2011
Device: Kindle Paperwhite
That looks good, but it appears to be a compiler on the kindle rather than a cross-compiler on the desktop. I'm looking for the arm-kindle-linux-gnueabi-gcc in the OP.
alethiophile is offline   Reply With Quote
Old 02-03-2011, 10:44 AM   #7
dent
Junior Member
dent began at the beginning.
 
Posts: 8
Karma: 10
Join Date: Jan 2011
Device: kindle 3
hey alethiophile,
see the downloads from NiLuJe in the jailbreak thread here. One of them (i think it's the last one, x-tc) contains a file called x-compile which is a log of his cross-compilation session including some small patches you have to apply to get the cross-compiler built.

fwiw, i built crosstool-ng 1.9.3 (NiLuJe used 1.9.0). I see now that 1.10 was released a few days ago.
dent is offline   Reply With Quote
Old 02-03-2011, 08:40 PM   #8
alethiophile
Member
alethiophile can differentiate black from dark navy bluealethiophile can differentiate black from dark navy bluealethiophile can differentiate black from dark navy bluealethiophile can differentiate black from dark navy bluealethiophile can differentiate black from dark navy bluealethiophile can differentiate black from dark navy bluealethiophile can differentiate black from dark navy bluealethiophile can differentiate black from dark navy bluealethiophile can differentiate black from dark navy bluealethiophile can differentiate black from dark navy bluealethiophile can differentiate black from dark navy blue
 
Posts: 10
Karma: 13156
Join Date: Feb 2011
Device: Kindle Paperwhite
Thanks.
alethiophile is offline   Reply With Quote
Old 02-03-2011, 09:45 PM   #9
jsstylos
Junior Member
jsstylos has much to be proud ofjsstylos has much to be proud ofjsstylos has much to be proud ofjsstylos has much to be proud ofjsstylos has much to be proud ofjsstylos has much to be proud ofjsstylos has much to be proud ofjsstylos has much to be proud ofjsstylos has much to be proud ofjsstylos has much to be proud ofjsstylos has much to be proud of
 
Posts: 3
Karma: 27344
Join Date: Feb 2011
Device: Kindle 3
If you elevate permissions you can also play URLs from inside a Kindlet, using the reflection technique described here: http://www.mobileread.com/forums/sho...79&postcount=4

Here is a method that plays a mp3 from a URL. Setting up callbacks should be possible, although tedious, using reflection.

Code:
    private void playAudioFromUrlWrapper (final URL url) {
    	setDescription("Initiating connection");
		final ConnectivityHandler handler = new ConnectivityHandler() {
			public void connected() {
				try {
					playAudioFromUrl(url);
				} catch (IllegalStateException ise) {
					ise.printStackTrace();
				}
			}

			public void disabled(NetworkDisabledDetails details) {
				;
			}
		};
    	context.getConnectivity().submitSingleAttemptConnectivityRequest(handler, true);
    }
    
    private void playAudioFromUrl (URL url) {
        Class contextClass = context.getClass();
        Method[] methods = contextClass.getDeclaredMethods();
        Method audioMethod = methods[1];
        Object audioManagerObject;
        Class audioManagerClass;
        
        try {
        	audioManagerObject = audioMethod.invoke(context, new Object[0]);
        	audioManagerClass = audioManagerObject.getClass();
        	
        	Method[] audioManagerMethods = audioManagerClass.getDeclaredMethods();
        	Method createAudioPlayerMethod = audioManagerMethods[10];
        	Class mediaSourceClass = createAudioPlayerMethod.getParameterTypes()[0];
        	Constructor[] mediaSourceConstructors = mediaSourceClass.getConstructors();
        	//Constructor mediaSourceInputStreamConstructor = mediaSourceConstructors[3];
        	Constructor mediaSourceUrlConstructor = mediaSourceConstructors[1];
        	
        	Object[] mediaSourceArgs = new Object[1];
        	mediaSourceArgs[0] = url;
        	Object mediaSourceObject = mediaSourceUrlConstructor.newInstance(mediaSourceArgs);
        	
        	Object[] createAudioPlayerArgs = new Object[1];
        	createAudioPlayerArgs[0] = mediaSourceObject;
        	Object audioObject = createAudioPlayerMethod.invoke(audioManagerObject, createAudioPlayerArgs);
        	Class audioClass = audioObject.getClass();
        	
        	Method[] audioMethods = audioClass.getDeclaredMethods();
        	Method playMethod = audioMethods[12];
        	playMethod.invoke(audioObject, new Object[0]);
        	        	
		} catch (IllegalArgumentException e1) {
			e1.printStackTrace();
		} catch (IllegalAccessException e1) {
			e1.printStackTrace();
		} catch (InvocationTargetException e1) {
			e1.printStackTrace();
		} catch (InstantiationException e1) {
			e1.printStackTrace();
		}
    }
jsstylos is offline   Reply With Quote
Old 02-04-2011, 09:39 AM   #10
visgean
Junior Member
visgean began at the beginning.
 
Posts: 5
Karma: 10
Join Date: Jan 2011
Device: Kindle 3g
btw: i was also looking for gcc for kindle, I have found this post: http://www.linuxforums.org/forum/mis...ols-arm11.html , but i didnt managed to compile gcc for arm11...
visgean is offline   Reply With Quote
Reply

Tags
cross-compile, gstreamer, kindle 3g

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
compiling fbreader for pocketbook Almiel PocketBook 9 08-09-2010 07:18 PM
Problems compiling unkilbeeg Sigil 1 09-13-2009 02:49 PM
iLiad Please, help me with simple compiling first steps Sunn Sunn iRex Developer's Corner 7 07-22-2008 05:11 PM
iLiad compiling Minimo jtq iRex Developer's Corner 11 09-03-2007 06:33 AM
PRS-500 Compiling for the Reader alex_d Sony Reader Dev Corner 29 07-15-2007 01:29 PM


All times are GMT -4. The time now is 12:50 PM.


MobileRead.com is a privately owned, operated and funded community.