]> git.sesse.net Git - casparcg/blobdiff - core/producer/transition/transition_producer.cpp
#467 [framerate_producer] Fixed nb_frames() and frame_number() calculation
[casparcg] / core / producer / transition / transition_producer.cpp
index aed74fd4ce52869c2e00ad87b842ee000a5cd664..590aca44d248fc02d3c27c9e4179ffb1ca86512c 100644 (file)
@@ -19,7 +19,7 @@
 * Author: Robert Nagy, ronag89@gmail.com
 */
 
-#include "../../stdafx.h"
+#include "../../StdAfx.h"
 
 #include "transition_producer.h"
 
 
 #include <tbb/parallel_invoke.h>
 
+#include <future>
+
 namespace caspar { namespace core {    
 
 class transition_producer : public frame_producer_base
 {      
-       monitor::basic_subject                          event_subject_;
+       spl::shared_ptr<monitor::subject>       monitor_subject_;
        const field_mode                                        mode_;
-       int                                                                     current_frame_;
+       int                                                                     current_frame_          = 0;
        
        const transition_info                           info_;
                
        spl::shared_ptr<frame_producer>         dest_producer_;
-       spl::shared_ptr<frame_producer>         source_producer_;
+       spl::shared_ptr<frame_producer>         source_producer_        = frame_producer::empty();
 
-       bool                                                            paused_;
+       bool                                                            paused_                         = false;
                
 public:
        explicit transition_producer(const field_mode& mode, const spl::shared_ptr<frame_producer>& dest, const transition_info& info) 
                : mode_(mode)
-               , current_frame_(0)
                , info_(info)
                , dest_producer_(dest)
-               , source_producer_(frame_producer::empty())
-               , paused_(false)
        {
-               dest->subscribe(event_subject_);
+               dest->monitor_output().attach_parent(monitor_subject_);
 
                CASPAR_LOG(info) << print() << L" Initialized";
        }
@@ -93,10 +92,10 @@ public:
                                source = source_producer_->last_frame();
                });                     
                                                
-               event_subject_  << monitor::event("transition/frame") % current_frame_ % info_.duration
-                                               << monitor::event("transition/type") % [&]() -> std::string
+               *monitor_subject_       << monitor::message("/transition/frame") % current_frame_ % info_.duration
+                                                       << monitor::message("/transition/type") % [&]() -> std::string
                                                                                                                                {
-                                                                                                                                       switch(info_.type.value())
+                                                                                                                                       switch(info_.type)
                                                                                                                                        {
                                                                                                                                        case transition_type::mix:              return "mix";
                                                                                                                                        case transition_type::wipe:             return "wipe";
@@ -117,12 +116,22 @@ public:
 
                return frame_producer_base::last_frame();
        }
-                       
+
+       constraints& pixel_constraints() override
+       {
+               return dest_producer_->pixel_constraints();
+       }
+
        uint32_t nb_frames() const override
        {
                return dest_producer_->nb_frames();
        }
 
+       uint32_t frame_number() const override
+       {
+               return dest_producer_->frame_number();
+       }
+
        std::wstring print() const override
        {
                return L"transition[" + source_producer_->print() + L"=>" + dest_producer_->print() + L"]";
@@ -138,9 +147,9 @@ public:
                return dest_producer_->info();
        }
        
-       boost::unique_future<std::wstring> call(const std::wstring& str) override
+       std::future<std::wstring> call(const std::vector<std::wstring>& params) override
        {
-               return dest_producer_->call(str);
+               return dest_producer_->call(params);
        }
 
        // transition_producer
@@ -202,14 +211,19 @@ public:
                return draw_frame::over(s_frame, d_frame);
        }
 
-       void subscribe(const monitor::observable::observer_ptr& o) override                                                                                                                     
+       monitor::subject& monitor_output()
+       {
+               return *monitor_subject_;
+       }
+
+       void on_interaction(const interaction_event::ptr& event) override
        {
-               event_subject_.subscribe(o);
+               dest_producer_->on_interaction(event);
        }
 
-       void unsubscribe(const monitor::observable::observer_ptr& o) override           
+       bool collides(double x, double y) const override
        {
-               event_subject_.unsubscribe(o);
+               return dest_producer_->collides(x, y);
        }
 };