]> git.sesse.net Git - casparcg/blob - core/producer/scene/const_producer.cpp
Fix a few Clang warnings.
[casparcg] / core / producer / scene / const_producer.cpp
1 /*
2 * Copyright (c) 2011 Sveriges Television AB <info@casparcg.com>
3 *
4 * This file is part of CasparCG (www.casparcg.com).
5 *
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.
10 *
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.
15 *
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/>.
18 *
19 * Author: Helge Norberg, helge.norberg@svt.se
20 */
21
22 #include "../../StdAfx.h"
23
24 #include "const_producer.h"
25
26 #include "../frame_producer.h"
27 #include "../../frame/draw_frame.h"
28
29 namespace caspar { namespace core {
30
31 class const_producer : public frame_producer_base
32 {
33         monitor::subject monitor_subject_;
34         std::vector<draw_frame> frames_;
35         std::vector<draw_frame>::const_iterator seek_position_;
36         constraints constraints_;
37 public:
38         const_producer(const draw_frame& frame, int width, int height)
39                 : constraints_(width, height)
40         {
41                 frames_.push_back(frame);
42                 seek_position_ = frames_.begin();
43                 CASPAR_LOG(info) << print() << L" Initialized";
44         }
45
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)
50         {
51                 CASPAR_LOG(info) << print() << L" Initialized";
52         }
53
54         draw_frame receive_impl() override
55         {
56                 auto result = *seek_position_;
57
58                 if (seek_position_ + 1 != frames_.end())
59                         ++seek_position_;
60
61                 return result;
62         }
63
64         constraints& pixel_constraints() override
65         {
66                 return constraints_;
67         }
68         
69         std::wstring print() const override
70         {
71                 return L"const[]";
72         }
73
74         std::wstring name() const override
75         {
76                 return L"const";
77         }
78         
79         boost::property_tree::wptree info() const override
80         {
81                 boost::property_tree::wptree info;
82                 info.add(L"type", L"const");
83                 return info;
84         }
85
86         monitor::subject& monitor_output() override
87         {
88                 return monitor_subject_;
89         }
90 };
91
92 spl::shared_ptr<frame_producer> create_const_producer(
93                 const draw_frame& frame, int width, int height)
94 {
95         return spl::make_shared<const_producer>(frame, width, height);
96 }
97
98 spl::shared_ptr<frame_producer> create_const_producer(
99                 std::vector<draw_frame>&& frames, int width, int height)
100 {
101         return spl::make_shared<const_producer>(std::move(frames), width, height);
102 }
103
104 }}