mirror of
https://github.com/brunoherbelin/vimix.git
synced 2025-12-21 07:09:59 +01:00
OSC Peer to peer request
Added OSC mechanism to request network stream. Improved stability of H264 streaming.
This commit is contained in:
@@ -38,6 +38,7 @@
|
||||
#include "TransitionView.h"
|
||||
#include "NetworkToolkit.h"
|
||||
#include "UserInterfaceManager.h"
|
||||
#include "Streamer.h"
|
||||
|
||||
#include "ControlManager.h"
|
||||
|
||||
@@ -119,6 +120,11 @@ void Control::RequestListener::ProcessMessage( const osc::ReceivedMessage& m,
|
||||
Control::manager().sendBatchStatus(remoteEndpoint);
|
||||
}
|
||||
}
|
||||
// Request stream
|
||||
else if ( target.compare(OSC_STREAM) == 0 )
|
||||
{
|
||||
Control::manager().receiveStreamAttribute(attribute, m.ArgumentStream(), sender);
|
||||
}
|
||||
// ALL sources target: apply attribute to all sources of the session
|
||||
else if ( target.compare(OSC_ALL) == 0 )
|
||||
{
|
||||
@@ -999,6 +1005,68 @@ void Control::receiveMultitouchAttribute(const std::string &attribute,
|
||||
|
||||
}
|
||||
|
||||
|
||||
void Control::receiveStreamAttribute(const std::string &attribute,
|
||||
osc::ReceivedMessageArgumentStream arguments,
|
||||
const std::string &sender)
|
||||
{
|
||||
try {
|
||||
if (Streaming::manager().enabled()) {
|
||||
// Stream request /vimix/stream/request
|
||||
if ( attribute.compare(OSC_STREAM_REQUEST) == 0 ) {
|
||||
int port = 0;
|
||||
const char *label = nullptr;
|
||||
// read arguments, port is mandatory, label optionnal
|
||||
arguments >> port;
|
||||
if (arguments.Eos())
|
||||
arguments >> osc::EndMessage;
|
||||
else
|
||||
arguments >> label >> osc::EndMessage;
|
||||
// remove prevous identical stream
|
||||
Streaming::manager().removeStream(sender, port);
|
||||
// add the requested stream to manager
|
||||
Streaming::manager().addStream(sender, port, label == nullptr ? sender : label);
|
||||
}
|
||||
// Stream disconnection request /vimix/stream/disconnect
|
||||
else if ( attribute.compare(OSC_STREAM_DISCONNECT) == 0 ) {
|
||||
|
||||
NetworkToolkit::StreamConfig removed;
|
||||
|
||||
// Port is given: remove stream from that sender at given port
|
||||
try {
|
||||
osc::ReceivedMessageArgumentStream arg = arguments;
|
||||
int port = 0;
|
||||
arg >> port;
|
||||
// no exception, remove that port
|
||||
removed = Streaming::manager().removeStream(sender, port);
|
||||
// silently ignore any other argument
|
||||
}
|
||||
catch (osc::WrongArgumentTypeException &) {
|
||||
}
|
||||
// no stream was removed by port
|
||||
if (!removed.port) {
|
||||
// try by client name if given: remove all streams with that name
|
||||
const char *label = nullptr;
|
||||
arguments >> label >> osc::EndMessage;
|
||||
// no exception, remove that label
|
||||
Streaming::manager().removeStreams(label);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (osc::MissingArgumentException &e) {
|
||||
Log::Info(CONTROL_OSC_MSG "Missing argument for attribute '%s' for target %s.", attribute.c_str(), OSC_STREAM);
|
||||
}
|
||||
catch (osc::ExcessArgumentException &e) {
|
||||
Log::Info(CONTROL_OSC_MSG "Too many arguments for attribute '%s' for target %s.", attribute.c_str(), OSC_STREAM);
|
||||
}
|
||||
catch (osc::WrongArgumentTypeException &e) {
|
||||
Log::Info(CONTROL_OSC_MSG "Invalid argument for attribute '%s' for target %s.", attribute.c_str(), OSC_STREAM);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
void Control::sendSourceAttibutes(const IpEndpointName &remoteEndpoint, std::string target, Source *s)
|
||||
{
|
||||
// default values
|
||||
|
||||
Reference in New Issue
Block a user