2 * Copyright (c) 2011 Sveriges Television AB <info@casparcg.com>
4 * This file is part of CasparCG (www.casparcg.com).
6 * CasparCG is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
11 * CasparCG is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with CasparCG. If not, see <http://www.gnu.org/licenses/>.
19 * Author: Nicklas P Andersson
25 #include <core/video_channel.h>
27 #include "../util/ProtocolStrategy.h"
28 #include "CIICommand.h"
30 #include <core/producer/stage.h>
32 #include <common/executor.h>
36 namespace caspar { namespace protocol { namespace cii {
38 class CIIProtocolStrategy : public IO::IProtocolStrategy
41 CIIProtocolStrategy(const std::vector<spl::shared_ptr<core::video_channel>>& channels);
43 void Parse(const TCHAR* pData, int charCount, IO::ClientInfoPtr pClientInfo);
44 std::string GetCodepage() {return "ISO-8859-1";} //ISO 8859-1
46 void SetProfile(const std::wstring& profile) {currentProfile_ = profile;}
48 spl::shared_ptr<core::video_channel> GetChannel() const{return this->pChannel_;}
50 void DisplayMediaFile(const std::wstring& filename);
51 void DisplayTemplate(const std::wstring& titleName);
52 void WriteTemplateData(const std::wstring& templateName, const std::wstring& titleName, const std::wstring& xmlData);
57 TitleHolder() : titleName(TEXT("")), pframe_producer(core::frame_producer::empty()) {}
58 TitleHolder(const std::wstring& name, spl::shared_ptr<core::frame_producer> pFP) : titleName(name), pframe_producer(pFP) {}
59 TitleHolder(const TitleHolder& th) : titleName(th.titleName), pframe_producer(th.pframe_producer) {}
60 const TitleHolder& operator=(const TitleHolder& th)
62 titleName = th.titleName;
63 pframe_producer = th.pframe_producer;
65 bool operator==(const TitleHolder& rhs)
67 return pframe_producer == rhs.pframe_producer;
70 std::wstring titleName;
71 spl::shared_ptr<core::frame_producer> pframe_producer;
72 friend CIIProtocolStrategy;
76 typedef std::list<TitleHolder> TitleList;
78 spl::shared_ptr<core::frame_producer> GetPreparedTemplate(const std::wstring& name);
79 void PutPreparedTemplate(const std::wstring& name, spl::shared_ptr<core::frame_producer>& pframe_producer);
81 static const TCHAR TokenDelimiter;
82 static const std::wstring MessageDelimiter;
84 void ProcessMessage(const std::wstring& message, IO::ClientInfoPtr pClientInfo);
85 int TokenizeMessage(const std::wstring& message, std::vector<std::wstring>* pTokenVector);
86 CIICommandPtr Create(const std::wstring& name);
89 std::wstring currentMessage_;
91 std::wstring currentProfile_;
92 spl::shared_ptr<core::video_channel> pChannel_;