Open Lighting Architecture  0.9.0
 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
15  *
16  * StreamingClient.h
17  * Interface to the Streaming Client class.
18  * Copyright (C) 2005-2010 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 
53  public:
57  class Options {
58  public:
64 
69  bool auto_start;
70 
74  uint16_t server_port;
75  };
76 
80  class SendArgs {
81  public:
87  uint8_t priority;
88 
89  SendArgs() : priority(ola::dmx::SOURCE_PRIORITY_DEFAULT) {}
90  };
91 
98  explicit StreamingClient(bool auto_start = true);
99 
104  explicit StreamingClient(const Options &options);
105 
111 
117  bool Setup();
118 
124  void Stop();
125 
133  bool SendDmx(unsigned int universe, const DmxBuffer &data);
134 
141  bool SendDMX(unsigned int universe,
142  const DmxBuffer &data,
143  const SendArgs &args);
144 
145  void ChannelClosed();
146 
147  private:
148  bool m_auto_start;
149  uint16_t m_server_port;
150  ola::network::TCPSocket *m_socket;
151  ola::io::SelectServer *m_ss;
152  class ola::rpc::RpcChannel *m_channel;
153  class ola::proto::OlaServerService_Stub *m_stub;
154  bool m_socket_closed;
155 
156  bool Send(unsigned int universe, uint8_t priority, const DmxBuffer &data);
157 
159 };
160 } // namespace client
161 } // namespace ola
162 #endif // INCLUDE_OLA_CLIENT_STREAMINGCLIENT_H_