]> git.sesse.net Git - casparcg/commitdiff
2.0.2: Refactoring. AMCP commands now executed asynchronously when possible, which...
authorronag <ronag@362d55ac-95cf-4e76-9f9a-cbaa9c17b72d>
Wed, 30 Nov 2011 18:35:30 +0000 (18:35 +0000)
committerronag <ronag@362d55ac-95cf-4e76-9f9a-cbaa9c17b72d>
Wed, 30 Nov 2011 18:35:30 +0000 (18:35 +0000)
git-svn-id: https://casparcg.svn.sourceforge.net/svnroot/casparcg/server/branches/2.0.2@1732 362d55ac-95cf-4e76-9f9a-cbaa9c17b72d

14 files changed:
core/mixer/mixer.cpp
core/mixer/mixer.h
core/producer/color/color_producer.cpp
core/producer/frame/frame_factory.h
core/producer/stage.cpp
core/producer/stage.h
modules/decklink/interop/DeckLinkAPI_h.h
modules/decklink/interop/DeckLinkAPI_i.c
modules/flash/producer/cg_producer.cpp
modules/flash/producer/flash_producer.cpp
modules/image/producer/image_producer.cpp
modules/image/producer/image_scroll_producer.cpp
protocol/amcp/AMCPCommandsImpl.cpp
shell/casparcg.config

index beb1665b64128ac8c7c0568026cb94ccf95e9ac8..045dbe36bf70544463debaa45ed6d8086c8b7515 100644 (file)
@@ -164,19 +164,10 @@ public:
        {               \r
                return image_mixer_.create_frame(tag, desc);\r
        }\r
-       \r
-       safe_ptr<core::write_frame> create_frame(const void* tag, size_t width, size_t height, core::pixel_format::type pix_fmt)\r
-       {\r
-               // Create bgra frame\r
-               core::pixel_format_desc desc;\r
-               desc.pix_fmt = pix_fmt;\r
-               desc.planes.push_back(core::pixel_format_desc::plane(width, height, 4));\r
-               return create_frame(tag, desc);\r
-       }\r
-               \r
+                       \r
        void set_transform(int index, const frame_transform& transform, unsigned int mix_duration, const std::wstring& tween)\r
        {\r
-               executor_.invoke([&]\r
+               executor_.begin_invoke([=]\r
                {\r
                        auto src = transforms_[index].fetch();\r
                        auto dst = transform;\r
@@ -186,7 +177,7 @@ public:
                                \r
        void apply_transform(int index, const std::function<frame_transform(frame_transform)>& transform, unsigned int mix_duration, const std::wstring& tween)\r
        {\r
-               executor_.invoke([&]\r
+               executor_.begin_invoke([=]\r
                {\r
                        auto src = transforms_[index].fetch();\r
                        auto dst = transform(src);\r
@@ -196,7 +187,7 @@ public:
 \r
        void clear_transforms(int index)\r
        {\r
-               executor_.invoke([&]\r
+               executor_.begin_invoke([=]\r
                {\r
                        transforms_.erase(index);\r
                        blend_modes_.erase(index);\r
@@ -205,7 +196,7 @@ public:
 \r
        void clear_transforms()\r
        {\r
-               executor_.invoke([&]\r
+               executor_.begin_invoke([=]\r
                {\r
                        transforms_.clear();\r
                        blend_modes_.clear();\r
@@ -214,7 +205,7 @@ public:
                \r
        void set_blend_mode(int index, blend_mode::type value)\r
        {\r
-               executor_.invoke([&]\r
+               executor_.begin_invoke([=]\r
                {\r
                        blend_modes_[index] = value;\r
                }, high_priority);\r
@@ -241,14 +232,6 @@ mixer::mixer(const safe_ptr<diagnostics::graph>& graph, const safe_ptr<target_t>
 void mixer::send(const std::pair<std::map<int, safe_ptr<core::basic_frame>>, std::shared_ptr<void>>& frames){ impl_->send(frames);}\r
 core::video_format_desc mixer::get_video_format_desc() const { return impl_->get_video_format_desc(); }\r
 safe_ptr<core::write_frame> mixer::create_frame(const void* tag, const core::pixel_format_desc& desc){ return impl_->create_frame(tag, desc); }                \r
-safe_ptr<core::write_frame> mixer::create_frame(const void* tag, size_t width, size_t height, core::pixel_format::type pix_fmt)\r
-{\r
-       // Create bgra frame\r
-       core::pixel_format_desc desc;\r
-       desc.pix_fmt = pix_fmt;\r
-       desc.planes.push_back(core::pixel_format_desc::plane(width, height, 4));\r
-       return create_frame(tag, desc);\r
-}\r
 void mixer::set_frame_transform(int index, const core::frame_transform& transform, unsigned int mix_duration, const std::wstring& tween){impl_->set_transform(index, transform, mix_duration, tween);}\r
 void mixer::apply_frame_transform(int index, const std::function<core::frame_transform(core::frame_transform)>& transform, unsigned int mix_duration, const std::wstring& tween)\r
 {impl_->apply_transform(index, transform, mix_duration, tween);}\r
index 4b52ac8199983429f22f1b390ae64467165142da..d1c841d3e2523c67918efd7218d5e8a2061ef48a 100644 (file)
@@ -56,7 +56,6 @@ public:
        // mixer\r
 \r
        safe_ptr<core::write_frame> create_frame(const void* tag, const core::pixel_format_desc& desc);         \r
-       safe_ptr<core::write_frame> create_frame(const void* tag, size_t width, size_t height, pixel_format::type pix_fmt = pixel_format::bgra);                \r
        \r
        core::video_format_desc get_video_format_desc() const; // nothrow\r
        void set_video_format_desc(const video_format_desc& format_desc);\r
index b6b738c8d00e3c49fd274485b1b3386c0fe72a18..b7d4ab7e294064a62a03864ab35cb2c8f12c8d0a 100644 (file)
@@ -119,8 +119,11 @@ safe_ptr<core::write_frame> create_color_frame(void* tag, const safe_ptr<core::f
        auto color2 = get_hex_color(color);\r
        if(color2.length() != 9 || color2[0] != '#')\r
                BOOST_THROW_EXCEPTION(invalid_argument() << arg_name_info("color") << arg_value_info(narrow(color2)) << msg_info("Invalid color."));\r
-\r
-       auto frame = frame_factory->create_frame(tag, 1, 1, pixel_format::bgra);\r
+       \r
+       core::pixel_format_desc desc;\r
+       desc.pix_fmt = pixel_format::bgra;\r
+       desc.planes.push_back(core::pixel_format_desc::plane(1, 1, 4));\r
+       auto frame = frame_factory->create_frame(tag, desc);\r
                \r
        // Read color from hex-string and write to frame pixel.\r
 \r
index c8880155bec68e11e00f843754c440a9f4ee8bb4..fa5deffff1859becef2ec4eb47400b7ce07fb487 100644 (file)
@@ -33,8 +33,7 @@ struct video_format_desc;
                \r
 struct frame_factory : boost::noncopyable\r
 {\r
-       virtual safe_ptr<write_frame> create_frame(const void* video_stream_tag, const pixel_format_desc& desc) = 0;\r
-       virtual safe_ptr<write_frame> create_frame(const void* video_stream_tag, size_t width, size_t height, pixel_format::type pix_fmt = pixel_format::bgra) = 0;             \r
+       virtual safe_ptr<write_frame> create_frame(const void* video_stream_tag, const pixel_format_desc& desc) = 0;    \r
        \r
        virtual video_format_desc get_video_format_desc() const = 0; // nothrow\r
 };\r
index 9f5bc86a683134cbd8345d2ba12a147ea611f084..3799b87a1f274c797f040e4408bf237544aed901 100644 (file)
@@ -108,7 +108,7 @@ public:
 \r
        void load(int index, const safe_ptr<frame_producer>& producer, bool preview, int auto_play_delta)\r
        {\r
-               executor_.invoke([&]\r
+               executor_.begin_invoke([=]\r
                {\r
                        layers_[index].load(producer, preview, auto_play_delta);\r
                }, high_priority);\r
@@ -116,7 +116,7 @@ public:
 \r
        void pause(int index)\r
        {               \r
-               executor_.invoke([&]\r
+               executor_.begin_invoke([=]\r
                {\r
                        layers_[index].pause();\r
                }, high_priority);\r
@@ -124,7 +124,7 @@ public:
 \r
        void play(int index)\r
        {               \r
-               executor_.invoke([&]\r
+               executor_.begin_invoke([=]\r
                {\r
                        layers_[index].play();\r
                }, high_priority);\r
@@ -132,7 +132,7 @@ public:
 \r
        void stop(int index)\r
        {               \r
-               executor_.invoke([&]\r
+               executor_.begin_invoke([=]\r
                {\r
                        layers_[index].stop();\r
                }, high_priority);\r
@@ -140,7 +140,7 @@ public:
 \r
        void clear(int index)\r
        {\r
-               executor_.invoke([&]\r
+               executor_.begin_invoke([=]\r
                {\r
                        layers_.erase(index);\r
                }, high_priority);\r
@@ -148,7 +148,7 @@ public:
                \r
        void clear()\r
        {\r
-               executor_.invoke([&]\r
+               executor_.begin_invoke([=]\r
                {\r
                        layers_.clear();\r
                }, high_priority);\r
@@ -156,62 +156,74 @@ public:
        \r
        boost::unique_future<std::wstring> call(int index, bool foreground, const std::wstring& param)\r
        {\r
-               return std::move(*executor_.invoke([&]\r
+               return std::move(*executor_.invoke([=]\r
                {\r
                        return std::make_shared<boost::unique_future<std::wstring>>(std::move(layers_[index].call(foreground, param)));\r
                }, high_priority));\r
        }\r
+       \r
+       void swap_layers(const safe_ptr<stage>& other)\r
+       {\r
+               if(other->impl_.get() == this)\r
+                       return;\r
+               \r
+               auto func = [=]\r
+               {\r
+                       std::swap(layers_, other->impl_->layers_);\r
+               };              \r
+               executor_.begin_invoke([=]\r
+               {\r
+                       other->impl_->executor_.invoke(func, high_priority);\r
+               }, high_priority);\r
+       }\r
 \r
        void swap_layer(int index, size_t other_index)\r
        {\r
-               executor_.invoke([&]\r
+               executor_.begin_invoke([=]\r
                {\r
                        std::swap(layers_[index], layers_[other_index]);\r
                }, high_priority);\r
        }\r
 \r
-       void swap_layer(int index, size_t other_index, stage& other)\r
+       void swap_layer(int index, size_t other_index, const safe_ptr<stage>& other)\r
        {\r
-               if(other.impl_.get() == this)\r
+               if(other->impl_.get() == this)\r
                        swap_layer(index, other_index);\r
                else\r
                {\r
-                       auto func = [&]\r
+                       auto func = [=]\r
                        {\r
-                               std::swap(layers_[index], other.impl_->layers_[other_index]);\r
+                               std::swap(layers_[index], other->impl_->layers_[other_index]);\r
                        };              \r
-                       executor_.invoke([&]{other.impl_->executor_.invoke(func, high_priority);}, high_priority);\r
+                       executor_.begin_invoke([=]\r
+                       {\r
+                               other->impl_->executor_.invoke(func, high_priority);\r
+                       }, high_priority);\r
                }\r
        }\r
 \r
-       void swap(stage& other)\r
-       {\r
-               if(other.impl_.get() == this)\r
-                       return;\r
-               \r
-               auto func = [&]\r
-               {\r
-                       std::swap(layers_, other.impl_->layers_);\r
-               };              \r
-               executor_.invoke([&]{other.impl_->executor_.invoke(func, high_priority);}, high_priority);\r
-       }\r
-\r
-       layer_status get_status(int index)\r
+       boost::unique_future<layer_status> get_status(int index)\r
        {               \r
-               return executor_.invoke([&]\r
+               return executor_.begin_invoke([=]\r
                {\r
                        return layers_[index].status();\r
                }, high_priority );\r
        }\r
        \r
-       safe_ptr<frame_producer> foreground(int index)\r
+       boost::unique_future<safe_ptr<frame_producer>> foreground(int index)\r
        {\r
-               return executor_.invoke([=]{return layers_[index].foreground();}, high_priority);\r
+               return executor_.begin_invoke([=]\r
+               {\r
+                       return layers_[index].foreground();\r
+               }, high_priority);\r
        }\r
        \r
-       safe_ptr<frame_producer> background(int index)\r
+       boost::unique_future<safe_ptr<frame_producer>> background(int index)\r
        {\r
-               return executor_.invoke([=]{return layers_[index].background();}, high_priority);\r
+               return executor_.begin_invoke([=]\r
+               {\r
+                       return layers_[index].background();\r
+               }, high_priority);\r
        }\r
        \r
        void set_video_format_desc(const video_format_desc& format_desc)\r
@@ -225,18 +237,18 @@ public:
 \r
 stage::stage(const safe_ptr<diagnostics::graph>& graph, const safe_ptr<target_t>& target, const video_format_desc& format_desc) : impl_(new implementation(graph, target, format_desc)){}\r
 void stage::spawn_token(){impl_->spawn_token();}\r
-void stage::swap(stage& other){impl_->swap(other);}\r
 void stage::load(int index, const safe_ptr<frame_producer>& producer, bool preview, int auto_play_delta){impl_->load(index, producer, preview, auto_play_delta);}\r
 void stage::pause(int index){impl_->pause(index);}\r
 void stage::play(int index){impl_->play(index);}\r
 void stage::stop(int index){impl_->stop(index);}\r
 void stage::clear(int index){impl_->clear(index);}\r
 void stage::clear(){impl_->clear();}\r
+void stage::swap_layers(const safe_ptr<stage>& other){impl_->swap_layers(other);}\r
 void stage::swap_layer(int index, size_t other_index){impl_->swap_layer(index, other_index);}\r
-void stage::swap_layer(int index, size_t other_index, stage& other){impl_->swap_layer(index, other_index, other);}\r
-layer_status stage::get_status(int index){return impl_->get_status(index);}\r
-safe_ptr<frame_producer> stage::foreground(size_t index) {return impl_->foreground(index);}\r
-safe_ptr<frame_producer> stage::background(size_t index) {return impl_->background(index);}\r
-void stage::set_video_format_desc(const video_format_desc& format_desc){impl_->set_video_format_desc(format_desc);}\r
+void stage::swap_layer(int index, size_t other_index, const safe_ptr<stage>& other){impl_->swap_layer(index, other_index, other);}\r
+boost::unique_future<layer_status> stage::get_status(int index){return impl_->get_status(index);}\r
+boost::unique_future<safe_ptr<frame_producer>> stage::foreground(size_t index) {return impl_->foreground(index);}\r
+boost::unique_future<safe_ptr<frame_producer>> stage::background(size_t index) {return impl_->background(index);}\r
 boost::unique_future<std::wstring> stage::call(int index, bool foreground, const std::wstring& param){return impl_->call(index, foreground, param);}\r
+void stage::set_video_format_desc(const video_format_desc& format_desc){impl_->set_video_format_desc(format_desc);}\r
 }}
\ No newline at end of file
index 13e9d046ff019b959fa115f8402507e6bd532727..9e393f46e5b4d120048faa8d7e1da5ef8e069b9b 100644 (file)
@@ -44,7 +44,6 @@ public:
 \r
        void spawn_token();\r
 \r
-       void swap(stage& other);\r
                        \r
        void load(int index, const safe_ptr<frame_producer>& producer, bool preview = false, int auto_play_delta = -1);\r
        void pause(int index);\r
@@ -52,13 +51,14 @@ public:
        void stop(int index);\r
        void clear(int index);\r
        void clear();   \r
-       boost::unique_future<std::wstring> call(int index, bool foreground, const std::wstring& param);\r
+       void swap_layers(const safe_ptr<stage>& other);\r
        void swap_layer(int index, size_t other_index);\r
-       void swap_layer(int index, size_t other_index, stage& other);\r
-\r
-       layer_status get_status(int index);\r
-       safe_ptr<frame_producer> foreground(size_t index);\r
-       safe_ptr<frame_producer> background(size_t index);\r
+       void swap_layer(int index, size_t other_index, const safe_ptr<stage>& other);\r
+       \r
+       boost::unique_future<std::wstring>                              call(int index, bool foreground, const std::wstring& param);\r
+       boost::unique_future<layer_status>                              get_status(int index);\r
+       boost::unique_future<safe_ptr<frame_producer>>  foreground(size_t index);\r
+       boost::unique_future<safe_ptr<frame_producer>>  background(size_t index);\r
        \r
        void set_video_format_desc(const video_format_desc& format_desc);\r
 \r
index 0a81f2a586b1cdc9e027e99ae3d8a59614d7468a..1ea2456c46832218c815f056794ea13dd8a9a659 100644 (file)
@@ -4,7 +4,7 @@
 \r
 \r
  /* File created by MIDL compiler version 7.00.0555 */\r
-/* at Mon Nov 28 22:42:59 2011\r
+/* at Wed Nov 30 19:17:46 2011\r
  */\r
 /* Compiler settings for interop\DeckLinkAPI.idl:\r
     Oicf, W1, Zp8, env=Win32 (32b run), target_arch=X86 7.00.0555 \r
index db8e310e324962af2513cf53b7294d149456f689..45cfc15768bef312bd92fb109326fb90d00e3cdc 100644 (file)
@@ -6,7 +6,7 @@
 \r
 \r
  /* File created by MIDL compiler version 7.00.0555 */\r
-/* at Mon Nov 28 22:42:59 2011\r
+/* at Wed Nov 30 19:17:46 2011\r
  */\r
 /* Compiler settings for interop\DeckLinkAPI.idl:\r
     Oicf, W1, Zp8, env=Win32 (32b run), target_arch=X86 7.00.0555 \r
index a7d2f938799771309b18aeaf412aba7471e46008..26f04d4a5aaf2a28c60567962ae795d8420d3aa6 100644 (file)
@@ -182,7 +182,7 @@ public:
        \r
 safe_ptr<cg_producer> get_default_cg_producer(const safe_ptr<core::video_channel>& video_channel, int render_layer)\r
 {      \r
-       auto flash_producer = video_channel->stage()->foreground(render_layer);\r
+       auto flash_producer = video_channel->stage()->foreground(render_layer).get();\r
 \r
        if(flash_producer->print().find(L"flash[") == std::string::npos) // UGLY hack\r
        {\r
index da8a34d26e89691d5d43b2aafc85f3c2cef7fadd..b3e0072ed4f298e2d085fa6b1026180549db142e 100644 (file)
@@ -248,7 +248,11 @@ public:
                        fast_memclr(bmp_.data(), width_*height_*4);\r
                        ax_->DrawControl(bmp_);\r
                \r
-                       auto frame = frame_factory_->create_frame(this, width_, height_);\r
+                       core::pixel_format_desc desc;\r
+                       desc.pix_fmt = core::pixel_format::bgra;\r
+                       desc.planes.push_back(core::pixel_format_desc::plane(width_, height_, 4));\r
+                       auto frame = frame_factory_->create_frame(this, desc);\r
+\r
                        fast_memcpy(frame->image_data().begin(), bmp_.data(), width_*height_*4);\r
                        frame->commit();\r
                        head_ = frame;\r
index fcadb7aaba52cbe4cdeafd669ae9c8c53aafdd96..532fd9d216e141d624da7faaf8502d62167f7984 100644 (file)
@@ -49,7 +49,12 @@ struct image_producer : public core::frame_producer
        {\r
                auto bitmap = load_image(filename_);\r
                FreeImage_FlipVertical(bitmap.get());\r
-               auto frame = frame_factory->create_frame(this, FreeImage_GetWidth(bitmap.get()), FreeImage_GetHeight(bitmap.get()), core::pixel_format::bgra);\r
+               \r
+               core::pixel_format_desc desc;\r
+               desc.pix_fmt = core::pixel_format::bgra;\r
+               desc.planes.push_back(core::pixel_format_desc::plane(FreeImage_GetWidth(bitmap.get()), FreeImage_GetHeight(bitmap.get()), 4));\r
+               auto frame = frame_factory->create_frame(this, desc);\r
+\r
                std::copy_n(FreeImage_GetBits(bitmap.get()), frame->image_data().size(), frame->image_data().begin());\r
                frame->commit();\r
                frame_ = std::move(frame);\r
index 93a07c65c6d351be75c73d9d36225231950e866c..860a0391e4fb0989fdaa11c02666737cdef016ef 100644 (file)
@@ -84,7 +84,11 @@ struct image_scroll_producer : public core::frame_producer
                {\r
                        while(count > 0)\r
                        {\r
-                               auto frame = frame_factory->create_frame(reinterpret_cast<void*>(rand()), width_, format_desc_.height);\r
+                               core::pixel_format_desc desc;\r
+                               desc.pix_fmt = core::pixel_format::bgra;\r
+                               desc.planes.push_back(core::pixel_format_desc::plane(width_, format_desc_.height, 4));\r
+                               auto frame = frame_factory->create_frame(reinterpret_cast<void*>(rand()), desc);\r
+\r
                                if(count >= frame->image_data().size())\r
                                {       \r
                                        std::copy_n(bytes + count - frame->image_data().size(), frame->image_data().size(), frame->image_data().begin());\r
@@ -113,7 +117,10 @@ struct image_scroll_producer : public core::frame_producer
                        int i = 0;\r
                        while(count > 0)\r
                        {\r
-                               auto frame = frame_factory->create_frame(reinterpret_cast<void*>(rand()), format_desc_.width, height_);\r
+                               core::pixel_format_desc desc;\r
+                               desc.pix_fmt = core::pixel_format::bgra;\r
+                               desc.planes.push_back(core::pixel_format_desc::plane(format_desc_.width, height_, 4));\r
+                               auto frame = frame_factory->create_frame(reinterpret_cast<void*>(rand()), desc);\r
                                if(count >= frame->image_data().size())\r
                                {       \r
                                        for(size_t y = 0; y < height_; ++y)\r
index 444bbf1cfdb2e9146ce3042f0556d9cf70452eb0..62ffd1b23403f938a621ff8ccca11db188b6e94f 100644 (file)
@@ -491,13 +491,13 @@ bool SwapCommand::DoExecute()
                        int l1 = GetLayerIndex();\r
                        int l2 = boost::lexical_cast<int>(strs.at(1));\r
 \r
-                       ch1->stage()->swap_layer(l1, l2, *ch2->stage());\r
+                       ch1->stage()->swap_layer(l1, l2, ch2->stage());\r
                }\r
                else\r
                {\r
                        auto ch1 = GetChannel();\r
                        auto ch2 = GetChannels().at(boost::lexical_cast<int>(_parameters[0])-1);\r
-                       ch1->stage()->swap(*ch2->stage());\r
+                       ch1->stage()->swap_layers(ch2->stage());\r
                }\r
 \r
                CASPAR_LOG(info) << "Swapped successfully";\r
@@ -804,7 +804,7 @@ bool StatusCommand::DoExecute()
 {                              \r
        if (GetLayerIndex() > -1)\r
        {\r
-               auto status = GetChannel()->stage()->get_status(GetLayerIndex());\r
+               auto status = GetChannel()->stage()->get_status(GetLayerIndex()).get();\r
                std::wstringstream status_text;\r
                status_text\r
                        << L"201 STATUS OK\r\n"\r
index 7303afce0425c0afe11e96dfef72164ae87a9c5b..4d3d10108d3c4062f8facce97dd12f1ed508f111 100644 (file)
@@ -1,18 +1,18 @@
 <?xml version="1.0" encoding="utf-8"?>\r
 <configuration>\r
   <paths>\r
-    <media-path>F:\casparcg\_media\</media-path>\r
-    <log-path>F:\casparcg\_log\</log-path>\r
-    <data-path>F:\casparcg\_data\</data-path>\r
-    <template-path>F:\casparcg\_templates\</template-path>\r
+    <media-path>D:\casparcg\_media\</media-path>\r
+    <log-path>D:\casparcg\_log\</log-path>\r
+    <data-path>D:\casparcg\_data\</data-path>\r
+    <template-path>D:\casparcg\_templates\</template-path>\r
   </paths>\r
   <channels>\r
     <channel>\r
       <video-mode>PAL</video-mode>\r
       <consumers>\r
-        <bluefish>\r
+        <decklink>\r
           <embedded-audio>true</embedded-audio>\r
-        </bluefish>\r
+        </decklink>\r
       </consumers>\r
     </channel>\r
   </channels>\r