]> 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, 26 Nov 2011 22:42:48 +0000 (22:42 +0000)
committerronag <ronag@362d55ac-95cf-4e76-9f9a-cbaa9c17b72d>
Sat, 26 Nov 2011 22:42:48 +0000 (22:42 +0000)
core/producer/playlist/playlist_producer.cpp

index 4ff24b6a6c0f3af5afe4ea53dfa1762b367bdc04..204ffcc9d34154ccbb8bf2a9de80ade95523943b 100644 (file)
@@ -52,12 +52,7 @@ struct playlist_producer : public frame_producer
        virtual safe_ptr<basic_frame> receive(int hints) override\r
        {\r
                if(current_ == frame_producer::empty() && !producers_.empty())\r
-               {\r
-                       current_ = producers_.front();\r
-                       producers_.pop_front();\r
-                       if(loop_)\r
-                               producers_.push_back(current_);\r
-               }\r
+                       next();\r
 \r
                auto frame = current_->receive(hints);\r
                if(frame == basic_frame::eof())\r
@@ -76,7 +71,7 @@ struct playlist_producer : public frame_producer
 \r
        virtual std::wstring print() const override\r
        {\r
-               return L"playlist[]";\r
+               return L"playlist[" + current_->print() + L"]";\r
        }       \r
 \r
        virtual int64_t nb_frames() const  override\r
@@ -98,7 +93,9 @@ struct playlist_producer : public frame_producer
                static const boost::wregex push_front_exp       (L"PUSH_FRONT (?<PARAM>.+)");           \r
                static const boost::wregex push_back_exp        (L"(PUSH_BACK|PUSH) (?<PARAM>.+)");\r
                static const boost::wregex pop_front_exp        (L"POP_FRONT");         \r
-               static const boost::wregex pop_back_exp         (L"(POP_BACK|POP)");                    \r
+               static const boost::wregex pop_back_exp         (L"(POP_BACK|POP)");\r
+               static const boost::wregex clear_exp            (L"CLEAR");\r
+               static const boost::wregex next_exp                     (L"NEXT");\r
                static const boost::wregex insert_exp           (L"INSERT (?<POS>\\d+) (?<PARAM>.+)");  \r
                static const boost::wregex remove_exp           (L"REMOVE (?<POS>\\d+) (?<PARAM>.+)");  \r
                static const boost::wregex list_exp                     (L"LIST");                      \r
@@ -114,6 +111,10 @@ struct playlist_producer : public frame_producer
                        return pop_front(); \r
                else if(boost::regex_match(param, what, pop_back_exp))\r
                        return pop_back(); \r
+               else if(boost::regex_match(param, what, clear_exp))\r
+                       return clear();\r
+               else if(boost::regex_match(param, what, next_exp))\r
+                       return next(); \r
                else if(boost::regex_match(param, what, insert_exp))\r
                        return insert(boost::lexical_cast<size_t>(what["POS"].str()), what["PARAM"].str());\r
                else if(boost::regex_match(param, what, remove_exp))\r
@@ -154,6 +155,24 @@ struct playlist_producer : public frame_producer
                return L"";\r
        }\r
        \r
+       std::wstring clear()\r
+       {\r
+               producers_.clear();\r
+               return L"";\r
+       }\r
+\r
+       std::wstring next()\r
+       {\r
+               if(!producers_.empty())\r
+               {\r
+                       current_ = producers_.front();\r
+                       producers_.pop_front();\r
+                       if(loop_)\r
+                               producers_.push_back(current_);\r
+               }\r
+               return L"";\r
+       }\r
+       \r
        std::wstring  insert(size_t pos, const std::wstring& str)\r
        {\r
                if(pos >= producers_.size())\r
@@ -172,7 +191,7 @@ struct playlist_producer : public frame_producer
 \r
        std::wstring list() const\r
        {\r
-               std::wstring result = L"<playlist>";\r
+               std::wstring result = L"<playlist>\n";\r
                BOOST_FOREACH(auto& producer, producers_)               \r
                        result += L"\t<producer>" + producer->print() + L"</producer>\n";\r
                return result + L"</playlist>";\r