2 * Copyright (c) 2011 Sveriges Television AB <info@casparcg.com>
4 * This file is part of CasparCG (www.casparcg.com).
6 * CasparCG is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
11 * CasparCG is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with CasparCG. If not, see <http://www.gnu.org/licenses/>.
19 * Author: Helge Norberg, helge.norberg@svt.se
22 #include "../../StdAfx.h"
24 #include "const_producer.h"
26 #include "../frame_producer.h"
27 #include "../../frame/draw_frame.h"
29 namespace caspar { namespace core {
31 class const_producer : public frame_producer_base
33 monitor::subject monitor_subject_;
34 std::vector<draw_frame> frames_;
35 std::vector<draw_frame>::const_iterator seek_position_;
36 constraints constraints_;
38 const_producer(const draw_frame& frame, int width, int height)
39 : constraints_(width, height)
41 frames_.push_back(frame);
42 seek_position_ = frames_.begin();
43 CASPAR_LOG(info) << print() << L" Initialized";
46 const_producer(std::vector<draw_frame>&& frames, int width, int height)
47 : frames_(std::move(frames))
48 , seek_position_(frames_.begin())
49 , constraints_(width, height)
51 CASPAR_LOG(info) << print() << L" Initialized";
54 draw_frame receive_impl() override
56 auto result = *seek_position_;
58 if (seek_position_ + 1 != frames_.end())
64 constraints& pixel_constraints() override
69 std::wstring print() const override
74 std::wstring name() const override
79 boost::property_tree::wptree info() const override
81 boost::property_tree::wptree info;
82 info.add(L"type", L"const");
86 monitor::subject& monitor_output() override
88 return monitor_subject_;
92 spl::shared_ptr<frame_producer> create_const_producer(
93 const draw_frame& frame, int width, int height)
95 return spl::make_shared<const_producer>(frame, width, height);
98 spl::shared_ptr<frame_producer> create_const_producer(
99 std::vector<draw_frame>&& frames, int width, int height)
101 return spl::make_shared<const_producer>(std::move(frames), width, height);