[xiph-cvs] cvs commit: ices/src input.c input.h stream.c stream_shared.c

Jack Moffitt jack at xiph.org
Tue Jan 22 19:40:29 PST 2002



jack        02/01/22 19:40:29

  Modified:    src      input.c input.h stream.c stream_shared.c
  Log:
  Ported ices to the new libshout api.  This is untested right now, although
  It Compiles Fine(TM).  I'll test shortly.

Revision  Changes    Path
1.12      +3 -3      ices/src/input.c

Index: input.c
===================================================================
RCS file: /usr/local/cvsroot/ices/src/input.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- input.c	2001/11/10 04:47:24	1.11
+++ input.c	2002/01/23 03:40:28	1.12
@@ -2,7 +2,7 @@
  *  - Main producer control loop. Fetches data from input modules, and controls
  *    submission of these to the instance threads. Timing control happens here.
  *
- * $Id: input.c,v 1.11 2001/11/10 04:47:24 msmith Exp $
+ * $Id: input.c,v 1.12 2002/01/23 03:40:28 jack Exp $
  * 
  * Copyright (c) 2001 Michael Smith <msmith at labyrinth.net.au>
  *
@@ -78,7 +78,7 @@
         {NULL,NULL}
 };
 
-/* This is identical to shout_sleep(), really. */
+/* This is identical to shout_sync(), really. */
 static void _sleep(timing_control *control)
 {
         uint64_t sleep;
@@ -104,7 +104,7 @@
 
 static int _calculate_ogg_sleep(ref_buffer *buf, timing_control *control)
 {
-	/* Largely copied from shout_send_data(), without the sending happening.*/
+	/* Largely copied from shout_send(), without the sending happening.*/
         ogg_stream_state os;
         ogg_page og;
         ogg_packet op;

<p><p>1.4       +2 -2      ices/src/input.h

Index: input.h
===================================================================
RCS file: /usr/local/cvsroot/ices/src/input.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- input.h	2001/09/25 12:04:21	1.3
+++ input.h	2002/01/23 03:40:28	1.4
@@ -1,7 +1,7 @@
 /* input.h
  * - Input functions
  *
- * $Id: input.h,v 1.3 2001/09/25 12:04:21 msmith Exp $
+ * $Id: input.h,v 1.4 2002/01/23 03:40:28 jack Exp $
  *
  * Copyright (c) 2001 Michael Smith <msmith at labyrinth.net.au>
  *
@@ -28,7 +28,7 @@
         input_module_t *input;
     reencode_state *reenc;
     encoder_state *enc;
-    shout_conn_t conn;
+    shout_t *shout;
     vorbis_comment vc;
 } stream_description;
 

<p><p>1.10      +63 -26    ices/src/stream.c

Index: stream.c
===================================================================
RCS file: /usr/local/cvsroot/ices/src/stream.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- stream.c	2001/11/10 04:47:24	1.9
+++ stream.c	2002/01/23 03:40:28	1.10
@@ -1,7 +1,7 @@
 /* stream.c
  * - Core streaming functions/main loop.
  *
- * $Id: stream.c,v 1.9 2001/11/10 04:47:24 msmith Exp $
+ * $Id: stream.c,v 1.10 2002/01/23 03:40:28 jack Exp $
  *
  * Copyright (c) 2001 Michael Smith <msmith at labyrinth.net.au>
  *
@@ -46,8 +46,9 @@
  */
 void *ices_instance_stream(void *arg)
 {
-	int ret;
+	int ret, shouterr;
         ref_buffer *buffer;
+	char *connip;
         stream_description *sdsc = arg;
         instance_t *stream = sdsc->stream;
         input_module_t *inmod = sdsc->input;
@@ -56,29 +57,66 @@
         
         vorbis_comment_init(&sdsc->vc);
 
-	shout_init_connection(&sdsc->conn);
+	sdsc->shout = shout_new();
+
+	/* we only support the ice protocol and vorbis streams currently */
+	shout_set_format(sdsc->shout, SHOUT_FORMAT_VORBIS);
+	shout_set_protocol(sdsc->shout, SHOUT_PROTOCOL_ICE);
+
         signal(SIGPIPE, signal_hup_handler);
 
-	sdsc->conn.ip = malloc(16);
-	if(!resolver_getip(stream->hostname, sdsc->conn.ip, 16))
+	connip = malloc(16);
+	if(!resolver_getip(stream->hostname, connip, 16))
         {
                 LOG_ERROR1("Could not resolve hostname \"%s\"", stream->hostname);
-		free(sdsc->conn.ip);
+		free(connip);
                 stream->died = 1;
                 return NULL;
         }
 
-	sdsc->conn.port = stream->port;
-	sdsc->conn.password = strdup(stream->password);
-	sdsc->conn.mount = strdup(stream->mount);
+	if (!(shout_set_host(sdsc->shout, connip)) == SHOUTERR_SUCCESS) {
+		LOG_ERROR1("libshout error: %s\n", shout_get_error(sdsc->shout));
+		free(connip);
+		stream->died = 1;
+		return NULL;
+	}
 
+	shout_set_port(sdsc->shout, stream->port);
+	if (!(shout_set_password(sdsc->shout, stream->password)) == SHOUTERR_SUCCESS) {
+		LOG_ERROR1("libshout error: %s\n", shout_get_error(sdsc->shout));
+		free(connip);
+		stream->died = 1;
+		return NULL;
+	}
+	if (!(shout_set_mount(sdsc->shout, stream->mount)) == SHOUTERR_SUCCESS) {
+		LOG_ERROR1("libshout error: %s\n", shout_get_error(sdsc->shout));
+		free(connip);
+		stream->died = 1;
+		return NULL;
+	}
+
         /* set the metadata for the stream */
         if (ices_config->stream_name)
-		sdsc->conn.name = strdup(ices_config->stream_name);
+		if (!(shout_set_name(sdsc->shout, ices_config->stream_name)) == SHOUTERR_SUCCESS) {
+			LOG_ERROR1("libshout error: %s\n", shout_get_error(sdsc->shout));
+			free(connip);
+			stream->died = 1;
+			return NULL;
+		}
         if (ices_config->stream_genre)
-		sdsc->conn.genre = strdup(ices_config->stream_genre);
+		if (!(shout_set_genre(sdsc->shout, ices_config->stream_genre)) == SHOUTERR_SUCCESS) {
+			LOG_ERROR1("libshout error: %s\n", shout_get_error(sdsc->shout));
+			free(connip);
+			stream->died = 1;
+			return NULL;
+		}
         if (ices_config->stream_description)
-		sdsc->conn.description = strdup(ices_config->stream_description);
+		if (!(shout_set_description(sdsc->shout, ices_config->stream_description)) == SHOUTERR_SUCCESS) {
+			LOG_ERROR1("libshout error: %s\n", shout_get_error(sdsc->shout));
+			free(connip);
+			stream->died = 1;
+			return NULL;
+		}
 
         if(encoding)
         {
@@ -100,10 +138,10 @@
             LOG_INFO1("Saving stream to file %s", stream->savefilename);
     }
 
-	if(shout_connect(&sdsc->conn))
+	if((shouterr = shout_open(sdsc->shout)) == SHOUTERR_SUCCESS)
         {
                 LOG_INFO3("Connected to server: %s:%d%s", 
-				sdsc->conn.ip, sdsc->conn.port, sdsc->conn.mount);
+				shout_get_host(sdsc->shout), shout_get_port(sdsc->shout), shout_get_mount(sdsc->shout));
 
                 while(1)
                 {
@@ -161,8 +199,8 @@
             else if(ret == 0)
                         {
                                 LOG_ERROR1("Send error: %s", 
-                        shout_strerror(sdsc->conn.error));
-				if(sdsc->conn.error == SHOUTERR_SOCKET)
+                        shout_get_error(sdsc->shout));
+				if(shouterr == SHOUTERR_SOCKET)
                                 {
                                         int i=0;
 
@@ -183,19 +221,19 @@
                                         {
                                                 i++;
                                                 LOG_WARN0("Trying reconnect after server socket error");
-						shout_disconnect(&sdsc->conn);
-						if(shout_connect(&sdsc->conn))
+						shout_close(sdsc->shout);
+						if((shouterr = shout_open(sdsc->shout)) == SHOUTERR_SUCCESS)
                                                 {
                                                         LOG_INFO3("Connected to server: %s:%d%s", 
-                                    sdsc->conn.ip, sdsc->conn.port, 
-                                    sdsc->conn.mount);
+                                    shout_get_host(sdsc->shout), shout_get_port(sdsc->shout), 
+                                    shout_get_mount(sdsc->shout));
                                                         break;
                                                 }
                                                 else
                                                 {
                                                         LOG_ERROR3("Failed to reconnect to %s:%d (%s)",
-								sdsc->conn.ip,sdsc->conn.port,
-								shout_strerror(sdsc->conn.error));
+								shout_get_host(sdsc->shout),shout_get_port(sdsc->shout),
+								shout_get_error(sdsc->shout));
                                                         if(i==stream->reconnect_attempts)
                                                         {
                                                                 LOG_ERROR0("Reconnect failed too many times, "
@@ -217,16 +255,15 @@
         else
         {
                 LOG_ERROR3("Failed initial connect to %s:%d (%s)", 
-				sdsc->conn.ip,sdsc->conn.port,
-                shout_strerror(sdsc->conn.error));
+				shout_get_host(sdsc->shout),shout_get_port(sdsc->shout), shout_get_error(sdsc->shout));
         }
         
-	shout_disconnect(&sdsc->conn);
+	shout_close(sdsc->shout);
 
     if(stream->savefile != NULL) 
         fclose(stream->savefile);
 
-	free(sdsc->conn.ip);
+    	shout_free(sdsc->shout);
         encode_clear(sdsc->enc);
         reencode_clear(sdsc->reenc);
         vorbis_comment_clear(&sdsc->vc);

<p><p>1.5       +2 -2      ices/src/stream_shared.c

Index: stream_shared.c
===================================================================
RCS file: /usr/local/cvsroot/ices/src/stream_shared.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- stream_shared.c	2001/09/25 12:04:22	1.4
+++ stream_shared.c	2002/01/23 03:40:28	1.5
@@ -1,7 +1,7 @@
 /* stream_shared.c
  * - Stream utility functions.
  *
- * $Id: stream_shared.c,v 1.4 2001/09/25 12:04:22 msmith Exp $
+ * $Id: stream_shared.c,v 1.5 2002/01/23 03:40:28 jack Exp $
  *
  * Copyright (c) 2001 Michael Smith <msmith at labyrinth.net.au>
  *
@@ -37,7 +37,7 @@
             LOG_ERROR1("Failed to write %d bytes to savefile", len);
     }
 
-    return shout_send_data(&s->conn, buf, len);
+    return shout_send(s->shout, buf, len);
 }
 
 void stream_release_buffer(ref_buffer *buf)

<p><p><p>--- >8 ----
List archives:  http://www.xiph.org/archives/
Ogg project homepage: http://www.xiph.org/ogg/
To unsubscribe from this list, send a message to 'cvs-request at xiph.org'
containing only the word 'unsubscribe' in the body.  No subject is needed.
Unsubscribe messages sent to the list will be ignored/filtered.



More information about the commits mailing list