1 #include "../stdafx.h"
\r
5 #include "../producer/frame_producer.h"
\r
7 #include "../frame/frame_format.h"
\r
9 namespace caspar { namespace renderer {
\r
11 struct layer::implementation
\r
13 implementation() : preview_frame_(nullptr), active_(nullptr), background_(nullptr) {}
\r
15 void load(const frame_producer_ptr& frame_producer, load_option option)
\r
17 if(frame_producer == nullptr)
\r
18 BOOST_THROW_EXCEPTION(null_argument() << arg_name_info("frame_producer"));
\r
20 last_frame_ = nullptr;
\r
21 if(option == load_option::preview)
\r
23 last_frame_ = frame_producer->get_frame();
\r
24 if(last_frame_ != nullptr)
\r
25 last_frame_->audio_data().clear(); // No audio
\r
27 background_ = frame_producer;
\r
29 else if(option == load_option::auto_play)
\r
31 background_ = frame_producer;
\r
35 background_ = frame_producer;
\r
40 if(background_ != nullptr)
\r
42 background_->set_leading_producer(active_);
\r
43 active_ = background_;
\r
44 background_ = nullptr;
\r
58 last_frame_ = nullptr;
\r
64 background_ = nullptr;
\r
67 gpu_frame_ptr get_frame()
\r
69 if(!active_ || is_paused_)
\r
74 last_frame_ = active_->get_frame();
\r
78 CASPAR_LOG_CURRENT_EXCEPTION();
\r
80 CASPAR_LOG(warning) << "Removed producer from layer.";
\r
83 if(last_frame_ == nullptr)
\r
85 active_ = active_->get_following_producer();
\r
86 last_frame_ = get_frame();
\r
91 tbb::atomic<bool> is_paused_;
\r
92 gpu_frame_ptr last_frame_;
\r
93 gpu_frame_ptr preview_frame_;
\r
94 frame_producer_ptr active_;
\r
95 frame_producer_ptr background_;
\r
98 layer::layer() : impl_(new implementation()){}
\r
99 layer::layer(layer&& other) : impl_(std::move(other.impl_)){other.impl_ = nullptr;}
\r
100 layer::layer(const layer& other) : impl_(new implementation(*other.impl_)) {}
\r
101 layer& layer::operator=(layer&& other)
\r
103 impl_ = std::move(other.impl_);
\r
104 other.impl_ = nullptr;
\r
107 layer& layer::operator=(const layer& other)
\r
110 impl_.swap(temp.impl_);
\r
113 void layer::load(const frame_producer_ptr& frame_producer, load_option option){return impl_->load(frame_producer, option);}
\r
114 void layer::play(){impl_->play();}
\r
115 void layer::pause(){impl_->pause();}
\r
116 void layer::stop(){impl_->stop();}
\r
117 void layer::clear(){impl_->clear();}
\r
118 gpu_frame_ptr layer::get_frame() {return impl_->get_frame();}
\r
119 frame_producer_ptr layer::active() const { return impl_->active_;}
\r
120 frame_producer_ptr layer::background() const { return impl_->background_;}
\r