]> git.sesse.net Git - casparcg/blob - core/producer/flash/ct_producer.cpp
2.0.0.2: Mayor flash producer readability and maintainability improvements.
[casparcg] / core / producer / flash / ct_producer.cpp
1 /*\r
2 * copyright (c) 2010 Sveriges Television AB <info@casparcg.com>\r
3 *\r
4 *  This file is part of CasparCG.\r
5 *\r
6 *    CasparCG is free software: you can redistribute it and/or modify\r
7 *    it under the terms of the GNU General Public License as published by\r
8 *    the Free Software Foundation, either version 3 of the License, or\r
9 *    (at your option) any later version.\r
10 *\r
11 *    CasparCG is distributed in the hope that it will be useful,\r
12 *    but WITHOUT ANY WARRANTY; without even the implied warranty of\r
13 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
14 *    GNU General Public License for more details.\r
15 \r
16 *    You should have received a copy of the GNU General Public License\r
17 *    along with CasparCG.  If not, see <http://www.gnu.org/licenses/>.\r
18 *\r
19 */\r
20  \r
21 #include "../../stdafx.h"\r
22 \r
23 #include "ct_producer.h"\r
24 \r
25 #include "cg_producer.h"\r
26 \r
27 #include "../../processor/draw_frame.h"\r
28 #include "../../server.h"\r
29 \r
30 #include <boost/assign/list_of.hpp>\r
31 \r
32 using namespace boost::assign;\r
33 \r
34 namespace caspar { namespace core { namespace flash {\r
35 \r
36 struct ct_producer : public cg_producer\r
37 {\r
38         ct_producer(ct_producer&& other) : initialized_(std::move(other.initialized_)), filename_(std::move(other.filename_)){}\r
39         ct_producer(const std::wstring& filename) : filename_(filename), initialized_(false){}\r
40 \r
41         safe_ptr<draw_frame> receive()\r
42         {\r
43                 if(!initialized_)\r
44                 {\r
45                         cg_producer::add(0, filename_, 1);\r
46                         initialized_ = true;\r
47                 }\r
48                 return cg_producer::receive();\r
49         }\r
50 \r
51         std::wstring print() const\r
52         {\r
53                 return L"ct[" + filename_ + L"]";\r
54         }\r
55 \r
56         bool initialized_;\r
57         std::wstring filename_;\r
58 };\r
59         \r
60 safe_ptr<frame_producer> create_ct_producer(const std::vector<std::wstring>& params) \r
61 {\r
62         std::wstring filename = server::media_folder() + L"\\" + params[0] + L".ct";\r
63         return boost::filesystem::exists(filename) ? make_safe<ct_producer>(filename) : frame_producer::empty();\r
64 }\r
65 \r
66 }}}