]> git.sesse.net Git - casparcg/commitdiff
2.0.2: playlist_producer: Forgot to add files.
authorronag <ronag@362d55ac-95cf-4e76-9f9a-cbaa9c17b72d>
Fri, 25 Nov 2011 16:02:24 +0000 (16:02 +0000)
committerronag <ronag@362d55ac-95cf-4e76-9f9a-cbaa9c17b72d>
Fri, 25 Nov 2011 16:02:24 +0000 (16:02 +0000)
git-svn-id: https://casparcg.svn.sourceforge.net/svnroot/casparcg/server/branches/2.0.2@1656 362d55ac-95cf-4e76-9f9a-cbaa9c17b72d

core/producer/playlist/playlist_producer.cpp [new file with mode: 0644]
core/producer/playlist/playlist_producer.h [new file with mode: 0644]

diff --git a/core/producer/playlist/playlist_producer.cpp b/core/producer/playlist/playlist_producer.cpp
new file mode 100644 (file)
index 0000000..885f2b5
--- /dev/null
@@ -0,0 +1,121 @@
+/*\r
+* copyright (c) 2010 Sveriges Television AB <info@casparcg.com>\r
+*\r
+*  This file is part of CasparCG.\r
+*\r
+*    CasparCG is free software: you can redistribute it and/or modify\r
+*    it under the terms of the GNU General Public License as published by\r
+*    the Free Software Foundation, either version 3 of the License, or\r
+*    (at your option) any later version.\r
+*\r
+*    CasparCG is distributed in the hope that it will be useful,\r
+*    but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+*    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+*    GNU General Public License for more details.\r
+\r
+*    You should have received a copy of the GNU General Public License\r
+*    along with CasparCG.  If not, see <http://www.gnu.org/licenses/>.\r
+*\r
+*/ \r
+#include "../../stdafx.h"\r
+\r
+#include "playlist_producer.h"\r
+\r
+#include <core/producer/frame_producer.h>\r
+#include <core/producer/frame/basic_frame.h>\r
+\r
+namespace caspar { namespace core {    \r
+\r
+struct playlist_producer : public frame_producer\r
+{                              \r
+       safe_ptr<frame_factory>                         factory_;\r
+       safe_ptr<basic_frame>                           last_frame_;\r
+       safe_ptr<frame_producer>                        current_;\r
+       bool                                                            loop_;\r
+\r
+       std::list<safe_ptr<frame_producer>> producers_;\r
+\r
+       playlist_producer(const safe_ptr<frame_factory>& factory, bool loop) \r
+               : factory_(factory)\r
+               , last_frame_(basic_frame::empty())\r
+               , current_(frame_producer::empty())\r
+               , loop_(loop)\r
+       {\r
+       }\r
+       \r
+       virtual safe_ptr<basic_frame> receive(int hints)\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
+\r
+               auto frame = current_->receive(hints);\r
+               if(frame == basic_frame::eof())\r
+               {\r
+                       current_ = frame_producer::empty();\r
+                       return receive(hints);\r
+               }\r
+\r
+               return last_frame_ = frame;\r
+       }\r
+\r
+       virtual safe_ptr<core::basic_frame> last_frame() const\r
+       {\r
+               return disable_audio(last_frame_);\r
+       }\r
+\r
+       virtual std::wstring print() const\r
+       {\r
+               return L"playlist[]";\r
+       }       \r
+\r
+       virtual int64_t nb_frames() const \r
+       {\r
+               return std::numeric_limits<int>::max();\r
+       }\r
+\r
+       virtual std::wstring param(const std::wstring& param)\r
+       {\r
+               const static std::wstring push_front_str        = L"PUSH_FRONT ";\r
+               const static std::wstring push_back_str         = L"PUSH_BACK ";\r
+\r
+               auto pos = param.find(push_front_str);\r
+\r
+               if(pos  != std::wstring::npos)\r
+                       push_front(param.substr(pos+push_front_str.size()));\r
+                               \r
+               pos = param.find(push_back_str);\r
+               \r
+               if(pos  != std::wstring::npos)\r
+                       push_back(param.substr(pos+push_back_str.size()));\r
+\r
+               return L"";\r
+       }\r
+       \r
+       void push_back(const std::wstring& param)\r
+       {\r
+               producers_.push_back(create_producer(factory_, param)); \r
+       }\r
+\r
+       void push_front(const std::wstring& param)\r
+       {\r
+               producers_.push_front(create_producer(factory_, param)); \r
+       }\r
+};\r
+\r
+safe_ptr<frame_producer> create_playlist_producer(const safe_ptr<core::frame_factory>& frame_factory, const std::vector<std::wstring>& params)\r
+{\r
+       if(boost::range::find(params, L"PLAYLIST") == params.end())\r
+               return core::frame_producer::empty();\r
+\r
+       bool loop = boost::range::find(params, L"LOOP") != params.end();\r
+\r
+       return make_safe<playlist_producer>(frame_factory, loop);\r
+}\r
+\r
+}}\r
+\r
diff --git a/core/producer/playlist/playlist_producer.h b/core/producer/playlist/playlist_producer.h
new file mode 100644 (file)
index 0000000..efb5421
--- /dev/null
@@ -0,0 +1,32 @@
+/*\r
+* copyright (c) 2010 Sveriges Television AB <info@casparcg.com>\r
+*\r
+*  This file is part of CasparCG.\r
+*\r
+*    CasparCG is free software: you can redistribute it and/or modify\r
+*    it under the terms of the GNU General Public License as published by\r
+*    the Free Software Foundation, either version 3 of the License, or\r
+*    (at your option) any later version.\r
+*\r
+*    CasparCG is distributed in the hope that it will be useful,\r
+*    but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+*    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+*    GNU General Public License for more details.\r
+\r
+*    You should have received a copy of the GNU General Public License\r
+*    along with CasparCG.  If not, see <http://www.gnu.org/licenses/>.\r
+*\r
+*/\r
+#pragma once\r
+\r
+#include "../frame_producer.h"\r
+\r
+#include <string>\r
+#include <memory>\r
+#include <vector>\r
+\r
+namespace caspar { namespace core {\r
+       \r
+safe_ptr<frame_producer> create_playlist_producer(const safe_ptr<core::frame_factory>& frame_factory, const std::vector<std::wstring>& params);\r
+\r
+}}
\ No newline at end of file