-/*\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
-#include "../../stdafx.h"\r
-\r
-#include "gpu_write_frame.h"\r
-\r
-#include <core/producer/frame/pixel_format.h>\r
-\r
-#include "../image/image_mixer.h"\r
-#include "../audio/audio_mixer.h"\r
-\r
-#include "../gpu/host_buffer.h"\r
-\r
-#include <common/gl/gl_check.h>\r
-\r
-#include <boost/range/algorithm.hpp>\r
-\r
-namespace caspar { namespace mixer {\r
- \r
-struct gpu_write_frame::implementation : boost::noncopyable\r
-{ \r
- std::vector<safe_ptr<host_buffer>> buffers_;\r
- std::vector<short> audio_data_;\r
- const core::pixel_format_desc desc_;\r
- int tag_;\r
-\r
-public:\r
- implementation(int tag, const core::pixel_format_desc& desc, const std::vector<safe_ptr<host_buffer>>& buffers) \r
- : desc_(desc)\r
- , buffers_(buffers)\r
- , tag_(tag){}\r
- \r
- void accept(gpu_write_frame& self, core::frame_visitor& visitor)\r
- {\r
- visitor.begin(self);\r
- visitor.visit(self);\r
- visitor.end();\r
- }\r
-\r
- boost::iterator_range<unsigned char*> image_data(size_t index)\r
- {\r
- if(index >= buffers_.size() || !buffers_[index]->data())\r
- return boost::iterator_range<const unsigned char*>();\r
- auto ptr = static_cast<unsigned char*>(buffers_[index]->data());\r
- return boost::iterator_range<unsigned char*>(ptr, ptr+buffers_[index]->size());\r
- }\r
-\r
- const boost::iterator_range<const unsigned char*> image_data(size_t index) const\r
- {\r
- if(index >= buffers_.size() || !buffers_[index]->data())\r
- return boost::iterator_range<const unsigned char*>();\r
- auto ptr = static_cast<const unsigned char*>(buffers_[index]->data());\r
- return boost::iterator_range<const unsigned char*>(ptr, ptr+buffers_[index]->size());\r
- }\r
-};\r
- \r
-gpu_write_frame::gpu_write_frame(int tag, const core::pixel_format_desc& desc, const std::vector<safe_ptr<host_buffer>>& buffers) : impl_(new implementation(tag, desc, buffers)){}\r
-void gpu_write_frame::accept(core::frame_visitor& visitor){impl_->accept(*this, visitor);}\r
-\r
-boost::iterator_range<unsigned char*> gpu_write_frame::image_data(size_t index){return impl_->image_data(index);}\r
-std::vector<short>& gpu_write_frame::audio_data() { return impl_->audio_data_; }\r
-const boost::iterator_range<const unsigned char*> gpu_write_frame::image_data(size_t index) const\r
-{\r
- return boost::iterator_range<const unsigned char*>(impl_->image_data(index).begin(), impl_->image_data(index).end());\r
-}\r
-const boost::iterator_range<const short*> gpu_write_frame::audio_data() const\r
-{\r
- return boost::iterator_range<const short*>(impl_->audio_data_.data(), impl_->audio_data_.data() + impl_->audio_data_.size());\r
-}\r
-int gpu_write_frame::tag() const {return impl_->tag_;}\r
-const core::pixel_format_desc& gpu_write_frame::get_pixel_format_desc() const{return impl_->desc_;}\r
-std::vector<safe_ptr<host_buffer>>& gpu_write_frame::get_plane_buffers(){return impl_->buffers_;}\r
-}}
\ No newline at end of file