Main Page | Alphabetical List | Data Structures | File List | Data Fields | Globals

config.c

Go to the documentation of this file.
00001 
00044 #include <cfg/os.h>
00045 #include <cfg/clock.h>
00046 #include <dev/board.h>
00047 
00048 #include <stdlib.h>
00049 #include <string.h>
00050 #include <stdio.h>
00051 #include <fcntl.h>
00052 #include <io.h>
00053 
00054 #include <sys/version.h>
00055 #include <sys/confnet.h>
00056 #include <sys/atom.h>
00057 #include <sys/heap.h>
00058 #include <sys/thread.h>
00059 #include <sys/timer.h>
00060 #include <sys/event.h>
00061 #include <sys/socket.h>
00062 
00063 #include <hxmp3/mp3dec.h>
00064 
00065 #include <netinet/tcp.h>
00066 #include <arpa/inet.h>
00067 #include <net/route.h>
00068 #include <pro/dhcp.h>
00069 
00070 #include "config.h"
00071 #include "webradio.h"
00072 
00073 HTTP_PROXY proxy;
00074 STATIONCONF *station;
00075 
00084 int ConfigStation(u_char idx, CONST char *symbol, CONST char * url)
00085 {
00086     u_long ip;
00087     u_short port = 80;
00088     char *buf;
00089     char *cp;
00090 
00091     if (idx >= MAXNUM_STATIONS) {
00092         /* New entry. Find a free slot. */
00093         idx = 0;
00094         while (idx < MAXNUM_STATIONS && station[idx].rs_port) {
00095             idx++;
00096         }
00097     }
00098     if (idx >= MAXNUM_STATIONS) {
00099         /* We are full. */
00100         return -1;
00101     }
00102 
00103     buf = malloc(strlen(url) + 1);
00104 
00105     /* Extract IP address. */
00106     cp = buf;
00107     while (*url && *url != '/' && *url != ':')
00108         *cp++ = *url++;
00109     *cp = 0;
00110     if ((int) (ip = inet_addr(buf)) == -1)
00111         idx = -1;
00112     else {
00113         /* Extract URL path. */
00114         cp = buf;
00115         if (*url == '/') {
00116             url++;
00117             while (*url && *url != ':')
00118                 *cp++ = *url++;
00119         }
00120         *cp = 0;
00121 
00122         /* Extract port. */
00123         if (*url == ':') {
00124             port = atoi(url + 1);
00125         }
00126         if (port) {
00127             station[idx].rs_ip = ip;
00128             station[idx].rs_port = port;
00129             if (*buf) {
00130                 station[idx].rs_url_path = malloc(strlen(buf) + 1);
00131                 strcpy(station[idx].rs_url_path, buf);
00132             }
00133             if (symbol && *symbol) {
00134                 station[idx].rs_symbol = malloc(strlen(symbol) + 1);
00135                 strcpy(station[idx].rs_symbol, symbol);
00136             }
00137             else {
00138                 station[idx].rs_symbol = NULL;
00139             }
00140         }
00141     }
00142     free(buf);
00143 
00144     return idx;
00145 }
00146 
00150 static void ConfigCreate(void)
00151 {
00152     u_char idx;
00153 
00154     if (station == 0)
00155         station = malloc(MAXNUM_STATIONS * sizeof(STATIONCONF));
00156     else {
00157         /* Release all memory occupied by the current configuration. */
00158         for (idx = 0; idx < MAXNUM_STATIONS; idx++) {
00159             if (station[idx].rs_port == 0)
00160                 break;
00161             if (station[idx].rs_url_path) {
00162                 free(station[idx].rs_url_path);
00163             }
00164         }
00165     }
00166     memset(station, 0, MAXNUM_STATIONS * sizeof(STATIONCONF));
00167 }
00168 
00175 void ConfigResetFactory(void)
00176 {
00177     ConfigCreate();
00178 
00179     /* Set HTTP proxy. */
00180 #ifdef MY_PROXY_IP
00181     proxy.proxy_ip = inet_addr(MY_PROXY_IP);
00182     proxy.proxy_port = MY_PROXY_PORT;
00183 #endif
00184 
00185     /* 
00186      * Add pre-configured radio stations. 
00187      */
00188 
00189     /* SAM7X low bandwidth. */
00190     ConfigStation(MAXNUM_STATIONS, NULL, "195.210.39.28:8000"); //Sky.FM Smooth Jazz
00191     ConfigStation(MAXNUM_STATIONS, NULL, "24.226.190.4:8000");
00192     /* Initially start this one. */
00193     radio.rc_rstation = ConfigStation(MAXNUM_STATIONS, NULL, "66.225.205.99:80");
00194     ConfigStation(MAXNUM_STATIONS, NULL, "201.245.105.98:8000");
00195     ConfigStation(MAXNUM_STATIONS, NULL, "207.134.25.235:8000");
00196     ConfigStation(MAXNUM_STATIONS, NULL, "189.166.28.170:8000");
00197 
00198 #if defined(AT91SAM9260_EK)
00199     ConfigStation(MAXNUM_STATIONS, "AfriRhythms", "38.96.148.26:8155");
00200 
00201     ConfigStation(MAXNUM_STATIONS, "AnimeNfo", "213.251.163.188:15220");
00202 
00203     ConfigStation(MAXNUM_STATIONS, "Atlantic Sound Factory", "64.62.166.165:3000");
00204 
00205     ConfigStation(MAXNUM_STATIONS, "BigB", "70.87.68.38:9000");
00206     ConfigStation(MAXNUM_STATIONS, "BigB", "74.52.7.164:9000");
00207     ConfigStation(MAXNUM_STATIONS, "BigB", "67.19.249.226:8000");
00208 
00209     ConfigStation(MAXNUM_STATIONS, "China Classic", "72.21.49.122:8202");
00210 
00211     ConfigStation(MAXNUM_STATIONS, "CorBinA", "80.237.155.22:8016"); //256kbps 44100 stereo
00212     ConfigStation(MAXNUM_STATIONS, "CorBinA", "85.21.79.9:8000"); //256kbps 44100 stereo
00213     ConfigStation(MAXNUM_STATIONS, "CorBinA", "85.21.79.5:8000"); //256kbps 44100 stereo
00214 
00215     ConfigStation(MAXNUM_STATIONS, "DopeLabs", "72.36.193.82:8000");
00216 
00217     ConfigStation(MAXNUM_STATIONS, "EL POTOSI", "189.167.34.93:8000");
00218 
00219     ConfigStation(MAXNUM_STATIONS, "Flensburg", "85.25.143.134:8165");
00220 
00221     /* Start with a reliable station. */
00222     radio.rc_rstation = ConfigStation(MAXNUM_STATIONS, "FREQUENCE3", "88.191.22.199:8000");
00223     ConfigStation(MAXNUM_STATIONS, "FREQUENCE3", "194.158.114.68:8000");
00224     ConfigStation(MAXNUM_STATIONS, "FREQUENCE3", "194.158.114.67:8000");
00225     ConfigStation(MAXNUM_STATIONS, "FREQUENCE3", "193.251.154.243:8000");
00226     ConfigStation(MAXNUM_STATIONS, "FREQUENCE3", "213.186.56.206:8000");
00227     ConfigStation(MAXNUM_STATIONS, "FREQUENCE3", "194.158.114.66:8000");
00228     ConfigStation(MAXNUM_STATIONS, "FREQUENCE3", "213.186.41.160:8000");
00229     ConfigStation(MAXNUM_STATIONS, "FREQUENCE3", "88.191.11.19:8000");
00230     ConfigStation(MAXNUM_STATIONS, "FREQUENCE3", "62.4.21.91:8000");
00231     ConfigStation(MAXNUM_STATIONS, "FREQUENCE3", "212.129.62.140:8000");
00232     ConfigStation(MAXNUM_STATIONS, "FREQUENCE3", "194.117.194.66:8000");
00233     ConfigStation(MAXNUM_STATIONS, "FREQUENCE3", "213.186.37.124:8000");
00234     ConfigStation(MAXNUM_STATIONS, "FREQUENCE3", "80.65.234.120:8000");
00235     ConfigStation(MAXNUM_STATIONS, "FREQUENCE3", "213.161.201.21:8000");
00236     ConfigStation(MAXNUM_STATIONS, "FREQUENCE3", "213.186.60.54:8000");
00237     ConfigStation(MAXNUM_STATIONS, "FREQUENCE3", "193.251.154.242:8000");
00238     ConfigStation(MAXNUM_STATIONS, "FREQUENCE3", "83.143.18.76:8000");
00239     ConfigStation(MAXNUM_STATIONS, "FREQUENCE3", "193.17.192.35:8000");
00240     ConfigStation(MAXNUM_STATIONS, "FREQUENCE3", "193.222.128.135:8000");
00241 
00242     ConfigStation(MAXNUM_STATIONS, "JP HiP", "83.149.104.21:2112");
00243     ConfigStation(MAXNUM_STATIONS, "JP HiP", "220.95.232.121:7188");
00244     ConfigStation(MAXNUM_STATIONS, "JP HiP", "67.19.219.94:7188");
00245 
00246     ConfigStation(MAXNUM_STATIONS, "KPLU Jazz", "205.234.238.46:80"); //24000 mono
00247 
00248     ConfigStation(MAXNUM_STATIONS, "Plusz", "80.95.64.86:8002"); //256kbps 44100 stereo
00249 
00250     ConfigStation(MAXNUM_STATIONS, "Radio from the Ether", "66.32.148.136:8000");
00251 
00252     ConfigStation(MAXNUM_STATIONS, "Radio Space", "142.169.126.180:8438");
00253     ConfigStation(MAXNUM_STATIONS, "Radio Space", "208.53.158.162:8000");
00254 
00255     ConfigStation(MAXNUM_STATIONS, "SKY.FM Classic", "128.177.3.80:4078"); //16000 mono
00256     ConfigStation(MAXNUM_STATIONS, "SKY.FM Classic", "66.90.113.135:8010"); //16000 mono
00257     ConfigStation(MAXNUM_STATIONS, "SKY.FM Classic", "206.98.167.99:8406"); //16000 mono
00258 
00259     ConfigStation(MAXNUM_STATIONS, "SKY.FM Hits", "212.23.5.99:8006");
00260     ConfigStation(MAXNUM_STATIONS, "SKY.FM Hits", "160.79.128.62:6628");
00261     ConfigStation(MAXNUM_STATIONS, "SKY.FM Hits", "64.74.207.40:8628");
00262 
00263     ConfigStation(MAXNUM_STATIONS, "SKY.FM Jazz", "207.200.96.227/stream/1030");
00264 
00265     ConfigStation(MAXNUM_STATIONS, "WGBH Classic", "64.71.145.106:8004"); //44100 stereo with intro
00266 
00267     ConfigStation(MAXNUM_STATIONS, "WHYY 91FM", "207.245.67.204:80");
00268 
00269     ConfigStation(MAXNUM_STATIONS, "WNYC FM", "66.225.205.136:80");
00270     ConfigStation(MAXNUM_STATIONS, "WNYC FM", "66.225.205.135:80");
00271     ConfigStation(MAXNUM_STATIONS, "WNYC FM", "66.225.205.59:80");
00272 
00273     ConfigStation(MAXNUM_STATIONS, ".977 Hitz Channel", "64.236.34.97/stream/1074");
00274     ConfigStation(MAXNUM_STATIONS, ".977 Hitz Channel", "205.188.215.230:8002");
00275 
00276     ConfigStation(MAXNUM_STATIONS, "181.fm", "205.188.215.230:8000");
00277 
00278     ConfigStation(MAXNUM_STATIONS, "YEKAROO", "216.75.63.56:8000");
00279 
00280     ConfigStation(MAXNUM_STATIONS, "Zhong Shuo", "64.71.150.28:16838");
00281 
00282     //AAC Test ConfigStation(MAXNUM_STATIONS, "NetClassix", "67.43.161.248:80");
00283 #endif
00284 
00285     /* Initial radio control settings. */
00286     radio.rc_rvolume = -32;
00287 }
00288 

Generated on Fri Feb 23 17:28:49 2007 for SAM Internet Radio by  doxygen 1.4.4