X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=core%2Fconsumer%2Fframe_consumer.h;h=e09e4edcfe263f8a36c5a22359b831fe3fab445b;hb=c90f93ca757a8e0875e705e6e7db3dea9a58f7d7;hp=fd4ac355bc55218a009f2785aa03e40558176092;hpb=f78d434c81a83b428ae2e24af862d5f2702c34f9;p=casparcg diff --git a/core/consumer/frame_consumer.h b/core/consumer/frame_consumer.h index fd4ac355b..e09e4edcf 100644 --- a/core/consumer/frame_consumer.h +++ b/core/consumer/frame_consumer.h @@ -1,60 +1,104 @@ -/* -* Copyright (c) 2011 Sveriges Television AB -* -* This file is part of CasparCG (www.casparcg.com). -* -* CasparCG is free software: you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation, either version 3 of the License, or -* (at your option) any later version. -* -* CasparCG is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with CasparCG. If not, see . -* -* Author: Robert Nagy, ronag89@gmail.com -*/ - -#pragma once - -#include - -#include -#include - -#include -#include -#include - -namespace caspar { namespace core { - -class read_frame; -struct video_format_desc; - -struct frame_consumer : boost::noncopyable -{ - virtual ~frame_consumer() {} - - virtual bool send(const safe_ptr& frame) = 0; - virtual void initialize(const video_format_desc& format_desc, int channel_index) = 0; - virtual std::string print() const = 0; - virtual boost::property_tree::ptree info() const = 0; - virtual bool has_synchronization_clock() const {return true;} - virtual size_t buffer_depth() const = 0; - virtual int index() const = 0; - - static const safe_ptr& empty(); -}; - -safe_ptr create_consumer_cadence_guard(const safe_ptr& consumer); - -typedef std::function(const std::vector&)> consumer_factory_t; - -void register_consumer_factory(const consumer_factory_t& factory); -safe_ptr create_consumer(const std::vector& params); - -}} \ No newline at end of file +/* +* Copyright (c) 2011 Sveriges Television AB +* +* This file is part of CasparCG (www.casparcg.com). +* +* CasparCG is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* CasparCG is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with CasparCG. If not, see . +* +* Author: Robert Nagy, ronag89@gmail.com +*/ + +#pragma once + +#include "../monitor/monitor.h" +#include "../fwd.h" +#include "../help/help_repository.h" + +#include +#include + +#include + +#include +#include +#include + +namespace caspar { namespace core { + +// Interface +class frame_consumer +{ + frame_consumer(const frame_consumer&); + frame_consumer& operator=(const frame_consumer&); +public: + + // Static Members + + static const spl::shared_ptr& empty(); + + // Constructors + + frame_consumer(){} + virtual ~frame_consumer() {} + + // Methods + + virtual std::future 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::subject& monitor_output() = 0; + + // Properties + + virtual std::wstring print() const = 0; + 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; // -1 to not participate in frame presentation synchronization + virtual int index() const = 0; + virtual int64_t presentation_frame_age_millis() const = 0; +}; + +typedef std::function( + const std::vector&, + interaction_sink* sink)> consumer_factory_t; +typedef std::function( + const boost::property_tree::wptree& element, + interaction_sink* sink)> preconfigured_consumer_factory_t; + +class frame_consumer_registry : boost::noncopyable +{ +public: + frame_consumer_registry(spl::shared_ptr 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 create_consumer( + const std::vector& params, + interaction_sink* sink) const; + spl::shared_ptr create_consumer( + const std::wstring& element_name, + const boost::property_tree::wptree& element, + interaction_sink* sink) const; +private: + struct impl; + spl::shared_ptr impl_; +}; + +void destroy_consumers_synchronously(); + +}}