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
\r
13 safe_ptr<frame_producer> foreground_;
\r
14 safe_ptr<frame_producer> background_;
\r
15 safe_ptr<basic_frame> last_frame_;
\r
19 : foreground_(frame_producer::empty())
\r
20 , background_(frame_producer::empty())
\r
21 , last_frame_(basic_frame::empty())
\r
22 , is_paused_(false){}
\r
24 void pause(){is_paused_ = true;}
\r
25 void resume(){is_paused_ = false;}
\r
27 void load(const safe_ptr<frame_producer>& producer, bool preview)
\r
29 background_ = producer;
\r
41 if(background_ != frame_producer::empty())
\r
43 background_->set_leading_producer(foreground_);
\r
44 foreground_ = background_;
\r
45 background_ = frame_producer::empty();
\r
53 last_frame_ = basic_frame::empty();
\r
54 foreground_ = frame_producer::empty();
\r
57 safe_ptr<basic_frame> receive()
\r
60 last_frame_->get_audio_transform().set_has_audio(false);
\r
62 last_frame_ = receive_and_follow(foreground_);
\r
68 layer::layer() : impl_(new implementation()){}
\r
69 layer::layer(layer&& other) : impl_(std::move(other.impl_)){}
\r
70 layer& layer::operator=(layer&& other)
\r
72 impl_ = std::move(other.impl_);
\r
75 layer::layer(const layer& other) : impl_(new implementation(*other.impl_)){}
\r
76 layer& layer::operator=(const layer& other)
\r
82 void layer::swap(layer& other)
\r
84 impl_.swap(other.impl_);
\r
86 void layer::load(const safe_ptr<frame_producer>& frame_producer, bool preview){return impl_->load(frame_producer, preview);}
\r
87 void layer::play(){impl_->play();}
\r
88 void layer::pause(){impl_->pause();}
\r
89 void layer::stop(){impl_->stop();}
\r
90 safe_ptr<basic_frame> layer::receive() {return impl_->receive();}
\r
91 safe_ptr<frame_producer> layer::foreground() const { return impl_->foreground_;}
\r
92 safe_ptr<frame_producer> layer::background() const { return impl_->background_;}
\r