olegkunitsyn / libshout-java Goto Github PK
View Code? Open in Web Editor NEWLibshout binding for streaming audio to Icecast servers from Java applications
License: MIT License
Libshout binding for streaming audio to Icecast servers from Java applications
License: MIT License
According to JEP 313 Native-Header Generation Tool (javah) was removed from OpenJDK. There is no more possibility to compile libshout-java native classes.
When the shared object .so file is loaded, two file paths are attempted:
static {
try {
System.load(System.getProperty("user.dir") + "/libshout-java.so");
} catch (UnsatisfiedLinkError e) {
System.load(System.getProperty("user.dir") + "/target/libshout-java.so");
}
}
Because the catch block is used for flow control it is possible that the original cause stack trace is swallowed an a misleading one is printed instead:
I am building a service which doesnt always have something to play. Ive found that if it opens the connection right before playing it works fine, but then the next thing played gets a socket error. Is there any way aroung this?
Hi there, I'm trying to test this library using
Libshout libshout = new Libshout();
System.out.println(libshout.getVersion());
but when I run , i got error like this
Exception in thread "main" java.lang.UnsatisfiedLinkError: C:\Users\Danial\Documents\NetBeansProjects\JavaApplication6\target\libshout-java.so: Can't load this .dll (machine code=0x101) on a AMD 64-bit platform
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary1(ClassLoader.java:1965)
at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1890)
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1851)
at java.lang.Runtime.load0(Runtime.java:795)
at java.lang.System.load(System.java:1062)
at com.gmail.kunicins.olegs.libshout.Libshout.(Libshout.java:10)
at javaapplication6.JavaApplication6.main(JavaApplication6.java:27)
Java Result: 1
it seem it cant run on windows :(, how to resolve this, or did u have libshout-java.so which can run on windows 64 bit?
`Libshout icecast = new Libshout();
setxxx(xx);
icecast.open();`
the result is :
java.io.IOException Socket is busy.
icecast.setNonBlocking(false);
so can you tell me the right way to use nonblocking?
Hello,
I believe the setMeta
method you have added is incorrect. The code is:
public void setMeta(String key, String value) throws IOException {
long instanceMeta = shout_metadata_new();
if (shout_set_metadata(this.instance, instanceMeta) != SUCCESS) {
throw new IOException(shout_get_error(this.instance));
}
if (shout_metadata_add(instanceMeta, key, value) != SUCCESS) {
throw new IOException(shout_get_error(this.instance));
}
}
First, the shout metadata instance should be freed manually according to the docs, with shout_metadata_free
:
shout_metadata_t *shout_metadata_new();
Allocates a new metadata structure, or returns NULL if no memory is available. The returned structure should be freed with shout_metadata_free when you are done with it.
Second, you need to call shout_metadata_add
before calling shout_set_metadata
, since adding new metadata to the struct does not update the stream metadata, it just updates the metadata struct.
Third, the only parameter that should ever be set with shout_metadata_add
is: name
. Extract from an IRC conversation on #icecast
:
<cc0> hello, i am using libshout to send metadata updates for an mp3 icecast stream. i understand that for metadata libshout makes an http get request to the icecast2 server with the url-encoded parameters specifying the metadata info
<cc0> i was wondering whether there were other parameters/fields than "song"? e.g. "url", ...
<cc0> i haven't been able to find any info or spec on this
<ePirat> no
<ePirat> [...] mp3 metadata only can support single string of metadata
<cc0> with id3 tags you can add multiple metadata tags to the stream right?
<ePirat> no
<ePirat> id3 is impossible to be used for streaming
<ePirat> what is used for metadata when streaming mp3 is called ICY and only supports a single string
<cc0> ePirat: okay, i see. ;) so it is reasonable to assume that the only metadata parameter that should ever be sent is "song"?
<ePirat> yes
<ePirat> not 100% if you could send artist or something, but if, then icecast would just join them together separated with a "-"
Following these points, depending on the level of abstraction you (@OlegKunitsyn) want to provide for your library, the different ways this issue can be addressed are:
shout_metadata_new
, shout_metadata_add
, shout_set_metadata
, and shout_metadata_free
, using an opaque object with no public methods or fields, representing an opaque instanceMeta
handle;shout_metadata_new
, as etiher a Libshout
method or a class constructor, that would return an object of class e.g. LibshoutMetadata
, which would implement AutoCloseable
(close
would call shout_metadata_free
), and have add
and set
methods (the set
method could also be a method on Libshout
);setMeta
method with a single public void setMetadata(String metadata) throws IOException
method, which would create a new metadata instance, add metadata for parameter song
to value metadata
, set it on the stream, then free the instance.I highly recommend going for the third solution since the only metadata parameter/key that is used is song
and removing the parameter will remove the confusion on metadata handling. Also, it is very cumbersome and error-prone to manually track an object initialisation and explicit close, and the cost associated with creating and freeing a single instance of the metadata type is small enough.
I am creating a pull request to implement the third solution and will keep you updated.
Hi there!
I'm doing a simple call like this libshout.setMeta("song", "song-title-here");
but receive the following stack trace:
java.io.IOException: No error
at com.gmail.kunicins.olegs.libshout.Libshout.setMeta(Libshout.java:387)
It seems others have run into this issue as well but with no solution: https://stackoverflow.com/questions/41600905/cannot-update-icecast-metadata-with-libshout
Any guidance on what is going wrong?
What needs to be done to build Android version of this?
Damien
Have you any reconmendation or experience how I get with to run on Windows?
I need to stream sequentially some mp3. I tried the example at homepage, but it didn't work.
Could you please write an example work with multi-mp3?
Thanks.
I know that it only supports MP3 and OGG Streams but does anybody know how to play .acc streams?
Have a trouble with mvn install:
Libshout/libshout-java/src/main/native/libshout.c:4:10: fatal error: 'shout/shout.h' file not found
#include <shout/shout.h>
^
1 error generated.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 4.395 s
[INFO] Finished at: 2016-12-28T15:14:27+02:00
[INFO] Final Memory: 7M/123M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.codehaus.mojo:native-maven-plugin:1.0-alpha-8:compile (javah) on project libshout-java: Error executing command line. Exit code:1 -> [Help 1]
I am seeing weird behavior in displaying "current playing" meta data . When I run my program from eclipse it displays everything just fine. however, the the same program is run from built jar files using the same icecast server , it does not display that meta data. Are there any specific non-documented ports/features etc which are only active while in eclipse? It is hard to debug as no errors are thrown.
OS
Description: Ubuntu 18.04 LTS
Release: 18.04
Codename: bionic
gcc
gcc (Ubuntu 7.3.0-16ubuntu3) 7.3.0
Java
openjdk version "1.8.0_171"
OpenJDK Runtime Environment (build 1.8.0_171-8u171-b11-0ubuntu0.18.04.1-b11)
OpenJDK 64-Bit Server VM (build 25.171-b11, mixed mode)
Icecast
Icecast 2.4.3
libshout-dev
libshout3-dev/bionic,now 2.4.1-2build1 amd64
mvn install
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building libshout-java 2.2.2
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ libshout-java ---
[INFO] Deleting /home/denys/libshout-java/target
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ libshout-java ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory /home/denys/libshout-java/src/main/resources
[INFO]
[INFO] --- maven-compiler-plugin:2.5.1:compile (default-compile) @ libshout-java ---
[INFO] Compiling 1 source file to /home/denys/libshout-java/target/classes
[INFO]
[INFO] --- native-maven-plugin:1.0-alpha-8:javah (javah) @ libshout-java ---
[INFO] /bin/sh -c cd /home/denys/libshout-java && javah -d /home/denys/libshout-java/target/native -classpath /home/denys/libshout-java/target/classes com.gmail.kunicins.olegs.libshout.Libshout
Picked up _JAVA_OPTIONS: -Djava.net.preferIPv4Stack=true
[INFO]
[INFO] --- native-maven-plugin:1.0-alpha-8:compile (javah) @ libshout-java ---
[INFO] /bin/sh -c cd /home/denys/libshout-java && gcc -fpic -Wall -I/home/denys/libshout-java/src/main/native -I/usr/lib/jvm/java-8-openjdk-amd64/jre/../include/darwin -I/home/denys/libshout-java/target/native -I/usr/lib/jvm/java-8-openjdk-amd64/jre/../include -I/usr/lib/jvm/java-8-openjdk-amd64/jre/../include/linux -o/home/denys/libshout-java/target/objs/libshout.o -c /home/denys/libshout-java/src/main/native/libshout.c
[INFO]
[INFO] --- native-maven-plugin:1.0-alpha-8:link (javah) @ libshout-java ---
[INFO] /bin/sh -c cd /home/denys/libshout-java && gcc -shared -lshout -o/home/denys/libshout-java/target/libshout-java-2.2.2.jar target/objs/libshout.o -o /home/denys/libshout-java/target/libshout-java.so
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ libshout-java ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 2 resources
[INFO]
[INFO] --- maven-compiler-plugin:2.5.1:testCompile (default-testCompile) @ libshout-java ---
[INFO] Compiling 1 source file to /home/denys/libshout-java/target/test-classes
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ libshout-java ---
[INFO] Surefire report directory: /home/denys/libshout-java/target/surefire-reports
-------------------------------------------------------
T E S T S
-------------------------------------------------------
Picked up _JAVA_OPTIONS: -Djava.net.preferIPv4Stack=true
Running com.gmail.kunicins.olegs.libshout.LibshoutTest
/usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java: symbol lookup error: /home/denys/libshout-java/target/libshout-java.so: undefined symbol: shout_init
Results :
Tests run: 0, Failures: 0, Errors: 0, Skipped: 0
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 5.525 s
[INFO] Finished at: 2018-06-26T00:41:31+03:00
[INFO] Final Memory: 16M/232M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12.4:test (default-test) on project libshout-java: Execution default-test of goal org.apache.maven.plugins:maven-surefire-plugin:2.12.4:test failed: The forked VM terminated without saying properly goodbye. VM crash or System.exit called ? -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginExecutionException
Hello,
Do you know any solution to have individual song informations when using a dj mix as source file?
Maybe cue sheets ?
Is there a way to inject metadata somehow ?
Cheers Marc
Hello, I'm kinda new to Icecast and want to set up a simple automatic audio stream which plays music from my own music library.
The problem is that I can't seem to find any information about how to set up a project with this library. I copied the sample code from README.md, but as soon as the new Libshout object get initialized it throws this error:
symbol lookup error: libshout-java.so: undefined symbol: shout_init
And the program exits with Java result 127.
I noticed that the readme file says that the library is ready for use on 32-bit systems, does that mean it does not work on my 64-bit Xubuntu PC?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.