1 #include "../stdafx.h"
\r
4 #include "frame_producer.h"
\r
6 #include "../producer/frame/basic_frame.h"
\r
7 #include "../producer/frame/audio_transform.h"
\r
9 namespace caspar { namespace core {
\r
11 struct layer::implementation : boost::noncopyable
\r
14 safe_ptr<frame_producer> foreground_;
\r
15 safe_ptr<frame_producer> background_;
\r
16 safe_ptr<basic_frame> last_frame_;
\r
19 implementation(int index)
\r
21 , foreground_(frame_producer::empty())
\r
22 , background_(frame_producer::empty())
\r
23 , last_frame_(basic_frame::empty())
\r
24 , is_paused_(false){}
\r
34 CASPAR_LOG(info) << foreground_->print() << L" Resumed.";
\r
38 void load(const safe_ptr<frame_producer>& producer, bool play_on_load, bool preview)
\r
40 background_ = producer;
\r
51 CASPAR_LOG(info) << producer->print() << L" Loaded.";
\r
56 if(background_ != frame_producer::empty())
\r
58 background_->set_leading_producer(foreground_);
\r
59 foreground_ = background_;
\r
60 background_ = frame_producer::empty();
\r
61 CASPAR_LOG(info) << foreground_->print() << L" Active.";
\r
69 last_frame_ = basic_frame::empty();
\r
70 foreground_ = frame_producer::empty();
\r
73 safe_ptr<basic_frame> receive()
\r
76 last_frame_->get_audio_transform().set_has_audio(false);
\r
78 last_frame_ = receive_and_follow(foreground_);
\r
83 std::wstring print() const
\r
85 return L"layer[" + boost::lexical_cast<std::wstring>(index_) + L"]";
\r
89 layer::layer(int index) : impl_(new implementation(index)){}
\r
90 layer::layer(layer&& other) : impl_(std::move(other.impl_)){}
\r
91 layer& layer::operator=(layer&& other)
\r
93 impl_ = std::move(other.impl_);
\r
96 void layer::swap(layer& other)
\r
98 impl_->foreground_.swap(other.impl_->foreground_);
\r
99 impl_->background_.swap(other.impl_->background_);
\r
100 impl_->last_frame_.swap(other.impl_->last_frame_);
\r
101 std::swap(impl_->is_paused_ , other.impl_->is_paused_ );
\r
103 void layer::load(const safe_ptr<frame_producer>& frame_producer, bool play_on_load, bool preview){return impl_->load(frame_producer, play_on_load, preview);}
\r
104 void layer::play(){impl_->play();}
\r
105 void layer::pause(){impl_->pause();}
\r
106 void layer::stop(){impl_->stop();}
\r
107 safe_ptr<basic_frame> layer::receive() {return impl_->receive();}
\r
108 safe_ptr<frame_producer> layer::foreground() const { return impl_->foreground_;}
\r
109 safe_ptr<frame_producer> layer::background() const { return impl_->background_;}
\r
110 std::wstring layer::print() const { return impl_->print();}
\r