mirror of
https://github.com/brunoherbelin/vimix.git
synced 2025-12-11 18:34:58 +01:00
Creation of the Connection Manager : this new mechanism continuously
checks for the presence of vimix programs in the network neibourhood. The list of connections can then be used for indentifying streaming requests and offers.
This commit is contained in:
103
NetworkSource.h
103
NetworkSource.h
@@ -1,16 +1,98 @@
|
||||
#ifndef NETWORKSOURCE_H
|
||||
#define NETWORKSOURCE_H
|
||||
|
||||
#include "osc/OscReceivedElements.h"
|
||||
#include "osc/OscPacketListener.h"
|
||||
#include "osc/OscOutboundPacketStream.h"
|
||||
#include "ip/UdpSocket.h"
|
||||
|
||||
#include "NetworkToolkit.h"
|
||||
#include "StreamSource.h"
|
||||
|
||||
class NetworkSource : public StreamSource
|
||||
{
|
||||
std::string address_;
|
||||
|
||||
public:
|
||||
NetworkSource();
|
||||
|
||||
// Source interface
|
||||
void accept (Visitor& v) override;
|
||||
|
||||
// StreamSource interface
|
||||
Stream *stream() const override { return stream_; }
|
||||
|
||||
// specific interface
|
||||
void setAddress(const std::string &address);
|
||||
std::string address() const;
|
||||
|
||||
glm::ivec2 icon() const override { return glm::ivec2(11, 8); }
|
||||
|
||||
};
|
||||
|
||||
|
||||
class HostsResponsesListener : public osc::OscPacketListener {
|
||||
|
||||
protected:
|
||||
|
||||
virtual void ProcessMessage( const osc::ReceivedMessage& m,
|
||||
const IpEndpointName& remoteEndpoint );
|
||||
};
|
||||
|
||||
|
||||
class NetworkHosts
|
||||
{
|
||||
friend class NetworkSource;
|
||||
friend class HostsResponsesListener;
|
||||
|
||||
NetworkHosts();
|
||||
NetworkHosts(NetworkHosts const& copy); // Not Implemented
|
||||
NetworkHosts& operator=(NetworkHosts const& copy); // Not Implemented
|
||||
|
||||
|
||||
public:
|
||||
|
||||
static NetworkHosts& manager()
|
||||
{
|
||||
// The only instance
|
||||
static NetworkHosts _instance;
|
||||
return _instance;
|
||||
}
|
||||
|
||||
int numHosts () const;
|
||||
std::string name (int index) const;
|
||||
std::string description (int index) const;
|
||||
|
||||
int index (const std::string &address) const;
|
||||
bool connected (const std::string &address) const;
|
||||
bool disconnected (const std::string &address) const;
|
||||
|
||||
Source *createSource(const std::string &address) const;
|
||||
|
||||
private:
|
||||
|
||||
std::vector< std::string > src_address_;
|
||||
std::vector< std::string > src_description_;
|
||||
bool list_uptodate_;
|
||||
|
||||
std::list< NetworkSource * > network_sources_;
|
||||
|
||||
static void ask();
|
||||
static void listen();
|
||||
HostsResponsesListener listener_;
|
||||
UdpListeningReceiveSocket *receiver_;
|
||||
void addHost(const std::string &address, int protocol, int width, int height);
|
||||
void removeHost(const std::string &address);
|
||||
|
||||
};
|
||||
|
||||
|
||||
class NetworkStream : public Stream
|
||||
{
|
||||
public:
|
||||
|
||||
NetworkStream();
|
||||
void open(NetworkToolkit::Protocol protocol, const std::string &host, uint port );
|
||||
bool ping(int *w, int *h);
|
||||
|
||||
glm::ivec2 resolution();
|
||||
|
||||
@@ -23,26 +105,7 @@ private:
|
||||
std::string host_;
|
||||
uint port_;
|
||||
|
||||
static GstFlowReturn callback_sample (GstAppSink *, gpointer );
|
||||
};
|
||||
|
||||
class NetworkSource : public StreamSource
|
||||
{
|
||||
public:
|
||||
NetworkSource();
|
||||
|
||||
// Source interface
|
||||
void accept (Visitor& v) override;
|
||||
|
||||
// StreamSource interface
|
||||
Stream *stream() const override { return stream_; }
|
||||
|
||||
// specific interface
|
||||
NetworkStream *networkstream() const;
|
||||
void connect(NetworkToolkit::Protocol protocol, const std::string &address);
|
||||
|
||||
glm::ivec2 icon() const override { return glm::ivec2(11, 8); }
|
||||
|
||||
};
|
||||
|
||||
#endif // NETWORKSOURCE_H
|
||||
|
||||
Reference in New Issue
Block a user