]> git.sesse.net Git - casparcg/blobdiff - core/video_channel.cpp
git-svn-id: https://casparcg.svn.sourceforge.net/svnroot/casparcg/server/branches...
[casparcg] / core / video_channel.cpp
index a44d9b64c220480584bb6c45affa047b6e6e4738..fcd43fe044369333a3e8857805dba91931f50d12 100644 (file)
 #include "producer/stage.h"\r
 #include "mixer/mixer.h"\r
 #include "consumer/output.h"\r
-#include "frame/data_frame.h"\r
+#include "frame/frame.h"\r
+#include "frame/draw_frame.h"\r
 #include "frame/frame_factory.h"\r
 \r
 #include <common/diagnostics/graph.h>\r
 #include <common/env.h>\r
-#include <common/concurrency/lock.h>\r
-#include <common/concurrency/executor.h>\r
+#include <common/lock.h>\r
+#include <common/executor.h>\r
 \r
 #include <core/mixer/image/image_mixer.h>\r
 \r
 \r
 namespace caspar { namespace core {\r
 \r
-struct video_channel::impl sealed : public frame_factory\r
+struct video_channel::impl sealed\r
 {\r
-       reactive::basic_subject<spl::shared_ptr<const data_frame>> frame_subject_;\r
-       monitor::subject                                                                event_subject_;\r
+       monitor::basic_subject                                                  event_subject_;\r
 \r
        const int                                                                               index_;\r
 \r
@@ -59,17 +59,19 @@ struct video_channel::impl sealed : public frame_factory
        const spl::shared_ptr<diagnostics::graph>               graph_;\r
 \r
        caspar::core::output                                                    output_;\r
+       spl::shared_ptr<image_mixer>                                    image_mixer_;\r
        caspar::core::mixer                                                             mixer_;\r
        caspar::core::stage                                                             stage_; \r
 \r
        executor                                                                                executor_;\r
 public:\r
-       impl(int index, const core::video_format_desc& format_desc, spl::unique_ptr<image_mixer> image_mixer)  \r
+       impl(int index, const core::video_format_desc& format_desc, std::unique_ptr<image_mixer> image_mixer)  \r
                : event_subject_(monitor::path() % "channel" % index)\r
                , index_(index)\r
                , format_desc_(format_desc)\r
                , output_(graph_, format_desc, index)\r
-               , mixer_(graph_, std::move(image_mixer))\r
+               , image_mixer_(std::move(image_mixer))\r
+               , mixer_(graph_, image_mixer_)\r
                , stage_(graph_)\r
                , executor_(L"video_channel")\r
        {\r
@@ -83,29 +85,24 @@ public:
 \r
                CASPAR_LOG(info) << print() << " Successfully Initialized.";\r
        }\r
-       \r
-       // frame_factory\r
-                                               \r
-       virtual spl::shared_ptr<write_frame> create_frame(const void* tag, const core::pixel_format_desc& desc) override\r
-       {               \r
-               return mixer_.create_frame(tag, desc);\r
-       }\r
-       \r
-       virtual core::video_format_desc video_format_desc() const\r
+                                                       \r
+       core::video_format_desc video_format_desc() const\r
        {\r
                return lock(format_desc_mutex_, [&]\r
                {\r
                        return format_desc_;\r
                });\r
        }\r
-       \r
-       // video_channel\r
-       \r
+               \r
        void video_format_desc(const core::video_format_desc& format_desc)\r
        {\r
                lock(format_desc_mutex_, [&]\r
                {\r
-                       format_desc_ = format_desc;\r
+                       if(format_desc_ != format_desc)\r
+                       {\r
+                               format_desc_ = format_desc;\r
+                               stage_.clear();\r
+                       }\r
                });\r
        }\r
 \r
@@ -126,15 +123,13 @@ public:
                        auto mixed_frame  = mixer_(std::move(stage_frames), format_desc);\r
 \r
                        // Consume\r
-                       \r
-                       frame_subject_ << mixed_frame;\r
-                       \r
+                                               \r
                        output_(std::move(mixed_frame), format_desc);\r
                \r
                        graph_->set_value("tick-time", frame_timer.elapsed()*format_desc.fps*0.5);\r
 \r
-                       event_subject_ << monitor::event("debug/profiler")  % frame_timer.elapsed() % (1.0/format_desc_.fps)\r
-                                                       << monitor::event("format")             % u8(format_desc.name);\r
+                       event_subject_  << monitor::event("profiler/time")      % frame_timer.elapsed() % (1.0/format_desc_.fps)\r
+                                                       << monitor::event("format")                     % format_desc.name;\r
                }\r
                catch(...)\r
                {\r
@@ -166,19 +161,18 @@ public:
        }\r
 };\r
 \r
-video_channel::video_channel(int index, const core::video_format_desc& format_desc, spl::unique_ptr<image_mixer> image_mixer) : impl_(new impl(index, format_desc, std::move(image_mixer))){}\r
+video_channel::video_channel(int index, const core::video_format_desc& format_desc, std::unique_ptr<image_mixer> image_mixer) : impl_(new impl(index, format_desc, std::move(image_mixer))){}\r
+video_channel::~video_channel(){}\r
 const stage& video_channel::stage() const { return impl_->stage_;} \r
 stage& video_channel::stage() { return impl_->stage_;} \r
 const mixer& video_channel::mixer() const{ return impl_->mixer_;} \r
 mixer& video_channel::mixer() { return impl_->mixer_;} \r
 const output& video_channel::output() const { return impl_->output_;} \r
 output& video_channel::output() { return impl_->output_;} \r
-spl::shared_ptr<frame_factory> video_channel::frame_factory() { return impl_;} \r
+spl::shared_ptr<frame_factory> video_channel::frame_factory() { return impl_->image_mixer_;} \r
 core::video_format_desc video_channel::video_format_desc() const{return impl_->video_format_desc();}\r
 void core::video_channel::video_format_desc(const core::video_format_desc& format_desc){impl_->video_format_desc(format_desc);}\r
-boost::property_tree::wptree video_channel::info() const{return impl_->info();}\r
-void video_channel::subscribe(const frame_observable::observer_ptr& o) {impl_->frame_subject_.subscribe(o);}\r
-void video_channel::unsubscribe(const frame_observable::observer_ptr& o) {impl_->frame_subject_.unsubscribe(o);}               \r
+boost::property_tree::wptree video_channel::info() const{return impl_->info();}                \r
 void video_channel::subscribe(const monitor::observable::observer_ptr& o) {impl_->event_subject_.subscribe(o);}\r
 void video_channel::unsubscribe(const monitor::observable::observer_ptr& o) {impl_->event_subject_.unsubscribe(o);}\r
 \r