Mercurial > audlegacy-plugins
annotate src/icecast/icecast.c @ 2779:ada024f94eb4
added very basic buffering implementation; added server port configuration control
author | Andrew O. Shadoura <bugzilla@tut.by> |
---|---|
date | Thu, 03 Jul 2008 15:42:00 +0300 |
parents | f1f7ee810de8 |
children | c40585c57877 |
rev | line source |
---|---|
2767
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
1 /* Icecast-Plugin |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
2 * (C) copyright 2008 based of FileWriter-plugin |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
3 * |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
4 * Original Out-Lame-Plugin: |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
5 * (C) copyright 2002 Lars Siebold <khandha5@gmx.net> |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
6 * (C) copyright 2006-2007 porting to audacious by Yoshiki Yazawa <yaz@cc.rim.or.jp> |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
7 * |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
8 * This program is free software; you can redistribute it and/or modify |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
9 * it under the terms of the GNU General Public License as published by |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
10 * the Free Software Foundation; either version 2 of the License, or |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
11 * (at your option) any later version. |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
12 * |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
13 * This program is distributed in the hope that it will be useful, |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
16 * GNU General Public License for more details. |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
17 * |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
18 * You should have received a copy of the GNU General Public License |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
19 * along with this program; if not, write to the Free Software |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
21 */ |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
22 |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
23 #include "../filewriter/filewriter.h" |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
24 #include "../filewriter/plugins.h" |
2773
624e5ed793a5
added basic libshout functionality; fixed ice_close to close connection after timeout only
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2768
diff
changeset
|
25 #include <shout/shout.h> |
2767
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
26 |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
27 struct format_info input; |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
28 |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
29 static GtkWidget *configure_win = NULL, *configure_vbox; |
2779
ada024f94eb4
added very basic buffering implementation; added server port configuration control
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2774
diff
changeset
|
30 static GtkWidget *addr_hbox, *addr_label, *addr_entry, *port_spin; |
2767
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
31 static GtkWidget *configure_bbox, *configure_ok, *configure_cancel; |
2773
624e5ed793a5
added basic libshout functionality; fixed ice_close to close connection after timeout only
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2768
diff
changeset
|
32 static guint ice_tid=0; |
2767
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
33 |
2779
ada024f94eb4
added very basic buffering implementation; added server port configuration control
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2774
diff
changeset
|
34 static gint ice_close_timeout; |
ada024f94eb4
added very basic buffering implementation; added server port configuration control
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2774
diff
changeset
|
35 |
2767
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
36 static GtkWidget *streamformat_hbox, *streamformat_label, *streamformat_combo, *plugin_button; |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
37 |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
38 enum streamformat_t |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
39 { |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
40 #ifdef FILEWRITER_MP3 |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
41 MP3, |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
42 #endif |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
43 #ifdef FILEWRITER_VORBIS |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
44 VORBIS, |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
45 #endif |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
46 streamformat_MAX |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
47 }; |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
48 |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
49 static gint streamformat = VORBIS; |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
50 |
2773
624e5ed793a5
added basic libshout functionality; fixed ice_close to close connection after timeout only
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2768
diff
changeset
|
51 static unsigned int streamformat_shout[] = |
624e5ed793a5
added basic libshout functionality; fixed ice_close to close connection after timeout only
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2768
diff
changeset
|
52 { |
624e5ed793a5
added basic libshout functionality; fixed ice_close to close connection after timeout only
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2768
diff
changeset
|
53 #ifdef FILEWRITER_MP3 |
624e5ed793a5
added basic libshout functionality; fixed ice_close to close connection after timeout only
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2768
diff
changeset
|
54 SHOUT_FORMAT_MP3, |
624e5ed793a5
added basic libshout functionality; fixed ice_close to close connection after timeout only
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2768
diff
changeset
|
55 #endif |
624e5ed793a5
added basic libshout functionality; fixed ice_close to close connection after timeout only
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2768
diff
changeset
|
56 #ifdef FILEWRITER_VORBIS |
624e5ed793a5
added basic libshout functionality; fixed ice_close to close connection after timeout only
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2768
diff
changeset
|
57 SHOUT_FORMAT_OGG |
624e5ed793a5
added basic libshout functionality; fixed ice_close to close connection after timeout only
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2768
diff
changeset
|
58 #endif |
624e5ed793a5
added basic libshout functionality; fixed ice_close to close connection after timeout only
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2768
diff
changeset
|
59 }; |
624e5ed793a5
added basic libshout functionality; fixed ice_close to close connection after timeout only
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2768
diff
changeset
|
60 |
2767
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
61 static FileWriter plugin; |
2779
ada024f94eb4
added very basic buffering implementation; added server port configuration control
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2774
diff
changeset
|
62 static uint8_t outputbuffer[4096]; |
ada024f94eb4
added very basic buffering implementation; added server port configuration control
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2774
diff
changeset
|
63 static guint outputlength=0; |
2767
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
64 static gchar *server_address = NULL; |
2779
ada024f94eb4
added very basic buffering implementation; added server port configuration control
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2774
diff
changeset
|
65 static gint server_port=8000; |
2767
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
66 |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
67 VFSFile *output_file = NULL; |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
68 guint64 written = 0; |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
69 guint64 offset = 0; |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
70 Tuple *tuple = NULL; |
2773
624e5ed793a5
added basic libshout functionality; fixed ice_close to close connection after timeout only
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2768
diff
changeset
|
71 static shout_t *shout = NULL; |
2767
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
72 |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
73 static void ice_init(void); |
2773
624e5ed793a5
added basic libshout functionality; fixed ice_close to close connection after timeout only
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2768
diff
changeset
|
74 static void ice_cleanup(void); |
2767
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
75 static void ice_about(void); |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
76 static gint ice_open(AFormat fmt, gint rate, gint nch); |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
77 static void ice_write(void *ptr, gint length); |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
78 static gint ice_write_output(void *ptr, gint length); |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
79 static void ice_close(void); |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
80 static void ice_flush(gint time); |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
81 static void ice_pause(short p); |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
82 static gint ice_free(void); |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
83 static gint ice_playing(void); |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
84 static gint ice_get_written_time(void); |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
85 static gint ice_get_output_time(void); |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
86 static void ice_configure(void); |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
87 /*static int ice_mod_samples(gpointer * d, gint length, AFormat afmt, gint srate, gint nch);*/ |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
88 |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
89 OutputPlugin ice_op = |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
90 { |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
91 .description = "Icecast Plugin", |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
92 .init = ice_init, |
2773
624e5ed793a5
added basic libshout functionality; fixed ice_close to close connection after timeout only
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2768
diff
changeset
|
93 .cleanup = ice_cleanup, |
2767
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
94 .about = ice_about, |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
95 .configure = ice_configure, |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
96 .open_audio = ice_open, |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
97 .write_audio = ice_write, |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
98 .close_audio = ice_close, |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
99 .flush = ice_flush, |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
100 .pause = ice_pause, |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
101 .buffer_free = ice_free, |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
102 .buffer_playing = ice_playing, |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
103 .output_time = ice_get_output_time, |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
104 .written_time = ice_get_written_time |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
105 }; |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
106 /* |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
107 EffectPlugin ice_ep = |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
108 { |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
109 .description = "Icecast Plugin", |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
110 .init = ice_init, |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
111 .cleanup = ice_cleanup, |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
112 .about = ice_about, |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
113 .configure = ice_configure, |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
114 .mod_samples = ice_mod_samples, |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
115 }; |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
116 */ |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
117 OutputPlugin *ice_oplist[] = { &ice_op, NULL }; |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
118 |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
119 SIMPLE_OUTPUT_PLUGIN(icecast, ice_oplist); |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
120 |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
121 static void set_plugin(void) |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
122 { |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
123 if (streamformat < 0 || streamformat >= streamformat_MAX) |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
124 streamformat = 0; |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
125 |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
126 #ifdef FILEWRITER_MP3 |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
127 if (streamformat == MP3) |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
128 plugin = mp3_plugin; |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
129 #endif |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
130 #ifdef FILEWRITER_VORBIS |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
131 if (streamformat == VORBIS) |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
132 plugin = vorbis_plugin; |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
133 #endif |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
134 } |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
135 |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
136 static void ice_init(void) |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
137 { |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
138 ConfigDb *db; |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
139 puts("ICE_INIT"); |
2773
624e5ed793a5
added basic libshout functionality; fixed ice_close to close connection after timeout only
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2768
diff
changeset
|
140 shout_init(); |
624e5ed793a5
added basic libshout functionality; fixed ice_close to close connection after timeout only
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2768
diff
changeset
|
141 printf("Using libshout %s\n", shout_version(NULL, NULL, NULL)); |
2767
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
142 |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
143 db = aud_cfg_db_open(); |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
144 aud_cfg_db_get_int(db, "icecast", "streamformat", &streamformat); |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
145 aud_cfg_db_get_string(db, "icecast", "server_address", &server_address); |
2779
ada024f94eb4
added very basic buffering implementation; added server port configuration control
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2774
diff
changeset
|
146 aud_cfg_db_get_int(db, "icecast", "server_port", &server_port); |
ada024f94eb4
added very basic buffering implementation; added server port configuration control
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2774
diff
changeset
|
147 if (!server_port) server_port=8000; |
ada024f94eb4
added very basic buffering implementation; added server port configuration control
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2774
diff
changeset
|
148 aud_cfg_db_get_int(db, "icecast", "timeout", &ice_close_timeout); |
ada024f94eb4
added very basic buffering implementation; added server port configuration control
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2774
diff
changeset
|
149 if (!ice_close_timeout) ice_close_timeout=5; |
2767
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
150 aud_cfg_db_close(db); |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
151 |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
152 set_plugin(); |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
153 if (plugin.init) |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
154 plugin.init(&ice_write_output); |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
155 } |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
156 |
2773
624e5ed793a5
added basic libshout functionality; fixed ice_close to close connection after timeout only
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2768
diff
changeset
|
157 static void ice_cleanup(void) |
624e5ed793a5
added basic libshout functionality; fixed ice_close to close connection after timeout only
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2768
diff
changeset
|
158 { |
2774
f1f7ee810de8
add metadata to stream + flush() should do a real flush at least with mp3
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2773
diff
changeset
|
159 if (shout) |
f1f7ee810de8
add metadata to stream + flush() should do a real flush at least with mp3
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2773
diff
changeset
|
160 { |
f1f7ee810de8
add metadata to stream + flush() should do a real flush at least with mp3
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2773
diff
changeset
|
161 shout_close(shout); |
f1f7ee810de8
add metadata to stream + flush() should do a real flush at least with mp3
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2773
diff
changeset
|
162 } |
2773
624e5ed793a5
added basic libshout functionality; fixed ice_close to close connection after timeout only
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2768
diff
changeset
|
163 shout_shutdown(); |
624e5ed793a5
added basic libshout functionality; fixed ice_close to close connection after timeout only
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2768
diff
changeset
|
164 } |
624e5ed793a5
added basic libshout functionality; fixed ice_close to close connection after timeout only
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2768
diff
changeset
|
165 |
2767
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
166 void ice_about(void) |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
167 { |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
168 static GtkWidget *dialog; |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
169 |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
170 if (dialog != NULL) |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
171 return; |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
172 |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
173 dialog = audacious_info_dialog(_("About Icecast-Plugin"), |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
174 _("Icecast-Plugin\n\n" |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
175 "This program is free software; you can redistribute it and/or modify\n" |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
176 "it under the terms of the GNU General Public License as published by\n" |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
177 "the Free Software Foundation; either version 2 of the License, or\n" |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
178 "(at your option) any later version.\n" |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
179 "\n" |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
180 "This program is distributed in the hope that it will be useful,\n" |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
181 "but WITHOUT ANY WARRANTY; without even the implied warranty of\n" |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
182 "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n" |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
183 "GNU General Public License for more details.\n" |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
184 "\n" |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
185 "You should have received a copy of the GNU General Public License\n" |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
186 "along with this program; if not, write to the Free Software\n" |
2768 | 187 "Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,\n" |
2767
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
188 "USA."), _("Ok"), FALSE, NULL, NULL); |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
189 gtk_signal_connect(GTK_OBJECT(dialog), "destroy", |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
190 GTK_SIGNAL_FUNC(gtk_widget_destroyed), &dialog); |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
191 } |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
192 |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
193 static gint ice_open(AFormat fmt, gint rate, gint nch) |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
194 { |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
195 gint rv; |
2774
f1f7ee810de8
add metadata to stream + flush() should do a real flush at least with mp3
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2773
diff
changeset
|
196 gint pos; |
f1f7ee810de8
add metadata to stream + flush() should do a real flush at least with mp3
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2773
diff
changeset
|
197 Playlist *playlist; |
2767
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
198 |
2773
624e5ed793a5
added basic libshout functionality; fixed ice_close to close connection after timeout only
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2768
diff
changeset
|
199 if (ice_tid) |
624e5ed793a5
added basic libshout functionality; fixed ice_close to close connection after timeout only
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2768
diff
changeset
|
200 { |
624e5ed793a5
added basic libshout functionality; fixed ice_close to close connection after timeout only
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2768
diff
changeset
|
201 g_source_remove(ice_tid); |
624e5ed793a5
added basic libshout functionality; fixed ice_close to close connection after timeout only
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2768
diff
changeset
|
202 ice_tid = 0; |
624e5ed793a5
added basic libshout functionality; fixed ice_close to close connection after timeout only
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2768
diff
changeset
|
203 } |
624e5ed793a5
added basic libshout functionality; fixed ice_close to close connection after timeout only
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2768
diff
changeset
|
204 |
2767
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
205 input.format = fmt; |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
206 input.frequency = rate; |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
207 input.channels = nch; |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
208 |
2774
f1f7ee810de8
add metadata to stream + flush() should do a real flush at least with mp3
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2773
diff
changeset
|
209 playlist = aud_playlist_get_active(); |
f1f7ee810de8
add metadata to stream + flush() should do a real flush at least with mp3
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2773
diff
changeset
|
210 if(!playlist) |
f1f7ee810de8
add metadata to stream + flush() should do a real flush at least with mp3
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2773
diff
changeset
|
211 return 0; |
2773
624e5ed793a5
added basic libshout functionality; fixed ice_close to close connection after timeout only
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2768
diff
changeset
|
212 |
2774
f1f7ee810de8
add metadata to stream + flush() should do a real flush at least with mp3
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2773
diff
changeset
|
213 pos = aud_playlist_get_position(playlist); |
f1f7ee810de8
add metadata to stream + flush() should do a real flush at least with mp3
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2773
diff
changeset
|
214 tuple = aud_playlist_get_tuple(playlist, pos); |
2773
624e5ed793a5
added basic libshout functionality; fixed ice_close to close connection after timeout only
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2768
diff
changeset
|
215 |
2774
f1f7ee810de8
add metadata to stream + flush() should do a real flush at least with mp3
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2773
diff
changeset
|
216 if (!shout) |
2773
624e5ed793a5
added basic libshout functionality; fixed ice_close to close connection after timeout only
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2768
diff
changeset
|
217 { |
2774
f1f7ee810de8
add metadata to stream + flush() should do a real flush at least with mp3
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2773
diff
changeset
|
218 rv = (plugin.open)(); |
f1f7ee810de8
add metadata to stream + flush() should do a real flush at least with mp3
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2773
diff
changeset
|
219 |
f1f7ee810de8
add metadata to stream + flush() should do a real flush at least with mp3
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2773
diff
changeset
|
220 if (!(shout = shout_new())) |
f1f7ee810de8
add metadata to stream + flush() should do a real flush at least with mp3
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2773
diff
changeset
|
221 return 0; |
f1f7ee810de8
add metadata to stream + flush() should do a real flush at least with mp3
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2773
diff
changeset
|
222 |
f1f7ee810de8
add metadata to stream + flush() should do a real flush at least with mp3
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2773
diff
changeset
|
223 if (shout_set_host(shout, server_address) != SHOUTERR_SUCCESS) |
f1f7ee810de8
add metadata to stream + flush() should do a real flush at least with mp3
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2773
diff
changeset
|
224 { |
f1f7ee810de8
add metadata to stream + flush() should do a real flush at least with mp3
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2773
diff
changeset
|
225 printf("Error setting hostname: %s\n", shout_get_error(shout)); |
f1f7ee810de8
add metadata to stream + flush() should do a real flush at least with mp3
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2773
diff
changeset
|
226 return 0; |
f1f7ee810de8
add metadata to stream + flush() should do a real flush at least with mp3
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2773
diff
changeset
|
227 } |
f1f7ee810de8
add metadata to stream + flush() should do a real flush at least with mp3
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2773
diff
changeset
|
228 |
f1f7ee810de8
add metadata to stream + flush() should do a real flush at least with mp3
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2773
diff
changeset
|
229 if (shout_set_protocol(shout, SHOUT_PROTOCOL_HTTP) != SHOUTERR_SUCCESS) |
f1f7ee810de8
add metadata to stream + flush() should do a real flush at least with mp3
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2773
diff
changeset
|
230 { |
f1f7ee810de8
add metadata to stream + flush() should do a real flush at least with mp3
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2773
diff
changeset
|
231 printf("Error setting protocol: %s\n", shout_get_error(shout)); |
f1f7ee810de8
add metadata to stream + flush() should do a real flush at least with mp3
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2773
diff
changeset
|
232 return 0; |
f1f7ee810de8
add metadata to stream + flush() should do a real flush at least with mp3
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2773
diff
changeset
|
233 } |
f1f7ee810de8
add metadata to stream + flush() should do a real flush at least with mp3
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2773
diff
changeset
|
234 |
2779
ada024f94eb4
added very basic buffering implementation; added server port configuration control
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2774
diff
changeset
|
235 if (shout_set_port(shout, server_port) != SHOUTERR_SUCCESS) |
2774
f1f7ee810de8
add metadata to stream + flush() should do a real flush at least with mp3
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2773
diff
changeset
|
236 { |
f1f7ee810de8
add metadata to stream + flush() should do a real flush at least with mp3
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2773
diff
changeset
|
237 printf("Error setting port: %s\n", shout_get_error(shout)); |
f1f7ee810de8
add metadata to stream + flush() should do a real flush at least with mp3
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2773
diff
changeset
|
238 return 0; |
f1f7ee810de8
add metadata to stream + flush() should do a real flush at least with mp3
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2773
diff
changeset
|
239 } |
2773
624e5ed793a5
added basic libshout functionality; fixed ice_close to close connection after timeout only
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2768
diff
changeset
|
240 |
2774
f1f7ee810de8
add metadata to stream + flush() should do a real flush at least with mp3
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2773
diff
changeset
|
241 if (shout_set_password(shout, "password") != SHOUTERR_SUCCESS) |
f1f7ee810de8
add metadata to stream + flush() should do a real flush at least with mp3
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2773
diff
changeset
|
242 { |
f1f7ee810de8
add metadata to stream + flush() should do a real flush at least with mp3
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2773
diff
changeset
|
243 printf("Error setting password: %s\n", shout_get_error(shout)); |
f1f7ee810de8
add metadata to stream + flush() should do a real flush at least with mp3
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2773
diff
changeset
|
244 return 0; |
f1f7ee810de8
add metadata to stream + flush() should do a real flush at least with mp3
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2773
diff
changeset
|
245 } |
f1f7ee810de8
add metadata to stream + flush() should do a real flush at least with mp3
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2773
diff
changeset
|
246 |
f1f7ee810de8
add metadata to stream + flush() should do a real flush at least with mp3
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2773
diff
changeset
|
247 if (shout_set_mount(shout, "/test") != SHOUTERR_SUCCESS) |
f1f7ee810de8
add metadata to stream + flush() should do a real flush at least with mp3
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2773
diff
changeset
|
248 { |
f1f7ee810de8
add metadata to stream + flush() should do a real flush at least with mp3
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2773
diff
changeset
|
249 printf("Error setting mount: %s\n", shout_get_error(shout)); |
f1f7ee810de8
add metadata to stream + flush() should do a real flush at least with mp3
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2773
diff
changeset
|
250 return 0; |
f1f7ee810de8
add metadata to stream + flush() should do a real flush at least with mp3
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2773
diff
changeset
|
251 } |
f1f7ee810de8
add metadata to stream + flush() should do a real flush at least with mp3
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2773
diff
changeset
|
252 |
f1f7ee810de8
add metadata to stream + flush() should do a real flush at least with mp3
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2773
diff
changeset
|
253 if (shout_set_user(shout, "source") != SHOUTERR_SUCCESS) |
f1f7ee810de8
add metadata to stream + flush() should do a real flush at least with mp3
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2773
diff
changeset
|
254 { |
f1f7ee810de8
add metadata to stream + flush() should do a real flush at least with mp3
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2773
diff
changeset
|
255 printf("Error setting user: %s\n", shout_get_error(shout)); |
f1f7ee810de8
add metadata to stream + flush() should do a real flush at least with mp3
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2773
diff
changeset
|
256 return 0; |
f1f7ee810de8
add metadata to stream + flush() should do a real flush at least with mp3
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2773
diff
changeset
|
257 } |
f1f7ee810de8
add metadata to stream + flush() should do a real flush at least with mp3
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2773
diff
changeset
|
258 |
f1f7ee810de8
add metadata to stream + flush() should do a real flush at least with mp3
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2773
diff
changeset
|
259 if (shout_set_format(shout, streamformat_shout[streamformat]) != SHOUTERR_SUCCESS) |
f1f7ee810de8
add metadata to stream + flush() should do a real flush at least with mp3
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2773
diff
changeset
|
260 { |
f1f7ee810de8
add metadata to stream + flush() should do a real flush at least with mp3
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2773
diff
changeset
|
261 printf("Error setting user: %s\n", shout_get_error(shout)); |
f1f7ee810de8
add metadata to stream + flush() should do a real flush at least with mp3
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2773
diff
changeset
|
262 return 0; |
f1f7ee810de8
add metadata to stream + flush() should do a real flush at least with mp3
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2773
diff
changeset
|
263 } |
f1f7ee810de8
add metadata to stream + flush() should do a real flush at least with mp3
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2773
diff
changeset
|
264 |
f1f7ee810de8
add metadata to stream + flush() should do a real flush at least with mp3
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2773
diff
changeset
|
265 if (shout_open(shout) != SHOUTERR_SUCCESS) |
f1f7ee810de8
add metadata to stream + flush() should do a real flush at least with mp3
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2773
diff
changeset
|
266 { |
f1f7ee810de8
add metadata to stream + flush() should do a real flush at least with mp3
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2773
diff
changeset
|
267 printf("Error connecting to server: %s\n", shout_get_error(shout)); |
f1f7ee810de8
add metadata to stream + flush() should do a real flush at least with mp3
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2773
diff
changeset
|
268 return 0; |
f1f7ee810de8
add metadata to stream + flush() should do a real flush at least with mp3
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2773
diff
changeset
|
269 } |
2773
624e5ed793a5
added basic libshout functionality; fixed ice_close to close connection after timeout only
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2768
diff
changeset
|
270 } |
2774
f1f7ee810de8
add metadata to stream + flush() should do a real flush at least with mp3
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2773
diff
changeset
|
271 else |
f1f7ee810de8
add metadata to stream + flush() should do a real flush at least with mp3
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2773
diff
changeset
|
272 rv = 1; |
2773
624e5ed793a5
added basic libshout functionality; fixed ice_close to close connection after timeout only
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2768
diff
changeset
|
273 |
624e5ed793a5
added basic libshout functionality; fixed ice_close to close connection after timeout only
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2768
diff
changeset
|
274 { |
2774
f1f7ee810de8
add metadata to stream + flush() should do a real flush at least with mp3
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2773
diff
changeset
|
275 shout_metadata_t *sm = NULL; |
f1f7ee810de8
add metadata to stream + flush() should do a real flush at least with mp3
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2773
diff
changeset
|
276 sm = shout_metadata_new(); |
f1f7ee810de8
add metadata to stream + flush() should do a real flush at least with mp3
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2773
diff
changeset
|
277 if (sm) |
f1f7ee810de8
add metadata to stream + flush() should do a real flush at least with mp3
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2773
diff
changeset
|
278 { |
f1f7ee810de8
add metadata to stream + flush() should do a real flush at least with mp3
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2773
diff
changeset
|
279 shout_metadata_add(sm, "charset", "UTF-8"); |
f1f7ee810de8
add metadata to stream + flush() should do a real flush at least with mp3
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2773
diff
changeset
|
280 shout_metadata_add(sm, "title", aud_tuple_get_string(tuple, FIELD_TITLE, NULL)); |
f1f7ee810de8
add metadata to stream + flush() should do a real flush at least with mp3
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2773
diff
changeset
|
281 shout_metadata_add(sm, "artist", aud_tuple_get_string(tuple, FIELD_ARTIST, NULL)); |
f1f7ee810de8
add metadata to stream + flush() should do a real flush at least with mp3
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2773
diff
changeset
|
282 shout_set_metadata(shout, sm); |
f1f7ee810de8
add metadata to stream + flush() should do a real flush at least with mp3
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2773
diff
changeset
|
283 shout_metadata_free(sm); |
f1f7ee810de8
add metadata to stream + flush() should do a real flush at least with mp3
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2773
diff
changeset
|
284 } |
2773
624e5ed793a5
added basic libshout functionality; fixed ice_close to close connection after timeout only
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2768
diff
changeset
|
285 } |
624e5ed793a5
added basic libshout functionality; fixed ice_close to close connection after timeout only
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2768
diff
changeset
|
286 |
2767
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
287 puts("ICE_OPEN"); |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
288 return rv; |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
289 } |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
290 |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
291 static void convert_buffer(gpointer buffer, gint length) |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
292 { |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
293 gint i; |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
294 |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
295 if (input.format == FMT_S8) |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
296 { |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
297 guint8 *ptr1 = buffer; |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
298 gint8 *ptr2 = buffer; |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
299 |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
300 for (i = 0; i < length; i++) |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
301 *(ptr1++) = *(ptr2++) ^ 128; |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
302 } |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
303 if (input.format == FMT_S16_BE) |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
304 { |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
305 gint16 *ptr = buffer; |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
306 |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
307 for (i = 0; i < length >> 1; i++, ptr++) |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
308 *ptr = GUINT16_SWAP_LE_BE(*ptr); |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
309 } |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
310 if (input.format == FMT_S16_NE) |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
311 { |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
312 gint16 *ptr = buffer; |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
313 |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
314 for (i = 0; i < length >> 1; i++, ptr++) |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
315 *ptr = GINT16_TO_LE(*ptr); |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
316 } |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
317 if (input.format == FMT_U16_BE) |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
318 { |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
319 gint16 *ptr1 = buffer; |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
320 guint16 *ptr2 = buffer; |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
321 |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
322 for (i = 0; i < length >> 1; i++, ptr2++) |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
323 *(ptr1++) = GINT16_TO_LE(GUINT16_FROM_BE(*ptr2) ^ 32768); |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
324 } |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
325 if (input.format == FMT_U16_LE) |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
326 { |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
327 gint16 *ptr1 = buffer; |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
328 guint16 *ptr2 = buffer; |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
329 |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
330 for (i = 0; i < length >> 1; i++, ptr2++) |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
331 *(ptr1++) = GINT16_TO_LE(GUINT16_FROM_LE(*ptr2) ^ 32768); |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
332 } |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
333 if (input.format == FMT_U16_NE) |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
334 { |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
335 gint16 *ptr1 = buffer; |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
336 guint16 *ptr2 = buffer; |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
337 |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
338 for (i = 0; i < length >> 1; i++, ptr2++) |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
339 *(ptr1++) = GINT16_TO_LE((*ptr2) ^ 32768); |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
340 } |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
341 } |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
342 |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
343 static void ice_write(void *ptr, gint length) |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
344 { |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
345 if (input.format == FMT_S8 || input.format == FMT_S16_BE || |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
346 input.format == FMT_U16_LE || input.format == FMT_U16_BE || |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
347 input.format == FMT_U16_NE) |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
348 convert_buffer(ptr, length); |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
349 #ifdef WORDS_BIGENDIAN |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
350 if (input.format == FMT_S16_NE) |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
351 convert_buffer(ptr, length); |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
352 #endif |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
353 |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
354 plugin.write(ptr, length); |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
355 } |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
356 |
2779
ada024f94eb4
added very basic buffering implementation; added server port configuration control
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2774
diff
changeset
|
357 static gint ice_real_write(void* ptr, gint length) |
2767
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
358 { |
2779
ada024f94eb4
added very basic buffering implementation; added server port configuration control
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2774
diff
changeset
|
359 int ret; |
ada024f94eb4
added very basic buffering implementation; added server port configuration control
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2774
diff
changeset
|
360 if (!length) return length; |
2773
624e5ed793a5
added basic libshout functionality; fixed ice_close to close connection after timeout only
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2768
diff
changeset
|
361 ret = shout_send(shout, ptr, length); |
2774
f1f7ee810de8
add metadata to stream + flush() should do a real flush at least with mp3
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2773
diff
changeset
|
362 //shout_send_raw(shout, ptr, length); |
2773
624e5ed793a5
added basic libshout functionality; fixed ice_close to close connection after timeout only
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2768
diff
changeset
|
363 shout_sync(shout); |
624e5ed793a5
added basic libshout functionality; fixed ice_close to close connection after timeout only
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2768
diff
changeset
|
364 printf("ice_write[%d:%d](", ret, length); |
2779
ada024f94eb4
added very basic buffering implementation; added server port configuration control
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2774
diff
changeset
|
365 { |
ada024f94eb4
added very basic buffering implementation; added server port configuration control
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2774
diff
changeset
|
366 int i; |
ada024f94eb4
added very basic buffering implementation; added server port configuration control
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2774
diff
changeset
|
367 for (i=0;(i<length)&&(i<16);i++) printf("%c",g_ascii_isprint(((char*)ptr)[i])?(((char*)ptr)[i]):'.'); |
ada024f94eb4
added very basic buffering implementation; added server port configuration control
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2774
diff
changeset
|
368 } |
2767
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
369 printf(")\n"); |
2779
ada024f94eb4
added very basic buffering implementation; added server port configuration control
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2774
diff
changeset
|
370 return 0; |
ada024f94eb4
added very basic buffering implementation; added server port configuration control
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2774
diff
changeset
|
371 //return ret; |
ada024f94eb4
added very basic buffering implementation; added server port configuration control
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2774
diff
changeset
|
372 } |
ada024f94eb4
added very basic buffering implementation; added server port configuration control
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2774
diff
changeset
|
373 |
ada024f94eb4
added very basic buffering implementation; added server port configuration control
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2774
diff
changeset
|
374 static gint ice_write_output(void *ptr, gint length) |
ada024f94eb4
added very basic buffering implementation; added server port configuration control
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2774
diff
changeset
|
375 { |
ada024f94eb4
added very basic buffering implementation; added server port configuration control
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2774
diff
changeset
|
376 if ((!shout) || (!length)) return 0; |
ada024f94eb4
added very basic buffering implementation; added server port configuration control
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2774
diff
changeset
|
377 printf("outputlength=%d, length=%d...",outputlength, length); |
ada024f94eb4
added very basic buffering implementation; added server port configuration control
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2774
diff
changeset
|
378 if ((outputlength>4000)||((outputlength+length)>4096)) |
ada024f94eb4
added very basic buffering implementation; added server port configuration control
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2774
diff
changeset
|
379 { |
ada024f94eb4
added very basic buffering implementation; added server port configuration control
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2774
diff
changeset
|
380 printf("flushing\n"); |
ada024f94eb4
added very basic buffering implementation; added server port configuration control
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2774
diff
changeset
|
381 outputlength=ice_real_write(outputbuffer, outputlength); |
ada024f94eb4
added very basic buffering implementation; added server port configuration control
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2774
diff
changeset
|
382 } |
ada024f94eb4
added very basic buffering implementation; added server port configuration control
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2774
diff
changeset
|
383 { |
ada024f94eb4
added very basic buffering implementation; added server port configuration control
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2774
diff
changeset
|
384 if (length>4096) |
ada024f94eb4
added very basic buffering implementation; added server port configuration control
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2774
diff
changeset
|
385 { |
ada024f94eb4
added very basic buffering implementation; added server port configuration control
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2774
diff
changeset
|
386 printf("data too long, flushing\n"); |
ada024f94eb4
added very basic buffering implementation; added server port configuration control
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2774
diff
changeset
|
387 ice_real_write(ptr, length); |
ada024f94eb4
added very basic buffering implementation; added server port configuration control
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2774
diff
changeset
|
388 } |
ada024f94eb4
added very basic buffering implementation; added server port configuration control
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2774
diff
changeset
|
389 else |
ada024f94eb4
added very basic buffering implementation; added server port configuration control
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2774
diff
changeset
|
390 { |
ada024f94eb4
added very basic buffering implementation; added server port configuration control
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2774
diff
changeset
|
391 printf("adding\n"); |
ada024f94eb4
added very basic buffering implementation; added server port configuration control
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2774
diff
changeset
|
392 memcpy(&(outputbuffer[outputlength]), ptr, length); |
ada024f94eb4
added very basic buffering implementation; added server port configuration control
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2774
diff
changeset
|
393 outputlength+=length; |
ada024f94eb4
added very basic buffering implementation; added server port configuration control
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2774
diff
changeset
|
394 } |
ada024f94eb4
added very basic buffering implementation; added server port configuration control
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2774
diff
changeset
|
395 } |
2767
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
396 return length; |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
397 } |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
398 |
2773
624e5ed793a5
added basic libshout functionality; fixed ice_close to close connection after timeout only
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2768
diff
changeset
|
399 static gboolean ice_real_close(gpointer data) |
2767
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
400 { |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
401 plugin.close(); |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
402 |
2773
624e5ed793a5
added basic libshout functionality; fixed ice_close to close connection after timeout only
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2768
diff
changeset
|
403 if (shout) |
2767
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
404 { |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
405 written = 0; |
2773
624e5ed793a5
added basic libshout functionality; fixed ice_close to close connection after timeout only
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2768
diff
changeset
|
406 shout_close(shout); |
2767
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
407 } |
2773
624e5ed793a5
added basic libshout functionality; fixed ice_close to close connection after timeout only
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2768
diff
changeset
|
408 shout = NULL; |
624e5ed793a5
added basic libshout functionality; fixed ice_close to close connection after timeout only
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2768
diff
changeset
|
409 ice_tid=0; |
624e5ed793a5
added basic libshout functionality; fixed ice_close to close connection after timeout only
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2768
diff
changeset
|
410 puts("ICE_REAL_CLOSE"); |
624e5ed793a5
added basic libshout functionality; fixed ice_close to close connection after timeout only
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2768
diff
changeset
|
411 return FALSE; |
624e5ed793a5
added basic libshout functionality; fixed ice_close to close connection after timeout only
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2768
diff
changeset
|
412 } |
624e5ed793a5
added basic libshout functionality; fixed ice_close to close connection after timeout only
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2768
diff
changeset
|
413 |
624e5ed793a5
added basic libshout functionality; fixed ice_close to close connection after timeout only
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2768
diff
changeset
|
414 |
624e5ed793a5
added basic libshout functionality; fixed ice_close to close connection after timeout only
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2768
diff
changeset
|
415 static void ice_close(void) |
624e5ed793a5
added basic libshout functionality; fixed ice_close to close connection after timeout only
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2768
diff
changeset
|
416 { |
624e5ed793a5
added basic libshout functionality; fixed ice_close to close connection after timeout only
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2768
diff
changeset
|
417 if (ice_tid) g_source_remove(ice_tid); |
624e5ed793a5
added basic libshout functionality; fixed ice_close to close connection after timeout only
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2768
diff
changeset
|
418 ice_tid=g_timeout_add_seconds(3, ice_real_close, NULL); |
624e5ed793a5
added basic libshout functionality; fixed ice_close to close connection after timeout only
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2768
diff
changeset
|
419 puts("ICE_CLOSE: starting timer"); |
2767
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
420 } |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
421 |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
422 static void ice_flush(gint time) |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
423 { |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
424 if (time < 0) |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
425 return; |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
426 |
2774
f1f7ee810de8
add metadata to stream + flush() should do a real flush at least with mp3
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2773
diff
changeset
|
427 plugin.flush(); |
f1f7ee810de8
add metadata to stream + flush() should do a real flush at least with mp3
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2773
diff
changeset
|
428 ice_open(input.format, input.frequency, input.channels); |
f1f7ee810de8
add metadata to stream + flush() should do a real flush at least with mp3
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2773
diff
changeset
|
429 |
2767
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
430 offset = time; |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
431 } |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
432 |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
433 static void ice_pause(short p) |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
434 { |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
435 } |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
436 |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
437 static gint ice_free(void) |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
438 { |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
439 return plugin.free(); |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
440 } |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
441 |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
442 static gint ice_playing(void) |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
443 { |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
444 return plugin.playing(); |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
445 } |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
446 |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
447 static gint ice_get_written_time(void) |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
448 { |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
449 return plugin.get_written_time(); |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
450 } |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
451 |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
452 static gint ice_get_output_time(void) |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
453 { |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
454 return ice_get_written_time(); |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
455 } |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
456 |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
457 static void configure_ok_cb(gpointer data) |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
458 { |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
459 ConfigDb *db; |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
460 |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
461 streamformat = gtk_combo_box_get_active(GTK_COMBO_BOX(streamformat_combo)); |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
462 |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
463 g_free(server_address); |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
464 server_address = g_strdup(gtk_entry_get_text(GTK_ENTRY(addr_entry))); |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
465 |
2779
ada024f94eb4
added very basic buffering implementation; added server port configuration control
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2774
diff
changeset
|
466 server_port = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(port_spin)); |
ada024f94eb4
added very basic buffering implementation; added server port configuration control
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2774
diff
changeset
|
467 |
2767
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
468 db = aud_cfg_db_open(); |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
469 aud_cfg_db_set_int(db, "icecast", "streamformat", streamformat); |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
470 aud_cfg_db_set_string(db, "icecast", "server_address", server_address); |
2779
ada024f94eb4
added very basic buffering implementation; added server port configuration control
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2774
diff
changeset
|
471 aud_cfg_db_set_int(db, "icecast", "server_port", server_port); |
ada024f94eb4
added very basic buffering implementation; added server port configuration control
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2774
diff
changeset
|
472 aud_cfg_db_set_int(db, "icecast", "timeout", ice_close_timeout); |
2767
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
473 |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
474 aud_cfg_db_close(db); |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
475 |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
476 gtk_widget_destroy(configure_win); |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
477 } |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
478 |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
479 static void streamformat_cb(GtkWidget *combo, gpointer data) |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
480 { |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
481 streamformat = gtk_combo_box_get_active(GTK_COMBO_BOX(streamformat_combo)); |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
482 set_plugin(); |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
483 if (plugin.init) |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
484 plugin.init(&ice_write_output); |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
485 |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
486 gtk_widget_set_sensitive(plugin_button, plugin.configure != NULL); |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
487 } |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
488 |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
489 static void plugin_configure_cb(GtkWidget *button, gpointer data) |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
490 { |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
491 if (plugin.configure) |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
492 plugin.configure(); |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
493 } |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
494 |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
495 static void configure_destroy(void) |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
496 { |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
497 } |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
498 |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
499 static void ice_configure(void) |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
500 { |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
501 if (!configure_win) |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
502 { |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
503 configure_win = gtk_window_new(GTK_WINDOW_TOPLEVEL); |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
504 |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
505 gtk_signal_connect(GTK_OBJECT(configure_win), "destroy", |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
506 GTK_SIGNAL_FUNC(configure_destroy), NULL); |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
507 gtk_signal_connect(GTK_OBJECT(configure_win), "destroy", |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
508 GTK_SIGNAL_FUNC(gtk_widget_destroyed), |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
509 &configure_win); |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
510 |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
511 gtk_window_set_title(GTK_WINDOW(configure_win), |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
512 _("Icecast Configuration")); |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
513 gtk_window_set_position(GTK_WINDOW(configure_win), GTK_WIN_POS_MOUSE); |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
514 |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
515 gtk_container_set_border_width(GTK_CONTAINER(configure_win), 10); |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
516 |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
517 configure_vbox = gtk_vbox_new(FALSE, 10); |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
518 gtk_container_add(GTK_CONTAINER(configure_win), configure_vbox); |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
519 |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
520 |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
521 streamformat_hbox = gtk_hbox_new(FALSE, 5); |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
522 gtk_box_pack_start(GTK_BOX(configure_vbox), streamformat_hbox, FALSE, FALSE, 0); |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
523 |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
524 streamformat_label = gtk_label_new(_("Output stream format:")); |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
525 gtk_box_pack_start(GTK_BOX(streamformat_hbox), streamformat_label, FALSE, FALSE, 0); |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
526 |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
527 streamformat_combo = gtk_combo_box_new_text(); |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
528 #ifdef FILEWRITER_MP3 |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
529 gtk_combo_box_append_text(GTK_COMBO_BOX(streamformat_combo), "MP3"); |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
530 #endif |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
531 #ifdef FILEWRITER_VORBIS |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
532 gtk_combo_box_append_text(GTK_COMBO_BOX(streamformat_combo), "Vorbis"); |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
533 #endif |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
534 gtk_box_pack_start(GTK_BOX(streamformat_hbox), streamformat_combo, FALSE, FALSE, 0); |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
535 gtk_combo_box_set_active(GTK_COMBO_BOX(streamformat_combo), streamformat); |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
536 g_signal_connect(G_OBJECT(streamformat_combo), "changed", G_CALLBACK(streamformat_cb), NULL); |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
537 |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
538 plugin_button = gtk_button_new_with_label(_("Configure")); |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
539 gtk_widget_set_sensitive(plugin_button, plugin.configure != NULL); |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
540 g_signal_connect(G_OBJECT(plugin_button), "clicked", G_CALLBACK(plugin_configure_cb), NULL); |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
541 gtk_box_pack_end(GTK_BOX(streamformat_hbox), plugin_button, FALSE, FALSE, 0); |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
542 |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
543 |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
544 |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
545 |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
546 gtk_box_pack_start(GTK_BOX(configure_vbox), gtk_hseparator_new(), FALSE, FALSE, 0); |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
547 |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
548 addr_hbox = gtk_hbox_new(FALSE, 5); |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
549 gtk_box_pack_start(GTK_BOX(configure_vbox), addr_hbox, FALSE, FALSE, 0); |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
550 |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
551 addr_label = gtk_label_new(_("Server address:")); |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
552 gtk_box_pack_start(GTK_BOX(addr_hbox), addr_label, FALSE, FALSE, 0); |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
553 |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
554 addr_entry = gtk_entry_new(); |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
555 |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
556 gtk_entry_set_text(GTK_ENTRY(addr_entry), server_address); |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
557 |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
558 gtk_box_pack_start(GTK_BOX(addr_hbox), addr_entry, TRUE, TRUE, 0); |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
559 |
2779
ada024f94eb4
added very basic buffering implementation; added server port configuration control
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2774
diff
changeset
|
560 port_spin = gtk_spin_button_new_with_range(0.0, 65535.0, 1.0); |
ada024f94eb4
added very basic buffering implementation; added server port configuration control
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2774
diff
changeset
|
561 |
ada024f94eb4
added very basic buffering implementation; added server port configuration control
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2774
diff
changeset
|
562 gtk_spin_button_set_digits(GTK_SPIN_BUTTON(port_spin), 0); |
ada024f94eb4
added very basic buffering implementation; added server port configuration control
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2774
diff
changeset
|
563 |
ada024f94eb4
added very basic buffering implementation; added server port configuration control
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2774
diff
changeset
|
564 gtk_spin_button_set_value(GTK_SPIN_BUTTON(port_spin), (gdouble)server_port); |
ada024f94eb4
added very basic buffering implementation; added server port configuration control
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2774
diff
changeset
|
565 |
ada024f94eb4
added very basic buffering implementation; added server port configuration control
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2774
diff
changeset
|
566 gtk_box_pack_start(GTK_BOX(addr_hbox), port_spin, TRUE, TRUE, 0); |
ada024f94eb4
added very basic buffering implementation; added server port configuration control
Andrew O. Shadoura <bugzilla@tut.by>
parents:
2774
diff
changeset
|
567 |
2767
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
568 gtk_box_pack_start(GTK_BOX(configure_vbox), gtk_hseparator_new(), FALSE, FALSE, 0); |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
569 |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
570 configure_bbox = gtk_hbutton_box_new(); |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
571 gtk_button_box_set_layout(GTK_BUTTON_BOX(configure_bbox), |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
572 GTK_BUTTONBOX_END); |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
573 gtk_button_box_set_spacing(GTK_BUTTON_BOX(configure_bbox), 5); |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
574 gtk_box_pack_start(GTK_BOX(configure_vbox), configure_bbox, |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
575 FALSE, FALSE, 0); |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
576 |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
577 configure_cancel = gtk_button_new_from_stock(GTK_STOCK_CANCEL); |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
578 gtk_signal_connect_object(GTK_OBJECT(configure_cancel), "clicked", |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
579 GTK_SIGNAL_FUNC(gtk_widget_destroy), |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
580 GTK_OBJECT(configure_win)); |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
581 gtk_box_pack_start(GTK_BOX(configure_bbox), configure_cancel, |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
582 TRUE, TRUE, 0); |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
583 |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
584 configure_ok = gtk_button_new_from_stock(GTK_STOCK_OK); |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
585 gtk_signal_connect(GTK_OBJECT(configure_ok), "clicked", |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
586 GTK_SIGNAL_FUNC(configure_ok_cb), NULL); |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
587 gtk_box_pack_start(GTK_BOX(configure_bbox), configure_ok, |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
588 TRUE, TRUE, 0); |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
589 |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
590 gtk_widget_show_all(configure_win); |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
591 } |
fa4b58a08f4c
started icecast plugin (derived from filewriter)
Andrew O. Shadoura <bugzilla@tut.by>
parents:
diff
changeset
|
592 } |