Open Lighting Architecture  0.9.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
StreamingClient.h
Go to the documentation of this file.
1 /*
2  * This library is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU Lesser General Public
4  * License as published by the Free Software Foundation; either
5  * version 2.1 of the License, or (at your option) any later version.
6  *
7  * This library is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
10  * Lesser General Public License for more details.
11  *
12  * You should have received a copy of the GNU Lesser General Public
13  * License along with this library; if not, write to the Free Software
14  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
15  *
16  * StreamingClient.h
17  * Interface to the Streaming Client class.
18  * Copyright (C) 2005 Simon Newton
19  */
25 #ifndef INCLUDE_OLA_CLIENT_STREAMINGCLIENT_H_
26 #define INCLUDE_OLA_CLIENT_STREAMINGCLIENT_H_
27 
28 #include <ola/BaseTypes.h>
29 #include <ola/DmxBuffer.h>
30 #include <ola/base/Macro.h>
32 
33 namespace ola {
34 
35 namespace io { class SelectServer; }
36 namespace network { class TCPSocket; }
37 namespace proto { class OlaServerService_Stub; }
38 namespace rpc { class RpcChannel; }
39 
40 namespace client {
41 
47  public:
51  class SendArgs {
52  public:
58  uint8_t priority;
59 
60  SendArgs() : priority(ola::dmx::SOURCE_PRIORITY_DEFAULT) {}
61  };
62 
63  virtual ~StreamingClientInterface() {}
64 
65  virtual bool Setup() = 0;
66 
67  virtual void Stop() = 0;
68 
69  virtual bool SendDmx(unsigned int universe, const DmxBuffer &data) = 0;
70 
71  virtual bool SendDMX(unsigned int universe,
72  const DmxBuffer &data,
73  const SendArgs &args) = 0;
74 };
75 
87  public:
91  class Options {
92  public:
98 
104 
108  uint16_t server_port;
109  };
110 
117  explicit StreamingClient(bool auto_start = true);
118 
123  explicit StreamingClient(const Options &options);
124 
130 
136  bool Setup();
137 
143  void Stop();
144 
152  bool SendDmx(unsigned int universe, const DmxBuffer &data);
153 
160  bool SendDMX(unsigned int universe,
161  const DmxBuffer &data,
162  const SendArgs &args);
163 
164  void ChannelClosed();
165 
166  private:
167  bool m_auto_start;
168  uint16_t m_server_port;
169  ola::network::TCPSocket *m_socket;
170  ola::io::SelectServer *m_ss;
171  class ola::rpc::RpcChannel *m_channel;
172  class ola::proto::OlaServerService_Stub *m_stub;
173  bool m_socket_closed;
174 
175  bool Send(unsigned int universe, uint8_t priority, const DmxBuffer &data);
176 
178 };
179 } // namespace client
180 } // namespace ola
181 #endif // INCLUDE_OLA_CLIENT_STREAMINGCLIENT_H_