2 * copyright (c) 2010 Sveriges Television AB <info@casparcg.com>
\r
4 * This file is part of CasparCG.
\r
6 * CasparCG is free software: you can redistribute it and/or modify
\r
7 * it under the terms of the GNU General Public License as published by
\r
8 * the Free Software Foundation, either version 3 of the License, or
\r
9 * (at your option) any later version.
\r
11 * CasparCG is distributed in the hope that it will be useful,
\r
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
14 * GNU General Public License for more details.
\r
16 * You should have received a copy of the GNU General Public License
\r
17 * along with CasparCG. If not, see <http://www.gnu.org/licenses/>.
\r
22 #include <common/memory/safe_ptr.h>
\r
24 #include "../producer/frame/basic_frame.h"
\r
25 #include "../producer/frame/frame_factory.h"
\r
27 #include <boost/noncopyable.hpp>
\r
29 #include <functional>
\r
33 namespace caspar { namespace core {
\r
35 class frame_producer : boost::noncopyable
\r
38 virtual ~frame_producer(){}
\r
40 virtual safe_ptr<basic_frame> receive() = 0;
\r
41 virtual safe_ptr<frame_producer> get_following_producer() const {return frame_producer::empty();} // nothrow
\r
42 virtual void set_leading_producer(const safe_ptr<frame_producer>& /*producer*/) {} // nothrow
\r
43 virtual void param(const std::wstring&){}
\r
45 virtual std::wstring print() const = 0;
\r
47 static const safe_ptr<frame_producer>& empty() // nothrow
\r
49 struct empty_frame_producer : public frame_producer
\r
51 virtual safe_ptr<basic_frame> receive(){return basic_frame::empty();}
\r
52 virtual void set_frame_factory(const safe_ptr<frame_factory>&){}
\r
53 virtual std::wstring print() const { return L"empty";}
\r
55 static safe_ptr<frame_producer> producer = make_safe<empty_frame_producer>();
\r
59 static const safe_ptr<frame_producer>& eof() // nothrow
\r
61 struct eof_frame_producer : public frame_producer
\r
63 virtual safe_ptr<basic_frame> receive(){return basic_frame::eof();}
\r
64 virtual void set_frame_factory(const safe_ptr<frame_factory>&){}
\r
65 virtual std::wstring print() const { return L"eof";}
\r
67 static safe_ptr<frame_producer> producer = make_safe<eof_frame_producer>();
\r
72 safe_ptr<basic_frame> receive(safe_ptr<frame_producer>& producer);
\r
74 std::wostream& operator<<(std::wostream& out, const frame_producer& producer);
\r
75 std::wostream& operator<<(std::wostream& out, const safe_ptr<const frame_producer>& producer);
\r
77 typedef std::function<safe_ptr<core::frame_producer>(const safe_ptr<frame_factory>&, const std::vector<std::wstring>&)> producer_factory_t;
\r
79 void register_producer_factory(const producer_factory_t& factory);
\r
80 safe_ptr<core::frame_producer> create_producer(const safe_ptr<frame_factory>&, const std::vector<std::wstring>& params);
\r