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
23 #include "video_channel.h"
\r
25 #include "video_channel_context.h"
\r
27 #include "video_format.h"
\r
28 #include "producer/layer.h"
\r
30 #include <common/concurrency/executor.h>
\r
32 #include <boost/range/algorithm_ext/erase.hpp>
\r
35 #pragma warning(disable : 4355)
\r
38 namespace caspar { namespace core {
\r
40 struct video_channel::implementation : boost::noncopyable
\r
42 video_channel_context context_;
\r
44 safe_ptr<frame_consumer_device> consumer_;
\r
45 safe_ptr<frame_mixer_device> mixer_;
\r
46 safe_ptr<frame_producer_device> producer_;
\r
49 implementation(int index, const video_format_desc& format_desc, ogl_device& ogl)
\r
50 : context_(index, ogl, format_desc)
\r
51 , consumer_(new frame_consumer_device(context_))
\r
52 , mixer_(new frame_mixer_device(context_))
\r
53 , producer_(new frame_producer_device(context_))
\r
55 CASPAR_LOG(info) << print() << " Successfully Initialized.";
\r
56 context_.execution().begin_invoke([this]{tick();});
\r
61 // Stop context before destroying devices.
\r
62 context_.execution().stop();
\r
63 context_.execution().join();
\r
64 context_.destruction().stop();
\r
65 context_.destruction().join();
\r
70 auto simple_frames = producer_->execute();
\r
71 auto finished_frame = mixer_->execute(simple_frames);
\r
72 consumer_->execute(finished_frame);
\r
74 context_.execution().begin_invoke([this]{tick();});
\r
77 std::wstring print() const
\r
79 return context_.print();
\r
82 void set_video_format_desc(const video_format_desc& format_desc)
\r
84 context_.execution().begin_invoke([=]
\r
86 context_.set_format_desc(format_desc);
\r
91 video_channel::video_channel(int index, const video_format_desc& format_desc, ogl_device& ogl) : impl_(new implementation(index, format_desc, ogl)){}
\r
92 video_channel::video_channel(video_channel&& other) : impl_(std::move(other.impl_)){}
\r
93 safe_ptr<frame_producer_device> video_channel::producer() { return impl_->producer_;}
\r
94 safe_ptr<frame_mixer_device> video_channel::mixer() { return impl_->mixer_;}
\r
95 safe_ptr<frame_consumer_device> video_channel::consumer() { return impl_->consumer_;}
\r
96 video_format_desc video_channel::get_video_format_desc() const{return impl_->context_.get_format_desc();}
\r
97 void video_channel::set_video_format_desc(const video_format_desc& format_desc){impl_->set_video_format_desc(format_desc);}
\r
98 std::wstring video_channel::print() const { return impl_->print();}
\r