]> git.sesse.net Git - casparcg/commitdiff
git-svn-id: https://casparcg.svn.sourceforge.net/svnroot/casparcg/server/branches...
authorronag <ronag@362d55ac-95cf-4e76-9f9a-cbaa9c17b72d>
Sun, 12 Feb 2012 14:13:57 +0000 (14:13 +0000)
committerronag <ronag@362d55ac-95cf-4e76-9f9a-cbaa9c17b72d>
Sun, 12 Feb 2012 14:13:57 +0000 (14:13 +0000)
12 files changed:
common/reactive.h
core/monitor/monitor.cpp
core/monitor/monitor.h
core/producer/frame_producer.cpp
core/producer/layer.cpp
core/producer/stage.cpp
core/producer/transition/transition_producer.cpp
core/video_channel.cpp
modules/ffmpeg/producer/ffmpeg_producer.cpp
shell/main.cpp
shell/server.cpp
shell/server.h

index 1e0eeb8a5cd62736da4ee4fb4f033ee981a3b020..646ad9e3f53fdd0be0d541e9e08ecdfd7300b8a4 100644 (file)
@@ -238,7 +238,7 @@ private:
 };\r
 \r
 template<typename I, typename O = I>\r
-class basic_subject : public subject<I, O>\r
+class basic_subject sealed : public subject<I, O>\r
 {      \r
     template <typename, typename> friend class basic_subject;\r
 \r
@@ -260,11 +260,7 @@ public:
                : impl_(std::move(other.impl_))\r
        {\r
        }\r
-\r
-       virtual ~basic_subject()\r
-       {\r
-       }\r
-\r
+       \r
        basic_subject& operator=(basic_subject&& other)\r
        {\r
                other.swap(*this);\r
index b258087804c1d362210a9aa77dcadc836c43a1db..d568e81775dc1ba062fe07e82fcc1871db68ea33 100644 (file)
@@ -54,13 +54,11 @@ path::path()
 path::path(const char* path)\r
        : str_(path)\r
 {\r
-\r
 }\r
 \r
 path::path(std::string path)\r
        : str_(path)\r
 {\r
-\r
 }\r
 \r
 path::path(const path& other)\r
@@ -99,34 +97,33 @@ bool path::empty() const
        return str_.empty();\r
 }\r
 \r
+std::ostream& operator<<(std::ostream& o, const path& p)\r
+{\r
+       o << p.str();\r
+       return o;\r
+}\r
+\r
 // event\r
 \r
 event::event(monitor::path path)\r
-       : read_only_(true)\r
-       , path_(std::move(path))\r
-       , params_(std::make_shared<params_t>())\r
+       : path_(std::move(path))\r
 {\r
 }\r
        \r
-event::event(monitor::path path, std::shared_ptr<params_t> params)\r
-       : read_only_(true)\r
-       , path_(std::move(path))\r
+event::event(monitor::path path, params_t params)\r
+       : path_(std::move(path))\r
        , params_(std::move(params))\r
 {\r
-       if(params_ == nullptr)\r
-               throw std::invalid_argument("params");\r
 }\r
 \r
 event::event(const event& other)\r
-       : read_only_(true)\r
-       , path_(other.path_)\r
+       : path_(other.path_)\r
        , params_(other.params_)\r
 {\r
 }\r
 \r
 event::event(event&& other)\r
-       : read_only_(true)\r
-       , path_(std::move(other.path_))\r
+       : path_(std::move(other.path_))\r
        , params_(std::move(other.params_))\r
 {\r
 }\r
@@ -139,7 +136,6 @@ event& event::operator=(event other)
 \r
 void event::swap(event& other)\r
 {\r
-       std::swap(read_only_, other.read_only_);\r
        std::swap(path_, other.path_);\r
        std::swap(params_, other.params_);\r
 }\r
@@ -151,7 +147,7 @@ const path& event::path() const
 \r
 const event::params_t& event::params() const   \r
 {\r
-       return *params_;\r
+       return params_;\r
 }\r
 \r
 event event::propagate(monitor::path path) const\r
@@ -159,4 +155,12 @@ event event::propagate(monitor::path path) const
        return event(std::move(path) % path_, params_);\r
 }\r
 \r
+std::ostream& operator<<(std::ostream& o, const event& e)\r
+{\r
+       o << e.path();\r
+       for(auto it = e.params().begin(); it != e.params().end(); ++it)\r
+               o << " " << *it;\r
+       return o;\r
+}\r
+\r
 }}
\ No newline at end of file
index 4c007db89ba9d4ec3a76abf58df0a2c3c95b43ee..21074d58a53ce2b868b01b4418463484e904f502 100644 (file)
 #define _SCL_SECURE_NO_WARNINGS\r
 #endif\r
 \r
+namespace boost {\r
+namespace detail { namespace variant {\r
+\r
+template <>\r
+struct has_nothrow_move<std::string>\r
+: mpl::true_\r
+{\r
+};\r
+  \r
+template <>\r
+struct has_nothrow_move<std::vector<int8_t>>\r
+: mpl::true_\r
+{\r
+};\r
+\r
+template <>\r
+struct has_nothrow_move<boost::chrono::duration<double, boost::ratio<1, 1>>>\r
+: mpl::true_\r
+{\r
+};\r
+\r
+}}}\r
+\r
 namespace caspar { namespace monitor {\r
        \r
 // path\r
@@ -67,6 +90,8 @@ path operator%(path path, T&& value)
        return std::move(path %= std::forward<T>(value));\r
 }\r
 \r
+std::ostream& operator<<(std::ostream& o, const path& p);\r
+\r
 // param\r
 \r
 typedef boost::chrono::duration<double, boost::ratio<1, 1>> duration;\r
@@ -83,7 +108,7 @@ public:
        typedef std::vector<param, tbb::cache_aligned_allocator<param>> params_t;\r
        \r
        event(path path);       \r
-       event(path path, std::shared_ptr<params_t> params);     \r
+       event(path path, params_t params);      \r
                                \r
        event(const event& other);\r
        event(event&& other);\r
@@ -94,12 +119,7 @@ public:
        template<typename T>\r
        event& operator%(T&& value)\r
        {\r
-               if(read_only_)\r
-               {\r
-                       read_only_ = false;\r
-                       params_ = spl::make_shared<params_t>(*params_);\r
-               }\r
-               params_->push_back(std::forward<T>(value));\r
+               params_.push_back(std::forward<T>(value));\r
                return *this;\r
        }\r
        \r
@@ -107,18 +127,22 @@ public:
        const path&             path() const;\r
        const params_t& params() const;\r
 private:\r
-       bool                                            read_only_;             \r
-       monitor::path                           path_;\r
-       std::shared_ptr<params_t>       params_;\r
+       monitor::path   path_;\r
+       params_t                params_;\r
 };\r
 \r
-typedef reactive::observable<monitor::event> observable;\r
-typedef reactive::observer<monitor::event> observer;\r
+std::ostream& operator<<(std::ostream& o, const event& e);\r
+\r
+// reactive\r
+\r
+typedef reactive::observable<monitor::event>   observable;\r
+typedef reactive::observer<monitor::event>             observer;\r
+typedef reactive::subject<monitor::event>              subject;\r
        \r
-class subject : public reactive::subject<monitor::event>\r
+class basic_subject sealed : public reactive::subject<monitor::event>\r
 {          \r
-       subject(const subject&);\r
-       subject& operator=(const subject&);\r
+       basic_subject(const basic_subject&);\r
+       basic_subject& operator=(const basic_subject&);\r
        \r
        class impl : public observer\r
        {\r
@@ -166,22 +190,18 @@ class subject : public reactive::subject<monitor::event>
        };\r
 \r
 public:                \r
-       subject(monitor::path path = monitor::path())\r
+       basic_subject(monitor::path path = monitor::path())\r
                : impl_(std::make_shared<impl>(std::move(path)))\r
 \r
        {\r
        }\r
                \r
-       subject(subject&& other)\r
+       basic_subject(basic_subject&& other)\r
                : impl_(std::move(other.impl_))\r
        {\r
        }\r
-\r
-       virtual ~subject()\r
-       {\r
-       }\r
-\r
-       subject& operator=(subject&& other)\r
+       \r
+       basic_subject& operator=(basic_subject&& other)\r
        {\r
                impl_ = std::move(other.impl_);\r
        }\r
index 5114b024d03209d5c765d39c7434e6a9f24d7667..0557e2e7432aace16e09b65d2c9b76179283e825 100644 (file)
@@ -99,7 +99,7 @@ public:
 \r
 class follow_producer_proxy : public producer_proxy_base\r
 {      \r
-       monitor::subject event_subject_;\r
+       monitor::basic_subject event_subject_;\r
 public:\r
        follow_producer_proxy(spl::shared_ptr<frame_producer>&& producer) \r
                : producer_proxy_base(std::move(producer))\r
index ab845d4d0fced7e4ed8bfabd4e27f5b990e6e84f..55bd73230d40b5061e9b6507be422865b16da1eb 100644 (file)
@@ -36,9 +36,9 @@ namespace caspar { namespace core {
 \r
 struct layer::impl\r
 {                              \r
-       monitor::subject                                        event_subject_;\r
-       monitor::subject                                        foreground_event_subject_;\r
-       monitor::subject                                        background_event_subject_;\r
+       monitor::basic_subject                          event_subject_;\r
+       monitor::basic_subject                          foreground_event_subject_;\r
+       monitor::basic_subject                          background_event_subject_;\r
        spl::shared_ptr<frame_producer>         foreground_;\r
        spl::shared_ptr<frame_producer>         background_;\r
        int64_t                                                         frame_number_;\r
index 7994b01a6927bd3c7370fe82e3218f807c17a6b4..b1c13614a3b64f43a9200b4e2d2640818611fa78 100644 (file)
@@ -49,7 +49,7 @@ namespace caspar { namespace core {
 struct stage::impl : public std::enable_shared_from_this<impl>\r
 {                              \r
        spl::shared_ptr<diagnostics::graph> graph_;\r
-       monitor::subject                                        event_subject_;\r
+       monitor::basic_subject                          event_subject_;\r
        std::map<int, layer>                            layers_;        \r
        std::map<int, tweened_transform>        tweens_;        \r
        executor                                                        executor_;\r
index a90d07e203b4ede934e6e9fee416d48e7303caeb..9d6176f54688a7d9b174761008c8b7afc82779bc 100644 (file)
@@ -34,7 +34,7 @@ namespace caspar { namespace core {
 \r
 struct transition_producer : public frame_producer\r
 {      \r
-       monitor::subject                                        event_subject_;\r
+       monitor::basic_subject                          event_subject_;\r
        const field_mode                                        mode_;\r
        int                                                                     current_frame_;\r
        \r
index f3cd8a0c3bd30565b429ca2edb3be5d0e631f8d4..c30166092c58f63c7676c4a57f47b4f1bbe81919 100644 (file)
@@ -49,7 +49,7 @@ namespace caspar { namespace core {
 struct video_channel::impl sealed : public frame_factory\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
index fa7443a657b4194870bfabef126434430024ae1b..2e32a1ae8057966eb1df1d1fe97d454abf48d881 100644 (file)
@@ -65,7 +65,7 @@ namespace caspar { namespace ffmpeg {
                                \r
 struct ffmpeg_producer : public core::frame_producer\r
 {\r
-       monitor::subject                                                                                        event_subject_;\r
+       monitor::basic_subject                                                                          event_subject_;\r
        const std::wstring                                                                                      filename_;\r
        \r
        const spl::shared_ptr<diagnostics::graph>                                       graph_;\r
index 118a8b9738a6a6dcf5334eced052258f66a5d67d..aa915c8aad8acb3b3542f639577d70d84bff94c8 100644 (file)
@@ -242,15 +242,15 @@ int main(int argc, wchar_t* argv[])
                        auto server = spl::make_shared<protocol::osc::server>(5253);\r
                        caspar_server.subscribe(server);\r
                                                \r
-                       auto console_obs = reactive::make_observer([](const monitor::event& e)\r
-                       {\r
-                               CASPAR_LOG(trace) << e.path().str().c_str();\r
-                       });\r
-\r
-                       caspar_server.subscribe(console_obs);\r
-\r
-\r
-\r
+                       //auto console_obs = reactive::make_observer([](const monitor::event& e)\r
+                       //{\r
+                       //      std::stringstream str;\r
+                       //      str << e;\r
+                       //      CASPAR_LOG(trace) << str.str().c_str();\r
+                       //});\r
+\r
+                       //caspar_server.subscribe(console_obs);\r
+                                               \r
                        // Create a amcp parser for console commands.\r
                        protocol::amcp::AMCPProtocolStrategy amcp(caspar_server.get_channels());\r
 \r
index ced8032d0462865474c881caf7e63a7dbf0b3e75..cda2a0ddbe6513cb618a7661e070b648247d4745 100644 (file)
@@ -65,7 +65,7 @@ using namespace protocol;
 \r
 struct server::impl : boost::noncopyable\r
 {\r
-       monitor::subject                                                                        event_subject_;\r
+       monitor::basic_subject                                                          event_subject_;\r
        accelerator::accelerator                                                        accelerator_;\r
        std::vector<spl::shared_ptr<IO::AsyncEventServer>>      async_servers_; \r
        std::vector<spl::shared_ptr<video_channel>>                     channels_;\r
index bc92d0babe33333d43cbecc20a174e31ea9de920..a9a3cd0cc595a6f905cfae3c18c5bba6bceef8bd 100644 (file)
@@ -35,7 +35,7 @@ namespace core {
        class video_channel;\r
 }\r
 \r
-class server sealed : public monitor::subject\r
+class server sealed : public monitor::observable\r
                                        , boost::noncopyable\r
 {\r
 public:\r