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
21 #include "../stdafx.h"
\r
24 #include "frame_producer.h"
\r
26 #include "../producer/frame/basic_frame.h"
\r
27 #include "../producer/frame/audio_transform.h"
\r
29 namespace caspar { namespace core {
\r
31 struct layer::implementation
\r
33 safe_ptr<frame_producer> foreground_;
\r
34 safe_ptr<frame_producer> background_;
\r
38 : foreground_(frame_producer::empty())
\r
39 , background_(frame_producer::empty())
\r
40 , is_paused_(false){}
\r
42 void pause(){is_paused_ = true;}
\r
43 void resume(){is_paused_ = false;}
\r
45 void load(const safe_ptr<frame_producer>& producer, bool preview)
\r
47 background_ = producer;
\r
49 if(preview) // Play the first frame and pause.
\r
59 if(background_ != frame_producer::empty())
\r
61 background_->set_leading_producer(foreground_);
\r
62 foreground_ = background_;
\r
63 background_ = frame_producer::empty();
\r
70 foreground_ = frame_producer::empty();
\r
73 safe_ptr<basic_frame> receive()
\r
76 return foreground_->last_frame();
\r
78 return receive_and_follow_w_last(foreground_);
\r
82 layer::layer() : impl_(new implementation()){}
\r
83 layer::layer(layer&& other) : impl_(std::move(other.impl_)){}
\r
84 layer& layer::operator=(layer&& other)
\r
86 impl_ = std::move(other.impl_);
\r
89 layer::layer(const layer& other) : impl_(new implementation(*other.impl_)){}
\r
90 layer& layer::operator=(const layer& other)
\r
96 void layer::swap(layer& other)
\r
98 impl_.swap(other.impl_);
\r
100 void layer::load(const safe_ptr<frame_producer>& frame_producer, bool preview){return impl_->load(frame_producer, preview);}
\r
101 void layer::play(){impl_->play();}
\r
102 void layer::pause(){impl_->pause();}
\r
103 void layer::stop(){impl_->stop();}
\r
104 safe_ptr<basic_frame> layer::receive() {return impl_->receive();}
\r
105 safe_ptr<frame_producer> layer::foreground() const { return impl_->foreground_;}
\r
106 safe_ptr<frame_producer> layer::background() const { return impl_->background_;}
\r