]> git.sesse.net Git - casparcg/blobdiff - core/consumer/frame_consumer.h
Created a consumer that provides sync to a channel based on the pace of another chann...
[casparcg] / core / consumer / frame_consumer.h
index 8a078f89cd6555eab8c99048335a37796d2a6d14..58ffeb61b62168581d4f2d91c4f2ea5d068c9897 100644 (file)
 #pragma once
 
 #include "../monitor/monitor.h"
+#include "../fwd.h"
+#include "../help/help_repository.h"
 
 #include <common/memory.h>
+#include <common/future_fwd.h>
 
 #include <boost/property_tree/ptree_fwd.hpp>
-#include <boost/thread/future.hpp>
 
 #include <functional>
 #include <string>
@@ -42,22 +44,22 @@ class frame_consumer
 public:
 
        // Static Members
-       
+
        static const spl::shared_ptr<frame_consumer>& empty();
 
        // Constructors
 
        frame_consumer(){}
        virtual ~frame_consumer() {}
-       
+
        // Methods
 
-       virtual boost::unique_future<bool>              send(class const_frame frame) = 0;
-       virtual void                                                    initialize(const struct video_format_desc& format_desc, int channel_index) = 0;
-       
+       virtual std::future<bool>                               send(const_frame frame) = 0;
+       virtual void                                                    initialize(const video_format_desc& format_desc, const audio_channel_layout& channel_layout, int channel_index) = 0;
+
        // monitor::observable
 
-       virtual monitor::source& monitor_output() = 0;
+       virtual monitor::subject& monitor_output() = 0;
 
        // Properties
 
@@ -65,13 +67,43 @@ public:
        virtual std::wstring                                    name() const = 0;
        virtual boost::property_tree::wptree    info() const = 0;
        virtual bool                                                    has_synchronization_clock() const {return true;}
-       virtual int                                                             buffer_depth() const = 0;
+       virtual int                                                             buffer_depth() const = 0; // -1 to not participate in frame presentation synchronization
        virtual int                                                             index() const = 0;
+       virtual int64_t                                                 presentation_frame_age_millis() const = 0;
+       virtual const frame_consumer*                   unwrapped() const { return this; }
 };
 
-typedef std::function<spl::shared_ptr<frame_consumer>(const std::vector<std::wstring>&)> consumer_factory_t;
+typedef std::function<spl::shared_ptr<frame_consumer>(
+               const std::vector<std::wstring>&,
+               interaction_sink* sink,
+               std::vector<spl::shared_ptr<video_channel>> channels)> consumer_factory_t;
+typedef std::function<spl::shared_ptr<frame_consumer>(
+               const boost::property_tree::wptree& element,
+               interaction_sink* sink,
+               std::vector<spl::shared_ptr<video_channel>> channels)> preconfigured_consumer_factory_t;
+
+class frame_consumer_registry : boost::noncopyable
+{
+public:
+       frame_consumer_registry(spl::shared_ptr<help_repository> help_repo);
+       void register_consumer_factory(const std::wstring& name, const consumer_factory_t& factory, const help_item_describer& describer);
+       void register_preconfigured_consumer_factory(
+                       const std::wstring& element_name,
+                       const preconfigured_consumer_factory_t& factory);
+       spl::shared_ptr<frame_consumer> create_consumer(
+                       const std::vector<std::wstring>& params,
+                       interaction_sink* sink,
+                       std::vector<spl::shared_ptr<video_channel>> channels) const;
+       spl::shared_ptr<frame_consumer> create_consumer(
+                       const std::wstring& element_name,
+                       const boost::property_tree::wptree& element,
+                       interaction_sink* sink,
+                       std::vector<spl::shared_ptr<video_channel>> channels) const;
+private:
+       struct impl;
+       spl::shared_ptr<impl> impl_;
+};
 
-void register_consumer_factory(const consumer_factory_t& factory);
-spl::shared_ptr<frame_consumer> create_consumer(const std::vector<std::wstring>& params);
+void destroy_consumers_synchronously();
 
-}}
\ No newline at end of file
+}}