]> 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 21:56:50 +0000 (21:56 +0000)
committerronag <ronag@362d55ac-95cf-4e76-9f9a-cbaa9c17b72d>
Sun, 12 Feb 2012 21:56:50 +0000 (21:56 +0000)
core/producer/color/color_producer.cpp
core/producer/frame_producer.cpp
core/producer/frame_producer.h
core/producer/separated/separated_producer.cpp
core/producer/transition/transition_producer.cpp
modules/decklink/producer/decklink_producer.cpp
modules/ffmpeg/producer/ffmpeg_producer.cpp
modules/flash/producer/flash_producer.cpp
modules/image/producer/image_producer.cpp
modules/image/producer/image_scroll_producer.cpp
modules/reroute/producer/reroute_producer.cpp

index 26b9d35d50cd7b8cf1a5cc876ff534a3f6b83b86..66accfb943810c9b80056ffd0e0d61752203122a 100644 (file)
@@ -65,6 +65,11 @@ public:
                return L"color";\r
        }\r
 \r
+       virtual spl::shared_ptr<draw_frame> last_frame() const override\r
+       {\r
+               return frame_;\r
+       }\r
+\r
        boost::property_tree::wptree info() const override\r
        {\r
                boost::property_tree::wptree info;\r
index 2dd249e5c37c4441114d71becddbb7dcc04c0fd7..4379100ed0faa6794905a1dfda68257b71880850 100644 (file)
@@ -44,11 +44,6 @@ void register_producer_factory(const producer_factory_t& factory)
        g_factories.push_back(factory);\r
 }\r
 \r
-spl::shared_ptr<class draw_frame> frame_producer::last_frame() const\r
-{\r
-       BOOST_THROW_EXCEPTION(not_implemented());\r
-}\r
-\r
 boost::unique_future<std::wstring> frame_producer::call(const std::wstring&) \r
 {\r
        BOOST_THROW_EXCEPTION(not_supported());\r
@@ -83,7 +78,6 @@ struct empty_frame_producer : public frame_producer
 class producer_proxy : public frame_producer\r
 {      \r
        std::shared_ptr<frame_producer> producer_;\r
-       spl::shared_ptr<draw_frame>             last_frame_;\r
 public:\r
        producer_proxy(spl::shared_ptr<frame_producer>&& producer) \r
                : producer_(std::move(producer))\r
@@ -120,20 +114,8 @@ public:
                }); \r
        }\r
        \r
-       virtual spl::shared_ptr<draw_frame>     receive(int hints) override                                                                                                             \r
-       {\r
-               auto frame = producer_->receive(hints);\r
-               \r
-               if(frame != draw_frame::late())\r
-                       last_frame_ = frame;\r
-\r
-               return std::move(frame);\r
-       }\r
-       virtual spl::shared_ptr<draw_frame>     last_frame() const override                                                                                                             \r
-       {\r
-               return draw_frame::still(last_frame_);\r
-       }\r
-\r
+       virtual spl::shared_ptr<draw_frame>     receive(int flags) override                                                                                                                                                             {return producer_->receive(flags);}\r
+       virtual spl::shared_ptr<draw_frame>     last_frame() const override                                                                                                                                                             {return producer_->last_frame();}\r
        virtual std::wstring                                                                            print() const override                                                                                                                  {return producer_->print();}\r
        virtual std::wstring                                                                            name() const override                                                                                                                   {return producer_->name();}\r
        virtual boost::property_tree::wptree                                            info() const override                                                                                                                   {return producer_->info();}\r
index eacb2058d04ab288d2b0eefc9c612cd536f02e0d..9afa06dffd0980916c533647ba11e0387e1199e3 100644 (file)
@@ -69,7 +69,7 @@ struct frame_producer : public monitor::observable
        virtual uint32_t nb_frames() const {return std::numeric_limits<uint32_t>::max();}\r
        \r
        virtual spl::shared_ptr<class draw_frame> receive(int flags) = 0;\r
-       virtual spl::shared_ptr<class draw_frame> last_frame() const;\r
+       virtual spl::shared_ptr<class draw_frame> last_frame() const = 0;\r
        \r
        static const spl::shared_ptr<frame_producer>& empty(); // nothrow\r
 \r
index ee845c74d771d61bfa3bcbb50cc2c36d3c937ae0..ba861cc483b75b605cac9ba1128334ac03cfe7fb 100644 (file)
@@ -36,12 +36,14 @@ struct separated_producer : public frame_producer
        spl::shared_ptr<frame_producer> key_producer_;\r
        spl::shared_ptr<draw_frame>             fill_;\r
        spl::shared_ptr<draw_frame>             key_;\r
-               \r
+       spl::shared_ptr<draw_frame>             last_frame_;\r
+                       \r
        explicit separated_producer(const spl::shared_ptr<frame_producer>& fill, const spl::shared_ptr<frame_producer>& key) \r
                : fill_producer_(fill)\r
                , key_producer_(key)\r
                , fill_(core::draw_frame::late())\r
                , key_(core::draw_frame::late())\r
+               , last_frame_(core::draw_frame::empty())\r
        {\r
        }\r
 \r
@@ -71,10 +73,18 @@ struct separated_producer : public frame_producer
 \r
                fill_ = draw_frame::late();\r
                key_  = draw_frame::late();\r
+               \r
+               if(frame != core::draw_frame::late())\r
+                       last_frame_ = frame;\r
 \r
                return frame;\r
        }\r
-       \r
+\r
+       virtual spl::shared_ptr<draw_frame> last_frame() const override\r
+       {\r
+               return draw_frame::still(last_frame_);\r
+       }\r
+               \r
        virtual uint32_t nb_frames() const override\r
        {\r
                return std::min(fill_producer_->nb_frames(), key_producer_->nb_frames());\r
index eaac208da91f0484f49de773c55843f30d0704b2..25022de5a77e115ad1a84fad47321c49077f3406 100644 (file)
@@ -39,6 +39,8 @@ struct transition_producer : public frame_producer
        int                                                                     current_frame_;\r
        \r
        const transition_info                           info_;\r
+\r
+       spl::shared_ptr<draw_frame>                     last_frame_;\r
        \r
        spl::shared_ptr<frame_producer>         dest_producer_;\r
        spl::shared_ptr<frame_producer>         source_producer_;\r
@@ -47,6 +49,7 @@ struct transition_producer : public frame_producer
                : mode_(mode)\r
                , current_frame_(0)\r
                , info_(info)\r
+               , last_frame_(draw_frame::empty())\r
                , dest_producer_(dest)\r
                , source_producer_(frame_producer::empty())\r
        {\r
@@ -100,6 +103,11 @@ struct transition_producer : public frame_producer
 \r
                return compose(dest, source);\r
        }\r
+\r
+       virtual spl::shared_ptr<draw_frame> last_frame() const override\r
+       {\r
+               return dest_producer_->last_frame();\r
+       }\r
        \r
        virtual uint32_t nb_frames() const override\r
        {\r
index e634ee57e12200fdb1ffa790fa517e6f3fd46e9e..89aed0f030f37274b4a6912221c1a1f284fc2f8a 100644 (file)
@@ -271,11 +271,13 @@ class decklink_producer_proxy : public core::frame_producer
 {              \r
        std::unique_ptr<decklink_producer>      producer_;\r
        const uint32_t                                          length_;\r
+       spl::shared_ptr<core::draw_frame>       last_frame_;\r
        executor                                                        executor_;\r
 public:\r
        explicit decklink_producer_proxy(const spl::shared_ptr<core::frame_factory>& frame_factory, const core::video_format_desc& format_desc, size_t device_index, const std::wstring& filter_str, uint32_t length)\r
                : executor_(L"decklink_producer[" + boost::lexical_cast<std::wstring>(device_index) + L"]")\r
                , length_(length)\r
+               , last_frame_(core::draw_frame::empty())\r
        {\r
                executor_.invoke([=]\r
                {\r
@@ -297,7 +299,17 @@ public:
                                \r
        virtual spl::shared_ptr<core::draw_frame> receive(int flags) override\r
        {\r
-               return producer_->get_frame(flags);\r
+               auto frame = producer_->get_frame(flags);\r
+\r
+               if(frame != core::draw_frame::late())\r
+                       last_frame_ = frame;\r
+\r
+               return frame;\r
+       }\r
+\r
+       virtual spl::shared_ptr<core::draw_frame> last_frame() const override\r
+       {\r
+               return core::draw_frame::still(last_frame_);\r
        }\r
                \r
        virtual uint32_t nb_frames() const override\r
index 919011fc208e9eb5bfb4f9a0a4cec86a188a0e0c..68e358b562069793dcf29996af140d6641f02d0e 100644 (file)
@@ -83,6 +83,8 @@ struct ffmpeg_producer : public core::frame_producer
        const uint32_t                                                                                          length_;\r
                \r
        int64_t                                                                                                         frame_number_;\r
+\r
+       spl::shared_ptr<core::draw_frame>                                                       last_frame_;\r
        \r
 public:\r
        explicit ffmpeg_producer(const spl::shared_ptr<core::frame_factory>& frame_factory, const std::wstring& filename, const std::wstring& filter, bool loop, uint32_t start, uint32_t length) \r
@@ -94,6 +96,7 @@ public:
                , start_(start)\r
                , length_(length)\r
                , frame_number_(0)\r
+               , last_frame_(core::draw_frame::empty())\r
        {\r
                graph_->set_color("frame-time", diagnostics::color(0.1f, 1.0f, 0.1f));\r
                graph_->set_color("underflow", diagnostics::color(0.6f, 0.3f, 0.9f));   \r
@@ -166,9 +169,17 @@ public:
                ++frame_number_;\r
 \r
                graph_->set_text(print());\r
+               \r
+               if(frame != core::draw_frame::late())\r
+                       last_frame_ = spl::make_shared_ptr(frame);\r
 \r
                return spl::make_shared_ptr(frame);\r
        }\r
+\r
+       virtual spl::shared_ptr<core::draw_frame> last_frame() const override\r
+       {\r
+               return core::draw_frame::still(last_frame_);\r
+       }\r
        \r
        virtual uint32_t nb_frames() const override\r
        {\r
index 26b95aae361734c7cb770259cbd127c3c724f5fe..af3bf4cbb1cb44ce7e3760ec57dadfb12832752a 100644 (file)
@@ -335,6 +335,8 @@ struct flash_producer : public core::frame_producer
                                \r
        std::unique_ptr<flash_renderer>                                                                         renderer_;\r
 \r
+       spl::shared_ptr<core::draw_frame>                                                                       last_frame_;\r
+\r
        executor                                                                                                                        executor_;      \r
 public:\r
        flash_producer(const spl::shared_ptr<core::frame_factory>& frame_factory, const std::wstring& filename, int width, int height) \r
@@ -343,6 +345,7 @@ public:
                , width_(width > 0 ? width : frame_factory->video_format_desc().width)\r
                , height_(height > 0 ? height : frame_factory->video_format_desc().height)\r
                , buffer_size_(env::properties().get(L"configuration.flash.buffer-depth", frame_factory_->video_format_desc().fps > 30.0 ? 4 : 2))\r
+               , last_frame_(core::draw_frame::empty())\r
                , executor_(L"flash_producer")\r
        {       \r
                sync_ = true;\r
@@ -373,11 +376,19 @@ public:
 \r
                if(output_buffer_.try_pop(frame))                       \r
                        executor_.begin_invoke(std::bind(&flash_producer::next, this));         \r
-               else\r
-                       graph_->set_tag("late-frame");\r
-                                               \r
+               else            \r
+                       graph_->set_tag("late-frame");          \r
+\r
+               if(frame != core::draw_frame::late())\r
+                       last_frame_ = frame;\r
+               \r
                return frame;\r
        }\r
+\r
+       virtual spl::shared_ptr<core::draw_frame> last_frame() const override\r
+       {\r
+               return core::draw_frame::still(last_frame_);\r
+       }\r
        \r
        virtual boost::unique_future<std::wstring> call(const std::wstring& param) override\r
        {       \r
index fa5b516d887137f96783fe5e1cdefb8e8a4d16b0..18f779bc94599c5c9454b52e08b5d72581e4004e 100644 (file)
@@ -69,6 +69,11 @@ struct image_producer : public core::frame_producer
        {\r
                return frame_;\r
        }\r
+\r
+       virtual spl::shared_ptr<core::draw_frame> last_frame() const override\r
+       {\r
+               return frame_;\r
+       }\r
                \r
        virtual std::wstring print() const override\r
        {\r
index aa297c32f62b172f0675a4b09d0b245826ad306c..b2e4bd27f61e036f03d7f4b9142759214684a2e2 100644 (file)
@@ -61,11 +61,14 @@ struct image_scroll_producer : public core::frame_producer
 \r
        std::array<double, 2>                                                   start_offset_;\r
 \r
+       spl::shared_ptr<core::draw_frame>                               last_frame_;\r
+\r
        explicit image_scroll_producer(const spl::shared_ptr<core::frame_factory>& frame_factory, const std::wstring& filename, int speed) \r
                : filename_(filename)\r
                , delta_(0)\r
                , format_desc_(frame_factory->video_format_desc())\r
                , speed_(speed)\r
+               , last_frame_(core::draw_frame::empty())\r
        {\r
                start_offset_.assign(0.0);\r
 \r
@@ -185,7 +188,12 @@ struct image_scroll_producer : public core::frame_producer
                        }\r
                }\r
 \r
-               return spl::make_shared<core::draw_frame>(frames_);\r
+               return last_frame_ = spl::make_shared<core::draw_frame>(frames_);\r
+       }\r
+\r
+       virtual spl::shared_ptr<core::draw_frame> last_frame() const override\r
+       {\r
+               return core::draw_frame::still(last_frame_);\r
        }\r
                        \r
        virtual std::wstring print() const override\r
index d2a7823c6c058df0bd26edf05851bf95ba4063eb..35d151de259fac97eefb6321c08513af6b2ce487 100644 (file)
@@ -56,10 +56,13 @@ class reroute_producer : public reactive::observer<spl::shared_ptr<const core::d
        std::queue<spl::shared_ptr<core::draw_frame>>                                                           frame_buffer_;\r
        uint64_t                                                                                                                                        frame_number_;\r
 \r
+       spl::shared_ptr<core::draw_frame>                                                                                       last_frame_;\r
+\r
 public:\r
        explicit reroute_producer(const spl::shared_ptr<core::frame_factory>& frame_factory) \r
                : frame_factory_(frame_factory)\r
                , frame_number_(0)\r
+               , last_frame_(core::draw_frame::empty())\r
        {\r
                graph_->set_color("late-frame", diagnostics::color(0.6f, 0.3f, 0.3f));\r
                graph_->set_color("dropped-frame", diagnostics::color(0.3f, 0.6f, 0.3f));\r
@@ -85,7 +88,7 @@ public:
                {\r
                        auto frame = frame_buffer_.front();\r
                        frame_buffer_.pop();\r
-                       return frame;\r
+                       return last_frame_ = frame;\r
                }\r
                \r
                std::shared_ptr<const core::data_frame> read_frame;\r
@@ -115,6 +118,11 @@ public:
 \r
                return receive(0);\r
        }       \r
+\r
+       virtual spl::shared_ptr<core::draw_frame> last_frame() const override\r
+       {\r
+               return core::draw_frame::still(last_frame_);\r
+       }\r
        \r
        virtual std::wstring print() const override\r
        {\r