\r
#include <agents.h>\r
#include <agents_extras.h>\r
+#include <ppl.h>\r
\r
#include <boost/algorithm/string.hpp>\r
#include <boost/foreach.hpp>\r
\r
filter_.push(av_frame);\r
\r
- while(true)\r
+ Concurrency::parallel_invoke(\r
+ [&]\r
{\r
- auto frame = filter_.poll();\r
- if(!frame)\r
- break;\r
- Concurrency::send<std::shared_ptr<AVFrame>>(*video_frames_, frame);\r
- }\r
- \r
- // It is assumed that audio is always equal or ahead of video.\r
- if(audio && SUCCEEDED(audio->GetBytes(&bytes)))\r
- {\r
- auto sample_frame_count = audio->GetSampleFrameCount();\r
- auto audio_data = reinterpret_cast<int32_t*>(bytes);\r
- Concurrency::send(*audio_buffers_, std::make_shared<core::audio_buffer>(audio_data, audio_data + sample_frame_count*format_desc_.audio_channels));\r
- }\r
- else\r
- Concurrency::send(*audio_buffers_, ffmpeg::empty_audio()); \r
+ while(true)\r
+ {\r
+ auto frame = filter_.poll();\r
+ if(!frame)\r
+ break;\r
+ Concurrency::send<std::shared_ptr<AVFrame>>(*video_frames_, frame);\r
+ }\r
+ },\r
+ [&]\r
+ { \r
+ // It is assumed that audio is always equal or ahead of video.\r
+ if(audio && SUCCEEDED(audio->GetBytes(&bytes)))\r
+ {\r
+ auto sample_frame_count = audio->GetSampleFrameCount();\r
+ auto audio_data = reinterpret_cast<int32_t*>(bytes);\r
+ Concurrency::send(*audio_buffers_, std::make_shared<core::audio_buffer>(audio_data, audio_data + sample_frame_count*format_desc_.audio_channels));\r
+ }\r
+ else\r
+ Concurrency::send(*audio_buffers_, ffmpeg::empty_audio()); \r
+ });\r
}\r
\r
}\r
filter& filter::operator=(filter&& other){impl_ = std::move(other.impl_); return *this;}\r
void filter::push(const std::shared_ptr<AVFrame>& frame){impl_->push(frame);}\r
std::shared_ptr<AVFrame> filter::poll(){return impl_->poll();}\r
+std::vector<safe_ptr<AVFrame>> filter::poll_all()\r
+{ \r
+ std::vector<safe_ptr<AVFrame>> frames;\r
+ while(true)\r
+ {\r
+ auto frame = poll();\r
+ if(!frame)\r
+ break;\r
+ frames.push_back(make_safe_ptr(frame));\r
+ }\r
+ return frames;\r
+}\r
\r
}}
\ No newline at end of file
auto av_frame = get_av_frame();\r
av_frame->data[0] = const_cast<uint8_t*>(frame->image_data().begin());\r
\r
- std::vector<safe_ptr<AVFrame>> frames;\r
- filter_.push(av_frame);\r
- while(true)\r
- {\r
- auto frame = filter_.poll();\r
- if(!frame)\r
- break;\r
- frames.push_back(make_safe_ptr(frame));\r
- }\r
+ auto frames = filter_.poll_all();\r
\r
if(frames.empty())\r
return;\r