[IPLUG/Standalone] fix clang mMidiOutChan warning
[wdl/wdl-ol.git] / WDL / scsrc.h
blob289fb9c44273ded05befb3e795a67ad6a2104321
1 /*
2 WDL - scsrc.h
3 Copyright (C) 2007, Cockos Incorporated
5 This software is provided 'as-is', without any express or implied
6 warranty. In no event will the authors be held liable for any damages
7 arising from the use of this software.
9 Permission is granted to anyone to use this software for any purpose,
10 including commercial applications, and to alter it and redistribute it
11 freely, subject to the following restrictions:
13 1. The origin of this software must not be misrepresented; you must not
14 claim that you wrote the original software. If you use this software
15 in a product, an acknowledgment in the product documentation would be
16 appreciated but is not required.
17 2. Altered source versions must be plainly marked as such, and must not be
18 misrepresented as being the original software.
19 3. This notice may not be removed or altered from any source distribution.
22 This file provides for an object to source a SHOUTcast (www.shoutcast.com) stream.
23 It uses the lameencdec.h interface (and lame_enc.dll) to encode, and JNetLib to send the data.
26 This object will not auto-reconnect on disconnect. If GetStatus() returns error, the callee needs to
27 delete the object and create a new one.
33 #ifndef _WDL_SCSRC_H_
34 #define _WDL_SCSRC_H_
36 #include <time.h>
37 #include "jnetlib/connection.h"
38 #include "jnetlib/httpget.h"
39 #include "lameencdec.h"
40 #include "wdlstring.h"
41 #include "fastqueue.h"
42 #include "queue.h"
43 #include "mutex.h"
45 class WDL_ShoutcastSource
47 public:
48 WDL_ShoutcastSource(const char *host, const char *pass, const char *name, bool pub=false,
49 const char *genre=NULL, const char *url=NULL,
51 int nch=2, int srate=44100, int kbps=128,
52 const char *ircchan=NULL
54 ~WDL_ShoutcastSource();
56 int GetStatus(); // returns 0 if connected/connecting, >0 if disconnected, -1 if failed connect (or other error) from the start
57 void GetStatusText(char *buf, int bufsz); // gets status text
59 void SetCurTitle(const char *title);
61 int GetSampleRate() { return m_srate; }
62 void OnSamples(float **samples, int nch, int chspread, int frames, double srate);
63 int RunStuff(); // returns nonzero if work done
66 void *userData;
67 int totalBitrate; // 0 for normal, otherwise if using NSV (below) set to kbps of total stream
68 // allows hooking to say, I dunno, package in some other format such as NSV?
69 void (*sendProcessor)(void *userData, WDL_Queue *dataout, WDL_Queue *data);
71 int GetAudioBitrate() { return m_br*1000; }
73 private:
75 WDL_Queue m_procdata;
77 LameEncoder *m_encoder;
78 int m_encoder_splsin;
80 WDL_String m_host,m_pass,m_url,m_genre,m_name,m_ircchan;
81 int m_br;
82 bool m_pub;
84 time_t m_titlecon_start,m_sendcon_start;
86 unsigned int m_bytesout;
87 int m_state;
88 int m_nch,m_srate;
90 double m_last_samples[2] WDL_FIXALIGN;
91 double m_rspos; // last resample fractional position
93 WDL_FastQueue m_samplequeue; // interleaved samples (float)
95 JNL_HTTPGet *m_titlecon;
96 JNL_Connection *m_sendcon;
98 WDL_TypedBuf<float> m_workbuf,m_rsbuf;
99 WDL_Mutex m_samplemutex;
100 WDL_Mutex m_titlemutex;
101 char m_title[512];
102 bool m_needtitle;
105 bool m_is_postmode;
106 unsigned int m_postmode_session;
107 int m_post_bytesleft;
108 int m_post_postsleft;
110 void PostModeConnect();
114 #endif // _WDL_SCSRC_H_