X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=core%2Fproducer%2Fframe_producer.h;h=830461d5b9841ca7a31c73bc28e0285033b1c88a;hb=a486c25d5e6ce0ebe08e9a2d793a447ff3cb797a;hp=8dbac788289d68384dc22b80ca40ae658b53556f;hpb=c2ce81cf2749e7adf26715227d80af1a325c7370;p=casparcg diff --git a/core/producer/frame_producer.h b/core/producer/frame_producer.h index 8dbac7882..830461d5b 100644 --- a/core/producer/frame_producer.h +++ b/core/producer/frame_producer.h @@ -20,94 +20,56 @@ #pragma once #include -#include - -#include "../producer/frame/basic_frame.h" -#include "../producer/frame/frame_factory.h" #include #include -#include #include +#include +#include +#include -namespace caspar { namespace core { +namespace caspar { + +class executor; + +namespace core { -class frame_producer : public object, boost::noncopyable +class basic_frame; +struct frame_factory; + +struct frame_producer : boost::noncopyable { public: + enum hints + { + NO_HINT = 0, + ALPHA_HINT = 1 + }; + virtual ~frame_producer(){} - //////////////////////////////////////////////////////////////////////////////////////////////////// - /// \fn virtual basic_frame :::receive() = 0; - /// - /// \brief Renders a frame. - /// - /// \note This function is run in through the tbb task_schedular and shall be *non blocking*. - /// - /// \return The frame. - //////////////////////////////////////////////////////////////////////////////////////////////////// - virtual safe_ptr receive() = 0; - - //////////////////////////////////////////////////////////////////////////////////////////////////// - /// \fn virtual std::shared_ptr :::get_following_producer() const - /// - /// \brief Gets the producer which will replace the current producer on EOF. - /// - /// \return The following producer, or nullptr if there is no following producer. - //////////////////////////////////////////////////////////////////////////////////////////////////// - virtual safe_ptr get_following_producer() const {return frame_producer::empty();} // nothrow - - //////////////////////////////////////////////////////////////////////////////////////////////////// - /// \fn virtual void :::set_leading_producer(const std::shared_ptr& producer) - /// - /// \brief Sets the producer which was run before the current producer. - /// - /// \param producer The leading producer. - //////////////////////////////////////////////////////////////////////////////////////////////////// - virtual void set_leading_producer(const safe_ptr& /*producer*/) {} // nothrow - - //////////////////////////////////////////////////////////////////////////////////////////////////// - /// \fn virtual void :::set_frame_factory(const safe_ptr& frame_factory) = 0; - /// - /// \brief Sets the frame frame_factory used to create frames. - /// - /// \param frame_factory The frame frame_factory. - //////////////////////////////////////////////////////////////////////////////////////////////////// - virtual void set_frame_factory(const safe_ptr& frame_factory) = 0; + virtual std::wstring print() const = 0; // nothrow virtual void param(const std::wstring&){} - - static const safe_ptr& empty() // nothrow - { - struct empty_frame_producer : public frame_producer - { - virtual safe_ptr receive(){return basic_frame::empty();} - virtual void set_frame_factory(const safe_ptr&){} - virtual void set_parent(const object* parent) {} - virtual std::wstring print() const { return L"empty";} - }; - static safe_ptr producer = make_safe(); - return producer; - } -}; -inline std::wostream& operator<<(std::wostream& out, const frame_producer& producer) -{ - out << producer.print().c_str(); - return out; -} + virtual safe_ptr get_following_producer() const {return frame_producer::empty();} // nothrow + virtual void set_leading_producer(const safe_ptr&) {} // nothrow + + virtual int64_t nb_frames() const {return std::numeric_limits::max();} + + virtual safe_ptr receive(int hints) = 0; + virtual safe_ptr last_frame() const = 0; -inline std::wostream& operator<<(std::wostream& out, const safe_ptr& producer) -{ - out << producer->print().c_str(); - return out; -} + static const safe_ptr& empty(); // nothrow +}; -typedef std::function(const std::vector&)> producer_factory_t; +safe_ptr receive_and_follow(safe_ptr& producer, int hints); -void register_producer_factory(const producer_factory_t& factory); -safe_ptr create_producer(const std::vector& params); +typedef std::function(const safe_ptr&, const std::vector&)> producer_factory_t; +void register_producer_factory(const producer_factory_t& factory); // Not thread-safe. +safe_ptr create_producer(const safe_ptr&, const std::vector& params); +safe_ptr create_destroy_producer_proxy(executor& destroy_context, const safe_ptr& producer); }}