1 #include "../stdafx.h"
\r
5 #include "../processor/draw_frame.h"
\r
6 #include "../producer/frame_producer.h"
\r
8 #include "../format/video_format.h"
\r
10 namespace caspar { namespace core {
\r
12 struct layer::implementation
\r
14 implementation() : foreground_(nullptr), background_(nullptr), last_frame_(draw_frame::empty()) {}
\r
16 void load(const frame_producer_ptr& frame_producer, load_option::type option)
\r
18 background_ = frame_producer;
\r
19 if(option == load_option::preview)
\r
21 foreground_ = nullptr;
\r
22 last_frame_ = frame_producer->receive();
\r
24 else if(option == load_option::auto_play)
\r
30 if(background_ != nullptr)
\r
32 background_->set_leading_producer(foreground_);
\r
33 foreground_ = std::move(background_);
\r
46 foreground_ = nullptr;
\r
47 last_frame_ = draw_frame::empty();
\r
52 foreground_ = nullptr;
\r
53 background_ = nullptr;
\r
54 last_frame_ = draw_frame::empty();
\r
57 draw_frame receive()
\r
59 if(!foreground_ || is_paused_)
\r
64 last_frame_ = foreground_->receive();
\r
66 if(last_frame_ == draw_frame::eof())
\r
68 CASPAR_LOG(info) << L"EOF: " << foreground_->print();
\r
69 auto following = foreground_->get_following_producer();
\r
71 following->set_leading_producer(foreground_);
\r
72 foreground_ = following;
\r
73 last_frame_ = receive();
\r
80 CASPAR_LOG_CURRENT_EXCEPTION();
\r
81 CASPAR_LOG(warning) << L"Removed " << (foreground_ ? foreground_->print() : L"empty") << L" from layer.";
\r
82 foreground_ = nullptr;
\r
83 last_frame_ = draw_frame::empty();
\r
91 tbb::atomic<bool> is_paused_;
\r
92 draw_frame last_frame_;
\r
93 frame_producer_ptr foreground_;
\r
94 frame_producer_ptr background_;
\r
97 layer::layer() : impl_(new implementation()){}
\r
98 layer::layer(layer&& other) : impl_(std::move(other.impl_)){other.impl_ = nullptr;}
\r
99 layer& layer::operator=(layer&& other)
\r
101 impl_ = std::move(other.impl_);
\r
102 other.impl_ = nullptr;
\r
105 void layer::load(const frame_producer_ptr& frame_producer, load_option::type option){return impl_->load(frame_producer, option);}
\r
106 void layer::play(){impl_->play();}
\r
107 void layer::pause(){impl_->pause();}
\r
108 void layer::stop(){impl_->stop();}
\r
109 void layer::clear(){impl_->clear();}
\r
110 draw_frame layer::receive() {return impl_->receive();}
\r
111 frame_producer_ptr layer::foreground() const { return impl_->foreground_;}
\r
112 frame_producer_ptr layer::background() const { return impl_->background_;}
\r