]> git.sesse.net Git - casparcg/blobdiff - core/producer/frame_producer.h
[ffmpeg] use implicit constructor of video_format_desc for clarity
[casparcg] / core / producer / frame_producer.h
index 4ff54790e07620d5646b82bdca8198987513ff01..cf7fb402ac8f6a7e4d42a70b50d9e13a850301c8 100644 (file)
 #pragma once
 
 #include "../monitor/monitor.h"
-#include "../video_format.h"
+#include "../fwd.h"
 #include "../interaction/interaction_sink.h"
+#include "../help/help_repository.h"
 #include "binding.h"
 
 #include <common/forward.h>
 #include <common/future_fwd.h>
 #include <common/memory.h>
-#include <common/enum_class.h>
 
 #include <cstdint>
 #include <limits>
@@ -73,14 +73,14 @@ public:
 
        // Methods      
 
-       virtual class draw_frame                                        receive() = 0;
-       virtual boost::unique_future<std::wstring>      call(const std::vector<std::wstring>& params) = 0;
+       virtual draw_frame                                                      receive() = 0;
+       virtual std::future<std::wstring>                       call(const std::vector<std::wstring>& params) = 0;
        virtual variable&                                                       get_variable(const std::wstring& name) = 0;
        virtual const std::vector<std::wstring>&        get_variables() const = 0;
        
        // monitor::observable
 
-       virtual monitor::source& monitor_output() = 0;
+       virtual monitor::subject& monitor_output() = 0;
 
        // interaction_sink
        virtual void on_interaction(const interaction_event::ptr& event) override { }
@@ -95,8 +95,7 @@ public:
        virtual boost::property_tree::wptree            info() const = 0;
        virtual uint32_t                                                        nb_frames() const = 0;
        virtual uint32_t                                                        frame_number() const = 0;
-       virtual class draw_frame                                        last_frame() = 0;
-       virtual class draw_frame                                        create_thumbnail_frame() = 0;
+       virtual draw_frame                                                      last_frame() = 0;
        virtual constraints&                                            pixel_constraints() = 0;
        virtual void                                                            leading_producer(const spl::shared_ptr<frame_producer>&) {}  
 };
@@ -109,7 +108,7 @@ public:
 
        // Methods      
 
-       virtual boost::unique_future<std::wstring>      call(const std::vector<std::wstring>& params) override;
+       virtual std::future<std::wstring>                       call(const std::vector<std::wstring>& params) override;
        virtual variable&                                                       get_variable(const std::wstring& name) override;
        virtual const std::vector<std::wstring>&        get_variables() const override;
        
@@ -120,26 +119,51 @@ public:
        void                                            paused(bool value) override;    
        uint32_t                                        nb_frames() const override;
        uint32_t                                        frame_number() const override;
-       virtual class draw_frame        last_frame() override;
-       virtual class draw_frame        create_thumbnail_frame() override;
+       virtual draw_frame                      last_frame() override;
 
 private:
-       virtual class draw_frame        receive() override;
-       virtual class draw_frame        receive_impl() = 0;
+       virtual draw_frame                      receive() override;
+       virtual draw_frame                      receive_impl() = 0;
 
        struct impl;
        friend struct impl;
        std::shared_ptr<impl> impl_;
 };
 
-typedef std::function<spl::shared_ptr<core::frame_producer>(const spl::shared_ptr<class frame_factory>&, const video_format_desc& format_desc, const std::vector<std::wstring>&)> producer_factory_t;
-void register_producer_factory(const producer_factory_t& factory); // Not thread-safe.
-void register_thumbnail_producer_factory(const producer_factory_t& factory); // Not thread-safe.
+class frame_producer_registry;
 
-spl::shared_ptr<core::frame_producer> create_producer(const spl::shared_ptr<frame_factory>&, const video_format_desc& format_desc, const std::vector<std::wstring>& params);
-spl::shared_ptr<core::frame_producer> create_producer(const spl::shared_ptr<frame_factory>&, const video_format_desc& format_desc, const std::wstring& params);
+struct frame_producer_dependencies
+{
+       spl::shared_ptr<core::frame_factory>                    frame_factory;
+       std::vector<spl::shared_ptr<video_channel>>             channels;
+       video_format_desc                                                               format_desc;
+       spl::shared_ptr<const frame_producer_registry>  producer_registry;
+
+       frame_producer_dependencies(
+                       const spl::shared_ptr<core::frame_factory>& frame_factory,
+                       const std::vector<spl::shared_ptr<video_channel>>& channels,
+                       const video_format_desc& format_desc,
+                       const spl::shared_ptr<const frame_producer_registry> producer_registry);
+};
+
+typedef std::function<spl::shared_ptr<core::frame_producer>(const frame_producer_dependencies&, const std::vector<std::wstring>&)> producer_factory_t;
+typedef std::function<draw_frame (const frame_producer_dependencies&, const std::wstring&)> thumbnail_producer_t;
+
+class frame_producer_registry : boost::noncopyable
+{
+public:
+       frame_producer_registry(spl::shared_ptr<help_repository> help_repo);
+       void register_producer_factory(std::wstring name, const producer_factory_t& factory, const help_item_describer& describer); // Not thread-safe.
+       void register_thumbnail_producer(const thumbnail_producer_t& thumbnail_producer); // Not thread-safe.
+       spl::shared_ptr<core::frame_producer> create_producer(const frame_producer_dependencies&, const std::vector<std::wstring>& params) const;
+       spl::shared_ptr<core::frame_producer> create_producer(const frame_producer_dependencies&, const std::wstring& params) const;
+       draw_frame create_thumbnail(const frame_producer_dependencies&, const std::wstring& media_file) const;
+private:
+       struct impl;
+       spl::shared_ptr<impl> impl_;
+};
 
 spl::shared_ptr<core::frame_producer> create_destroy_proxy(spl::shared_ptr<core::frame_producer> producer);
-spl::shared_ptr<core::frame_producer> create_thumbnail_producer(const spl::shared_ptr<frame_factory>&, const video_format_desc& format_desc, const std::wstring& media_file);
+void destroy_producers_synchronously();
 
 }}