Frank Weissenborn / Shoutcast
Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers Shoutcast.h Source File

Shoutcast.h

00001 #ifndef __SHOUTCAST_H
00002 #define __SHOUTCAST_H
00003 
00004 #include "EthernetNetIf.h"
00005 
00006 #include "DNSRequest.h"
00007 
00008 #include "defines.h"
00009 
00010 class Shoutcast
00011 {
00012 public:
00013     Shoutcast(const char* devId, char * big_buffer,  int big_buffer_size, char * small_buffer, int small_buffer_size);
00014     
00015      /**
00016      * Get previous genre.
00017      *
00018      * @return pointer to null terminatetd string.
00019      */
00020     const char* GetPrevGenre();
00021      /**
00022      * Get current genre.
00023      *
00024      * @return pointer to null terminatetd string.
00025      */
00026     const char* GetCurrGenre();
00027     
00028      /**
00029      * Get next genre.
00030      *
00031      * @return pointer to null terminatetd string.
00032      */
00033     const char* GetNextGenre();
00034     
00035     int GetChannel(char* name, int length); //cache
00036     int GetTop500(char* name, int length);
00037     
00038      /**
00039      * Get previous channel.
00040      *
00041      * @param name A target key name.
00042      * @param length A pointer to a value storage.
00043      * @return 0, all okay -1, eror getting channel, -2 no channels in list.
00044      */
00045     int GetPrevChannel(char* name, int length);
00046     /**
00047      * Get current channel.
00048      *
00049      * @param name A target key name.
00050      * @param length A pointer to a value storage.
00051      * @return 0, all okay -1, eror getting channel, -2 no channels in list.
00052      */
00053     int GetCurrChannel(char* name, int length);
00054     /**
00055      * Get next channel.
00056      *
00057      * @param name A target key name.
00058      * @param length A pointer to a value storage.
00059      * @return 0, all okay -1, eror getting channel, -2 no channels in list.
00060      */
00061     int GetNextChannel(char* name, int length);
00062     
00063      /**
00064      * Get IP and port of current shoutcast channel.
00065      *
00066      * @param address pointer to address.
00067      * @param port pointer to port.
00068      * @return 0, all okay -1, error 1, error parsing pls
00069      */
00070     int TuneIn(IpAddr* address, int* port, char * path, const int length);
00071     int GetNextAddress(IpAddr* address, int* port, char * path, const int length);
00072     int GetCurrAddress(IpAddr* address, int* port, char * path, const int length);
00073     int GetPrevAddress(IpAddr* address, int* port, char * path, const int length);
00074     
00075     
00076     
00077 private:
00078     const char* _devId;
00079     int ParseChannelList(const char* channelList);
00080     int ParsePls();
00081     int GetChannel(char* name, int length, int channelNumber);
00082     int GetAddressData(IpAddr* address, int* port,char * path, const int length, int addressNumber);
00083     void onReply(DNSReply reply);
00084     int ResolveDNSRequest(IpAddr* addr, char * url);
00085     int GetChannelId(int channelNumber);
00086     char * _big_buffer;
00087     int _big_buffer_size;
00088     char * _small_buffer;
00089     int _small_buffer_size;
00090     
00091     unsigned int _genreCounter;
00092     unsigned int _maxChannel;
00093     unsigned int _currentChannel;
00094     unsigned int _maxAddress;
00095     unsigned int _currentAddress;
00096     FILE *_fpin;
00097     FILE *_fpout;
00098 };
00099 
00100 #endif