1 #include "../stdafx.h"
\r
5 #include "../producer/frame_producer.h"
\r
7 #include "../frame/frame_format.h"
\r
9 namespace caspar { namespace core { namespace renderer {
\r
11 struct layer::implementation
\r
13 implementation() : preview_frame_(nullptr), active_(nullptr), background_(nullptr), last_frame_(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 background_ = frame_producer;
\r
22 if(option == load_option::preview)
\r
24 last_frame_ = frame_producer->get_frame();
\r
25 if(last_frame_ != nullptr)
\r
26 last_frame_->audio_data().clear(); // No audio
\r
29 else if(option == load_option::auto_play)
\r
35 if(background_ != nullptr)
\r
37 background_->set_leading_producer(active_);
\r
38 active_ = background_;
\r
39 background_ = nullptr;
\r
53 last_frame_ = nullptr;
\r
59 background_ = nullptr;
\r
60 last_frame_ = nullptr;
\r
63 gpu_frame_ptr get_frame()
\r
65 if(!active_ || is_paused_)
\r
70 last_frame_ = active_->get_frame();
\r
74 CASPAR_LOG_CURRENT_EXCEPTION();
\r
76 last_frame_ = nullptr;
\r
77 CASPAR_LOG(warning) << "Removed producer from layer.";
\r
80 if(last_frame_ == nullptr && active_ != nullptr)
\r
82 active_ = active_->get_following_producer();
\r
83 last_frame_ = get_frame();
\r
88 tbb::atomic<bool> is_paused_;
\r
89 gpu_frame_ptr last_frame_;
\r
90 gpu_frame_ptr preview_frame_;
\r
91 frame_producer_ptr active_;
\r
92 frame_producer_ptr background_;
\r
95 layer::layer() : impl_(new implementation()){}
\r
96 layer::layer(layer&& other) : impl_(std::move(other.impl_)){other.impl_ = nullptr;}
\r
97 layer::layer(const layer& other) : impl_(new implementation(*other.impl_)) {}
\r
98 layer& layer::operator=(layer&& other)
\r
100 impl_ = std::move(other.impl_);
\r
101 other.impl_ = nullptr;
\r
104 layer& layer::operator=(const layer& other)
\r
107 impl_.swap(temp.impl_);
\r
110 void layer::load(const frame_producer_ptr& frame_producer, load_option option){return impl_->load(frame_producer, option);}
\r
111 void layer::play(){impl_->play();}
\r
112 void layer::pause(){impl_->pause();}
\r
113 void layer::stop(){impl_->stop();}
\r
114 void layer::clear(){impl_->clear();}
\r
115 gpu_frame_ptr layer::get_frame() {return impl_->get_frame();}
\r
116 frame_producer_ptr layer::active() const { return impl_->active_;}
\r
117 frame_producer_ptr layer::background() const { return impl_->background_;}
\r