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