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
23 #ifndef __AMCPCOMMANDSIMPL_H__
24 #define __AMCPCOMMANDSIMPL_H__
26 #include "AMCPCommand.h"
28 #include <boost/thread/future.hpp>
29 #include <core/thumbnail_generator.h>
31 namespace caspar { namespace protocol {
33 std::wstring ListMedia();
34 std::wstring ListTemplates();
38 class ChannelGridCommand : public AMCPCommandBase<0>
41 explicit ChannelGridCommand(IO::ClientInfoPtr client) : AMCPCommandBase(client) {}
42 std::wstring print() const { return L"ChannelGridCommand";}
46 class DiagnosticsCommand : public AMCPCommandBase<0>
49 explicit DiagnosticsCommand(IO::ClientInfoPtr client) : AMCPCommandBase(client) {}
50 std::wstring print() const { return L"DiagnosticsCommand";}
54 class CallCommand : public AMCPChannelCommandBase<1>
57 CallCommand(IO::ClientInfoPtr client, const channel_context& channel, unsigned int channel_index, int layer_index) : AMCPChannelCommandBase(client, channel, channel_index, layer_index)
61 std::wstring print() const { return L"CallCommand";}
65 class MixerCommand : public AMCPChannelCommandBase<1>
68 MixerCommand(IO::ClientInfoPtr client, const channel_context& channel, unsigned int channel_index, int layer_index) : AMCPChannelCommandBase(client, channel, channel_index, layer_index)
72 std::wstring print() const { return L"MixerCommand";}
76 class AddCommand : public AMCPChannelCommandBase<1>
79 AddCommand(IO::ClientInfoPtr client, const channel_context& channel, unsigned int channel_index, int layer_index) : AMCPChannelCommandBase(client, channel, channel_index, layer_index)
83 std::wstring print() const { return L"AddCommand";}
87 class RemoveCommand : public AMCPChannelCommandBase<0>
90 RemoveCommand(IO::ClientInfoPtr client, const channel_context& channel, unsigned int channel_index, int layer_index) : AMCPChannelCommandBase(client, channel, channel_index, layer_index)
94 std::wstring print() const { return L"RemoveCommand";}
98 class SwapCommand : public AMCPChannelCommandBase<1>, AMCPChannelsAwareCommand
101 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)
105 std::wstring print() const { return L"SwapCommand";}
109 class LoadCommand : public AMCPChannelCommandBase<1>
112 LoadCommand(IO::ClientInfoPtr client, const channel_context& channel, unsigned int channel_index, int layer_index) : AMCPChannelCommandBase(client, channel, channel_index, layer_index)
116 std::wstring print() const { return L"LoadCommand";}
121 class PlayCommand: public AMCPChannelCommandBase<0>, public AMCPChannelsAwareCommand
124 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)
128 std::wstring print() const { return L"PlayCommand";}
132 class LoadbgCommand : public AMCPChannelCommandBase<1>, public AMCPChannelsAwareCommand
135 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)
137 LoadbgCommand(const PlayCommand& rhs) : AMCPChannelCommandBase<1>(rhs), AMCPChannelsAwareCommand(rhs) {}
140 std::wstring print() const { return L"LoadbgCommand";}
144 class PauseCommand: public AMCPChannelCommandBase<0>
147 PauseCommand(IO::ClientInfoPtr client, const channel_context& channel, unsigned int channel_index, int layer_index) : AMCPChannelCommandBase(client, channel, channel_index, layer_index)
151 std::wstring print() const { return L"PauseCommand";}
155 class StopCommand : public AMCPChannelCommandBase<0>
158 StopCommand(IO::ClientInfoPtr client, const channel_context& channel, unsigned int channel_index, int layer_index) : AMCPChannelCommandBase(client, channel, channel_index, layer_index)
162 std::wstring print() const { return L"StopCommand";}
166 class ClearCommand : public AMCPChannelCommandBase<0>
169 ClearCommand(IO::ClientInfoPtr client, const channel_context& channel, unsigned int channel_index, int layer_index) : AMCPChannelCommandBase(client, channel, channel_index, layer_index)
173 std::wstring print() const { return L"ClearCommand";}
177 class PrintCommand : public AMCPChannelCommandBase<0>
180 PrintCommand(IO::ClientInfoPtr client, const channel_context& channel, unsigned int channel_index, int layer_index) : AMCPChannelCommandBase(client, channel, channel_index, layer_index)
184 std::wstring print() const { return L"PrintCommand";}
188 class LogCommand : public AMCPCommandBase<2>
191 explicit LogCommand(IO::ClientInfoPtr client) : AMCPCommandBase(client) {}
192 std::wstring print() const { return L"LogCommand";}
196 class CGCommand : public AMCPChannelCommandBase<1>
199 CGCommand(IO::ClientInfoPtr client, const channel_context& channel, unsigned int channel_index, int layer_index) : AMCPChannelCommandBase(client, channel, channel_index, layer_index)
203 std::wstring print() const { return L"CGCommand";}
205 bool ValidateLayer(const std::wstring& layerstring);
208 bool DoExecutePlay();
209 bool DoExecuteStop();
210 bool DoExecuteNext();
211 bool DoExecuteRemove();
212 bool DoExecuteClear();
213 bool DoExecuteUpdate();
214 bool DoExecuteInvoke();
215 bool DoExecuteInfo();
218 class DataCommand : public AMCPCommandBase<1>
221 explicit DataCommand(IO::ClientInfoPtr client) : AMCPCommandBase(client) {}
223 std::wstring print() const { return L"DataCommand";}
225 bool DoExecuteStore();
226 bool DoExecuteRetrieve();
227 bool DoExecuteRemove();
228 bool DoExecuteList();
231 class ClsCommand : public AMCPCommandBase<0>
234 explicit ClsCommand(IO::ClientInfoPtr client) : AMCPCommandBase(client) {}
235 std::wstring print() const { return L"ClsCommand";}
239 class TlsCommand : public AMCPCommandBase<0>
242 explicit TlsCommand(IO::ClientInfoPtr client) : AMCPCommandBase(client) {}
243 std::wstring print() const { return L"TlsCommand";}
247 class CinfCommand : public AMCPCommandBase<1>
250 explicit CinfCommand(IO::ClientInfoPtr client) : AMCPCommandBase(client) {}
251 std::wstring print() const { return L"CinfCommand";}
255 class InfoCommand : public AMCPCommandBase<0>, AMCPChannelsAwareCommand
258 InfoCommand(IO::ClientInfoPtr client, const std::vector<channel_context>& channels) : AMCPChannelsAwareCommand(channels), AMCPCommandBase(client) {}
259 std::wstring print() const { return L"InfoCommand";}
263 class VersionCommand : public AMCPCommandBase<0>
266 explicit VersionCommand(IO::ClientInfoPtr client) : AMCPCommandBase(client) {}
267 std::wstring print() const { return L"VersionCommand";}
271 class ByeCommand : public AMCPCommandBase<0>
274 explicit ByeCommand(IO::ClientInfoPtr client) : AMCPCommandBase(client) {}
275 std::wstring print() const { return L"ByeCommand";}
279 class SetCommand : public AMCPChannelCommandBase<2>
282 SetCommand(IO::ClientInfoPtr client, const channel_context& channel, unsigned int channel_index, int layer_index) : AMCPChannelCommandBase(client, channel, channel_index, layer_index)
285 std::wstring print() const { return L"SetCommand";}
289 class LockCommand : public AMCPCommandBase<1>, AMCPChannelsAwareCommand
292 LockCommand(IO::ClientInfoPtr client, const std::vector<channel_context>& channels) : AMCPChannelsAwareCommand(channels), AMCPCommandBase(client) {}
293 std::wstring print() const { return L"LockCommand";}
297 class ThumbnailCommand : public AMCPCommandBase<1>
300 ThumbnailCommand::ThumbnailCommand(IO::ClientInfoPtr client, std::shared_ptr<core::thumbnail_generator> thumb_gen) : AMCPCommandBase(client), thumb_gen_(thumb_gen)
302 std::wstring print() const { return L"ThumbnailCommand";}
306 bool DoExecuteRetrieve();
307 bool DoExecuteList();
308 bool DoExecuteGenerate();
309 bool DoExecuteGenerateAll();
311 std::shared_ptr<core::thumbnail_generator> thumb_gen_;
314 class KillCommand : public AMCPCommandBase<0>
317 KillCommand(IO::ClientInfoPtr client, boost::promise<bool>& shutdown_server_now) : AMCPCommandBase(client), shutdown_server_now_(&shutdown_server_now) {}
318 std::wstring print() const { return L"KillCommand";}
322 boost::promise<bool>* shutdown_server_now_;
325 //class KillCommand : public AMCPCommand
329 // virtual bool DoExecute();
330 // virtual AMCPCommandCondition CheckConditions();
332 // virtual bool NeedChannel() {
335 // virtual AMCPCommandScheduling GetDefaultScheduling() {
336 // return AddToQueue;
338 // virtual int GetMinimumParameters() {
344 }} //namespace caspar
346 #endif //__AMCPCOMMANDSIMPL_H__