]> git.sesse.net Git - casparcg/commitdiff
git-svn-id: https://casparcg.svn.sourceforge.net/svnroot/casparcg/server/branches...
authorronag <ronag@362d55ac-95cf-4e76-9f9a-cbaa9c17b72d>
Sat, 10 Mar 2012 10:31:25 +0000 (10:31 +0000)
committerronag <ronag@362d55ac-95cf-4e76-9f9a-cbaa9c17b72d>
Sat, 10 Mar 2012 10:31:25 +0000 (10:31 +0000)
modules/ffmpeg/producer/ffmpeg_producer.cpp

index f1074d99bfe6b7190ad26a65148748c5b2b4c467..a2528946c1e1945354eec8c265a46800a9824de1 100644 (file)
@@ -35,6 +35,7 @@
 #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
@@ -214,9 +215,45 @@ public:
        \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
@@ -265,47 +302,7 @@ public:
        {\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