]> git.sesse.net Git - casparcg/commitdiff
git-svn-id: https://casparcg.svn.sourceforge.net/svnroot/casparcg/server/branches...
authorronag <ronag@362d55ac-95cf-4e76-9f9a-cbaa9c17b72d>
Mon, 17 Jan 2011 22:03:32 +0000 (22:03 +0000)
committerronag <ronag@362d55ac-95cf-4e76-9f9a-cbaa9c17b72d>
Mon, 17 Jan 2011 22:03:32 +0000 (22:03 +0000)
14 files changed:
common/common.vcxproj
common/common.vcxproj.filters
core/consumer/bluefish/bluefish_consumer.cpp
core/consumer/decklink/decklink_consumer.cpp
core/consumer/frame_consumer_device.cpp
core/consumer/frame_consumer_device.h
core/consumer/ogl/ogl_consumer.cpp
core/producer/layer.cpp
protocol/amcp/AMCPCommand.h
protocol/amcp/AMCPCommandsImpl.cpp
protocol/amcp/AMCPCommandsImpl.h
protocol/amcp/AMCPProtocolStrategy.cpp
shell/caspar.config
shell/main.cpp

index 9dce102fd1e858d8ceea382537237939393c091a..f8cba38e0fef695c3745a7ef9bc7dc87b1311db1 100644 (file)
     <ClInclude Include="memory\safe_ptr.h" />\r
     <ClInclude Include="env.h" />\r
     <ClInclude Include="stdafx.h" />\r
+    <ClInclude Include="utility\assert.h" />\r
     <ClInclude Include="utility\string_convert.h" />\r
     <ClInclude Include="utility\timer.h" />\r
   </ItemGroup>\r
index 71d7a2adaa98fca8cc837b5c6188d2d84c7b142b..6bc2825b4a636a0a365d00c1e80c1725fa697031 100644 (file)
@@ -84,5 +84,8 @@
     <ClInclude Include="env.h">\r
       <Filter>Source</Filter>\r
     </ClInclude>\r
+    <ClInclude Include="utility\assert.h">\r
+      <Filter>Source\utility</Filter>\r
+    </ClInclude>\r
   </ItemGroup>\r
 </Project>
\ No newline at end of file
index 73ef0a6e09ea5f9338f7479b11c643295c911831..7808c7db37982993502df01e3375ed6334ea1e93 100644 (file)
@@ -336,9 +336,9 @@ safe_ptr<frame_consumer> create_bluefish_consumer(const std::vector<std::wstring
        int device_index = 1;\r
        bool embed_audio = false;\r
 \r
-       try{device_index = boost::lexical_cast<int>(params[2]);}\r
+       try{if(params.size() > 2) device_index = boost::lexical_cast<int>(params[2]);}\r
        catch(boost::bad_lexical_cast&){}\r
-       try{embed_audio = boost::lexical_cast<bool>(params[3]);}\r
+       try{if(params.size() > 3) embed_audio = boost::lexical_cast<bool>(params[3]);}\r
        catch(boost::bad_lexical_cast&){}\r
 \r
        return make_safe<bluefish_consumer>(format_desc, device_index, embed_audio);\r
index 729ba9ad288b2a0ef79d91a30ccbb79b472f1bbb..484f93faf198198254077a7bd54a12a5af9e4d0c 100644 (file)
@@ -297,11 +297,11 @@ safe_ptr<frame_consumer> create_decklink_consumer(const std::vector<std::wstring
        bool embed_audio = false;\r
        bool internal_key = false;\r
 \r
-       try{device_index = boost::lexical_cast<int>(params[2]);}\r
+       try{if(params.size() > 2) device_index = boost::lexical_cast<int>(params[2]);}\r
        catch(boost::bad_lexical_cast&){}\r
-       try{embed_audio = boost::lexical_cast<bool>(params[3]);}\r
+       try{if(params.size() > 3) embed_audio = boost::lexical_cast<bool>(params[3]);}\r
        catch(boost::bad_lexical_cast&){}\r
-       try{internal_key = boost::lexical_cast<bool>(params[4]);}\r
+       try{if(params.size() > 4) internal_key = boost::lexical_cast<bool>(params[4]);}\r
        catch(boost::bad_lexical_cast&){}\r
 \r
        return make_safe<decklink_consumer>(format_desc, device_index, embed_audio, internal_key);\r
index 6879eda6e230610965bd89ce258feab5bddb2c57..f035fac734085e1ef24566740beb255eec2b674d 100644 (file)
@@ -10,6 +10,7 @@
 \r
 #include <common/concurrency/executor.h>\r
 #include <common/utility/timer.h>\r
+#include <common/utility/assert.h>\r
 \r
 #include <boost/range/algorithm_ext/erase.hpp>\r
 #include <boost/range/algorithm.hpp>\r
@@ -62,6 +63,15 @@ public:
                                consumers_.erase(it);\r
                });\r
        }\r
+\r
+       safe_ptr<frame_consumer> get(int index)\r
+       {\r
+               return executor_.invoke([&]() -> safe_ptr<frame_consumer>\r
+               {\r
+                       auto it = consumers_.find(index);\r
+                       return it != consumers_.end() && it->second ? safe_ptr<frame_consumer>(it->second) : frame_consumer::empty();\r
+               });\r
+       }\r
                        \r
        void send(const safe_ptr<const read_frame>& frame)\r
        {               \r
@@ -97,5 +107,6 @@ frame_consumer_device::frame_consumer_device(frame_consumer_device&& other) : im
 frame_consumer_device::frame_consumer_device(const video_format_desc& format_desc) : impl_(new implementation(format_desc)){}\r
 void frame_consumer_device::add(int index, const safe_ptr<frame_consumer>& consumer){impl_->add(index, consumer);}\r
 void frame_consumer_device::remove(int index){impl_->remove(index);}\r
+safe_ptr<frame_consumer> frame_consumer_device::get(int index) { return impl_->get(index); }\r
 void frame_consumer_device::send(const safe_ptr<const read_frame>& future_frame) { impl_->send(future_frame); }\r
 }}
\ No newline at end of file
index b44bccafdc2e80de6e0d1ccd9194f8b8a84680c2..6e45e5bfa27dd4288b00511c3a61235bd90a7459 100644 (file)
@@ -21,6 +21,8 @@ public:
 \r
        void add(int index, const safe_ptr<frame_consumer>& consumer);\r
        void remove(int index);\r
+       safe_ptr<frame_consumer> get(int index);\r
+\r
        void send(const safe_ptr<const read_frame>& future_frame); // nothrow\r
 private:\r
        struct implementation;\r
index 89f760a3f338599712280a8f3b085cb8d186aa79..6036ae3b653d433eba54c7beb0d1c9a1e981a0fa 100644 (file)
@@ -265,9 +265,9 @@ safe_ptr<frame_consumer> create_ogl_consumer(const std::vector<std::wstring>& pa
        stretch stretch = stretch::fill;\r
        bool windowed = true;\r
        \r
-       try{screen_index = boost::lexical_cast<int>(params[2]);}\r
+       try{if(params.size() > 2) screen_index = boost::lexical_cast<int>(params[2]);}\r
        catch(boost::bad_lexical_cast&){}\r
-       try{windowed = boost::lexical_cast<bool>(params[3]);}\r
+       try{if(params.size() > 3) windowed = boost::lexical_cast<bool>(params[3]);}\r
        catch(boost::bad_lexical_cast&){}\r
 \r
        return make_safe<ogl_consumer>(format_desc, screen_index, stretch, windowed);\r
index 9f3f6f266b6da0cf6e23db8a8a0268d4d2c62019..21db1d15316afa1f8d47b02eac34e8690531a75d 100644 (file)
@@ -9,6 +9,8 @@
 \r
 #include "../video_format.h"\r
 \r
+#include <common/utility/assert.h>\r
+\r
 namespace caspar { namespace core {\r
 \r
 struct layer::implementation : boost::noncopyable\r
@@ -101,7 +103,7 @@ public:
                        last_frame_ = foreground_->receive(); \r
                        if(last_frame_ == draw_frame::eof())\r
                        {\r
-                               assert(foreground_ != frame_producer::empty());\r
+                               CASPAR_ASSERT(foreground_ != frame_producer::empty());\r
 \r
                                auto following = foreground_->get_following_producer();\r
                                following->set_leading_producer(foreground_);\r
@@ -113,6 +115,7 @@ public:
                        }\r
                        else\r
                        {\r
+                               last_frame_ = draw_frame(last_frame_);\r
                                last_frame_->get_image_transform().gain *= video_gain_;\r
                                last_frame_->get_image_transform().alpha *= video_opacity_;\r
                                last_frame_->get_audio_transform().gain *= audio_gain_;\r
index a2d384f331acf6b2da2701b7fd70e18aef259a68..dfbd8ca7d6f54370a8c545cbfaecd6ceaedca195 100644 (file)
@@ -59,6 +59,9 @@ namespace amcp {
                void SetChannel(const std::shared_ptr<core::channel>& pChannel){pChannel_ = pChannel;}\r
                std::shared_ptr<core::channel> GetChannel(){return pChannel_;}\r
 \r
+               void SetChannels(const std::vector<safe_ptr<core::channel>>& channels){channels_ = channels;}\r
+               const std::vector<safe_ptr<core::channel>>& GetChannels() { return channels_; }\r
+\r
                void SetChannelIndex(unsigned int channelIndex){channelIndex_ = channelIndex;}\r
                unsigned int GetChannelIndex(){return channelIndex_;}\r
 \r
@@ -85,6 +88,7 @@ namespace amcp {
                int layerIndex_;\r
                IO::ClientInfoPtr pClientInfo_;\r
                std::shared_ptr<core::channel> pChannel_;\r
+               std::vector<safe_ptr<core::channel>> channels_;\r
                AMCPCommandScheduling scheduling_;\r
                std::wstring replyString_;\r
        };\r
index 8e085df24807853ab5fc8a862328539b23ac8509..34a486922e04a7e1c8f6139616bd966333992493 100644 (file)
@@ -226,6 +226,45 @@ bool MixerCommand::DoExecute()
        }\r
 }\r
 \r
+bool SwapCommand::DoExecute()\r
+{      \r
+       //Perform loading of the clip\r
+       try\r
+       {\r
+               std::vector<std::string> strs;\r
+               boost::split(strs, _parameters[0], boost::is_any_of("-"));\r
+                       \r
+               auto ch1 = GetChannel();\r
+               auto ch2 = GetChannels().at(boost::lexical_cast<int>(strs.at(0))-1);\r
+\r
+               int l1 = GetLayerIndex();\r
+               int l2 = boost::lexical_cast<int>(strs.at(1));\r
+               \r
+               auto c1 = ch1->consumer().get(l1);\r
+               auto c2 = ch2->consumer().get(l2);\r
+\r
+               ch2->consumer().add(l1, c1);\r
+               ch1->consumer().add(l2, c2);\r
+               CASPAR_LOG(info) << "Swapped successfully";\r
+\r
+               SetReplyString(TEXT("202 SWAP OK\r\n"));\r
+\r
+               return true;\r
+       }\r
+       catch(file_not_found&)\r
+       {\r
+               CASPAR_LOG_CURRENT_EXCEPTION();\r
+               SetReplyString(TEXT("404 SWAP ERROR\r\n"));\r
+               return false;\r
+       }\r
+       catch(...)\r
+       {\r
+               CASPAR_LOG_CURRENT_EXCEPTION();\r
+               SetReplyString(TEXT("502 SWAP FAILED\r\n"));\r
+               return false;\r
+       }\r
+}\r
+\r
 bool AddCommand::DoExecute()\r
 {      \r
        //Perform loading of the clip\r
index 913f3748ca4b5d84894a2f372b437be49046e809..c1ac74d4e99cf6470ed303cad673f918cafc3afe 100644 (file)
@@ -48,6 +48,12 @@ class RemoveCommand : public AMCPCommandBase<true, AddToQueue, 0>
        bool DoExecute();\r
 };\r
 \r
+class SwapCommand : public AMCPCommandBase<true, AddToQueue, 1>\r
+{\r
+       std::wstring print() const { return L"SwapCommand";}\r
+       bool DoExecute();\r
+};\r
+\r
 class LoadCommand : public AMCPCommandBase<true, AddToQueue, 1>\r
 {\r
        std::wstring print() const { return L"LoadCommand";}\r
index 88985df83cde63f2161aa3a353258a65f1b0721c..478f4642a701c13fed99d809fb6551a814df4724 100644 (file)
@@ -261,6 +261,7 @@ AMCPCommandPtr AMCPProtocolStrategy::InterpretCommandString(const std::wstring&
                                }\r
 \r
                                pCommand->SetChannel(pChannel);\r
+                               pCommand->SetChannels(channels_);\r
                                pCommand->SetChannelIndex(channelIndex);\r
                                pCommand->SetLayerIntex(layerIndex);\r
 \r
@@ -310,6 +311,7 @@ AMCPCommandPtr AMCPProtocolStrategy::CommandFactory(const std::wstring& str)
        transform(s.begin(), s.end(), s.begin(), toupper);\r
        \r
        if         (s == TEXT("MIXER"))         return std::make_shared<MixerCommand>();\r
+       else if(s == TEXT("SWAP"))              return std::make_shared<SwapCommand>();\r
        else if(s == TEXT("LOAD"))              return std::make_shared<LoadCommand>();\r
        else if(s == TEXT("LOADBG"))    return std::make_shared<LoadbgCommand>();\r
        else if(s == TEXT("ADD"))               return std::make_shared<AddCommand>();\r
index b2c2f77cc7acd9dca9a015719179a8da1addee7e..69d159b2673a5872325990061d874a70a07cc777 100644 (file)
         </bluefish-->\r
       </consumers>\r
     </channel>\r
+    <channel>\r
+    <videomode>PAL</videomode>\r
+    <consumers>\r
+      <ogl>\r
+        <device>1</device>\r
+        <stretch>uniform</stretch>\r
+        <windowed>true</windowed>\r
+      </ogl>\r
+      <audio/>\r
+      <!--decklink>\r
+          <device>1</device>\r
+          <embedded-audio>true</embedded-audio>\r
+        </decklink-->\r
+      <!--bluefish>\r
+          <device>1</device> \r
+          <embedded-audio>true</embedded-audio>\r
+        </bluefish-->\r
+    </consumers>\r
+    </channel>\r
   </channels>\r
   <controllers>\r
     <tcpcontroller>\r
index e12789cc0628900b97bdb42af657434503dd0a6e..01ddc0ee724a2399d10e4259c2af5c68e93d6ef1 100644 (file)
@@ -37,6 +37,7 @@
 #include <common/exception/exceptions.h>\r
 #include <common/log/log.h>\r
 #include <common/env.h>\r
+#include <common/utility/assert.h>\r
 #include <protocol/amcp/AMCPProtocolStrategy.h>\r
 \r
 using namespace caspar;\r