SPAOP
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
StreamMulticaster.h
Go to the documentation of this file.
1 /*
2  * Copyright 2014 Martin Hansen
3  *
4  * This file is part of SPAOP (Spatial Audio Object Positioner).
5  *
6  * SPAOP is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * SPAOP is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with SPAOP. If not, see <http://www.gnu.org/licenses/>.
18  */
19 
20 #ifndef __stream_multicaster__StreamMulticaster__
21 #define __stream_multicaster__StreamMulticaster__
22 
23 #include <iostream>
24 #include <stdint.h>
25 #include "WonderOscServerSender.h"
27 #include "Parsetools.h"
28 
29 namespace wonderlo {
30 
60 {
61 public:
81  StreamMulticaster(const std::string& sourceHost, const std::string& sourcePort,
82  const std::string& mcGroup, const std::string& mcPort,
83  const std::string& mcIfaceIp, const std::string& connectPort,
84  const std::string& streamInPort, const std::string& streamName,
85  const uint8_t ttl=VISUAL_MC_TTL);
86 
88  virtual ~StreamMulticaster();
89 
94  int getConnectPort() const;
95 
100  int getStreamInPort() const;
101 
106  std::string getStreamSourceHost() const;
107 
112  std::string getStreamSourcePort() const;
113 
118  std::string getMulticastGroup() const;
119 
124  std::string getMulticastPort() const;
125 
132  std::string getMulticastIface() const;
133 
148  static int main(const std::string& cWonderAddr="",
149  const std::string& type="visual");
150 
151 private:
152  lowrappers::ServerThread connectIn_;
153  lowrappers::ServerThread streamIn_;
154  lowrappers::Address streamSource_;
155  lowrappers::Address mcGroup_;
156  const std::string streamPath_; // "/WONDER/stream/streamName/"
157 
158  //==============================================================================
159  // vvvvv handlers for incoming OSC-messages:
160 
161  int forwardMessage(const char *path, const char *types, lo_arg **argv,
162  int argc, lo_message msg);
163 
164  int onStreamPingI(const char *path, const char *types,lo_arg **argv,
165  int argc, lo_message msg);
166 
167  int onStreamConnect(const char *path, const char *types,lo_arg **argv,
168  int argc, lo_message msg);
169 
170  int onUnknownConnectIn(const char *path, const char *types, lo_arg **argv,
171  int argc, lo_message msg);
172 };
173 
174 }
175 
176 #endif /* defined(__stream_multicaster__StreamMulticaster__) */
virtual ~StreamMulticaster()
Destructor.
Definition: StreamMulticaster.cpp:60
std::string getMulticastPort() const
Returns the port of the multicast group.
Definition: StreamMulticaster.cpp:96
A StreamMulticaster forwards any OSC messages that are sent to its StreamInPort to a multicast group...
Definition: StreamMulticaster.h:59
A wrapper for Liblo's lo_address.
Definition: Address.h:35
std::string getStreamSourcePort() const
Returns the port of the stream source (i.e.
Definition: StreamMulticaster.cpp:86
std::string getMulticastGroup() const
Returns the IP of the multicast group.
Definition: StreamMulticaster.cpp:91
int getConnectPort() const
Returns the port where incoming connect messages may be sent to.
Definition: StreamMulticaster.cpp:71
std::string getStreamSourceHost() const
Returns the hostname of the stream source (i.e.
Definition: StreamMulticaster.cpp:81
A server thread with Liblo-style callback capabilities.
Definition: ServerThread.h:52
StreamMulticaster(const std::string &sourceHost, const std::string &sourcePort, const std::string &mcGroup, const std::string &mcPort, const std::string &mcIfaceIp, const std::string &connectPort, const std::string &streamInPort, const std::string &streamName, const uint8_t ttl=VISUAL_MC_TTL)
Constructor.
Definition: StreamMulticaster.cpp:24
int getStreamInPort() const
Returns the port where the incoming stream is recieved.
Definition: StreamMulticaster.cpp:76
static int main(const std::string &cWonderAddr="", const std::string &type="visual")
A function that starts a StreamMulticaster-instance.
Definition: StreamMulticaster.cpp:106
std::string getMulticastIface() const
Returns the interface identifier for the network interface used for sending to the multicast group...
Definition: StreamMulticaster.cpp:101
#define VISUAL_MC_TTL
The time-to-live value for messages sent to the multicast group.
Definition: WonderHeader.h:101