[xiph-cvs] cvs commit: httpp httpp.c
Michael Smith
msmith at xiph.org
Mon Feb 11 01:11:19 PST 2002
msmith 02/02/11 01:11:18
Modified: src connection.c format.c format.h format_vorbis.c
source.c stats.h
. avl.h
. httpp.c
Log:
Bunch of fixes:
- connections are now matched to format plugins based on content-type headers,
and are rejected if there isn't a format handler for that content-type, or
there is no content-type at all.
- format_vorbis now handles pages with granulepos of -1 in the headers
correctly (this happens if the headers are fairly large, because of
many comments, for example).
- various #include fixes.
- buffer overflow in httpp.c fixed.
Revision Changes Path
1.8 +18 -1 icecast/src/connection.c
Index: connection.c
===================================================================
RCS file: /usr/local/cvsroot/icecast/src/connection.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- connection.c 2002/02/07 01:04:07 1.7
+++ connection.c 2002/02/11 09:11:17 1.8
@@ -336,6 +336,8 @@
}
if (parser->req_type == httpp_req_source) {
+ char *contenttype;
+
printf("DEBUG: source logging in\n");
stats_event_inc(NULL, "source_connections");
@@ -378,8 +380,23 @@
global_unlock();
stats_event_inc(NULL, "sources");
+
+ contenttype = httpp_getvar(parser, "content-type");
+
+ if (contenttype != NULL) {
+ format_type_t format = format_get_type(contenttype);
+ if(format < 0) {
+ WARN1("Content-type \"%s\" not supported, dropping source", contenttype);
+ continue;
+ }
+ else
+ source = source_create(con, parser, httpp_getvar(parser, HTTPP_VAR_URI), format);
+ }
+ else {
+ WARN0("No content-type header, cannot handle source");
+ continue;
+ }
- source = source_create(con, parser, httpp_getvar(parser, HTTPP_VAR_URI), FORMAT_TYPE_VORBIS);
source->shutdown_rwlock = &_source_shutdown_rwlock;
sock_set_blocking(con->sock, SOCK_NONBLOCK);
<p><p>1.4 +10 -0 icecast/src/format.c
Index: format.c
===================================================================
RCS file: /usr/local/cvsroot/icecast/src/format.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- format.c 2002/02/04 07:08:52 1.3
+++ format.c 2002/02/11 09:11:17 1.4
@@ -15,6 +15,16 @@
#include "format_vorbis.h"
+format_type_t format_get_type(char *contenttype)
+{
+ if(strcmp(contenttype, "application/x-ogg") == 0)
+ return FORMAT_TYPE_VORBIS;
+ else if(strcmp(contenttype, "audio/mpeg") == 0)
+ return FORMAT_TYPE_MP3;
+ else
+ return -1;
+}
+
format_plugin_t *format_get_plugin(format_type_t type, char *mount)
{
format_plugin_t *plugin;
<p><p>1.4 +1 -0 icecast/src/format.h
Index: format.h
===================================================================
RCS file: /usr/local/cvsroot/icecast/src/format.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- format.h 2002/02/04 07:08:52 1.3
+++ format.h 2002/02/11 09:11:17 1.4
@@ -32,6 +32,7 @@
void *_state;
} format_plugin_t;
+format_type_t format_get_type(char *contenttype);
format_plugin_t *format_get_plugin(format_type_t type, char *mount);
#endif /* __FORMAT_H__ */
<p><p>1.4 +6 -1 icecast/src/format_vorbis.c
Index: format_vorbis.c
===================================================================
RCS file: /usr/local/cvsroot/icecast/src/format_vorbis.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- format_vorbis.c 2002/02/04 07:08:52 1.3
+++ format_vorbis.c 2002/02/11 09:11:17 1.4
@@ -13,6 +13,7 @@
#include "refbuf.h"
+#include "stats.h"
#include "format.h"
typedef struct _vstate_tag
@@ -122,7 +123,11 @@
}
if (state->header >= 0) {
- if (ogg_page_granulepos(&state->og) == 0) {
+ /* FIXME: In some streams (non-vorbis ogg streams), this could get
+ * extras pages beyond the header. We need to collect the pages
+ * here anyway, but they may have to be discarded later.
+ */
+ if (ogg_page_granulepos(&state->og) <= 0) {
state->header++;
} else {
/* we're done caching headers */
<p><p>1.9 +2 -2 icecast/src/source.c
Index: source.c
===================================================================
RCS file: /usr/local/cvsroot/icecast/src/source.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- source.c 2002/02/07 01:04:07 1.8
+++ source.c 2002/02/11 09:11:17 1.9
@@ -178,11 +178,11 @@
/* we have a refbuf buffer, which a data block to be sent to
** all clients. if a client is not able to send the buffer
- ** immediately, it should store it on it's queue for the next
+ ** immediately, it should store it on its queue for the next
** go around.
**
** instead of sending the current block, a client should send
- ** all data in the cue, plus the current block, until either
+ ** all data in the queue, plus the current block, until either
** it runs out of data, or it hits a recoverable error like
** EAGAIN. this will allow a client that got slightly lagged
** to catch back up if it can
<p><p>1.3 +4 -0 icecast/src/stats.h
Index: stats.h
===================================================================
RCS file: /usr/local/cvsroot/icecast/src/stats.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- stats.h 2002/02/06 06:11:03 1.2
+++ stats.h 2002/02/11 09:11:17 1.3
@@ -1,6 +1,10 @@
#ifndef __STATS_H__
#define __STATS_H__
+#include "connection.h"
+#include "httpp.h"
+#include "client.h"
+
typedef struct _stats_connection_tag
{
connection_t *con;
<p><p>1.2 +3 -1 avl/avl.h
Index: avl.h
===================================================================
RCS file: /usr/local/cvsroot/avl/avl.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- avl.h 2001/09/10 02:28:03 1.1
+++ avl.h 2002/02/11 09:11:18 1.2
@@ -2,7 +2,7 @@
* Copyright (C) 1995 by Sam Rushing <rushing at nightmare.com>
*/
-/* $Id: avl.h,v 1.1 2001/09/10 02:28:03 jack Exp $ */
+/* $Id: avl.h,v 1.2 2002/02/11 09:11:18 msmith Exp $ */
#ifndef __AVL_H
#define __AVL_H
@@ -10,6 +10,8 @@
#ifdef __cplusplus
extern "C" {
#endif
+
+#include "thread.h"
typedef struct avl_node_tag {
void * key;
<p><p>1.4 +7 -8 httpp/httpp.c
Index: httpp.c
===================================================================
RCS file: /usr/local/cvsroot/httpp/httpp.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- httpp.c 2001/10/20 07:40:09 1.3
+++ httpp.c 2002/02/11 09:11:18 1.4
@@ -62,10 +62,11 @@
if (http_data == NULL)
return 0;
- /* make a local copy of the data */
- data = (char *)malloc(len);
+ /* make a local copy of the data, including 0 terminator */
+ data = (char *)malloc(len+1);
if (data == NULL) return 0;
memcpy(data, http_data, len);
+ data[len] = 0;
/* first we count how many lines there are
** and set up the line[] array
@@ -77,14 +78,12 @@
data[i] = '\0';
if (data[i] == '\n') {
lines++;
- if (i + 1 < len)
- if (data[i + 1] == '\n' || data[i + 1] == '\r') {
- data[i] = '\0';
- break;
- }
data[i] = '\0';
- if (i < len - 1)
+ if (i + 1 < len) {
+ if (data[i + 1] == '\n' || data[i + 1] == '\r')
+ break;
line[lines] = &data[i + 1];
+ }
}
}
<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