+/*\r
+* copyright (c) 2010 Sveriges Television AB <info@casparcg.com>\r
+*\r
+* This file is part of CasparCG.\r
+*\r
+* CasparCG is free software: you can redistribute it and/or modify\r
+* it under the terms of the GNU General Public License as published by\r
+* the Free Software Foundation, either version 3 of the License, or\r
+* (at your option) any later version.\r
+*\r
+* CasparCG is distributed in the hope that it will be useful,\r
+* but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
+* GNU General Public License for more details.\r
+\r
+* You should have received a copy of the GNU General Public License\r
+* along with CasparCG. If not, see <http://www.gnu.org/licenses/>.\r
+*\r
+*/\r
+\r
#include "../stdafx.h"\r
\r
#include "layer.h"\r
-#include "frame_producer.h"\r
\r
-#include "../producer/frame/basic_frame.h"\r
-#include "../producer/frame/audio_transform.h"\r
+#include "frame_producer.h"\r
\r
namespace caspar { namespace core {\r
\r
-struct layer::implementation : boost::noncopyable\r
+struct layer::implementation\r
{ \r
- int index_; \r
safe_ptr<frame_producer> foreground_;\r
safe_ptr<frame_producer> background_;\r
- safe_ptr<basic_frame> last_frame_;\r
bool is_paused_;\r
public:\r
- implementation(int index) \r
- : index_(index)\r
- , foreground_(frame_producer::empty())\r
+ implementation() \r
+ : foreground_(frame_producer::empty())\r
, background_(frame_producer::empty())\r
- , last_frame_(basic_frame::empty())\r
, is_paused_(false){}\r
\r
- void pause() \r
- {\r
- is_paused_ = true; \r
- }\r
-\r
- void resume()\r
- {\r
- if(is_paused_)\r
- CASPAR_LOG(info) << foreground_->print() << L" Resumed.";\r
- is_paused_ = false;\r
- }\r
+ void pause(){is_paused_ = true;}\r
+ void resume(){is_paused_ = false;}\r
\r
- void load(const safe_ptr<frame_producer>& producer, bool play_on_load, bool preview)\r
+ void load(const safe_ptr<frame_producer>& producer, bool preview)\r
{ \r
background_ = producer;\r
\r
- if(play_on_load)\r
- play(); \r
- else if(preview)\r
- {\r
+ if(preview) // Play the first frame and pause.\r
+ { \r
play();\r
receive();\r
pause();\r
}\r
-\r
- CASPAR_LOG(info) << producer->print() << L" Loaded.";\r
}\r
\r
void play()\r
background_->set_leading_producer(foreground_);\r
foreground_ = background_;\r
background_ = frame_producer::empty();\r
- CASPAR_LOG(info) << foreground_->print() << L" Active.";\r
}\r
resume();\r
}\r
\r
void stop()\r
{\r
- pause();\r
- last_frame_ = basic_frame::empty();\r
foreground_ = frame_producer::empty();\r
}\r
\r
safe_ptr<basic_frame> receive()\r
{ \r
- if(is_paused_) \r
- last_frame_->get_audio_transform().set_has_audio(false); \r
- else\r
- last_frame_ = receive_and_follow(foreground_);\r
-\r
- return last_frame_;\r
- }\r
+ if(is_paused_)\r
+ return foreground_->last_frame();\r
\r
- std::wstring print() const\r
- {\r
- return L"layer[" + boost::lexical_cast<std::wstring>(index_) + L"]";\r
+ return receive_and_follow_w_last(foreground_);\r
}\r
};\r
\r
-layer::layer(int index) : impl_(new implementation(index)){}\r
+layer::layer() : impl_(new implementation()){}\r
layer::layer(layer&& other) : impl_(std::move(other.impl_)){}\r
layer& layer::operator=(layer&& other)\r
{\r
impl_ = std::move(other.impl_);\r
return *this;\r
}\r
+layer::layer(const layer& other) : impl_(new implementation(*other.impl_)){}\r
+layer& layer::operator=(const layer& other)\r
+{\r
+ layer temp(other);\r
+ temp.swap(*this);\r
+ return *this;\r
+}\r
void layer::swap(layer& other)\r
{ \r
- impl_->foreground_.swap(other.impl_->foreground_);\r
- impl_->background_.swap(other.impl_->background_);\r
- impl_->last_frame_.swap(other.impl_->last_frame_);\r
- std::swap(impl_->is_paused_ , other.impl_->is_paused_ );\r
+ impl_.swap(other.impl_);\r
}\r
-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
+void layer::load(const safe_ptr<frame_producer>& frame_producer, bool preview){return impl_->load(frame_producer, preview);} \r
void layer::play(){impl_->play();}\r
void layer::pause(){impl_->pause();}\r
void layer::stop(){impl_->stop();}\r
safe_ptr<basic_frame> layer::receive() {return impl_->receive();}\r
safe_ptr<frame_producer> layer::foreground() const { return impl_->foreground_;}\r
safe_ptr<frame_producer> layer::background() const { return impl_->background_;}\r
-std::wstring layer::print() const { return impl_->print();}\r
}}
\ No newline at end of file