]> git.sesse.net Git - casparcg/commitdiff
2.1.0: Extracted "port" class.
authorronag <ronag@362d55ac-95cf-4e76-9f9a-cbaa9c17b72d>
Tue, 27 Mar 2012 18:08:38 +0000 (18:08 +0000)
committerronag <ronag@362d55ac-95cf-4e76-9f9a-cbaa9c17b72d>
Tue, 27 Mar 2012 18:08:38 +0000 (18:08 +0000)
git-svn-id: https://casparcg.svn.sourceforge.net/svnroot/casparcg/server/branches/2.1.0@2768 362d55ac-95cf-4e76-9f9a-cbaa9c17b72d

core/consumer/output.cpp
core/consumer/port.cpp [new file with mode: 0644]
core/consumer/port.h [new file with mode: 0644]
core/core.vcxproj
core/core.vcxproj.filters

index 34cb8edc1754a5a13c3410e99a4948a2a91877f7..3a0f7432faf18ba2cef09bf76af22e0e018ac4fc 100644 (file)
@@ -28,6 +28,7 @@
 #include "output.h"\r
 \r
 #include "frame_consumer.h"\r
+#include "port.h"\r
 \r
 #include "../video_format.h"\r
 #include "../frame/frame.h"\r
 #include <boost/timer.hpp>\r
 \r
 namespace caspar { namespace core {\r
-       \r
-class port : public monitor::observable\r
-{\r
-       port(const port&);\r
-       port& operator=(const port&);\r
-\r
-       monitor::basic_subject                          event_subject_;\r
-       std::shared_ptr<frame_consumer>         consumer_;\r
-       int                                                                     index_;\r
-       int                                                                     channel_index_;\r
-public:\r
-       port(int index, int channel_index, spl::shared_ptr<frame_consumer> consumer)\r
-               : event_subject_(monitor::path("port") % index)\r
-               , consumer_(std::move(consumer))\r
-               , index_(index)\r
-               , channel_index_(channel_index)\r
-       {\r
-               consumer_->subscribe(event_subject_);\r
-       }\r
-\r
-       port(port&& other)\r
-               : event_subject_(std::move(other.event_subject_))\r
-               , consumer_(std::move(other.consumer_))\r
-               , index_(other.index_)\r
-               , channel_index_(other.channel_index_)\r
-       {\r
-       }\r
-\r
-       port& operator=(port&& other)\r
-       {\r
-               event_subject_  = std::move(other.event_subject_);\r
-               consumer_               = std::move(other.consumer_);\r
-               index_                  = std::move(other.index_);\r
-               channel_index_  = std::move(other.channel_index_);\r
-       }\r
-\r
-       void video_format_desc(const struct video_format_desc& format_desc)\r
-       {\r
-               consumer_->initialize(format_desc, channel_index_);\r
-       }\r
-               \r
-       bool send(class const_frame frame)\r
-       {\r
-               event_subject_ << monitor::event("type") % consumer_->name();\r
-               return consumer_->send(frame);\r
-       }\r
-       \r
-       int index() const\r
-       {\r
-               return index_;\r
-       }\r
-\r
-       int buffer_depth() const\r
-       {\r
-               return consumer_->buffer_depth();\r
-       }\r
-\r
-       bool has_synchronization_clock() const\r
-       {\r
-               return consumer_->has_synchronization_clock();\r
-       }\r
-\r
-       boost::property_tree::wptree info() const\r
-       {\r
-               return consumer_->info();\r
-       }\r
-\r
-       void subscribe(const monitor::observable::observer_ptr& o) override\r
-       {\r
-               event_subject_.subscribe(o);\r
-       }\r
-\r
-       void unsubscribe(const monitor::observable::observer_ptr& o) override\r
-       {\r
-               event_subject_.unsubscribe(o);\r
-       }       \r
-};\r
 \r
 struct output::impl\r
 {              \r
@@ -285,10 +209,10 @@ public:
                return std::move(executor_.begin_invoke([&]() -> boost::property_tree::wptree\r
                {                       \r
                        boost::property_tree::wptree info;\r
-                       BOOST_FOREACH(auto& port, ports_ | boost::adaptors::map_values)\r
+                       BOOST_FOREACH(auto& port, ports_)\r
                        {\r
-                               info.add_child(L"consumers.consumer", port.info())\r
-                                       .add(L"index", port.index()); \r
+                               info.add_child(L"consumers.consumer", port.second.info())\r
+                                       .add(L"index", port.first); \r
                        }\r
                        return info;\r
                }, task_priority::high_priority));\r
diff --git a/core/consumer/port.cpp b/core/consumer/port.cpp
new file mode 100644 (file)
index 0000000..39cd272
--- /dev/null
@@ -0,0 +1,69 @@
+#include "../StdAfx.h"\r
+\r
+#include "port.h"\r
+\r
+#include "frame_consumer.h"\r
+#include "../frame/frame.h"\r
+\r
+namespace caspar { namespace core {\r
+\r
+struct port::impl\r
+{\r
+       monitor::basic_subject                          event_subject_;\r
+       std::shared_ptr<frame_consumer>         consumer_;\r
+       int                                                                     index_;\r
+       int                                                                     channel_index_;\r
+public:\r
+       impl(int index, int channel_index, spl::shared_ptr<frame_consumer> consumer)\r
+               : event_subject_(monitor::path("port") % index)\r
+               , consumer_(std::move(consumer))\r
+               , index_(index)\r
+               , channel_index_(channel_index)\r
+       {\r
+               consumer_->subscribe(event_subject_);\r
+       }\r
+       \r
+       void video_format_desc(const struct video_format_desc& format_desc)\r
+       {\r
+               consumer_->initialize(format_desc, channel_index_);\r
+       }\r
+               \r
+       bool send(const_frame frame)\r
+       {\r
+               event_subject_ << monitor::event("type") % consumer_->name();\r
+               return consumer_->send(std::move(frame));\r
+       }\r
+       \r
+       int index() const\r
+       {\r
+               return index_;\r
+       }\r
+\r
+       int buffer_depth() const\r
+       {\r
+               return consumer_->buffer_depth();\r
+       }\r
+\r
+       bool has_synchronization_clock() const\r
+       {\r
+               return consumer_->has_synchronization_clock();\r
+       }\r
+\r
+       boost::property_tree::wptree info() const\r
+       {\r
+               return consumer_->info();\r
+       }\r
+};\r
+\r
+port::port(int index, int channel_index, spl::shared_ptr<frame_consumer> consumer) : impl_(new impl(index, channel_index, std::move(consumer))){}\r
+port::port(port&& other) : impl_(std::move(other.impl_)){}\r
+port::~port(){}\r
+port& port::operator=(port&& other){impl_ = std::move(other.impl_); return *this;}\r
+bool port::send(const_frame frame){return impl_->send(std::move(frame));}      \r
+void port::subscribe(const monitor::observable::observer_ptr& o){impl_->event_subject_.subscribe(o);}\r
+void port::unsubscribe(const monitor::observable::observer_ptr& o){impl_->event_subject_.unsubscribe(o);}\r
+void port::video_format_desc(const struct video_format_desc& format_desc){impl_->video_format_desc(format_desc);}\r
+int port::buffer_depth() const{return impl_->buffer_depth();}\r
+bool port::has_synchronization_clock() const{return impl_->has_synchronization_clock();}\r
+boost::property_tree::wptree port::info() const{return impl_->info();}\r
+}}
\ No newline at end of file
diff --git a/core/consumer/port.h b/core/consumer/port.h
new file mode 100644 (file)
index 0000000..225447e
--- /dev/null
@@ -0,0 +1,47 @@
+#pragma once\r
+\r
+#include "../monitor/monitor.h"\r
+\r
+#include <common/memory.h>\r
+\r
+#include <boost/property_tree/ptree_fwd.hpp>\r
+\r
+namespace caspar { namespace core {\r
+\r
+class port : public monitor::observable\r
+{\r
+       port(const port&);\r
+       port& operator=(const port&);\r
+public:\r
+\r
+       // Static Members\r
+\r
+       // Constructors\r
+\r
+       port(int index, int channel_index, spl::shared_ptr<class frame_consumer> consumer);\r
+       port(port&& other);\r
+       ~port();\r
+\r
+       // Member Functions\r
+\r
+       port& operator=(port&& other);\r
+\r
+       bool send(class const_frame frame);     \r
+\r
+       // monitor::observable\r
+       \r
+       void subscribe(const monitor::observable::observer_ptr& o) override;\r
+       void unsubscribe(const monitor::observable::observer_ptr& o) override;\r
+\r
+       // Properties\r
+\r
+       void video_format_desc(const struct video_format_desc& format_desc);\r
+       int buffer_depth() const;\r
+       bool has_synchronization_clock() const;\r
+       boost::property_tree::wptree info() const;\r
+private:\r
+       struct impl;\r
+       std::unique_ptr<impl> impl_;\r
+};\r
+\r
+}}
\ No newline at end of file
index 5287015a514975e015dec8fbe24a1cf3bd24b1c5..2f28033226f11a1bbee10ee091048e8d83e81dc6 100644 (file)
     </Lib>\r
   </ItemDefinitionGroup>\r
   <ItemGroup>\r
+    <ClInclude Include="consumer\port.h" />\r
     <ClInclude Include="frame\draw_frame.h" />\r
     <ClInclude Include="frame\frame.h" />\r
     <ClInclude Include="frame\frame_factory.h" />\r
     <ClInclude Include="StdAfx.h" />\r
   </ItemGroup>\r
   <ItemGroup>\r
+    <ClCompile Include="consumer\port.cpp">\r
+      <PrecompiledHeaderFile Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">../StdAfx.h</PrecompiledHeaderFile>\r
+      <PrecompiledHeaderFile Condition="'$(Configuration)|$(Platform)'=='Release|x64'">../StdAfx.h</PrecompiledHeaderFile>\r
+    </ClCompile>\r
     <ClCompile Include="frame\frame.cpp">\r
       <PrecompiledHeaderFile Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">../StdAfx.h</PrecompiledHeaderFile>\r
       <PrecompiledHeaderFile Condition="'$(Configuration)|$(Platform)'=='Release|x64'">../StdAfx.h</PrecompiledHeaderFile>\r
index ce6033f7b39b05ab819e9b86913f6cdeb54cacfe..4dfb18a754192d20105b092d36b8bda543bc27e2 100644 (file)
     <ClInclude Include="frame\frame.h">\r
       <Filter>source\frame</Filter>\r
     </ClInclude>\r
+    <ClInclude Include="consumer\port.h">\r
+      <Filter>source\consumer</Filter>\r
+    </ClInclude>\r
   </ItemGroup>\r
   <ItemGroup>\r
     <ClCompile Include="producer\transition\transition_producer.cpp">\r
     <ClCompile Include="frame\frame.cpp">\r
       <Filter>source\frame</Filter>\r
     </ClCompile>\r
+    <ClCompile Include="consumer\port.cpp">\r
+      <Filter>source\consumer</Filter>\r
+    </ClCompile>\r
   </ItemGroup>\r
 </Project>
\ No newline at end of file