1 #include "../StdAfx.h"
\r
3 #include "write_frame.h"
\r
5 #include "host_buffer.h"
\r
7 #include "draw_frame.h"
\r
8 #include "image_processor.h"
\r
9 #include "audio_processor.h"
\r
10 #include "pixel_format.h"
\r
12 #include <common/gl/gl_check.h>
\r
14 #include <boost/range/algorithm.hpp>
\r
16 namespace caspar { namespace core {
\r
18 struct write_frame::implementation : boost::noncopyable
\r
21 std::vector<safe_ptr<host_buffer>> buffers_;
\r
22 std::vector<short> audio_data_;
\r
23 const pixel_format_desc desc_;
\r
26 implementation(write_frame& self, const pixel_format_desc& desc, std::vector<safe_ptr<host_buffer>> buffers)
\r
29 , buffers_(buffers){}
\r
31 void process_image(image_processor& processor)
\r
33 processor.begin(self_.get_image_transform());
\r
34 processor.process(desc_, buffers_);
\r
38 void process_audio(audio_processor& processor)
\r
40 processor.begin(self_.get_audio_transform());
\r
41 processor.process(audio_data_);
\r
45 boost::iterator_range<unsigned char*> image_data(size_t index)
\r
47 if(index >= buffers_.size() || !buffers_[index]->data())
\r
48 return boost::iterator_range<const unsigned char*>();
\r
49 auto ptr = static_cast<unsigned char*>(buffers_[index]->data());
\r
50 return boost::iterator_range<unsigned char*>(ptr, ptr+buffers_[index]->size());
\r
52 const boost::iterator_range<const unsigned char*> image_data(size_t index) const
\r
54 if(index >= buffers_.size() || !buffers_[index]->data())
\r
55 return boost::iterator_range<const unsigned char*>();
\r
56 auto ptr = static_cast<const unsigned char*>(buffers_[index]->data());
\r
57 return boost::iterator_range<const unsigned char*>(ptr, ptr+buffers_[index]->size());
\r
62 #pragma warning(disable : 4355) // 'this' : used in base member initializer list
\r
65 write_frame::write_frame(const pixel_format_desc& desc, std::vector<safe_ptr<host_buffer>> buffers) : impl_(new implementation(*this, desc, buffers)){}
\r
66 write_frame::write_frame(write_frame&& other) : impl_(std::move(other.impl_)){}
\r
67 void write_frame::swap(write_frame& other){impl_.swap(other.impl_);}
\r
68 write_frame& write_frame::operator=(write_frame&& other)
\r
70 write_frame temp(std::move(other));
\r
74 void write_frame::process_image(image_processor& processor){impl_->process_image(processor);}
\r
75 void write_frame::process_audio(audio_processor& processor){impl_->process_audio(processor);}
\r
76 boost::iterator_range<unsigned char*> write_frame::image_data(size_t index){return impl_->image_data(index);}
\r
77 std::vector<short>& write_frame::audio_data() { return impl_->audio_data_; }
\r