mirror of
https://github.com/brunoherbelin/vimix.git
synced 2025-12-11 10:19:59 +01:00
Improved log of OSC message.
This commit is contained in:
@@ -20,6 +20,7 @@
|
|||||||
#include <thread>
|
#include <thread>
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
#include <iomanip>
|
||||||
|
|
||||||
#include "osc/OscOutboundPacketStream.h"
|
#include "osc/OscOutboundPacketStream.h"
|
||||||
|
|
||||||
@@ -46,7 +47,7 @@ void Control::RequestListener::ProcessMessage( const osc::ReceivedMessage& m,
|
|||||||
|
|
||||||
try{
|
try{
|
||||||
#ifdef CONTROL_DEBUG
|
#ifdef CONTROL_DEBUG
|
||||||
Log::Info(CONTROL_OSC_MSG "received '%s' from %s", m.AddressPattern(), sender);
|
Log::Info(CONTROL_OSC_MSG "received '%s' from %s", FullMessage(m).c_str(), sender);
|
||||||
#endif
|
#endif
|
||||||
// TODO Preprocessing with Translator
|
// TODO Preprocessing with Translator
|
||||||
|
|
||||||
@@ -80,8 +81,9 @@ void Control::RequestListener::ProcessMessage( const osc::ReceivedMessage& m,
|
|||||||
// send the status of all sources
|
// send the status of all sources
|
||||||
Control::manager().sendSourcesStatus(remoteEndpoint, N);
|
Control::manager().sendSourcesStatus(remoteEndpoint, N);
|
||||||
}
|
}
|
||||||
else if ( attribute.compare(OSC_INFO_LOG) == 0)
|
else if ( attribute.compare(OSC_INFO_LOG) == 0) {
|
||||||
Log::Info(CONTROL_OSC_MSG "received '%s' from %s", m.AddressPattern(), sender);
|
Log::Info(CONTROL_OSC_MSG "received '%s' from %s", FullMessage(m).c_str(), sender);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// Output target: concerns attributes of the rendering output
|
// Output target: concerns attributes of the rendering output
|
||||||
else if ( target.compare(OSC_OUTPUT) == 0 )
|
else if ( target.compare(OSC_OUTPUT) == 0 )
|
||||||
@@ -115,16 +117,28 @@ void Control::RequestListener::ProcessMessage( const osc::ReceivedMessage& m,
|
|||||||
Mixer::manager().setCurrentNext();
|
Mixer::manager().setCurrentNext();
|
||||||
// confirm by sending back the current source attributes
|
// confirm by sending back the current source attributes
|
||||||
Control::manager().sendCurrentSourceAttibutes(remoteEndpoint);
|
Control::manager().sendCurrentSourceAttibutes(remoteEndpoint);
|
||||||
// send the updated status of all sources
|
//
|
||||||
Control::manager().sendSourcesStatus(remoteEndpoint);
|
// send the status of all sources
|
||||||
|
//
|
||||||
|
// (if an argument is given, it indicates the number of sources to update)
|
||||||
|
float N = 0.f;
|
||||||
|
if ( !m.ArgumentStream().Eos())
|
||||||
|
m.ArgumentStream() >> N >> osc::EndMessage;
|
||||||
|
Control::manager().sendSourcesStatus(remoteEndpoint, N);
|
||||||
}
|
}
|
||||||
else if ( attribute.compare(OSC_PREVIOUS) == 0) {
|
else if ( attribute.compare(OSC_PREVIOUS) == 0) {
|
||||||
// set current to PREVIOUS
|
// set current to PREVIOUS
|
||||||
Mixer::manager().setCurrentPrevious();
|
Mixer::manager().setCurrentPrevious();
|
||||||
// confirm by sending back the current source attributes
|
// confirm by sending back the current source attributes
|
||||||
Control::manager().sendCurrentSourceAttibutes(remoteEndpoint);
|
Control::manager().sendCurrentSourceAttibutes(remoteEndpoint);
|
||||||
// send the updated status of all sources
|
//
|
||||||
Control::manager().sendSourcesStatus(remoteEndpoint);
|
// send the status of all sources
|
||||||
|
//
|
||||||
|
// (if an argument is given, it indicates the number of sources to update)
|
||||||
|
float N = 0.f;
|
||||||
|
if ( !m.ArgumentStream().Eos())
|
||||||
|
m.ArgumentStream() >> N >> osc::EndMessage;
|
||||||
|
Control::manager().sendSourcesStatus(remoteEndpoint, N);
|
||||||
}
|
}
|
||||||
else if ( BaseToolkit::is_a_number( attribute.substr(1), &sourceid) ){
|
else if ( BaseToolkit::is_a_number( attribute.substr(1), &sourceid) ){
|
||||||
// set current to given INDEX
|
// set current to given INDEX
|
||||||
@@ -175,6 +189,52 @@ void Control::RequestListener::ProcessMessage( const osc::ReceivedMessage& m,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
std::string Control::RequestListener::FullMessage( const osc::ReceivedMessage& m )
|
||||||
|
{
|
||||||
|
// build a string with the address pattern of the message
|
||||||
|
std::ostringstream message;
|
||||||
|
message << m.AddressPattern() << " ";
|
||||||
|
|
||||||
|
// try to fill the string with the arguments
|
||||||
|
std::ostringstream arguments;
|
||||||
|
try{
|
||||||
|
// loop over all arguments
|
||||||
|
osc::ReceivedMessage::const_iterator arg = m.ArgumentsBegin();
|
||||||
|
while (arg != m.ArgumentsEnd()) {
|
||||||
|
if( arg->IsBool() ){
|
||||||
|
bool a = (arg++)->AsBoolUnchecked();
|
||||||
|
message << (a ? "T" : "F");
|
||||||
|
}
|
||||||
|
else if( arg->IsInt32() ){
|
||||||
|
int a = (arg++)->AsInt32Unchecked();
|
||||||
|
message << "i";
|
||||||
|
arguments << " " << a;
|
||||||
|
}
|
||||||
|
else if( arg->IsFloat() ){
|
||||||
|
float a = (arg++)->AsFloatUnchecked();
|
||||||
|
message << "f";
|
||||||
|
arguments << " " << std::fixed << std::setprecision(2) << a;
|
||||||
|
}
|
||||||
|
else if( arg->IsString() ){
|
||||||
|
const char *a = (arg++)->AsStringUnchecked();
|
||||||
|
message << "s";
|
||||||
|
arguments << " " << a;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch( osc::Exception& e ){
|
||||||
|
// any parsing errors such as unexpected argument types, or
|
||||||
|
// missing arguments get thrown as exceptions.
|
||||||
|
Log::Info(CONTROL_OSC_MSG "Ignoring error in message '%s': %s", m.AddressPattern(), e.what());
|
||||||
|
}
|
||||||
|
|
||||||
|
// append list of arguments to the message string
|
||||||
|
message << arguments.str();
|
||||||
|
|
||||||
|
// returns the full message
|
||||||
|
return message.str();
|
||||||
|
}
|
||||||
|
|
||||||
void Control::listen()
|
void Control::listen()
|
||||||
{
|
{
|
||||||
#ifdef CONTROL_DEBUG
|
#ifdef CONTROL_DEBUG
|
||||||
@@ -455,7 +515,6 @@ void Control::sendStatus(const IpEndpointName &remoteEndpoint)
|
|||||||
///
|
///
|
||||||
/// Agree to test
|
/// Agree to test
|
||||||
p << osc::BeginMessage( OSC_PREFIX OSC_INFO OSC_INFO_SYNC );
|
p << osc::BeginMessage( OSC_PREFIX OSC_INFO OSC_INFO_SYNC );
|
||||||
p << true;
|
|
||||||
p << osc::EndMessage;
|
p << osc::EndMessage;
|
||||||
/// output attributes
|
/// output attributes
|
||||||
p << osc::BeginMessage( OSC_PREFIX OSC_OUTPUT OSC_OUTPUT_ENABLE );
|
p << osc::BeginMessage( OSC_PREFIX OSC_OUTPUT OSC_OUTPUT_ENABLE );
|
||||||
|
|||||||
@@ -15,6 +15,7 @@
|
|||||||
#define OSC_ALL "/all"
|
#define OSC_ALL "/all"
|
||||||
#define OSC_SELECTED "/selected"
|
#define OSC_SELECTED "/selected"
|
||||||
#define OSC_CURRENT "/current"
|
#define OSC_CURRENT "/current"
|
||||||
|
#define OSC_VERSION "/version"
|
||||||
#define OSC_NEXT "/next"
|
#define OSC_NEXT "/next"
|
||||||
#define OSC_PREVIOUS "/previous"
|
#define OSC_PREVIOUS "/previous"
|
||||||
|
|
||||||
@@ -30,6 +31,7 @@
|
|||||||
#define OSC_SOURCE_TURN "/turn"
|
#define OSC_SOURCE_TURN "/turn"
|
||||||
#define OSC_SOURCE_RESET "/reset"
|
#define OSC_SOURCE_RESET "/reset"
|
||||||
|
|
||||||
|
|
||||||
class Session;
|
class Session;
|
||||||
class Source;
|
class Source;
|
||||||
|
|
||||||
@@ -61,6 +63,7 @@ protected:
|
|||||||
protected:
|
protected:
|
||||||
virtual void ProcessMessage( const osc::ReceivedMessage& m,
|
virtual void ProcessMessage( const osc::ReceivedMessage& m,
|
||||||
const IpEndpointName& remoteEndpoint );
|
const IpEndpointName& remoteEndpoint );
|
||||||
|
std::string FullMessage( const osc::ReceivedMessage& m );
|
||||||
};
|
};
|
||||||
|
|
||||||
void receiveOutputAttribute(const std::string &attribute,
|
void receiveOutputAttribute(const std::string &attribute,
|
||||||
|
|||||||
Binary file not shown.
Reference in New Issue
Block a user