Open Lighting Architecture
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
E131Device.h
1 /*
2  * This program is free software; you can redistribute it and/or modify
3  * it under the terms of the GNU General Public License as published by
4  * the Free Software Foundation; either version 2 of the License, or
5  * (at your option) any later version.
6  *
7  * This program 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
10  * GNU Library General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software
14  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
15  *
16  * E131Device.h
17  * Interface for the E1.31 device
18  * Copyright (C) 2007-2009 Simon Newton
19  */
20 
21 #ifndef PLUGINS_E131_E131DEVICE_H_
22 #define PLUGINS_E131_E131DEVICE_H_
23 
24 #include <string>
25 #include <vector>
26 #include "ola/acn/CID.h"
27 #include "olad/Device.h"
28 #include "olad/Plugin.h"
29 #include "plugins/e131/messages/E131ConfigMessages.pb.h"
30 
31 namespace ola {
32 namespace plugin {
33 namespace e131 {
34 
35 using google::protobuf::RpcController;
36 using ola::Plugin;
37 using ola::plugin::e131::Request;
38 using std::vector;
39 
40 class E131InputPort;
41 class E131OutputPort;
42 
43 class E131Device: public ola::Device {
44  public:
46  unsigned int input_ports;
47  unsigned int output_ports;
48  bool use_rev2;
49  bool prepend_hostname;
50  bool ignore_preview;
51  uint8_t dscp;
52 
54  : input_ports(0),
55  output_ports(0),
56  use_rev2(false),
57  prepend_hostname(true),
58  ignore_preview(true),
59  dscp(0) {
60  }
61  };
62 
63  E131Device(Plugin *owner,
64  const ola::acn::CID &cid,
65  std::string ip_addr,
66  class PluginAdaptor *plugin_adaptor,
67  const E131DeviceOptions &options);
68 
69  string DeviceId() const { return "1"; }
70 
71  void Configure(RpcController *controller,
72  const string &request,
73  string *response,
74  google::protobuf::Closure *done);
75 
76  protected:
77  bool StartHook();
78  void PrePortStop();
79  void PostPortStop();
80 
81  private:
82  class PluginAdaptor *m_plugin_adaptor;
83  class E131Node *m_node;
84  bool m_use_rev2;
85  bool m_prepend_hostname;
86  bool m_ignore_preview;
87  uint8_t m_dscp;
88  const unsigned int m_input_port_count, m_output_port_count;
89  vector<E131InputPort*> m_input_ports;
90  vector<E131OutputPort*> m_output_ports;
91  std::string m_ip_addr;
92  ola::acn::CID m_cid;
93 
94  void HandlePreviewMode(Request *request, string *response);
95  void HandlePortStatusRequest(string *response);
96  E131InputPort *GetE131InputPort(unsigned int port_id);
97  E131OutputPort *GetE131OutputPort(unsigned int port_id);
98 
99  static const char DEVICE_NAME[];
100 };
101 } // namespace e131
102 } // namespace plugin
103 } // namespace ola
104 #endif // PLUGINS_E131_E131DEVICE_H_