]> git.sesse.net Git - casparcg/blobdiff - protocol/amcp/AMCPCommandsImpl.cpp
2.0. Applied tk3 patch, STATUS command for layer status querying.
[casparcg] / protocol / amcp / AMCPCommandsImpl.cpp
index 726e4bdfdfa2b054ee6b2a2d4f9b49eb450d22a7..49d0b41e104ba5344b9fc33bb6585da5c5f8caec 100644 (file)
@@ -32,6 +32,8 @@
 #include <core/producer/transition/transition_producer.h>\r
 #include <core/producer/frame/image_transform.h>\r
 #include <core/producer/frame/audio_transform.h>\r
+#include <core/producer/stage.h>\r
+#include <core/producer/layer.h>\r
 #include <core/mixer/mixer.h>\r
 #include <core/consumer/output.h>\r
 \r
@@ -798,6 +800,32 @@ bool PrintCommand::DoExecute()
        return true;\r
 }\r
 \r
+bool StatusCommand::DoExecute()\r
+{                              \r
+       if (GetLayerIndex() > -1)\r
+       {\r
+               auto status = GetChannel()->stage()->get_status(GetLayerIndex());\r
+               std::wstringstream status_text;\r
+               status_text\r
+                       << L"202 STATUS OK\r\n"\r
+                       << L"FOREGROUND:"               << status.foreground << L"\r\n"\r
+                       << L"BACKGROUND:"               << status.background << L"\r\n"\r
+                       << L"STATUS:"                   << (status.is_paused ? L"PAUSED" : L"PLAYING") << L"\r\n"\r
+                       << L"TOTAL FRAMES:"             << (status.total_frames == std::numeric_limits<int64_t>::max() ? 0 : status.total_frames) << L"\r\n"\r
+                       << L"CURRENT FRAME:"    << status.current_frame << L"\r\n";\r
+\r
+               SetReplyString(status_text.str());\r
+               return true;\r
+       }\r
+       else\r
+       {\r
+               //NOTE: Possible to extend soo that "channel" status is returned when no layer is specified.\r
+\r
+               SetReplyString(TEXT("403 LAYER MUST BE SPECIFIED\r\n"));\r
+               return false;\r
+       }\r
+}\r
+\r
 bool LogCommand::DoExecute()\r
 {\r
        if(_parameters.at(0) == L"LEVEL")\r