]> git.sesse.net Git - casparcg/blob - core/processor/read_frame.cpp
89993bf76be17fcdc6219284e3881a1b656e8f58
[casparcg] / core / processor / read_frame.cpp
1 #include "../StdAfx.h"\r
2 \r
3 #include "read_frame.h"\r
4 \r
5 #include "host_buffer.h"\r
6 \r
7 #include <common/gl/gl_check.h>\r
8 \r
9 namespace caspar { namespace core {\r
10                                                                                                                                                                                                                                                                                                                         \r
11 struct read_frame::implementation : boost::noncopyable\r
12 {\r
13         safe_ptr<const host_buffer> image_data_;\r
14         std::vector<short> audio_data_;\r
15 \r
16 public:\r
17         implementation(safe_ptr<const host_buffer>&& image_data, std::vector<short>&& audio_data) \r
18                 : image_data_(std::move(image_data))\r
19                 , audio_data_(std::move(audio_data)){}  \r
20 };\r
21 \r
22 read_frame::read_frame(){}\r
23 read_frame::read_frame(safe_ptr<const host_buffer>&& image_data, std::vector<short>&& audio_data) : impl_(new implementation(std::move(image_data), std::move(audio_data))){}\r
24 \r
25 const boost::iterator_range<const unsigned char*> read_frame::image_data() const\r
26 {\r
27         if(!impl_ || !impl_->image_data_->data())\r
28                 return boost::iterator_range<const unsigned char*>();\r
29         auto ptr = static_cast<const unsigned char*>(impl_->image_data_->data());\r
30         return boost::iterator_range<const unsigned char*>(ptr, ptr + impl_->image_data_->size());\r
31 }\r
32 const boost::iterator_range<const short*> read_frame::audio_data() const\r
33 {\r
34         if(!impl_)\r
35                 return boost::iterator_range<const short*>();\r
36         return boost::iterator_range<const short*>(impl_->audio_data_.data(), impl_->audio_data_.data() + impl_->audio_data_.size());\r
37 }\r
38 \r
39 }}