31 |
#include <arpa/inet.h> |
#include <arpa/inet.h> |
32 |
#include <netdb.h> |
#include <netdb.h> |
33 |
|
|
34 |
|
#include "lscp.h" |
35 |
#include "lscpparser.h" |
#include "lscpparser.h" |
36 |
#include "../thread.h" |
#include "../Sampler.h" |
37 |
#include "../audiothread.h" |
#include "../common/Thread.h" |
38 |
|
|
39 |
/// TCP Port on which the server should listen for connection requests. |
/// TCP Port on which the server should listen for connection requests. |
40 |
#define LSCP_PORT 8888 |
#define LSCP_PORT 8888 |
41 |
|
|
42 |
|
using namespace LinuxSampler; |
43 |
|
|
44 |
/// Handle for a client connection (FIXME: doesn't work for more than one network connections of course, thus has to be included to the yyparse() parameters instead). |
/// Handle for a client connection (FIXME: doesn't work for more than one network connections of course, thus has to be included to the yyparse() parameters instead). |
45 |
extern int hSession; |
extern int hSession; |
46 |
|
|
54 |
*/ |
*/ |
55 |
class LSCPServer : public Thread { |
class LSCPServer : public Thread { |
56 |
public: |
public: |
57 |
LSCPServer(AudioThread* pEngine); |
LSCPServer(Sampler* pSampler); |
58 |
|
|
59 |
// Methods called by the parser |
// Methods called by the parser |
60 |
String LoadInstrument(String Filename, uint Instrument, uint SamplerChannel); |
String LoadInstrument(String Filename, uint uiInstrument, uint uiSamplerChannel); |
61 |
String LoadEngine(String EngineName, uint SamplerChannel); |
String LoadEngine(String EngineName, uint uiSamplerChannel); |
62 |
String GetChannels(); |
String GetChannels(); |
63 |
String AddChannel(); |
String AddChannel(); |
64 |
String RemoveChannel(uint SamplerChannel); |
String RemoveChannel(uint uiSamplerChannel); |
65 |
String GetAvailableEngines(); |
String GetAvailableEngines(); |
66 |
String GetEngineInfo(String EngineName); |
String GetEngineInfo(String EngineName); |
67 |
String GetChannelInfo(uint SamplerChannel); |
String GetChannelInfo(uint uiSamplerChannel); |
68 |
String GetVoiceCount(uint SamplerChannel); |
String GetVoiceCount(uint uiSamplerChannel); |
69 |
String GetStreamCount(uint SamplerChannel); |
String GetStreamCount(uint uiSamplerChannel); |
70 |
String GetBufferFill(fill_response_t ResponseType, uint SamplerChannel); |
String GetBufferFill(fill_response_t ResponseType, uint uiSamplerChannel); |
71 |
String SetAudioOutputType(audio_output_type_t AudioOutputType, uint SamplerChannel); |
String SetAudioOutputType(audio_output_type_t AudioOutputType, uint uiSamplerChannel); |
72 |
String SetAudioOutputChannel(uint AudioOutputChannel, uint SamplerChannel); |
String SetAudioOutputChannel(uint AudioOutputChannel, uint uiSamplerChannel); |
73 |
String SetMIDIInputPort(String MIDIInputPort, uint Samplerchannel); |
String SetMIDIInputType(midi_input_type_t MidiInputType, uint uiSamplerChannel); |
74 |
String SetMIDIInputChannel(uint MIDIChannel, uint SamplerChannel); |
String SetMIDIInputPort(String MIDIInputPort, uint uiSamplerchannel); |
75 |
String SetVolume(double Volume, uint SamplerChannel); |
String SetMIDIInputChannel(uint MIDIChannel, uint uiSamplerChannel); |
76 |
String ResetChannel(uint SamplerChannel); |
String SetVolume(double Volume, uint uiSamplerChannel); |
77 |
|
String ResetChannel(uint uiSamplerChannel); |
78 |
String SubscribeNotification(uint UDPPort); |
String SubscribeNotification(uint UDPPort); |
79 |
String UnsubscribeNotification(String SessionID); |
String UnsubscribeNotification(String SessionID); |
80 |
void AnswerClient(String ReturnMessage); |
void AnswerClient(String ReturnMessage); |
81 |
protected: |
protected: |
82 |
int hSocket; |
int hSocket; |
83 |
sockaddr_in SocketAddress; |
sockaddr_in SocketAddress; |
84 |
AudioThread* pEngine; // FIXME: as long as we only have one engine... |
Sampler* pSampler; |
85 |
|
|
86 |
int Main(); ///< Implementation of virtual method from class Thread |
int Main(); ///< Implementation of virtual method from class Thread |
87 |
private: |
private: |
106 |
} |
} |
107 |
} |
} |
108 |
|
|
109 |
inline String ToString(int i) { |
template<class T> inline String ToString(T o) { |
|
std::stringstream ss; |
|
|
ss << i; |
|
|
return ss.str(); |
|
|
} |
|
|
|
|
|
inline String ToString(double d) { |
|
110 |
std::stringstream ss; |
std::stringstream ss; |
111 |
ss << d; |
ss << o; |
112 |
return ss.str(); |
return ss.str(); |
113 |
} |
} |
114 |
}; |
}; |