diff --git a/ControlManager.cpp b/ControlManager.cpp index 6f7a5e5..14e6131 100644 --- a/ControlManager.cpp +++ b/ControlManager.cpp @@ -619,17 +619,37 @@ bool Control::receiveSourceAttribute(Source *target, const std::string &attribut arguments >> x >> osc::EndMessage; target->call( new SetDepth(x), true ); } - /// e.g. '/vimix/current/translation ff 10.0 2.2' + /// e.g. '/vimix/current/grab ff 10.0 2.2' else if ( attribute.compare(OSC_SOURCE_GRAB) == 0) { float x = 0.f, y = 0.f; arguments >> x >> y >> osc::EndMessage; target->call( new Grab( x, y, 0.f), true ); } + /// e.g. '/vimix/current/position ff 10.0 2.2' + else if ( attribute.compare(OSC_SOURCE_POSITION) == 0) { + float x = 0.f, y = 0.f; + arguments >> x >> y >> osc::EndMessage; + Group transform; + transform.copyTransform(target->group(View::GEOMETRY)); + transform.translation_.x = x; + transform.translation_.y = y; + target->call( new SetGeometry( &transform, 0.f), true ); + } /// e.g. '/vimix/current/scale ff 10.0 2.2' else if ( attribute.compare(OSC_SOURCE_RESIZE) == 0) { float x = 0.f, y = 0.f; arguments >> x >> y >> osc::EndMessage; target->call( new Resize( x, y, 0.f), true ); + } + /// e.g. '/vimix/current/size ff 1.0 2.2' + else if ( attribute.compare(OSC_SOURCE_SIZE) == 0) { + float x = 0.f, y = 0.f; + arguments >> x >> y >> osc::EndMessage; + Group transform; + transform.copyTransform(target->group(View::GEOMETRY)); + transform.scale_.x = x; + transform.scale_.y = y; + target->call( new SetGeometry( &transform, 0.f), true ); } /// e.g. '/vimix/current/turn f 1.0' else if ( attribute.compare(OSC_SOURCE_TURN) == 0) { @@ -641,10 +661,25 @@ bool Control::receiveSourceAttribute(Source *target, const std::string &attribut arguments >> y >> osc::EndMessage; target->call( new Turn( x, 0.f), true ); } + /// e.g. '/vimix/current/angle f 3.1416' + else if ( attribute.compare(OSC_SOURCE_ANGLE) == 0) { + float a = 0.f; + arguments >> a >> osc::EndMessage; + Group transform; + transform.copyTransform(target->group(View::GEOMETRY)); + transform.rotation_.z = a; + target->call( new SetGeometry( &transform, 0.f), true ); + } /// e.g. '/vimix/current/reset' else if ( attribute.compare(OSC_SOURCE_RESET) == 0) { target->call( new ResetGeometry(), true ); } + /// e.g. '/vimix/current/seek f 1.25' + else if ( attribute.compare(OSC_SOURCE_SEEK) == 0) { + float t = 0.f; + arguments >> t >> osc::EndMessage; + target->call( new Seek( t ), true ); + } #ifdef CONTROL_DEBUG else { Log::Info(CONTROL_OSC_MSG "Ignoring attribute '%s' for target %s.", attribute.c_str(), target->name().c_str()); diff --git a/ControlManager.h b/ControlManager.h index 67f6a42..29860c4 100644 --- a/ControlManager.h +++ b/ControlManager.h @@ -43,6 +43,10 @@ #define OSC_SOURCE_RESIZE "/resize" #define OSC_SOURCE_TURN "/turn" #define OSC_SOURCE_RESET "/reset" +#define OSC_SOURCE_POSITION "/position" +#define OSC_SOURCE_SIZE "/size" +#define OSC_SOURCE_ANGLE "/angle" +#define OSC_SOURCE_SEEK "/seek" #define OSC_SESSION "/session" #define OSC_SESSION_VERSION "/version" diff --git a/SourceCallback.cpp b/SourceCallback.cpp index cb4ae34..4bb4135 100644 --- a/SourceCallback.cpp +++ b/SourceCallback.cpp @@ -19,6 +19,8 @@ #include "defines.h" #include "Source.h" +#include "MediaSource.h" +#include "MediaPlayer.h" #include "UpdateCallback.h" #include "Visitor.h" #include "Log.h" @@ -458,6 +460,38 @@ SourceCallback *RePlay::clone() const } +Seek::Seek(float time) : SourceCallback(), target_time_(time) +{ +} + +void Seek::update(Source *s, float dt) +{ + SourceCallback::update(s, dt); + + // perform seek when ready + if ( status_ == READY ){ + + // access media player if target source is a media source + MediaSource *ms = dynamic_cast(s); + if (ms != nullptr) + ms->mediaplayer()->seek( GST_SECOND * target_time_ ); + + status_ = FINISHED; + } +} + +SourceCallback *Seek::clone() const +{ + return new Seek(target_time_); +} + +void Seek::accept(Visitor& v) +{ + SourceCallback::accept(v); + v.visit(*this); +} + + SetGeometry::SetGeometry(const Group *g, float ms, bool revert) : SourceCallback(), duration_(ms), bidirectional_(revert) { diff --git a/SourceCallback.h b/SourceCallback.h index ec93545..66ff688 100644 --- a/SourceCallback.h +++ b/SourceCallback.h @@ -24,7 +24,8 @@ public: CALLBACK_PLAY = 8, CALLBACK_REPLAY = 9, CALLBACK_RESETGEO = 10, - CALLBACK_LOCK = 11 + CALLBACK_LOCK = 11, + CALLBACK_SEEK = 12 } CallbackType; static SourceCallback *create(CallbackType type); @@ -34,7 +35,7 @@ public: virtual ~SourceCallback() {} virtual void update (Source *, float); - virtual void multiply (float) {}; + virtual void multiply (float) {} virtual SourceCallback *clone () const = 0; virtual SourceCallback *reverse (Source *) const { return nullptr; } virtual CallbackType type () const { return CALLBACK_GENERIC; } @@ -177,6 +178,22 @@ public: CallbackType type () const override { return CALLBACK_REPLAY; } }; +class Seek : public SourceCallback +{ + float target_time_; + +public: + Seek (float time = 0.f); + + float value () const { return target_time_;} + void setValue (float t) { target_time_ = t; } + + void update (Source *s, float dt) override; + SourceCallback *clone() const override; + CallbackType type () const override { return CALLBACK_SEEK; } + void accept (Visitor& v) override; +}; + class ResetGeometry : public SourceCallback { public: @@ -223,7 +240,7 @@ public: glm::vec2 value () const { return speed_; } void setValue (glm::vec2 d) { speed_ = d; } float duration () const { return duration_; } - void setDuration (float ns) { duration_ = ns; } + void setDuration (float ms) { duration_ = ms; } void update (Source *s, float) override; void multiply (float factor) override; diff --git a/docs/images/manual_clonefilter_0.png b/docs/images/manual_clonefilter_0.png index 04c8b81..904f3ca 100644 Binary files a/docs/images/manual_clonefilter_0.png and b/docs/images/manual_clonefilter_0.png differ diff --git a/docs/images/manual_clonefilter_1.png b/docs/images/manual_clonefilter_1.png index a754869..c566979 100644 Binary files a/docs/images/manual_clonefilter_1.png and b/docs/images/manual_clonefilter_1.png differ diff --git a/docs/images/manual_clonefilter_2.png b/docs/images/manual_clonefilter_2.png index 9d04b46..a14778a 100644 Binary files a/docs/images/manual_clonefilter_2.png and b/docs/images/manual_clonefilter_2.png differ