mirror of
https://github.com/brunoherbelin/vimix.git
synced 2025-12-11 18:34:58 +01:00
Implementation of Session control
With Session recall from OSC
This commit is contained in:
@@ -29,6 +29,7 @@
|
|||||||
#include "BaseToolkit.h"
|
#include "BaseToolkit.h"
|
||||||
#include "Mixer.h"
|
#include "Mixer.h"
|
||||||
#include "Source.h"
|
#include "Source.h"
|
||||||
|
#include "ActionManager.h"
|
||||||
|
|
||||||
#include "ControlManager.h"
|
#include "ControlManager.h"
|
||||||
|
|
||||||
@@ -81,13 +82,21 @@ void Control::RequestListener::ProcessMessage( const osc::ReceivedMessage& m,
|
|||||||
// 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 )
|
||||||
{
|
{
|
||||||
if ( attribute.compare(OSC_SYNC) == 0) {
|
if ( attribute.compare(OSC_SYNC) == 0 || Control::manager().receiveOutputAttribute(attribute, m.ArgumentStream())) {
|
||||||
// send the global status
|
// send the global status
|
||||||
Control::manager().sendOutputStatus(remoteEndpoint);
|
Control::manager().sendOutputStatus(remoteEndpoint);
|
||||||
}
|
}
|
||||||
else
|
}
|
||||||
if ( Control::manager().receiveOutputAttribute(attribute, m.ArgumentStream()) )
|
// Session target: concerns attributes of the session
|
||||||
|
else if ( target.compare(OSC_SESSION) == 0 )
|
||||||
|
{
|
||||||
|
if ( attribute.compare(OSC_SYNC) == 0 || Control::manager().receiveSessionAttribute(attribute, m.ArgumentStream()) ) {
|
||||||
|
// send the global status
|
||||||
Control::manager().sendOutputStatus(remoteEndpoint);
|
Control::manager().sendOutputStatus(remoteEndpoint);
|
||||||
|
// send the status of all sources
|
||||||
|
Control::manager().sendSourcesStatus(remoteEndpoint, m.ArgumentStream());
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
// ALL sources target: apply attribute to all sources of the session
|
// ALL sources target: apply attribute to all sources of the session
|
||||||
else if ( target.compare(OSC_ALL) == 0 )
|
else if ( target.compare(OSC_ALL) == 0 )
|
||||||
@@ -272,7 +281,7 @@ void Control::terminate()
|
|||||||
bool Control::receiveOutputAttribute(const std::string &attribute,
|
bool Control::receiveOutputAttribute(const std::string &attribute,
|
||||||
osc::ReceivedMessageArgumentStream arguments)
|
osc::ReceivedMessageArgumentStream arguments)
|
||||||
{
|
{
|
||||||
bool send_feedback = false;
|
bool need_feedback = false;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
/// e.g. '/vimix/output/enable' or '/vimix/output/enable 1.0' or '/vimix/output/enable 0.0'
|
/// e.g. '/vimix/output/enable' or '/vimix/output/enable 1.0' or '/vimix/output/enable 0.0'
|
||||||
@@ -310,7 +319,7 @@ bool Control::receiveOutputAttribute(const std::string &attribute,
|
|||||||
if (!arguments.Eos())
|
if (!arguments.Eos())
|
||||||
arguments >> f >> osc::EndMessage;
|
arguments >> f >> osc::EndMessage;
|
||||||
Mixer::manager().session()->setFadingTarget( Mixer::manager().session()->fading() + f * 0.001);
|
Mixer::manager().session()->setFadingTarget( Mixer::manager().session()->fading() + f * 0.001);
|
||||||
send_feedback = true;
|
need_feedback = true;
|
||||||
}
|
}
|
||||||
else if ( attribute.compare(OSC_OUTPUT_FADE_OUT) == 0) {
|
else if ( attribute.compare(OSC_OUTPUT_FADE_OUT) == 0) {
|
||||||
float f = 0.f;
|
float f = 0.f;
|
||||||
@@ -318,7 +327,7 @@ bool Control::receiveOutputAttribute(const std::string &attribute,
|
|||||||
if (!arguments.Eos())
|
if (!arguments.Eos())
|
||||||
arguments >> f >> osc::EndMessage;
|
arguments >> f >> osc::EndMessage;
|
||||||
Mixer::manager().session()->setFadingTarget( Mixer::manager().session()->fading() - f * 0.001);
|
Mixer::manager().session()->setFadingTarget( Mixer::manager().session()->fading() - f * 0.001);
|
||||||
send_feedback = true;
|
need_feedback = true;
|
||||||
}
|
}
|
||||||
#ifdef CONTROL_DEBUG
|
#ifdef CONTROL_DEBUG
|
||||||
else {
|
else {
|
||||||
@@ -337,7 +346,7 @@ bool Control::receiveOutputAttribute(const std::string &attribute,
|
|||||||
Log::Info(CONTROL_OSC_MSG "Invalid argument for attribute '%s' for target 'output'", attribute.c_str());
|
Log::Info(CONTROL_OSC_MSG "Invalid argument for attribute '%s' for target 'output'", attribute.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
return send_feedback;
|
return need_feedback;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Control::receiveSourceAttribute(Source *target, const std::string &attribute,
|
bool Control::receiveSourceAttribute(Source *target, const std::string &attribute,
|
||||||
@@ -442,6 +451,46 @@ bool Control::receiveSourceAttribute(Source *target, const std::string &attribut
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
bool Control::receiveSessionAttribute(const std::string &attribute,
|
||||||
|
osc::ReceivedMessageArgumentStream arguments)
|
||||||
|
{
|
||||||
|
bool need_feedback = false;
|
||||||
|
|
||||||
|
try {
|
||||||
|
if ( attribute.compare(OSC_SESSION_VERSION) == 0) {
|
||||||
|
float v = 0.f;
|
||||||
|
arguments >> v >> osc::EndMessage;
|
||||||
|
size_t id = (int) ceil(v);
|
||||||
|
std::list<uint64_t> snapshots = Action::manager().snapshots();
|
||||||
|
if ( id < snapshots.size() ) {
|
||||||
|
for (size_t i = 0; i < id; ++i)
|
||||||
|
snapshots.pop_back();
|
||||||
|
uint64_t snap = snapshots.back();
|
||||||
|
Action::manager().restore(snap);
|
||||||
|
}
|
||||||
|
need_feedback = true;
|
||||||
|
}
|
||||||
|
#ifdef CONTROL_DEBUG
|
||||||
|
else {
|
||||||
|
Log::Info(CONTROL_OSC_MSG "Ignoring attribute '%s' for target 'output'", attribute.c_str());
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
}
|
||||||
|
catch (osc::MissingArgumentException &e) {
|
||||||
|
Log::Info(CONTROL_OSC_MSG "Missing argument for attribute '%s' for target 'output'", attribute.c_str());
|
||||||
|
}
|
||||||
|
catch (osc::ExcessArgumentException &e) {
|
||||||
|
Log::Info(CONTROL_OSC_MSG "Too many arguments for attribute '%s' for target 'output'", attribute.c_str());
|
||||||
|
}
|
||||||
|
catch (osc::WrongArgumentTypeException &e) {
|
||||||
|
Log::Info(CONTROL_OSC_MSG "Invalid argument for attribute '%s' for target 'output'", attribute.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
return need_feedback;
|
||||||
|
}
|
||||||
|
|
||||||
void Control::sendCurrentSourceAttibutes(const IpEndpointName &remoteEndpoint)
|
void Control::sendCurrentSourceAttibutes(const IpEndpointName &remoteEndpoint)
|
||||||
{
|
{
|
||||||
// default values
|
// default values
|
||||||
|
|||||||
@@ -18,7 +18,6 @@
|
|||||||
#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"
|
||||||
|
|
||||||
@@ -35,6 +34,8 @@
|
|||||||
#define OSC_SOURCE_TURN "/turn"
|
#define OSC_SOURCE_TURN "/turn"
|
||||||
#define OSC_SOURCE_RESET "/reset"
|
#define OSC_SOURCE_RESET "/reset"
|
||||||
|
|
||||||
|
#define OSC_SESSION "/session"
|
||||||
|
#define OSC_SESSION_VERSION "/version"
|
||||||
|
|
||||||
class Session;
|
class Session;
|
||||||
class Source;
|
class Source;
|
||||||
@@ -76,6 +77,9 @@ protected:
|
|||||||
bool receiveSourceAttribute(Source *target, const std::string &attribute,
|
bool receiveSourceAttribute(Source *target, const std::string &attribute,
|
||||||
osc::ReceivedMessageArgumentStream arguments);
|
osc::ReceivedMessageArgumentStream arguments);
|
||||||
|
|
||||||
|
bool receiveSessionAttribute(const std::string &attribute,
|
||||||
|
osc::ReceivedMessageArgumentStream arguments);
|
||||||
|
|
||||||
void sendCurrentSourceAttibutes(const IpEndpointName& remoteEndpoint);
|
void sendCurrentSourceAttibutes(const IpEndpointName& remoteEndpoint);
|
||||||
void sendSourcesStatus(const IpEndpointName& remoteEndpoint, osc::ReceivedMessageArgumentStream arguments);
|
void sendSourcesStatus(const IpEndpointName& remoteEndpoint, osc::ReceivedMessageArgumentStream arguments);
|
||||||
void sendOutputStatus(const IpEndpointName& remoteEndpoint);
|
void sendOutputStatus(const IpEndpointName& remoteEndpoint);
|
||||||
|
|||||||
Binary file not shown.
Reference in New Issue
Block a user