1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
|
$NetBSD: patch-ac,v 1.1.1.1 2004/01/12 04:18:18 kim Exp $
--- mserv/output-icecast.c.orig Sun Aug 31 18:52:35 2003
+++ mserv/output-icecast.c Sat Oct 18 23:01:21 2003
@@ -170,7 +170,7 @@
*error = "Failed setting Icecast hostname";
goto failed;
}
- if (shout_set_protocol(o->shout, SHOUT_PROTOCOL_HTTP) != SHOUTERR_SUCCESS) {
+ if (shout_set_protocol(o->shout, SHOUT_PROTOCOL_XAUDIOCAST) != SHOUTERR_SUCCESS) {
mserv_log("Failed setting Icecast protocol: %s", shout_get_error(o->shout));
*error = "Failed setting Icecast protocol";
goto failed;
@@ -186,8 +186,8 @@
goto failed;
}
if (shout_set_mount(o->shout, mount) != SHOUTERR_SUCCESS) {
- mserv_log("Failed setting Icecast hostname: %s", shout_get_error(o->shout));
- *error = "Failed setting Icecast hostname";
+ mserv_log("Failed setting Icecast mount: %s", shout_get_error(o->shout));
+ *error = "Failed setting Icecast mount";
goto failed;
}
if (shout_set_user(o->shout, user) != SHOUTERR_SUCCESS) {
@@ -195,7 +195,7 @@
*error = "Failed setting Icecast user";
goto failed;
}
- if (shout_set_format(o->shout, SHOUT_FORMAT_VORBIS) != SHOUTERR_SUCCESS) {
+ if (shout_set_format(o->shout, SHOUT_FORMAT_MP3) != SHOUTERR_SUCCESS) {
mserv_log("Failed setting Icecast format: %s", shout_get_error(o->shout));
*error = "Failed setting Icecast format";
goto failed;
@@ -209,6 +209,7 @@
mserv_log("Successfully connected to Icecast host '%s@%s' for mount '%s'",
host, port, mount);
+#if 0
vorbis_info_init(&o->vi);
if (vorbis_encode_init(&o->vi, o->channels, o->samplerate, -1,
o->bitrate, -1) != 0) {
@@ -248,6 +249,8 @@
}
}
}
+#endif
+
/*
if (gettimeofday(&o->lasttime, NULL) == -1) {
*error = "Failed to gettimeofday()";
@@ -389,9 +392,11 @@
}
o->buffer_ready_bytes = 0;
}
+
/* if we have no ready buffer, and we have a full normal buffer,
* send it to vorbis */
if (o->buffer_ready_bytes == 0 && o->buffer_bytes == o->buffer_size) {
+#if 0
vorbbuf = vorbis_analysis_buffer(&o->vd,
o->buffer_size / (o->channels * 2));
if (mserv_debug)
@@ -413,7 +418,27 @@
o->buffer_size / (o->channels * 2));
vorbis_analysis_wrote(&o->vd, o->buffer_size / (o->channels * 2));
o->buffer_bytes = 0;
+#else
+ reqbufsize = o->buffer_ready_bytes + o->buffer_bytes;
+ reqbufsize = ((reqbufsize / 8192) + 1) * 8192; /* add granularity */
+ if (reqbufsize > o->buffer_ready_size) {
+ newbuf = realloc(o->buffer_ready, reqbufsize);
+ mserv_log("Extending output buffer size from %d to %d bytes",
+ o->buffer_ready_size, reqbufsize);
+ if (newbuf == NULL) {
+ mserv_log("Out of memory extending output buffer");
+ exit(1);
+ }
+ o->buffer_ready = newbuf;
+ o->buffer_ready_size = reqbufsize;
+ }
+ memcpy(o->buffer_ready + o->buffer_ready_bytes,
+ o->buffer_float, o->buffer_bytes);
+ o->buffer_ready_bytes += o->buffer_bytes;
+ o->buffer_bytes = 0;
+#endif
}
+
/* if we haven't got a full buffer, read in more from the player */
while (o->buffer_bytes < o->buffer_size) {
/* try and read more from the input stream */
@@ -508,6 +533,8 @@
}
}
}
+
+#if 0
/* does vorbis have anything decoded from what we've already sent it via
* vorbis_analysis_wrote above? */
if (mserv_debug)
@@ -550,6 +577,7 @@
mserv_log(" done. received %d ogg pages from libvorbis", pages);
mserv_log(" encoded output buffer now %d bytes", o->buffer_ready_bytes);
}
+#endif
}
/* end of stream: vorbis_analysis_wrote(&o->vd, 0); */
|