]> git.sesse.net Git - casparcg/blob - protocol/amcp/AMCPCommandsImpl.h
Manually merged 0edf4e5 (excluding changes to ffmpeg) from master
[casparcg] / protocol / amcp / AMCPCommandsImpl.h
1 /*
2 * Copyright (c) 2011 Sveriges Television AB <info@casparcg.com>
3 *
4 * This file is part of CasparCG (www.casparcg.com).
5 *
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.
10 *
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.
15 *
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/>.
18 *
19 * Author: Nicklas P Andersson
20 */
21
22  
23 #ifndef __AMCPCOMMANDSIMPL_H__
24 #define __AMCPCOMMANDSIMPL_H__
25
26 #include "AMCPCommand.h"
27
28 #include <core/thumbnail_generator.h>
29
30 namespace caspar { namespace protocol {
31         
32 std::wstring ListMedia();
33 std::wstring ListTemplates();
34
35 namespace amcp {
36         
37 class ChannelGridCommand : public AMCPCommandBase<0>
38 {
39 public:
40         explicit ChannelGridCommand(IO::ClientInfoPtr client) : AMCPCommandBase(client) {}
41         std::wstring print() const { return L"ChannelGridCommand";}
42         bool DoExecute();
43 };
44
45 class DiagnosticsCommand : public AMCPCommandBase<0>
46 {
47 public:
48         explicit DiagnosticsCommand(IO::ClientInfoPtr client) : AMCPCommandBase(client) {}
49         std::wstring print() const { return L"DiagnosticsCommand";}
50         bool DoExecute();
51 };
52
53 class CallCommand : public AMCPChannelCommandBase<1>
54 {
55 public:
56         CallCommand(IO::ClientInfoPtr client, const channel_context& channel, unsigned int channel_index, int layer_index) : AMCPChannelCommandBase(client, channel, channel_index, layer_index)
57         {}
58
59 private:
60         std::wstring print() const { return L"CallCommand";}
61         bool DoExecute();
62 };
63
64 class MixerCommand : public AMCPChannelCommandBase<1>
65 {
66 public:
67         MixerCommand(IO::ClientInfoPtr client, const channel_context& channel, unsigned int channel_index, int layer_index) : AMCPChannelCommandBase(client, channel, channel_index, layer_index)
68         {}
69
70 private:
71         std::wstring print() const { return L"MixerCommand";}
72         bool DoExecute();
73 };
74         
75 class AddCommand : public AMCPChannelCommandBase<1>
76 {
77 public:
78         AddCommand(IO::ClientInfoPtr client, const channel_context& channel, unsigned int channel_index, int layer_index) : AMCPChannelCommandBase(client, channel, channel_index, layer_index)
79         {}
80
81 private:
82         std::wstring print() const { return L"AddCommand";}
83         bool DoExecute();
84 };
85
86 class RemoveCommand : public AMCPChannelCommandBase<0>
87 {
88 public:
89         RemoveCommand(IO::ClientInfoPtr client, const channel_context& channel, unsigned int channel_index, int layer_index) : AMCPChannelCommandBase(client, channel, channel_index, layer_index)
90         {}
91
92 private:
93         std::wstring print() const { return L"RemoveCommand";}
94         bool DoExecute();
95 };
96
97 class SwapCommand : public AMCPChannelCommandBase<1>, AMCPChannelsAwareCommand
98 {
99 public:
100         SwapCommand(IO::ClientInfoPtr client, const channel_context& channel, unsigned int channel_index, int layer_index, const std::vector<channel_context>& channels) : AMCPChannelCommandBase(client, channel, channel_index, layer_index), AMCPChannelsAwareCommand(channels)
101         {}
102
103 private:
104         std::wstring print() const { return L"SwapCommand";}
105         bool DoExecute();
106 };
107
108 class LoadCommand : public AMCPChannelCommandBase<1>
109 {
110 public:
111         LoadCommand(IO::ClientInfoPtr client, const channel_context& channel, unsigned int channel_index, int layer_index) : AMCPChannelCommandBase(client, channel, channel_index, layer_index)
112         {}
113
114 private:
115         std::wstring print() const { return L"LoadCommand";}
116         bool DoExecute();
117 };
118
119
120 class PlayCommand: public AMCPChannelCommandBase<0>, public AMCPChannelsAwareCommand
121 {
122 public:
123         PlayCommand(IO::ClientInfoPtr client, const channel_context& channel, unsigned int channel_index, int layer_index, const std::vector<channel_context>& channels) : AMCPChannelCommandBase(client, channel, channel_index, layer_index), AMCPChannelsAwareCommand(channels)
124         {}
125
126 private:
127         std::wstring print() const { return L"PlayCommand";}
128         bool DoExecute();
129 };
130
131 class LoadbgCommand : public AMCPChannelCommandBase<1>, public AMCPChannelsAwareCommand
132 {
133 public:
134         LoadbgCommand(IO::ClientInfoPtr client, const channel_context& channel, unsigned int channel_index, int layer_index, const std::vector<channel_context>& channels) : AMCPChannelCommandBase(client, channel, channel_index, layer_index), AMCPChannelsAwareCommand(channels)
135         {}
136         LoadbgCommand(const PlayCommand& rhs) : AMCPChannelCommandBase<1>(rhs), AMCPChannelsAwareCommand(rhs) {}
137
138 private:
139         std::wstring print() const { return L"LoadbgCommand";}
140         bool DoExecute();
141 };
142
143 class PauseCommand: public AMCPChannelCommandBase<0>
144 {
145 public:
146         PauseCommand(IO::ClientInfoPtr client, const channel_context& channel, unsigned int channel_index, int layer_index) : AMCPChannelCommandBase(client, channel, channel_index, layer_index)
147         {}
148
149 private:
150         std::wstring print() const { return L"PauseCommand";}
151         bool DoExecute();
152 };
153
154 class StopCommand : public AMCPChannelCommandBase<0>
155 {
156 public:
157         StopCommand(IO::ClientInfoPtr client, const channel_context& channel, unsigned int channel_index, int layer_index) : AMCPChannelCommandBase(client, channel, channel_index, layer_index)
158         {}
159
160 private:
161         std::wstring print() const { return L"StopCommand";}
162         bool DoExecute();
163 };
164
165 class ClearCommand : public AMCPChannelCommandBase<0>
166 {
167 public:
168         ClearCommand(IO::ClientInfoPtr client, const channel_context& channel, unsigned int channel_index, int layer_index) : AMCPChannelCommandBase(client, channel, channel_index, layer_index)
169         {}
170
171 private:
172         std::wstring print() const { return L"ClearCommand";}
173         bool DoExecute();
174 };
175
176 class PrintCommand : public AMCPChannelCommandBase<0>
177 {
178 public:
179         PrintCommand(IO::ClientInfoPtr client, const channel_context& channel, unsigned int channel_index, int layer_index) : AMCPChannelCommandBase(client, channel, channel_index, layer_index)
180         {}
181
182 private:
183         std::wstring print() const { return L"PrintCommand";}
184         bool DoExecute();
185 };
186
187 class LogCommand : public AMCPCommandBase<2>
188 {
189 public:
190         explicit LogCommand(IO::ClientInfoPtr client) : AMCPCommandBase(client) {}
191         std::wstring print() const { return L"LogCommand";}
192         bool DoExecute();
193 };
194
195 class CGCommand : public AMCPChannelCommandBase<1>
196 {
197 public:
198         CGCommand(IO::ClientInfoPtr client, const channel_context& channel, unsigned int channel_index, int layer_index) : AMCPChannelCommandBase(client, channel, channel_index, layer_index)
199         {}
200
201 private:
202         std::wstring print() const { return L"CGCommand";}
203         bool DoExecute();
204         bool ValidateLayer(const std::wstring& layerstring);
205
206         bool DoExecuteAdd();
207         bool DoExecutePlay();
208         bool DoExecuteStop();
209         bool DoExecuteNext();
210         bool DoExecuteRemove();
211         bool DoExecuteClear();
212         bool DoExecuteUpdate();
213         bool DoExecuteInvoke();
214         bool DoExecuteInfo();
215 };
216
217 class DataCommand : public AMCPCommandBase<1>
218 {
219 public:
220         explicit DataCommand(IO::ClientInfoPtr client) : AMCPCommandBase(client) {}
221
222         std::wstring print() const { return L"DataCommand";}
223         bool DoExecute();
224         bool DoExecuteStore();
225         bool DoExecuteRetrieve();
226         bool DoExecuteRemove();
227         bool DoExecuteList();
228 };
229
230 class ClsCommand : public AMCPCommandBase<0>
231 {
232 public:
233         explicit ClsCommand(IO::ClientInfoPtr client) : AMCPCommandBase(client) {}
234         std::wstring print() const { return L"ClsCommand";}
235         bool DoExecute();
236 };
237
238 class TlsCommand : public AMCPCommandBase<0>
239 {
240 public:
241         explicit TlsCommand(IO::ClientInfoPtr client) : AMCPCommandBase(client) {}
242         std::wstring print() const { return L"TlsCommand";}
243         bool DoExecute();
244 };
245
246 class CinfCommand : public AMCPCommandBase<1>
247 {
248 public:
249         explicit CinfCommand(IO::ClientInfoPtr client) : AMCPCommandBase(client) {}
250         std::wstring print() const { return L"CinfCommand";}
251         bool DoExecute();
252 };
253
254 class InfoCommand : public AMCPCommandBase<0>, AMCPChannelsAwareCommand
255 {
256 public:
257         InfoCommand(IO::ClientInfoPtr client, const std::vector<channel_context>& channels) : AMCPChannelsAwareCommand(channels), AMCPCommandBase(client) {}
258         std::wstring print() const { return L"InfoCommand";}
259         bool DoExecute();
260 };
261
262 class VersionCommand : public AMCPCommandBase<0>
263 {
264 public:
265         explicit VersionCommand(IO::ClientInfoPtr client) : AMCPCommandBase(client) {}
266         std::wstring print() const { return L"VersionCommand";}
267         bool DoExecute();
268 };
269
270 class ByeCommand : public AMCPCommandBase<0>
271 {
272 public:
273         explicit ByeCommand(IO::ClientInfoPtr client) : AMCPCommandBase(client) {}
274         std::wstring print() const { return L"ByeCommand";}
275         bool DoExecute();
276 };
277
278 class SetCommand : public AMCPChannelCommandBase<2>
279 {
280 public:
281         SetCommand(IO::ClientInfoPtr client, const channel_context& channel, unsigned int channel_index, int layer_index) : AMCPChannelCommandBase(client, channel, channel_index, layer_index)
282         {}
283
284         std::wstring print() const { return L"SetCommand";}
285         bool DoExecute();
286 };
287
288 class LockCommand : public AMCPCommandBase<1>, AMCPChannelsAwareCommand
289 {
290 public:
291         LockCommand(IO::ClientInfoPtr client, const std::vector<channel_context>& channels) : AMCPChannelsAwareCommand(channels), AMCPCommandBase(client) {}
292         std::wstring print() const { return L"LockCommand";}
293         bool DoExecute();
294 };
295
296 class ThumbnailCommand : public AMCPCommandBase<1>
297 {
298 public:
299         ThumbnailCommand::ThumbnailCommand(IO::ClientInfoPtr client, std::shared_ptr<core::thumbnail_generator> thumb_gen) : AMCPCommandBase(client), thumb_gen_(thumb_gen) 
300         {}
301         std::wstring print() const { return L"ThumbnailCommand";}
302         bool DoExecute();
303
304 private:
305         bool DoExecuteRetrieve();
306         bool DoExecuteList();
307         bool DoExecuteGenerate();
308         bool DoExecuteGenerateAll();
309
310         std::shared_ptr<core::thumbnail_generator> thumb_gen_;
311 };
312
313 //class KillCommand : public AMCPCommand
314 //{
315 //public:
316 //      KillCommand() {}
317 //      virtual bool DoExecute();
318 //      virtual AMCPCommandCondition CheckConditions();
319 //
320 //      virtual bool NeedChannel() {
321 //              return false;
322 //      }
323 //      virtual AMCPCommandScheduling GetDefaultScheduling() {
324 //              return AddToQueue;
325 //      }
326 //      virtual int GetMinimumParameters() {
327 //              return 0;
328 //      }
329 //};
330
331 }       //namespace amcp
332 }}      //namespace caspar
333
334 #endif  //__AMCPCOMMANDSIMPL_H__