#include <common/log.h>\r
#include <common/param.h>\r
#include <common/diagnostics/graph.h>\r
+#include <common/future.h>\r
\r
#include <core/video_format.h>\r
#include <core/producer/frame_producer.h>\r
\r
boost::unique_future<std::wstring> call(const std::wstring& param) override\r
{\r
- boost::promise<std::wstring> promise;\r
- promise.set_value(do_call(param));\r
- return promise.get_future();\r
+ static const boost::wregex loop_exp(L"LOOP\\s*(?<VALUE>\\d?)?", boost::regex::icase);\r
+ static const boost::wregex seek_exp(L"SEEK\\s+(?<VALUE>\\d+)", boost::regex::icase);\r
+ static const boost::wregex length_exp(L"LENGTH\\s+(?<VALUE>\\d+)", boost::regex::icase);\r
+ static const boost::wregex start_exp(L"START\\s+(?<VALUE>\\d+)", boost::regex::icase);\r
+\r
+ std::wstring result;\r
+ \r
+ boost::wsmatch what;\r
+ if(boost::regex_match(param, what, loop_exp))\r
+ {\r
+ if(!what["VALUE"].str().empty())\r
+ input_.loop(boost::lexical_cast<bool>(what["VALUE"].str()));\r
+ result = boost::lexical_cast<std::wstring>(input_.loop());\r
+ }\r
+ else if(boost::regex_match(param, what, seek_exp))\r
+ {\r
+ input_.seek(boost::lexical_cast<uint32_t>(what["VALUE"].str()));\r
+ }\r
+ else if(boost::regex_match(param, what, length_exp))\r
+ {\r
+ if(!what["LENGTH"].str().empty())\r
+ {\r
+ if(boost::iequals(what["LENGTH"].str(), "NaN"))\r
+ input_.length(std::numeric_limits<uint32_t>::max());\r
+ else\r
+ input_.length(boost::lexical_cast<uint32_t>(what["LENGTH"].str()));\r
+ }\r
+ result = boost::lexical_cast<std::wstring>(input_.length());\r
+ }\r
+ else if(boost::regex_match(param, what, start_exp))\r
+ {\r
+ if(!what["START"].str().empty())\r
+ input_.start(boost::lexical_cast<uint32_t>(what["START"].str()));\r
+ result = boost::lexical_cast<std::wstring>(input_.start());\r
+ }\r
+ else\r
+ BOOST_THROW_EXCEPTION(invalid_argument());\r
+\r
+ return async(launch::deferred, [=]{return result;});\r
}\r
\r
std::wstring print() const override\r
{\r
return video_decoder_ ? ffmpeg::print_mode(video_decoder_->width(), video_decoder_->height(), fps_, !video_decoder_->is_progressive()) : L"n/a";\r
}\r
- \r
- std::wstring do_call(const std::wstring& param)\r
- {\r
- static const boost::wregex loop_exp(L"LOOP\\s*(?<VALUE>\\d?)?", boost::regex::icase);\r
- static const boost::wregex seek_exp(L"SEEK\\s+(?<VALUE>\\d+)", boost::regex::icase);\r
- static const boost::wregex length_exp(L"LENGTH\\s+(?<VALUE>\\d+)", boost::regex::icase);\r
- static const boost::wregex start_exp(L"START\\s+(?<VALUE>\\d+)", boost::regex::icase);\r
- \r
- boost::wsmatch what;\r
- if(boost::regex_match(param, what, loop_exp))\r
- {\r
- if(!what["VALUE"].str().empty())\r
- input_.loop(boost::lexical_cast<bool>(what["VALUE"].str()));\r
- return boost::lexical_cast<std::wstring>(input_.loop());\r
- }\r
- if(boost::regex_match(param, what, seek_exp))\r
- {\r
- input_.seek(boost::lexical_cast<uint32_t>(what["VALUE"].str()));\r
- return L"";\r
- }\r
- if(boost::regex_match(param, what, length_exp))\r
- {\r
- if(!what["LENGTH"].str().empty())\r
- {\r
- if(boost::iequals(what["LENGTH"].str(), "NaN"))\r
- input_.length(std::numeric_limits<uint32_t>::max());\r
- else\r
- input_.length(boost::lexical_cast<uint32_t>(what["LENGTH"].str()));\r
- }\r
- return boost::lexical_cast<std::wstring>(input_.length());\r
- }\r
- if(boost::regex_match(param, what, start_exp))\r
- {\r
- if(!what["START"].str().empty())\r
- input_.start(boost::lexical_cast<uint32_t>(what["START"].str()));\r
- return boost::lexical_cast<std::wstring>(input_.start());\r
- }\r
-\r
- BOOST_THROW_EXCEPTION(invalid_argument());\r
- }\r
-\r
+ \r
bool try_decode_frame(core::draw_frame& result)\r
{\r
for(int n = 0; n < 32; ++n)\r