]> git.sesse.net Git - casparcg/blobdiff - core/producer/frame_producer.h
Updated CHANGES.txt
[casparcg] / core / producer / frame_producer.h
index 4942c6f96d20d09f0e4e62370ef3a55ff2f54ea4..c7d62b35be5fd8489259777f4121db0cab2c9818 100644 (file)
 /*\r
-* copyright (c) 2010 Sveriges Television AB <info@casparcg.com>\r
+* Copyright 2013 Sveriges Television AB http://casparcg.com/\r
 *\r
-*  This file is part of CasparCG.\r
+* This file is part of CasparCG (www.casparcg.com).\r
 *\r
-*    CasparCG is free software: you can redistribute it and/or modify\r
-*    it under the terms of the GNU General Public License as published by\r
-*    the Free Software Foundation, either version 3 of the License, or\r
-*    (at your option) any later version.\r
+* CasparCG is free software: you can redistribute it and/or modify\r
+* it under the terms of the GNU General Public License as published by\r
+* the Free Software Foundation, either version 3 of the License, or\r
+* (at your option) any later version.\r
 *\r
-*    CasparCG is distributed in the hope that it will be useful,\r
-*    but WITHOUT ANY WARRANTY; without even the implied warranty of\r
-*    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
-*    GNU General Public License for more details.\r
-\r
-*    You should have received a copy of the GNU General Public License\r
-*    along with CasparCG.  If not, see <http://www.gnu.org/licenses/>.\r
+* CasparCG is distributed in the hope that it will be useful,\r
+* but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+* GNU General Public License for more details.\r
+*\r
+* You should have received a copy of the GNU General Public License\r
+* along with CasparCG. If not, see <http://www.gnu.org/licenses/>.\r
 *\r
+* Author: Robert Nagy, ronag89@gmail.com\r
 */\r
+\r
 #pragma once\r
 \r
-#include <common/memory/safe_ptr.h>\r
-#include <common/utility/printer.h>\r
+#include "../monitor/monitor.h"\r
 \r
-#include "../producer/frame/basic_frame.h"\r
-#include "../producer/frame/frame_factory.h"\r
+#include <common/memory/safe_ptr.h>\r
+#include <common/exception/exceptions.h>\r
 \r
 #include <boost/noncopyable.hpp>\r
 \r
+#include <algorithm>\r
+#include <functional>\r
 #include <string>\r
-#include <ostream>\r
+#include <vector>\r
+#include <stdint.h>\r
+#include <numeric>\r
 \r
-namespace caspar { namespace core {\r
+#include <boost/thread/future.hpp>\r
+#include <boost/property_tree/ptree_fwd.hpp>\r
 \r
-class frame_producer : boost::noncopyable\r
-{\r
-public:\r
-       virtual ~frame_producer(){}     \r
-\r
-       ////////////////////////////////////////////////////////////////////////////////////////////////////\r
-       /// \fn virtual basic_frame :::receive() = 0;\r
-       ///\r
-       /// \brief      Renders a frame.\r
-       ///             \r
-       /// \note       This function is run in through the tbb task_schedular and shall be *non blocking*.\r
-       ///\r
-       /// \return     The frame. \r
-       ////////////////////////////////////////////////////////////////////////////////////////////////////\r
-       virtual safe_ptr<basic_frame> receive() = 0;\r
-\r
-       ////////////////////////////////////////////////////////////////////////////////////////////////////\r
-       /// \fn virtual std::shared_ptr<frame_producer> :::get_following_producer() const\r
-       ///\r
-       /// \brief      Gets the producer which will replace the current producer on EOF. \r
-       ///\r
-       /// \return     The following producer, or nullptr if there is no following producer. \r
-       ////////////////////////////////////////////////////////////////////////////////////////////////////\r
-       virtual safe_ptr<frame_producer> get_following_producer() const {return frame_producer::empty();}  // nothrow\r
+namespace caspar { \r
        \r
-       ////////////////////////////////////////////////////////////////////////////////////////////////////\r
-       /// \fn virtual void :::set_leading_producer(const std::shared_ptr<frame_producer>& producer)\r
-       ///\r
-       /// \brief      Sets the producer which was run before the current producer. \r
-       ///\r
-       /// \param      producer        The leading producer.\r
-       ////////////////////////////////////////////////////////////////////////////////////////////////////\r
-       virtual void set_leading_producer(const safe_ptr<frame_producer>& /*producer*/) {}  // nothrow\r
+class executor;\r
        \r
-       ////////////////////////////////////////////////////////////////////////////////////////////////////\r
-       /// \fn virtual void :::initialize(const safe_ptr<frame_factory>& frame_factory) = 0;\r
-       ///\r
-       /// \brief      Provides the frame frame_factory used to create frames and initializes the producer. \r
-       ///\r
-       /// \param      frame_factory   The frame frame_factory. \r
-       ////////////////////////////////////////////////////////////////////////////////////////////////////\r
-       virtual void initialize(const safe_ptr<frame_factory>& frame_factory) = 0;\r
-\r
-       virtual void set_parent_printer(const printer& parent_printer) = 0;\r
-\r
-       static const safe_ptr<frame_producer>& empty()  // nothrow\r
+namespace core {\r
+\r
+class basic_frame;\r
+class parameters;\r
+struct frame_factory;\r
+\r
+struct frame_producer : boost::noncopyable\r
+{\r
+public:\r
+       enum hints\r
        {\r
-               struct empty_frame_producer : public frame_producer\r
-               {\r
-                       virtual safe_ptr<basic_frame> receive(){return basic_frame::empty();}\r
-                       virtual void initialize(const safe_ptr<frame_factory>&){}\r
-                       virtual std::wstring print() const { return L"empty";}\r
-                       virtual void set_parent_printer(const printer& parent_printer) {}\r
-               };\r
-               static safe_ptr<frame_producer> producer = make_safe<empty_frame_producer>();\r
-               return producer;\r
-       }\r
+               NO_HINT = 0,\r
+               ALPHA_HINT = 1,\r
+               DEINTERLACE_HINT\r
+       };\r
+\r
+       virtual ~frame_producer(){}     \r
 \r
        virtual std::wstring print() const = 0; // nothrow\r
-};\r
+       virtual boost::property_tree::wptree info() const = 0;\r
 \r
-inline std::wostream& operator<<(std::wostream& out, const frame_producer& producer)\r
-{\r
-       out << producer.print().c_str();\r
-       return out;\r
-}\r
+       virtual boost::unique_future<std::wstring> call(const std::wstring&) \r
+       {\r
+               BOOST_THROW_EXCEPTION(not_supported());\r
+       }\r
 \r
-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
+       virtual safe_ptr<frame_producer> get_following_producer() const {return frame_producer::empty();}  // nothrow\r
+       virtual void set_leading_producer(const safe_ptr<frame_producer>&) {}  // nothrow\r
+               \r
+       virtual uint32_t nb_frames() const {return std::numeric_limits<uint32_t>::max();}\r
+       \r
+       virtual safe_ptr<basic_frame> receive(int hints) = 0;\r
+       virtual safe_ptr<core::basic_frame> last_frame() const = 0;\r
+       virtual safe_ptr<basic_frame> create_thumbnail_frame();\r
 \r
-typedef std::function<safe_ptr<core::frame_producer>(const std::vector<std::wstring>&)> producer_factory_t;\r
+       static const safe_ptr<frame_producer>& empty(); // nothrow\r
 \r
-void register_producer_factory(const producer_factory_t& factory);\r
-safe_ptr<core::frame_producer> create_producer(const std::vector<std::wstring>& params);\r
+       virtual monitor::subject& monitor_output() = 0;\r
+};\r
 \r
+safe_ptr<basic_frame> receive_and_follow(safe_ptr<frame_producer>& producer, int hints);\r
+\r
+typedef std::function<safe_ptr<core::frame_producer>(const safe_ptr<frame_factory>&, const core::parameters& params)> producer_factory_t;\r
+void register_producer_factory(const producer_factory_t& factory); // Not thread-safe.\r
+void register_thumbnail_producer_factory(const producer_factory_t& factory); // Not thread-safe.\r
+safe_ptr<core::frame_producer> create_producer(const safe_ptr<frame_factory>&, const core::parameters& params);\r
+safe_ptr<core::frame_producer> create_producer(const safe_ptr<frame_factory>&, const std::wstring& params);\r
+safe_ptr<core::frame_producer> create_producer_destroy_proxy(safe_ptr<core::frame_producer> producer);\r
+safe_ptr<core::frame_producer> create_producer_print_proxy(safe_ptr<core::frame_producer> producer);\r
+safe_ptr<core::frame_producer> create_thumbnail_producer(const safe_ptr<frame_factory>& factory, const std::wstring& media_file);\r
+void destroy_producers_synchronously();\r
 \r
 }}\r