]> git.sesse.net Git - casparcg/blob - protocol/cii/CIIProtocolStrategy.h
git-svn-id: https://casparcg.svn.sourceforge.net/svnroot/casparcg/server/branches...
[casparcg] / protocol / cii / CIIProtocolStrategy.h
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 #pragma once\r
22 \r
23 #include <core/video_channel.h>\r
24 \r
25 #include "../util/ProtocolStrategy.h"\r
26 #include "CIICommand.h"\r
27 \r
28 #include <core/producer/stage.h>\r
29 \r
30 #include <common/concurrency/executor.h>\r
31 \r
32 namespace caspar { namespace protocol { namespace cii {\r
33 \r
34 class CIIProtocolStrategy : public IO::IProtocolStrategy\r
35 {\r
36 public:\r
37         CIIProtocolStrategy(const std::vector<safe_ptr<core::video_channel>>& channels);\r
38 \r
39         void Parse(const TCHAR* pData, int charCount, IO::ClientInfoPtr pClientInfo);\r
40         UINT GetCodepage() {return 28591;}      //ISO 8859-1\r
41 \r
42         void SetProfile(const std::wstring& profile) {currentProfile_ = profile;}\r
43 \r
44         safe_ptr<core::video_channel> GetChannel() const{return this->pChannel_;}\r
45 \r
46         void DisplayMediaFile(const std::wstring& filename);\r
47         void DisplayTemplate(const std::wstring& titleName);\r
48         void WriteTemplateData(const std::wstring& templateName, const std::wstring& titleName, const std::wstring& xmlData);\r
49 \r
50 public:\r
51         struct TitleHolder\r
52         {\r
53                 TitleHolder() : titleName(TEXT("")), pframe_producer(core::frame_producer::empty())     {}\r
54                 TitleHolder(const std::wstring& name, safe_ptr<core::frame_producer> pFP) : titleName(name), pframe_producer(pFP) {}\r
55                 TitleHolder(const TitleHolder& th) : titleName(th.titleName), pframe_producer(th.pframe_producer) {}\r
56                 const TitleHolder& operator=(const TitleHolder& th) \r
57                 {\r
58                         titleName = th.titleName;\r
59                         pframe_producer = th.pframe_producer;\r
60                 }\r
61                 bool operator==(const TitleHolder& rhs) \r
62                 {\r
63                         return pframe_producer == rhs.pframe_producer;\r
64                 }\r
65 \r
66                 std::wstring titleName;\r
67                 safe_ptr<core::frame_producer> pframe_producer;\r
68                 friend CIIProtocolStrategy;\r
69         };\r
70 private:\r
71 \r
72         typedef std::list<TitleHolder> TitleList;\r
73         TitleList titles_;\r
74         safe_ptr<core::frame_producer> GetPreparedTemplate(const std::wstring& name);\r
75         void PutPreparedTemplate(const std::wstring& name, safe_ptr<core::frame_producer>& pframe_producer);\r
76 \r
77         static const TCHAR TokenDelimiter;\r
78         static const std::wstring MessageDelimiter;\r
79 \r
80         void ProcessMessage(const std::wstring& message);\r
81         int TokenizeMessage(const std::wstring& message, std::vector<std::wstring>* pTokenVector);\r
82         CIICommandPtr Create(const std::wstring& name);\r
83 \r
84         executor executor_;\r
85         std::wstring currentMessage_;\r
86 \r
87         std::wstring currentProfile_;\r
88         safe_ptr<core::video_channel> pChannel_;\r
89 };\r
90 \r
91 }}}