X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=core%2Fconsumer%2Fframe_consumer.h;h=58ffeb61b62168581d4f2d91c4f2ea5d068c9897;hb=9e4b08cde6c6de9e83a3fff42d90affc3cd8e5bc;hp=a027e6a6d7395d4d36bee740674b351045f1720b;hpb=9eab3f3babf20837a645e745be2ca240a68554af;p=casparcg diff --git a/core/consumer/frame_consumer.h b/core/consumer/frame_consumer.h index a027e6a6d..58ffeb61b 100644 --- a/core/consumer/frame_consumer.h +++ b/core/consumer/frame_consumer.h @@ -1,59 +1,109 @@ -/* -* copyright (c) 2010 Sveriges Television AB -* -* This file is part of CasparCG. -* -* 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 . -* -*/ -#pragma once - -#include -#include - -#include - -#include - -namespace caspar { namespace core { - -class read_frame; -struct video_format_desc; - -struct frame_consumer : boost::noncopyable -{ - virtual ~frame_consumer() {} - - virtual void send(const safe_ptr& frame) = 0; - virtual size_t buffer_depth() const = 0; - virtual void initialize(const video_format_desc& format_desc) = 0; - virtual void set_parent_printer(const printer& parent_printer) = 0; - virtual std::wstring print() const = 0; - - static const safe_ptr& empty() - { - struct empty_frame_consumer : public frame_consumer - { - virtual void send(const safe_ptr&){} - virtual size_t buffer_depth() const{return 0;} - virtual void initialize(const video_format_desc&){} - virtual void set_parent_printer(const printer&){} - virtual std::wstring print() const {return L"empty";} - }; - static safe_ptr consumer = make_safe(); - return consumer; - } -}; - -}} \ 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; + virtual const frame_consumer* unwrapped() const { return this; } +}; + +typedef std::function( + const std::vector&, + interaction_sink* sink, + std::vector> channels)> consumer_factory_t; +typedef std::function( + const boost::property_tree::wptree& element, + interaction_sink* sink, + std::vector> channels)> 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, + std::vector> channels) const; + spl::shared_ptr create_consumer( + const std::wstring& element_name, + const boost::property_tree::wptree& element, + interaction_sink* sink, + std::vector> channels) const; +private: + struct impl; + spl::shared_ptr impl_; +}; + +void destroy_consumers_synchronously(); + +}}