]> git.sesse.net Git - casparcg/blobdiff - core/producer/frame_producer.h
git-svn-id: https://casparcg.svn.sourceforge.net/svnroot/casparcg/server/branches...
[casparcg] / core / producer / frame_producer.h
index f2644735ecbbf813ecea90ee5fd330eddcfbd66e..2b399e49693ab86628193d8eaf3ccdc5e4a11dfc 100644 (file)
 */\r
 #pragma once\r
 \r
-#include "../processor/write_frame.h"\r
-#include "../processor/frame_processor_device.h"\r
+#include "../mixer/frame/draw_frame.h"\r
+#include "../mixer/frame_factory.h"\r
+\r
+#include <common/memory/safe_ptr.h>\r
 \r
 #include <boost/noncopyable.hpp>\r
 \r
-#include <memory>\r
+#include <string>\r
+#include <ostream>\r
 \r
 namespace caspar { namespace core {\r
-       \r
+\r
 class frame_producer : boost::noncopyable\r
 {\r
 public:\r
        virtual ~frame_producer(){}     \r
 \r
        ////////////////////////////////////////////////////////////////////////////////////////////////////\r
-       /// \fn virtual gpu_frame_ptr :::receive() = 0;\r
+       /// \fn virtual draw_frame :::receive() = 0;\r
        ///\r
        /// \brief      Renders a frame.\r
        ///             \r
@@ -42,7 +45,7 @@ public:
        ///\r
        /// \return     The frame. \r
        ////////////////////////////////////////////////////////////////////////////////////////////////////\r
-       virtual gpu_frame_ptr receive() = 0;\r
+       virtual safe_ptr<draw_frame> receive() = 0;\r
 \r
        ////////////////////////////////////////////////////////////////////////////////////////////////////\r
        /// \fn virtual std::shared_ptr<frame_producer> :::get_following_producer() const\r
@@ -51,8 +54,8 @@ public:
        ///\r
        /// \return     The following producer, or nullptr if there is no following producer. \r
        ////////////////////////////////////////////////////////////////////////////////////////////////////\r
-       virtual std::shared_ptr<frame_producer> get_following_producer() const { return nullptr; }\r
-\r
+       virtual safe_ptr<frame_producer> get_following_producer() const {return frame_producer::empty();}  // nothrow\r
+       \r
        ////////////////////////////////////////////////////////////////////////////////////////////////////\r
        /// \fn virtual void :::set_leading_producer(const std::shared_ptr<frame_producer>& producer)\r
        ///\r
@@ -60,20 +63,31 @@ public:
        ///\r
        /// \param      producer        The leading producer.\r
        ////////////////////////////////////////////////////////////////////////////////////////////////////\r
-       virtual void set_leading_producer(const std::shared_ptr<frame_producer>& /*producer*/) {}\r
+       virtual void set_leading_producer(const safe_ptr<frame_producer>& /*producer*/) {}  // nothrow\r
        \r
        ////////////////////////////////////////////////////////////////////////////////////////////////////\r
-       /// \fn virtual void :::initialize(const frame_processor_device_ptr& frame_processor) = 0;\r
+       /// \fn virtual void :::initialize(const safe_ptr<frame_factory>& frame_factory) = 0;\r
        ///\r
-       /// \brief      Provides the frame frame_processor used to create frames and initializes the producer. \r
+       /// \brief      Provides the frame frame_factory used to create frames and initializes the producer. \r
        ///\r
-       /// \param      frame_processor The frame frame_processor\r
+       /// \param      frame_factory   The frame frame_factory\r
        ////////////////////////////////////////////////////////////////////////////////////////////////////\r
-       virtual void initialize(const frame_processor_device_ptr& frame_processor) = 0;\r
+       virtual void initialize(const safe_ptr<frame_factory>& frame_factory) = 0;\r
 \r
-       virtual std::wstring print() const { return L"Unknown frame_producer.";}\r
+       static const safe_ptr<frame_producer>& empty()  // nothrow\r
+       {\r
+               struct empty_frame_producer : public frame_producer\r
+               {\r
+                       virtual safe_ptr<draw_frame> receive(){return draw_frame::empty();}\r
+                       virtual void initialize(const safe_ptr<frame_factory>&){}\r
+                       virtual std::wstring print() const { return L"empty";}\r
+               };\r
+               static safe_ptr<frame_producer> producer = make_safe<empty_frame_producer>();\r
+               return producer;\r
+       }\r
+\r
+       virtual std::wstring print() const = 0; // nothrow\r
 };\r
-typedef std::shared_ptr<frame_producer> frame_producer_ptr;\r
 \r
 inline std::wostream& operator<<(std::wostream& out, const frame_producer& producer)\r
 {\r
@@ -81,4 +95,10 @@ inline std::wostream& operator<<(std::wostream& out, const frame_producer& produ
        return out;\r
 }\r
 \r
-}}
\ No newline at end of file
+inline std::wostream& operator<<(std::wostream& out, const safe_ptr<const frame_producer>& producer)\r
+{\r
+       out << producer->print().c_str();\r
+       return out;\r
+}\r
+\r
+}}\r