X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=core%2Fproducer%2Fframe_producer.h;h=830461d5b9841ca7a31c73bc28e0285033b1c88a;hb=a486c25d5e6ce0ebe08e9a2d793a447ff3cb797a;hp=b841b6088f04748c78b154275a6d4c6817ce6a03;hpb=83c5f97e508b267898ddbbdc19f91195df1bf146;p=casparcg diff --git a/core/producer/frame_producer.h b/core/producer/frame_producer.h index b841b6088..830461d5b 100644 --- a/core/producer/frame_producer.h +++ b/core/producer/frame_producer.h @@ -19,78 +19,57 @@ */ #pragma once -#include "../processor/draw_frame.h" -#include "../processor/frame_processor_device.h" +#include #include -#include +#include +#include +#include +#include +#include -namespace caspar { namespace core { +namespace caspar { -class frame_producer : boost::noncopyable +class executor; + +namespace core { + +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 draw_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 draw_frame 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 std::shared_ptr get_following_producer() const { return nullptr; } - - //////////////////////////////////////////////////////////////////////////////////////////////////// - /// \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 std::shared_ptr& /*producer*/) {} + virtual std::wstring print() const = 0; // nothrow + + virtual void param(const std::wstring&){} + + 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();} - //////////////////////////////////////////////////////////////////////////////////////////////////// - /// \fn virtual void :::initialize(const frame_processor_device_ptr& frame_processor) = 0; - /// - /// \brief Provides the frame frame_processor used to create frames and initializes the producer. - /// - /// \param frame_processor The frame frame_processor. - //////////////////////////////////////////////////////////////////////////////////////////////////// - virtual void initialize(const frame_processor_device_ptr& frame_processor) = 0; - - virtual std::wstring print() const { return L"Unknown frame_producer.";} - - static const std::shared_ptr& empty() - { - struct empty_frame_producer : public frame_producer - { - virtual draw_frame receive(){return draw_frame::empty();} - virtual std::shared_ptr get_following_producer() const { return nullptr; } - virtual void initialize(const frame_processor_device_ptr&){} - }; - static std::shared_ptr empty_producer = std::make_shared(); - return empty_producer; - } + virtual safe_ptr receive(int hints) = 0; + virtual safe_ptr last_frame() const = 0; + + static const safe_ptr& empty(); // nothrow }; -typedef std::shared_ptr frame_producer_ptr; -inline std::wostream& operator<<(std::wostream& out, const frame_producer& producer) -{ - out << producer.print().c_str(); - return out; -} +safe_ptr receive_and_follow(safe_ptr& producer, int hints); + +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); -}} \ No newline at end of file +}}