\r
std::shared_ptr<CBlueVelvet4> blue_;\r
\r
- unsigned int device_index_;\r
- video_format_desc format_desc_;\r
+ const unsigned int device_index_;\r
+ const video_format_desc format_desc_;\r
\r
unsigned long mem_fmt_;\r
unsigned long upd_fmt_;\r
\r
std::array<blue_dma_buffer_ptr, 3> reserved_frames_; \r
\r
- bool embed_audio_;\r
+ const bool embed_audio_;\r
\r
public:\r
implementation::implementation(const video_format_desc& format_desc, unsigned int device_index, bool embed_audio) \r
{\r
struct plane\r
{\r
- plane() : linesize(0), width(0), height(0), size(0), channels(0){}\r
- plane(size_t width, size_t height, size_t channels)\r
- : linesize(width*channels), width(width), height(height), size(width*height*channels), channels(channels){}\r
size_t linesize;\r
size_t width;\r
size_t height;\r
size_t size;\r
size_t channels;\r
+\r
+ plane() \r
+ : linesize(0)\r
+ , width(0)\r
+ , height(0)\r
+ , size(0)\r
+ , channels(0){}\r
+\r
+ plane(size_t width, size_t height, size_t channels)\r
+ : linesize(width*channels)\r
+ , width(width)\r
+ , height(height)\r
+ , size(width*height*channels)\r
+ , channels(channels){}\r
};\r
\r
pixel_format_desc() : pix_fmt(pixel_format::invalid){}\r
{\r
executor executor_;\r
\r
- video_format_desc format_desc_;\r
-\r
+ const video_format_desc format_desc_;\r
const size_t device_index_;\r
\r
std::unique_ptr<decklink_input> input_;\r
\r
struct ffmpeg_producer : public frame_producer\r
{\r
- bool is_running_;\r
input input_; \r
std::unique_ptr<audio_decoder> audio_decoder_;\r
std::unique_ptr<video_decoder> video_decoder_;\r
\r
public:\r
explicit ffmpeg_producer(const std::wstring& filename, bool loop, double start_time = 0, double end_time = -1.0) \r
- : is_running_(true)\r
- , filename_(filename)\r
+ : filename_(filename)\r
, last_frame_(draw_frame(draw_frame::empty()))\r
, input_(filename, loop, start_time, end_time)\r
, video_decoder_(new video_decoder(input_.get_video_codec_context().get())) \r
\r
virtual safe_ptr<draw_frame> receive()\r
{\r
- while(is_running_ && ouput_channel_.empty() && !input_.is_eof())\r
+ while(ouput_channel_.empty() && !input_.is_eof())\r
{ \r
aligned_buffer video_packet;\r
if(video_frame_channel_.size() < 3) \r
{ // Video Decoding and Scaling\r
if(!video_packet.empty() && video_decoder_)\r
{\r
- try\r
- {\r
- auto frame = video_decoder_->execute(video_packet);\r
- video_frame_channel_.push_back(std::move(frame));\r
- }\r
- catch(...)\r
- {\r
- CASPAR_LOG_CURRENT_EXCEPTION();\r
- video_decoder_.reset();\r
- is_running_ = false;\r
- } \r
+ auto frame = video_decoder_->execute(video_packet);\r
+ video_frame_channel_.push_back(std::move(frame));\r
}\r
}, \r
[&] \r
last_frame_->audio_volume(0.0); // last_frame should not have audio\r
ouput_channel_.pop();\r
}\r
- else if(input_.is_eof() || !is_running_)\r
+ else if(input_.is_eof())\r
return draw_frame::eof();\r
\r
return result;\r
long long end_frame_;\r
long long frame_count_;\r
\r
- std::shared_ptr<AVFormatContext> format_context_; // Destroy this last\r
+ std::shared_ptr<AVFormatContext> format_context_; // Destroy this last\r
\r
- std::shared_ptr<AVCodecContext> video_codec_context_;\r
- std::shared_ptr<AVCodecContext> audio_codex_context_;\r
+ std::shared_ptr<AVCodecContext> video_codec_context_;\r
+ std::shared_ptr<AVCodecContext> audio_codex_context_;\r
\r
- const std::wstring filename_;\r
+ const std::wstring filename_;\r
\r
- tbb::atomic<bool> loop_;\r
- int video_s_index_;\r
- int audio_s_index_;\r
+ bool loop_;\r
+ int video_s_index_;\r
+ int audio_s_index_;\r
\r
tbb::atomic<size_t> buffer_size_;\r
\r
\r
public:\r
explicit implementation(const std::wstring& filename, bool loop, double start_time, double end_time) \r
- : video_s_index_(-1)\r
+ : loop_(loop)\r
+ , video_s_index_(-1)\r
, audio_s_index_(-1)\r
, filename_(filename)\r
{ \r
\r
static boost::once_flag avcodec_init_flag = BOOST_ONCE_INIT;\r
boost::call_once(avcodec_init, avcodec_init_flag); \r
-\r
- loop_ = loop; \r
- \r
+ \r
int errn;\r
AVFormatContext* weak_format_context_;\r
if((errn = -av_open_input_file(&weak_format_context_, narrow(filename).c_str(), nullptr, 0, nullptr)) > 0)\r
}\r
} co_;\r
\r
- std::wstring filename_;\r
+ const std::wstring filename_;\r
+ const video_format_desc format_desc_;\r
+\r
std::shared_ptr<frame_processor_device> frame_processor_;\r
- video_format_desc format_desc_;\r
\r
BYTE* bmp_data_; \r
std::shared_ptr<void> hdc_;\r
\r
public:\r
flash_renderer(const std::shared_ptr<frame_processor_device>& frame_processor, const std::wstring& filename) \r
- : head_(draw_frame::empty())\r
+ : filename_(filename)\r
+ , format_desc_(frame_processor->get_video_format_desc())\r
+ , frame_processor_(frame_processor)\r
, bmp_data_(nullptr)\r
- , ax_(nullptr)\r
- , filename_(filename)\r
, hdc_(CreateCompatibleDC(0), DeleteDC)\r
- , frame_processor_(frame_processor)\r
- , format_desc_(frame_processor->get_video_format_desc())\r
+ , ax_(nullptr)\r
+ , head_(draw_frame::empty())\r
{\r
CASPAR_LOG(info) << print() << L" Started";\r
\r
return draw_frame::empty();\r
\r
auto frame = render_simple_frame();\r
- if(format_desc_.mode != video_mode::progressive && ax_->GetFPS()/2.0 - format_desc_.fps >= 0.0)\r
+ if(ax_->GetFPS()/2.0 - format_desc_.fps >= 0.0)\r
frame = draw_frame::interlace(frame, render_simple_frame(), format_desc_.mode);\r
return frame;\r
}\r
\r
struct layer::implementation : boost::noncopyable\r
{ \r
- tbb::atomic<bool> is_paused_;\r
- safe_ptr<draw_frame> last_frame_;\r
safe_ptr<frame_producer> foreground_;\r
safe_ptr<frame_producer> background_;\r
+ safe_ptr<draw_frame> last_frame_;\r
const int index_;\r
+ bool is_paused_;\r
\r
public:\r
implementation(int index) \r
, background_(frame_producer::empty())\r
, last_frame_(draw_frame::empty())\r
, index_(index) \r
- {\r
- is_paused_ = false;\r
- }\r
+ , is_paused_(false){}\r
\r
- void load(const safe_ptr<frame_producer>& frame_producer, bool autoplay)\r
+ void load(const safe_ptr<frame_producer>& frame_producer, bool play_on_load)\r
{ \r
background_ = frame_producer;\r
CASPAR_LOG(info) << print() << " " << frame_producer->print() << " => background";\r
- if(autoplay)\r
+ if(play_on_load)\r
play(); \r
}\r
\r
other.impl_ = nullptr;\r
return *this;\r
}\r
-void layer::load(const safe_ptr<frame_producer>& frame_producer, bool autoplay){return impl_->load(frame_producer, autoplay);} \r
+void layer::load(const safe_ptr<frame_producer>& frame_producer, bool play_on_load){return impl_->load(frame_producer, play_on_load);} \r
void layer::preview(const safe_ptr<frame_producer>& frame_producer){return impl_->preview(frame_producer);} \r
void layer::play(){impl_->play();}\r
void layer::pause(){impl_->pause();}\r
layer(layer&& other); // nothrow\r
layer& operator=(layer&& other); // nothrow\r
\r
- void load(const safe_ptr<frame_producer>& producer, bool autoplay = false); // nothrow\r
+ void load(const safe_ptr<frame_producer>& producer, bool play_on_load = false); // nothrow\r
void preview(const safe_ptr<frame_producer>& producer); // nothrow\r
void play(); // nothrow\r
void pause(); // nothrow\r
\r
#include "../../video_format.h"\r
#include "../../processor/draw_frame.h"\r
-#include "../../processor/draw_frame.h"\r
#include "../../processor/frame_processor_device.h"\r
\r
#include <boost/range/algorithm/copy.hpp>\r