Attempting to use the latest libshout-2.0 will result
in compiler errors, documentation should state which
version to use:
globecomice.c:224: error: syntax error before '*' token
globecomice.c: In function `playFile':
globecomice.c:232: error: `filename' undeclared (first
use in this function)
globecomice.c:232: error: (Each undeclared identifier
is reported only once
globecomice.c:232: error: for each function it appears in.)
globecomice.c:255: error: `conn' undeclared (first use
in this function)
globecomice.c: In function `main':
globecomice.c:368: error: `shout_conn_t' undeclared
(first use in this function)
globecomice.c:368: error: syntax error before "conn"
globecomice.c:386: error: `conn' undeclared (first use
in this function)
There are quite a few items that are simply undeclared
or their structures/datatypes have changed. This seems
to be very poorly documented within libshout -- I could
not find any mention on the web or in their
documentation. I did come across an old document here
at sourceforge where someone else was having trouble,
ljardine recommended to use the 1.0.9 version of libshout.
In Gentoo, this requires: emege =libshout-1.0.9
Don't forget to unmerge libshout 2 first.
The differences between libshout 1.0.9 and libshout 2.0
are SIGNIFICANT. Compiled with success using
libshout-1.0.9
Logged In: YES
user_id=436862
Not specifically mentioning that libshout-1 is required is,
I think, bitrot: the last tar release of jukebox predates
the release of icecast2.
<rant>This is clearly icecast's fault: do not release a
product with the same name and a higher version number
unless it does the same thing, you stupid idiots. Changing
the API across a major version is just about acceptable;
changing the protocol used, but keeping the name, is just
dumb. Imagine if the Samba team released samba 5, and but it
did NFS instead of CIFS, or if the new Apache turned out to
be an FTP server.</rant>
No matter how righteously indignant I am, this problem is
not going to go away until jukebox either supports icecast2
(easier now that icecast has realised the OGG is not the
killer app they thought it was and actually supports mp3),
or notes in the documentation that it is incompatible with it.
Logged In: YES
user_id=436862
Towards the latter solution, here's a diff -u of Matt
Williams (mattrwilliams)' port of globecomice from libshout1
to libshout2 (posted in
https://sourceforge.net/forum/message.php?msg_id=2140748 )
against 4.1pre4, which I believe is what it was ported from.
Hopefully it should still apply easily to the CVS version.
This is only half the battle though: we need to either
detect if the user has icecast 1 or 2 (or somehow explain
the problem to them and ask them to choose), and then
compile the appropriate one, or somehow write a globecomice
that's compatible with either. The latter would be a hell of
a lot easier if the two (completely incompatible)
implementations didn't use the same header and library
names. (Not to mention that a system could potentially have
BOTH versions installed at the same time.
/I did not write this code/, Matt Williams (mattrwilliams)
did. It is not my intention to pass of his work as my own;
any monkey can make a diff.
Logged In: YES
user_id=436862
--- jukebox-4.1/src/globecomice.c Fri Feb 1 22:30:24 2002
+++ ./globecomice2.c Wed Dec 8 04:20:55 2004
@@ -1,4 +1,5 @@
#include <signal.h>
+#include <errno.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
@@ -142,13 +143,14 @@
#define BUFSIZE 4096
-void playFile(shout_conn_t *conn,char *filename)
+void playFile(shout_t *conn,char *filename)
{
int fd;
int searchsize;
int offset;
struct MP3Header head;
char* chopped_filename;
+shout_metadata_t *metadata;
fd=open(filename,O_RDONLY);
if (fd<0) {
@@ -173,13 +175,20 @@
chopped_filename--;
chopped_filename++;
- shout_update_metadata(conn, chopped_filename);
if (checkMP3(head)) {
- char buff[4096];
+char buff[BUFSIZE];
long rbuf, ret, total=0;
int sec10=head.bitrate*1280;
- printf("Playing %s with bitrate
%d\n",filename,head.bitrate);
+
+metadata=shout_metadata_new();
+ret=shout_metadata_add(metadata,"song",chopped_filename);
+if (ret!=SHOUTERR_SUCCESS) printf ("Error adding metadata\n");
+ret=shout_set_metadata(conn,metadata);
+if (ret!=SHOUTERR_SUCCESS) printf ("Error setting
metadata\n");
+shout_metadata_free(metadata);
+
+printf("Playing %s (%s) with bitrate
%d\n",filename,chopped_filename,head.bitrate);
lseek(fd,0,0);
while (1) {
if (goSeek) {
@@ -188,29 +197,30 @@
}
if (goQuit) {
goQuit=0;
- break;
+//break;
}
rbuf = read(fd,buff,BUFSIZE);
+if (rbuf < 0) printf("error %s\n", strerror(errno));
total = total + rbuf;
if (rbuf > 0) {
- ret = shout_send_data(conn, buff, rbuf);
- if (!ret) {
+ret = shout_send(conn, buff, rbuf);
+if (ret != SHOUTERR_SUCCESS) {
/* Something wrong occured (timeout?) */
- printf("globecomice: Send error: %i...\n",
conn->error);
+printf("globecomice: Send error: %s...\n",
shout_get_error(conn));
/* Try to reconnect before giving up */
printf("globecomice: Reconnecting to the icecast
srver...\n");
- shout_disconnect(conn);
- if (!shout_connect(conn)) {
+shout_close(conn);
+if (!shout_open(conn)) {
printf("globecomice: Error, couldn't reconnect to
server.\n");
break;
}
/* Try to send data again */
- ret = shout_send_data(conn, buff, rbuf);
- if (!ret) {
- printf("globecomice: Send data FAILED again: %d\n",
conn->error);
+ret = shout_send(conn, buff, rbuf);
+if (ret != SHOUTERR_SUCCESS) {
+printf("globecomice: Send data FAILED again: %s\n",
shout_get_error(conn));
break;
}
}
@@ -218,7 +228,7 @@
break;
}
- shout_sleep(conn);
+shout_sync(conn);
}
}
close(fd);
@@ -276,7 +286,7 @@
int main(int argc,char **argv)
{
- shout_conn_t conn;
+shout_t *conn;
int connected=0;
const char *user;
char* chopped_filename;
@@ -290,15 +300,19 @@
printf("Must set environment variable JUKEBOXBIN\n");
exit(2);
}
- shout_init_connection(&conn);
+shout_init();
+conn=shout_new();
gethostname(host,1024);
- conn.ip=argv[1];
- conn.port=atoi(argv[2]);
- conn.password=argv[3];
- conn.mount=argv[5];
- conn.name=host;
- conn.description="GlobeCom Jukebox";
+shout_set_host(conn,argv[1]);
+shout_set_port(conn,atoi(argv[2]));
+shout_set_password(conn,argv[3]);
+shout_set_mount(conn,argv[5]);
+shout_set_name(conn,host);
+shout_set_description(conn,"GlobeCom Jukebox");
+shout_set_protocol(conn,SHOUT_PROTOCOL_HTTP);
+shout_set_format(conn,SHOUT_FORMAT_MP3);
+shout_open(conn);
user=argv[4];
signal(SIGINT,Forward);
@@ -310,16 +324,18 @@
while(1) {
char filename[BUFSIZE+1];
if (!getFilename(connected,filename,user)) {
- shout_disconnect(&conn);
+shout_close(conn);
exit(1);
}
if (!connected) {
- if (!shout_connect(&conn)) {
- printf("Couldn't connect to icecast server\n");
+if (shout_get_connected(conn) != SHOUTERR_CONNECTED) {
+printf("Couldn't connect to icecast server:
%s\n",shout_get_error(conn));
exit(2);
}
connected=1;
}
- playFile(&conn,filename);
+playFile(conn,filename);
}
}
+
+
Logged In: YES
user_id=596175
To anyone dealing with this problem.... is there any
DISADVANTAGE to icecast2???? I think it's time we ditch
icecast1 and just require icecast2.... it's about time if
this is an issue.