]> git.sesse.net Git - casparcg/blob - protocol/amcp/AMCPCommandsImpl.h
f376d8463f044caaf36146ddf0ad286c2fbd9c0d
[casparcg] / protocol / amcp / AMCPCommandsImpl.h
1 /*\r
2 * Copyright 2013 Sveriges Television AB http://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 #ifndef __AMCPCOMMANDSIMPL_H__\r
24 #define __AMCPCOMMANDSIMPL_H__\r
25 \r
26 #include "AMCPCommand.h"\r
27 \r
28 namespace caspar {\r
29 \r
30 namespace core {\r
31         struct frame_transform;\r
32         struct frame_producer;\r
33 }\r
34 \r
35 namespace protocol {\r
36 \r
37 std::wstring ListMedia();\r
38 std::wstring ListTemplates();\r
39 \r
40 namespace amcp {\r
41         \r
42 class ChannelGridCommand : public AMCPCommandBase<false, AddToQueue, 0>\r
43 {\r
44         std::wstring print() const { return L"ChannelGridCommand";}\r
45         bool DoExecute();\r
46 };\r
47 \r
48 class DiagnosticsCommand : public AMCPCommandBase<false, AddToQueue, 0>\r
49 {\r
50         std::wstring print() const { return L"DiagnosticsCommand";}\r
51         bool DoExecute();\r
52 };\r
53 \r
54 class CallCommand : public AMCPCommandBase<true, AddToQueue, 1>\r
55 {\r
56         std::wstring print() const { return L"CallCommand";}\r
57         bool DoExecute();\r
58 };\r
59 \r
60 class MixerCommand : public AMCPCommandBase<true, AddToQueue, 1>\r
61 {\r
62         std::wstring print() const { return L"MixerCommand";}\r
63         core::frame_transform get_current_transform();\r
64         template<typename Func>\r
65         bool reply_value(const Func& extractor)\r
66         {\r
67                 auto value = extractor(get_current_transform());\r
68 \r
69                 SetReplyString(L"201 MIXER OK\r\n"\r
70                         + boost::lexical_cast<std::wstring>(value) + L"\r\n");\r
71 \r
72                 return true;\r
73         }\r
74         bool DoExecute();\r
75 };\r
76         \r
77 class AddCommand : public AMCPCommandBase<true, AddToQueue, 1>\r
78 {\r
79         std::wstring print() const { return L"AddCommand";}\r
80         bool DoExecute();\r
81 };\r
82 \r
83 class RemoveCommand : public AMCPCommandBase<true, AddToQueue, 0>\r
84 {\r
85         std::wstring print() const { return L"RemoveCommand";}\r
86         bool DoExecute();\r
87 };\r
88 \r
89 class SwapCommand : public AMCPCommandBase<true, AddToQueue, 1>\r
90 {\r
91         std::wstring print() const { return L"SwapCommand";}\r
92         bool DoExecute();\r
93 };\r
94 \r
95 class RouteCommand : public AMCPCommandBase<true, AddToQueue, 1>\r
96 {\r
97         std::wstring print() const { return L"RouteCommand";}\r
98         bool DoExecute();\r
99 public:\r
100         static safe_ptr<core::frame_producer> TryCreateProducer(AMCPCommand& command, std::wstring const& uri);\r
101 };\r
102 \r
103 /*class RouteCommand : public AMCPCommandBase<true, AddToQueue, 1>\r
104 {\r
105         std::wstring print() const { return L"RouteCommand";}\r
106         bool DoExecute();\r
107 };*/\r
108 \r
109 class LoadCommand : public AMCPCommandBase<true, AddToQueue, 1>\r
110 {\r
111         std::wstring print() const { return L"LoadCommand";}\r
112         bool DoExecute();\r
113 };\r
114 \r
115 class LoadbgCommand : public AMCPCommandBase<true, AddToQueue, 1>\r
116 {\r
117         std::wstring print() const { return L"LoadbgCommand";}\r
118         bool DoExecute();\r
119 };\r
120 \r
121 class PlayCommand: public AMCPCommandBase<true, AddToQueue, 0>\r
122 {\r
123         std::wstring print() const { return L"PlayCommand";}\r
124         bool DoExecute();\r
125 };\r
126 \r
127 class PauseCommand: public AMCPCommandBase<true, AddToQueue, 0>\r
128 {\r
129         std::wstring print() const { return L"PauseCommand";}\r
130         bool DoExecute();\r
131 };\r
132 \r
133 class StopCommand : public AMCPCommandBase<true, AddToQueue, 0>\r
134 {\r
135         std::wstring print() const { return L"StopCommand";}\r
136         bool DoExecute();\r
137 };\r
138 \r
139 class ClearCommand : public AMCPCommandBase<true, AddToQueue, 0>\r
140 {\r
141         std::wstring print() const { return L"ClearCommand";}\r
142         bool DoExecute();\r
143 };\r
144 \r
145 class PrintCommand : public AMCPCommandBase<true, AddToQueue, 0>\r
146 {\r
147         std::wstring print() const { return L"PrintCommand";}\r
148         bool DoExecute();\r
149 };\r
150 \r
151 class LogCommand : public AMCPCommandBase<false, AddToQueue, 0>\r
152 {\r
153         std::wstring print() const { return L"LogCommand";}\r
154         bool DoExecute();\r
155 };\r
156 \r
157 class CGCommand : public AMCPCommandBase<true, AddToQueue, 1>\r
158 {\r
159         std::wstring print() const { return L"CGCommand";}\r
160         bool DoExecute();\r
161         bool ValidateLayer(const std::wstring& layerstring);\r
162 \r
163         bool DoExecuteAdd();\r
164         bool DoExecutePlay();\r
165         bool DoExecuteStop();\r
166         bool DoExecuteNext();\r
167         bool DoExecuteRemove();\r
168         bool DoExecuteClear();\r
169         bool DoExecuteUpdate();\r
170         bool DoExecuteInvoke();\r
171         bool DoExecuteInfo();\r
172 };\r
173 \r
174 class DataCommand : public AMCPCommandBase<false, AddToQueue, 1>\r
175 {\r
176         std::wstring print() const { return L"DataCommand";}\r
177         bool DoExecute();\r
178         bool DoExecuteStore();\r
179         bool DoExecuteRetrieve();\r
180         bool DoExecuteRemove();\r
181         bool DoExecuteList();\r
182 };\r
183 \r
184 class ThumbnailCommand : public AMCPCommandBase<false, AddToQueue, 1>\r
185 {\r
186         std::wstring print() const { return L"ThumbnailCommand";}\r
187         bool DoExecute();\r
188         bool DoExecuteRetrieve();\r
189         bool DoExecuteList();\r
190         bool DoExecuteGenerate();\r
191         bool DoExecuteGenerateAll();\r
192 };\r
193 \r
194 class ClsCommand : public AMCPCommandBase<false, AddToQueue, 0>\r
195 {\r
196         std::wstring print() const { return L"ClsCommand";}\r
197         bool DoExecute();\r
198 };\r
199 \r
200 class TlsCommand : public AMCPCommandBase<false, AddToQueue, 0>\r
201 {\r
202         std::wstring print() const { return L"TlsCommand";}\r
203         bool DoExecute();\r
204 };\r
205 \r
206 class CinfCommand : public AMCPCommandBase<false, AddToQueue, 1>\r
207 {\r
208         std::wstring print() const { return L"CinfCommand";}\r
209         bool DoExecute();\r
210 };\r
211 \r
212 class InfoCommand : public AMCPCommandBase<false, AddToQueue, 0>\r
213 {\r
214 public:\r
215         std::wstring print() const { return L"InfoCommand";}\r
216         InfoCommand(const std::vector<safe_ptr<core::video_channel>>& channels) : channels_(channels){}\r
217         bool DoExecute();\r
218 private:\r
219         const std::vector<safe_ptr<core::video_channel>>& channels_;\r
220 };\r
221 \r
222 class VersionCommand : public AMCPCommandBase<false, AddToQueue, 0>\r
223 {\r
224         std::wstring print() const { return L"VersionCommand";}\r
225         bool DoExecute();\r
226 };\r
227 \r
228 class ByeCommand : public AMCPCommandBase<false, AddToQueue, 0>\r
229 {\r
230         std::wstring print() const { return L"ByeCommand";}\r
231         bool DoExecute();\r
232 };\r
233 \r
234 class SetCommand : public AMCPCommandBase<true, AddToQueue, 2>\r
235 {\r
236         std::wstring print() const { return L"SetCommand";}\r
237         bool DoExecute();\r
238 };\r
239 \r
240 class KillCommand : public AMCPCommandBase<false, AddToQueue, 0>\r
241 {\r
242         std::wstring print() const { return L"KillCommand";}\r
243         bool DoExecute();\r
244 };\r
245 \r
246 class RestartCommand : public AMCPCommandBase<false, AddToQueue, 0>\r
247 {\r
248         std::wstring print() const { return L"RestartCommand";}\r
249         bool DoExecute();\r
250 };\r
251 \r
252 }       //namespace amcp\r
253 }}      //namespace caspar\r
254 \r
255 #endif  //__AMCPCOMMANDSIMPL_H__