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 "channel.h"
\r
25 #include "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 channel::implementation : boost::noncopyable
\r
42 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_->receive();
\r
71 mixer_->send(simple_frames);
\r
72 auto finished_frame = mixer_->receive();
\r
73 consumer_->send(finished_frame);
\r
75 context_.execution.begin_invoke([this]{tick();});
\r
78 std::wstring print() const
\r
80 return context_.print();
\r
83 void set_video_format_desc(const video_format_desc& format_desc)
\r
85 context_.execution.begin_invoke([=]
\r
87 context_.format_desc = format_desc;
\r
92 channel::channel(int index, const video_format_desc& format_desc, ogl_device& ogl) : impl_(new implementation(index, format_desc, ogl)){}
\r
93 channel::channel(channel&& other) : impl_(std::move(other.impl_)){}
\r
94 safe_ptr<frame_producer_device> channel::producer() { return impl_->producer_;}
\r
95 safe_ptr<frame_mixer_device> channel::mixer() { return impl_->mixer_;}
\r
96 safe_ptr<frame_consumer_device> channel::consumer() { return impl_->consumer_;}
\r
97 const video_format_desc& channel::get_video_format_desc() const{return impl_->context_.format_desc;}
\r
98 void channel::set_video_format_desc(const video_format_desc& format_desc){impl_->set_video_format_desc(format_desc);}
\r
99 std::wstring channel::print() const { return impl_->print();}
\r