]> git.sesse.net Git - casparcg/commitdiff
2.0. Applied tk3 patch, STATUS command for layer status querying.
authorRonag <Ronag@362d55ac-95cf-4e76-9f9a-cbaa9c17b72d>
Sun, 14 Aug 2011 00:57:52 +0000 (00:57 +0000)
committerRonag <Ronag@362d55ac-95cf-4e76-9f9a-cbaa9c17b72d>
Sun, 14 Aug 2011 00:57:52 +0000 (00:57 +0000)
git-svn-id: https://casparcg.svn.sourceforge.net/svnroot/casparcg/server/branches/2.0.0.2@1165 362d55ac-95cf-4e76-9f9a-cbaa9c17b72d

core/producer/layer.cpp
core/producer/layer.h
core/producer/stage.cpp
core/producer/stage.h
protocol/amcp/AMCPCommandsImpl.cpp
protocol/amcp/AMCPCommandsImpl.h
protocol/amcp/AMCPProtocolStrategy.cpp

index 9ba6acaa5360094278f057d4cb138de55702c89f..9010954f4b587c8ac020c214d94b0ae205aedeef 100644 (file)
@@ -120,6 +120,18 @@ public:
                }\r
        }\r
 \r
+       layer_status status() const\r
+       {\r
+               layer_status status;\r
+               status.foreground        = foreground_->print();\r
+               status.background        = background_->print();\r
+               status.is_paused         = is_paused_;\r
+               status.total_frames      = foreground_->nb_frames();\r
+               status.current_frame = frame_number_;\r
+\r
+               return status;\r
+       }\r
+\r
        bool empty() const\r
        {\r
                return background_ == core::frame_producer::empty() && foreground_ == core::frame_producer::empty();\r
@@ -148,6 +160,9 @@ void layer::load(const safe_ptr<frame_producer>& frame_producer, bool preview, i
 void layer::play(){impl_->play();}\r
 void layer::pause(){impl_->pause();}\r
 void layer::stop(){impl_->stop();}\r
+bool layer::is_paused() const{return impl_->is_paused_;}\r
+int64_t layer::frame_number() const{return impl_->frame_number_;}\r
+layer_status layer::status() const {return impl_->status();}\r
 safe_ptr<basic_frame> layer::receive() {return impl_->receive();}\r
 safe_ptr<frame_producer> layer::foreground() const { return impl_->foreground_;}\r
 safe_ptr<frame_producer> layer::background() const { return impl_->background_;}\r
index eb976d5d7293a7ce5f4fcf00eb0381fd56efd678..e7991d1f310ad7b39c78fe473735a92bda6540c8 100644 (file)
@@ -29,6 +29,15 @@ namespace caspar { namespace core {
 struct frame_producer;\r
 class basic_frame;\r
 \r
+struct layer_status\r
+{\r
+       std::wstring    foreground;\r
+       std::wstring    background;\r
+       bool                    is_paused;\r
+       int64_t                 total_frames;\r
+       int64_t                 current_frame;\r
+};\r
+\r
 class layer : boost::noncopyable\r
 {\r
 public:\r
@@ -46,6 +55,11 @@ public:
        void stop(); // nothrow\r
        void param(const std::wstring& param);\r
 \r
+       bool is_paused() const;\r
+       int64_t frame_number() const;\r
+\r
+       layer_status status() const;\r
+\r
        bool empty() const;\r
 \r
        safe_ptr<frame_producer> foreground() const; // nothrow\r
index 1c5d99014f39b65db4bbc0ede4d7e982109307ef..d222b39d73e9a6b98319a7bd6bb35d666fb6bde7 100644 (file)
@@ -39,7 +39,7 @@
 #include <set>\r
 \r
 namespace caspar { namespace core {\r
-               \r
+       \r
 void destroy_producer(safe_ptr<frame_producer>& producer)\r
 {\r
        if(!producer.unique())\r
@@ -194,6 +194,14 @@ public:
                \r
                channel_.execution().invoke([&]{other.impl_->channel_.execution().invoke(func, high_priority);});\r
        }\r
+\r
+       layer_status get_status(int index)\r
+       {               \r
+               return channel_.execution().invoke([&]\r
+               {\r
+                       return layers_[index].status();\r
+               }, high_priority );\r
+       }\r
        \r
        boost::unique_future<safe_ptr<frame_producer>> foreground(int index)\r
        {\r
@@ -222,6 +230,7 @@ void stage::clear(int index){impl_->clear(index);}
 void stage::clear(){impl_->clear();}\r
 void stage::swap_layer(int index, size_t other_index){impl_->swap_layer(index, other_index);}\r
 void stage::swap_layer(int index, size_t other_index, stage& other){impl_->swap_layer(index, other_index, other);}\r
+layer_status stage::get_status(int index){return impl_->get_status(index);}\r
 boost::unique_future<safe_ptr<frame_producer>> stage::foreground(size_t index) {return impl_->foreground(index);}\r
 boost::unique_future<safe_ptr<frame_producer>> stage::background(size_t index) {return impl_->background(index);}\r
 std::map<int, safe_ptr<basic_frame>> stage::execute(){return impl_->execute();}\r
index 1217dc2c653c291f733a9ae177ee1601b7f2225a..b13e712571e6e2bc558706a9ba4a599ed5b03120 100644 (file)
@@ -30,7 +30,8 @@
 namespace caspar { namespace core {\r
 \r
 struct video_format_desc;\r
-class video_channel_context;;\r
+class video_channel_context;\r
+struct layer_status;\r
 \r
 class stage : boost::noncopyable\r
 {\r
@@ -49,6 +50,8 @@ public:
        void clear();   \r
        void swap_layer(int index, size_t other_index);\r
        void swap_layer(int index, size_t other_index, stage& other);\r
+\r
+       layer_status get_status(int index);\r
        boost::unique_future<safe_ptr<frame_producer>> foreground(size_t index);\r
        boost::unique_future<safe_ptr<frame_producer>> background(size_t index);\r
 \r
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
index 3f50f34a7f48f4d30383dd192eeb2a212bedba6e..ef5f53bda600c9d3a931bd68070823a851e3d4aa 100644 (file)
@@ -102,6 +102,12 @@ class PrintCommand : public AMCPCommandBase<true, AddToQueue, 0>
        bool DoExecute();\r
 };\r
 \r
+class StatusCommand : public AMCPCommandBase<true, AddToQueue, 0>\r
+{\r
+       std::wstring print() const { return L"StatusCommand";}\r
+       bool DoExecute();\r
+};\r
+\r
 class LogCommand : public AMCPCommandBase<false, AddToQueue, 0>\r
 {\r
        std::wstring print() const { return L"LogCommand";}\r
index 937922f22a455a181339fb12ac6a8a54f4c2df80..fdd685875b85f6ac0df9eb63a105ad0220c5a8de 100644 (file)
@@ -322,6 +322,7 @@ AMCPCommandPtr AMCPProtocolStrategy::CommandFactory(const std::wstring& str)
        else if(s == TEXT("STOP"))              return std::make_shared<StopCommand>();\r
        else if(s == TEXT("CLEAR"))             return std::make_shared<ClearCommand>();\r
        else if(s == TEXT("PRINT"))             return std::make_shared<PrintCommand>();\r
+       else if(s == TEXT("STATUS"))    return std::make_shared<StatusCommand>();\r
        else if(s == TEXT("LOG"))               return std::make_shared<LogCommand>();\r
        else if(s == TEXT("CG"))                return std::make_shared<CGCommand>();\r
        else if(s == TEXT("DATA"))              return std::make_shared<DataCommand>();\r