]> git.sesse.net Git - casparcg/commitdiff
2.0.0.2:
authorronag <ronag@362d55ac-95cf-4e76-9f9a-cbaa9c17b72d>
Tue, 14 Dec 2010 17:55:56 +0000 (17:55 +0000)
committerronag <ronag@362d55ac-95cf-4e76-9f9a-cbaa9c17b72d>
Tue, 14 Dec 2010 17:55:56 +0000 (17:55 +0000)
git-svn-id: https://casparcg.svn.sourceforge.net/svnroot/casparcg/server/branches/2.0.0.2@291 362d55ac-95cf-4e76-9f9a-cbaa9c17b72d

63 files changed:
common/concurrency/executor.h
common/gl/pixel_buffer_object.cpp
common/gl/pixel_buffer_object.h
common/io/AsyncEventServer.cpp
common/io/AsyncEventServer.h
common/io/ProtocolStrategy.h
common/utility/safe_ptr.h
core/channel.cpp
core/channel.h
core/consumer/bluefish/bluefish_consumer.cpp
core/consumer/bluefish/bluefish_consumer.h
core/consumer/decklink/decklink_consumer.cpp
core/consumer/decklink/decklink_consumer.h
core/consumer/frame_consumer.h
core/consumer/frame_consumer_device.cpp
core/consumer/frame_consumer_device.h
core/consumer/oal/oal_consumer.cpp
core/consumer/oal/oal_consumer.h
core/consumer/ogl/ogl_consumer.cpp
core/consumer/ogl/ogl_consumer.h
core/core.vcxproj
core/core.vcxproj.filters
core/processor/composite_frame.cpp
core/processor/composite_frame.h
core/processor/draw_frame.h
core/processor/frame_processor_device.cpp
core/processor/frame_processor_device.h
core/processor/frame_renderer.cpp
core/processor/frame_renderer.h
core/processor/fwd.h
core/processor/read_frame.cpp
core/processor/read_frame.h
core/processor/transform_frame.cpp
core/processor/transform_frame.h
core/processor/write_frame.cpp
core/processor/write_frame.h
core/producer/color/color_producer.cpp
core/producer/ffmpeg/ffmpeg_producer.cpp
core/producer/ffmpeg/video/video_transformer.cpp
core/producer/ffmpeg/video/video_transformer.h
core/producer/flash/cg_producer.cpp
core/producer/flash/cg_producer.h
core/producer/flash/flash_producer.cpp
core/producer/flash/flash_producer.h
core/producer/frame_producer.cpp [deleted file]
core/producer/frame_producer.h
core/producer/frame_producer_device.cpp
core/producer/frame_producer_device.h
core/producer/image/image_producer.cpp
core/producer/image/image_scroll_producer.cpp
core/producer/transition/transition_producer.cpp
core/producer/transition/transition_producer.h
core/protocol/amcp/AMCPCommand.h
core/protocol/amcp/AMCPCommandsImpl.cpp
core/protocol/amcp/AMCPCommandsImpl.h
core/protocol/amcp/AMCPProtocolStrategy.cpp
core/protocol/amcp/AMCPProtocolStrategy.h
core/protocol/cii/CIIProtocolStrategy.cpp
core/protocol/cii/CIIProtocolStrategy.h
core/protocol/clk/CLKProtocolStrategy.cpp
core/protocol/clk/CLKProtocolStrategy.h
core/server.cpp
core/server.h

index 0211495c815fd7264dbd54fb53874555b8b2fd07..c0b3f3bf1b4ad6d3ed6bdcff7319da40e479801c 100644 (file)
@@ -80,7 +80,7 @@ public:
        {       \r
                typedef decltype(func()) result_type; \r
                                \r
-               auto task = std::make_shared<boost::packaged_task<result_type>>(std::forward<Func>(func)); // boost::packaged_task cannot be moved, need to used shared_ptr.\r
+               auto task = std::make_shared<boost::packaged_task<result_type>>(std::forward<Func>(func)); // boost::packaged_task cannot be moved into lambda, need to used shared_ptr.\r
                auto future = task->get_future();\r
                \r
                task->set_wait_callback(std::function<void(decltype(*task)& task)>([=](decltype(*task)& task) // The std::function wrapper is required in order to add ::result_type to functor class.\r
index 96190ad4dfa99737a48fa8dbe6d859aa98369ead..c956d23d7bd2ce60d5cf3ebc23d78e453366e5b9 100644 (file)
@@ -78,7 +78,7 @@ struct pixel_buffer_object::implementation : boost::noncopyable
                GL(glBindTexture(GL_TEXTURE_2D, texture_));\r
        }\r
 \r
-       void begin_write()\r
+       void unmap_write()\r
        {\r
                bind_pbo(GL_PIXEL_UNPACK_BUFFER);\r
                if(mapped_)\r
@@ -90,7 +90,7 @@ struct pixel_buffer_object::implementation : boost::noncopyable
                writing_ = true;\r
        }\r
 \r
-       void* end_write()\r
+       void* map_write()\r
        {\r
                if(mapped_)\r
                {\r
@@ -111,7 +111,7 @@ struct pixel_buffer_object::implementation : boost::noncopyable
                return data_;\r
        }\r
        \r
-       void begin_read()\r
+       void unmap_read()\r
        {       \r
                bind_pbo(GL_PIXEL_PACK_BUFFER);\r
                if(mapped_)\r
@@ -123,7 +123,7 @@ struct pixel_buffer_object::implementation : boost::noncopyable
                reading_ = true;\r
        }\r
 \r
-       void* end_read()\r
+       void* map_read()\r
        {\r
                if(mapped_)\r
                {\r
@@ -187,10 +187,10 @@ void pixel_buffer_object::create(size_t width, size_t height, GLenum format)
 }\r
 void* pixel_buffer_object::data(){return impl_->data_;}\r
 const void* pixel_buffer_object::data() const{return impl_->data_;}\r
-void pixel_buffer_object::begin_write() { impl_->begin_write();}\r
-void* pixel_buffer_object::end_write() {return impl_->end_write();} \r
-void pixel_buffer_object::begin_read() { impl_->begin_read();}\r
-void* pixel_buffer_object::end_read(){return impl_->end_read();}\r
+void pixel_buffer_object::unmap_write() { impl_->unmap_write();}\r
+void* pixel_buffer_object::map_write() {return impl_->map_write();} \r
+void pixel_buffer_object::unmap_read() { impl_->unmap_read();}\r
+void* pixel_buffer_object::map_read(){return impl_->map_read();}\r
 void pixel_buffer_object::bind_texture() {impl_->bind_texture();}\r
 size_t pixel_buffer_object::width() const {return impl_->width_;}\r
 size_t pixel_buffer_object::height() const {return impl_->height_;}\r
index 9ca7056c44e6d1241a5198c741e3914258bfbc08..ca2982e1e580e7749cfc11b5b93c0c99948b0943 100644 (file)
@@ -21,11 +21,11 @@ public:
        void create(size_t width, size_t height, GLenum format = GL_BGRA);\r
        ~pixel_buffer_object(){}\r
 \r
-       void begin_write();\r
-       void* end_write();\r
+       void unmap_write();\r
+       void* map_write();\r
 \r
-       void begin_read();\r
-       void* end_read();\r
+       void unmap_read();\r
+       void* map_read();\r
 \r
        void is_smooth(bool smooth);\r
 \r
index f9976fea07985087da22bed49a4646f41c3c3682..1385c114ea3b5a73ddd391df61ccb96a5fe31c21 100644 (file)
@@ -45,7 +45,7 @@ long AsyncEventServer::instanceCount_ = 0;
 // AsyncEventServer constructor\r
 // PARAMS: port(TCP-port the server should listen to)\r
 // COMMENT: Initializes the WinSock2 library\r
-AsyncEventServer::AsyncEventServer(const ProtocolStrategyPtr& pProtocol, int port) : port_(port), pProtocolStrategy_(pProtocol)\r
+AsyncEventServer::AsyncEventServer(const safe_ptr<IProtocolStrategy>& pProtocol, int port) : port_(port), pProtocolStrategy_(pProtocol)\r
 {\r
        if(instanceCount_ == 0) {\r
                WSADATA wsaData;\r
@@ -351,15 +351,13 @@ bool AsyncEventServer::OnRead(SocketInfoPtr& pSI) {
                        return true;\r
                }\r
 \r
-               if(pProtocolStrategy_ != 0) {\r
-                       //Convert to widechar\r
-                       if(ConvertMultiByteToWideChar(pProtocolStrategy_->GetCodepage(), pSI->recvBuffer_, recvResult + pSI->recvLeftoverOffset_, pSI->wideRecvBuffer_, pSI->recvLeftoverOffset_))\r
-                               pProtocolStrategy_->Parse(&pSI->wideRecvBuffer_[0], pSI->wideRecvBuffer_.size(), pSI);\r
-                       else\r
-                       {\r
-                               CASPAR_LOG(error) << "Read from " << pSI->host_.c_str() << TEXT(" failed, could not convert command to UNICODE");\r
-                       }\r
-               }\r
+               //Convert to widechar\r
+               if(ConvertMultiByteToWideChar(pProtocolStrategy_->GetCodepage(), pSI->recvBuffer_, recvResult + pSI->recvLeftoverOffset_, pSI->wideRecvBuffer_, pSI->recvLeftoverOffset_))\r
+                       pProtocolStrategy_->Parse(&pSI->wideRecvBuffer_[0], pSI->wideRecvBuffer_.size(), pSI);\r
+               else                    \r
+                       CASPAR_LOG(error) << "Read from " << pSI->host_.c_str() << TEXT(" failed, could not convert command to UNICODE");\r
+                       \r
+               \r
 \r
                maxRecvLength = sizeof(pSI->recvBuffer_)-pSI->recvLeftoverOffset_;\r
                recvResult = recv(pSI->socket_, pSI->recvBuffer_+pSI->recvLeftoverOffset_, maxRecvLength, 0);\r
index 5d9558e30e248d24d14c2b75887ca4f9b586b7b1..37e9c8875ccaecd7c3d81cfc6b03753c07438c26 100644 (file)
@@ -28,6 +28,8 @@
 #pragma once\r
 #endif\r
 \r
+#include "../utility/safe_ptr.h"\r
+\r
 #include <string>\r
 #include <map>\r
 #include <vector>\r
@@ -54,11 +56,11 @@ class AsyncEventServer : public IRunnable
        AsyncEventServer& operator=(const AsyncEventServer&);\r
 \r
 public:\r
-       explicit AsyncEventServer(const ProtocolStrategyPtr& pProtocol, int port);\r
+       explicit AsyncEventServer(const safe_ptr<IProtocolStrategy>& pProtocol, int port);\r
        ~AsyncEventServer();\r
 \r
        bool Start();\r
-       void SetProtocolStrategy(ProtocolStrategyPtr pPS) {\r
+       void SetProtocolStrategy(safe_ptr<IProtocolStrategy> pPS) {\r
                pProtocolStrategy_ = pPS;\r
        }\r
 \r
@@ -78,7 +80,7 @@ private:
        void OnError(HANDLE waitEvent, int errorCode);\r
 \r
        SocketInfoPtr           pListenSocketInfo_;\r
-       ProtocolStrategyPtr     pProtocolStrategy_;\r
+       safe_ptr<IProtocolStrategy>     pProtocolStrategy_;\r
        int                                     port_;\r
 \r
        friend class SocketInfo;\r
index ac056e1219eb22746127992bd7194b2c30218c1c..7c139b387e2a88af62347499d60f3f9a673543f9 100644 (file)
 #include <string>\r
 #include "clientInfo.h"\r
 \r
-namespace caspar {\r
-namespace IO {\r
+namespace caspar { namespace IO {\r
 \r
 class IProtocolStrategy\r
 {\r
 public:\r
-       virtual ~IProtocolStrategy()\r
-       {}\r
+       virtual ~IProtocolStrategy(){}\r
 \r
        virtual void Parse(const wchar_t* pData, int charCount, ClientInfoPtr pClientInfo) = 0;\r
        virtual unsigned int GetCodepage() = 0;\r
 };\r
 \r
-typedef std::tr1::shared_ptr<IProtocolStrategy> ProtocolStrategyPtr;\r
-\r
-}      //namespace IO\r
-}      //namespace caspar
\ No newline at end of file
+}}     //namespace caspar
\ No newline at end of file
index 17bca8b126ca1ea5025ca935ce710da49df113ff..9c75e3d475cb5f7c35b0962f4997ea4c724c5c58 100644 (file)
@@ -18,6 +18,7 @@ public:
        safe_ptr() : impl_(std::make_shared<T>()){static_assert(!std::is_abstract<T>::value, "Cannot construct abstract class.");}      \r
        \r
        safe_ptr(const safe_ptr<T>& other) : impl_(other.impl_){}\r
+       safe_ptr(safe_ptr&& other) : impl_(other.impl_) {} // Move doesn't move.\r
        \r
        template<typename Y>\r
        safe_ptr(const safe_ptr<Y>& other, typename std::enable_if<std::is_convertible<Y*, T*>::value, void*>::type = 0) : impl_(other.impl_){}\r
@@ -29,6 +30,20 @@ public:
        template<typename Y>    \r
        safe_ptr(Y&& impl, typename std::enable_if<std::is_convertible<typename std::add_pointer<Y>::type, typename std::add_pointer<T>::type>::value, void>::type* = 0)\r
                : impl_(std::make_shared<Y>(std::forward<Y>(impl))) {}\r
+                       \r
+       template<typename Y>    \r
+       explicit safe_ptr(const std::shared_ptr<Y>& impl, typename std::enable_if<std::is_convertible<Y*, T*>::value, void*>::type = 0) : impl_(impl)\r
+       {\r
+               if(!impl_)\r
+                       BOOST_THROW_EXCEPTION(null_argument() << msg_info("impl"));\r
+       }\r
+       \r
+       template<typename Y>    \r
+       explicit safe_ptr(std::shared_ptr<Y>&& impl, typename std::enable_if<std::is_convertible<Y*, T*>::value, void*>::type = 0) : impl_(std::move(impl))\r
+       {\r
+               if(!impl_)\r
+                       BOOST_THROW_EXCEPTION(null_argument() << msg_info("impl"));\r
+       }\r
 \r
        template<typename Y>\r
        typename std::enable_if<std::is_convertible<Y*, T*>::value, safe_ptr<T>&>::type\r
@@ -60,19 +75,9 @@ public:
                                \r
        void swap(safe_ptr& other) { impl_.swap(other.impl_); } \r
        \r
-       std::shared_ptr<T> get_shared() const   { return impl_; }\r
-\r
-       static safe_ptr<T> from_shared(const std::shared_ptr<T>& impl) { return safe_ptr<T>(impl); }\r
-\r
-private:               \r
+       std::shared_ptr<T> get_shared() const { return impl_; }\r
        \r
-       template<typename Y>    \r
-       safe_ptr(const std::shared_ptr<Y>& impl, typename std::enable_if<std::is_convertible<Y*, T*>::value, void*>::type = 0) : impl_(impl)\r
-       {\r
-               if(!impl)\r
-                       BOOST_THROW_EXCEPTION(null_argument() << msg_info("impl"));\r
-       }\r
-\r
+private:       \r
        std::shared_ptr<T> impl_;\r
 };\r
 \r
@@ -115,21 +120,21 @@ template<typename T, typename P0>
 safe_ptr<T> make_safe(P0&& p0)\r
 {\r
        static_assert(!std::is_abstract<T>::value, "Cannot construct abstract class.");\r
-       return safe_ptr<T>(T(std::forward<P0>(p0)));\r
+       return safe_ptr<T>(std::make_shared<T>(std::forward<P0>(p0)));\r
 }\r
 \r
 template<typename T, typename P0, typename P1>\r
 safe_ptr<T> make_safe(P0&& p0, P1&& p1)\r
 {\r
        static_assert(!std::is_abstract<T>::value, "Cannot construct abstract class.");\r
-       return safe_ptr<T>(T(std::forward<P0>(p0), std::forward<P1>(p1)));\r
+       return safe_ptr<T>(std::make_shared<T>(std::forward<P0>(p0), std::forward<P1>(p1)));\r
 }\r
 \r
 template<typename T, typename P0, typename P1, typename P2>\r
 safe_ptr<T> make_safe(P0&& p0, P1&& p1, P2&& p2)\r
 {\r
        static_assert(!std::is_abstract<T>::value, "Cannot construct abstract class.");\r
-       return safe_ptr<T>(T(std::forward<P0>(p0), std::forward<P1>(p1), std::forward<P2>(p2)));\r
+       return safe_ptr<T>(std::make_shared<T>(std::forward<P0>(p0), std::forward<P1>(p1), std::forward<P2>(p2)));\r
 }\r
 \r
 }
\ No newline at end of file
index 44959a98c14125d99cbdc8ed949fd50f6fbdb4a0..713e1c612ec3b6d7066fd5ada68e66518a86f8f5 100644 (file)
@@ -11,7 +11,7 @@ namespace caspar { namespace core {
 struct channel::implementation : boost::noncopyable\r
 {\r
 public:\r
-       implementation(const frame_producer_device_ptr& producer_device, const frame_processor_device_ptr& processor_device, const frame_consumer_device_ptr& consumer_device)\r
+       implementation(const safe_ptr<frame_producer_device>& producer_device, const safe_ptr<frame_processor_device>& processor_device, const safe_ptr<frame_consumer_device>& consumer_device)\r
                : producer_device_(producer_device), processor_device_(processor_device), consumer_device_(consumer_device)\r
        {\r
        }\r
@@ -67,12 +67,13 @@ public:
        }\r
 \r
 private:\r
-       const frame_processor_device_ptr processor_device_; // Destroyed last inorder to have all frames returned to their pools.\r
-       const frame_producer_device_ptr producer_device_;\r
-       const frame_consumer_device_ptr consumer_device_;\r
+       const safe_ptr<frame_processor_device> processor_device_; // Destroyed last inorder to have all frames returned to their pools.\r
+       const safe_ptr<frame_producer_device>  producer_device_;\r
+       const safe_ptr<frame_consumer_device>  consumer_device_;\r
 };\r
 \r
-channel::channel(const frame_producer_device_ptr& producer_device, const frame_processor_device_ptr& processor_device, const frame_consumer_device_ptr& consumer_device)\r
+channel::channel(channel&& other) : impl_(std::move(other.impl_)){}\r
+channel::channel(const safe_ptr<frame_producer_device>& producer_device, const safe_ptr<frame_processor_device>& processor_device, const safe_ptr<frame_consumer_device>& consumer_device)\r
        : impl_(new implementation(producer_device, processor_device, consumer_device)){}\r
 void channel::load(int render_layer, const safe_ptr<frame_producer>& producer, load_option::type option){impl_->load(render_layer, producer, option);}\r
 void channel::pause(int render_layer){impl_->pause(render_layer);}\r
index d05c1b0172f5eceda5b3e2d47529b6118c6277b9..9ee3334bf3ea3b525358b1113ff19bbe26b3be3f 100644 (file)
@@ -23,7 +23,8 @@ namespace caspar { namespace core {
 class channel : boost::noncopyable\r
 {\r
 public:\r
-       channel(const frame_producer_device_ptr& producer_device, const frame_processor_device_ptr& processor_device, const frame_consumer_device_ptr& consumer_device);\r
+       channel(channel&& other);\r
+       channel(const safe_ptr<frame_producer_device>& producer_device, const safe_ptr<frame_processor_device>& processor_device, const safe_ptr<frame_consumer_device>& consumer_device);\r
        \r
        void load(int render_layer, const safe_ptr<frame_producer>& producer, load_option::type option = load_option::none);\r
        void pause(int render_layer);\r
@@ -38,6 +39,5 @@ private:
        struct implementation;\r
        std::shared_ptr<implementation> impl_;\r
 };\r
-typedef std::shared_ptr<channel> channel_ptr;\r
 \r
 }}
\ No newline at end of file
index 5ab081c0ee567be41cc41345008748d715eb3ddd..88d2350ea5af6580efc10328c3dadc61631f753c 100644 (file)
@@ -168,7 +168,7 @@ struct consumer::implementation : boost::noncopyable
                        CASPAR_LOG(error) << "BLUECARD ERROR: Failed to disable video output. (device " << device_index_ << TEXT(")");          \r
        }\r
 \r
-       void send(const safe_ptr<read_frame>& frame)\r
+       void send(const safe_ptr<const read_frame>& frame)\r
        {                       \r
                static size_t audio_samples = 1920;\r
                static size_t audio_nchannels = 2;\r
@@ -275,15 +275,16 @@ struct consumer::implementation : boost::noncopyable
        unsigned long   res_fmt_; \r
        unsigned long   engine_mode_;\r
 \r
-       boost::optional<safe_ptr<read_frame>> transferring_frame_;\r
+       boost::optional<safe_ptr<const read_frame>> transferring_frame_;\r
 \r
        std::array<page_locked_buffer_ptr, 3> hanc_buffers_;\r
        int current_id_;\r
        bool embed_audio_;\r
 };\r
 \r
+consumer::consumer(consumer&& other) : impl_(std::move(other.impl_)){}\r
 consumer::consumer(const video_format_desc& format_desc, unsigned int device_index, bool embed_audio) : impl_(new implementation(format_desc, device_index, embed_audio)){}    \r
-void consumer::send(const safe_ptr<read_frame>& frame){impl_->send(frame);}\r
+void consumer::send(const safe_ptr<const read_frame>& frame){impl_->send(frame);}\r
 frame_consumer::sync_mode consumer::synchronize(){return impl_->synchronize();}\r
 size_t consumer::buffer_depth() const{return impl_->buffer_depth();}\r
 }}}\r
index 37a0ce3791a4ac7e7f77fe15af367a6ed80a3b08..bf0aa4655290ed26b952d9f931ace7ed50db84b7 100644 (file)
@@ -27,9 +27,10 @@ namespace caspar { namespace core { namespace bluefish {
 class consumer : public frame_consumer\r
 {\r
 public:\r
+       consumer(consumer&& other);\r
        consumer(const video_format_desc& format_desc, unsigned int deviceIndex, bool embed_audio = false);\r
        \r
-       virtual void send(const safe_ptr<read_frame>&);\r
+       virtual void send(const safe_ptr<const read_frame>&);\r
        virtual sync_mode synchronize();\r
        virtual size_t buffer_depth() const;\r
 private:\r
index d2c0fb6d9b4a7e54ecf76d9ef6f43ccb04b339f6..0e0eb0bce1c7a9b22c6634a2ba0ea94cc7ab4109 100644 (file)
@@ -132,7 +132,7 @@ struct decklink_consumer::Implementation : boost::noncopyable
                CoUninitialize();\r
        }\r
        \r
-       void send(const safe_ptr<read_frame>& frame)\r
+       void send(const safe_ptr<const read_frame>& frame)\r
        {\r
                active_ = executor_.begin_invoke([=]\r
                {               \r
@@ -171,7 +171,7 @@ struct decklink_consumer::Implementation : boost::noncopyable
 };\r
 \r
 decklink_consumer::decklink_consumer(const video_format_desc& format_desc, bool internalKey) : pImpl_(new Implementation(format_desc, internalKey)){}\r
-void decklink_consumer::send(const safe_ptr<read_frame>& frame){pImpl_->send(frame);}\r
+void decklink_consumer::send(const safe_ptr<const read_frame>& frame){pImpl_->send(frame);}\r
 frame_consumer::sync_mode decklink_consumer::synchronize(){return pImpl_->synchronize();}\r
 size_t decklink_consumer::buffer_depth() const{return pImpl_->buffer_depth();}\r
        \r
index b3f057c8ca96c1962538aed471cd4ec84dd02041..95b093a6821791285299ad2dc97c94585d466e04 100644 (file)
@@ -30,7 +30,7 @@ class decklink_consumer : public frame_consumer
 public:\r
        explicit decklink_consumer(const video_format_desc& format_desc, bool internalKey = false);\r
        \r
-       virtual void send(const safe_ptr<read_frame>&);\r
+       virtual void send(const safe_ptr<const read_frame>&);\r
        virtual sync_mode synchronize();\r
        virtual size_t buffer_depth() const;\r
 private:\r
index fc52ab3baeb03ded7e3fafa6790bfce5ddc78410..3cdd0ad0607f0d8bdc3f1f9f1eb444eba50ddaa6 100644 (file)
@@ -38,7 +38,7 @@ struct frame_consumer : boost::noncopyable
 \r
        virtual ~frame_consumer() {}\r
 \r
-       virtual void send(const safe_ptr<read_frame>& frame) = 0;\r
+       virtual void send(const safe_ptr<const read_frame>& frame) = 0;\r
        virtual sync_mode synchronize() = 0;\r
        virtual size_t buffer_depth() const = 0;\r
 };\r
index b7aec6dd5004c614967b5d370d0dc3665cc86308..248cd1835c48adbeeecab6aeae0b64c9f41d9610 100644 (file)
@@ -39,7 +39,7 @@ private:
 struct frame_consumer_device::implementation\r
 {\r
 public:\r
-       implementation(const frame_processor_device_ptr& frame_processor, const video_format_desc& format_desc, const std::vector<frame_consumer_ptr>& consumers) \r
+       implementation(const safe_ptr<frame_processor_device>& frame_processor, const video_format_desc& format_desc, const std::vector<safe_ptr<frame_consumer>>& consumers) \r
                : frame_processor_(frame_processor), consumers_(consumers), fmt_(format_desc)\r
        {               \r
                std::vector<size_t> depths;\r
@@ -56,13 +56,13 @@ public:
                        executor_.begin_invoke([=]{tick();});\r
        }\r
 \r
-       void process(const safe_ptr<read_frame>& frame)\r
+       void process(const safe_ptr<const read_frame>& frame)\r
        {               \r
                buffer_.push_back(frame);\r
 \r
                clock_sync clock;\r
                \r
-               boost::range::for_each(consumers_, [&](const frame_consumer_ptr& consumer)\r
+               boost::range::for_each(consumers_, [&](const safe_ptr<frame_consumer>& consumer)\r
                {\r
                        size_t offset = max_depth_ - consumer->buffer_depth();\r
                        if(offset < buffer_.size())\r
@@ -70,7 +70,7 @@ public:
                });\r
                        \r
                frame_consumer::sync_mode sync = frame_consumer::ready;\r
-               boost::range::for_each(consumers_, [&](const frame_consumer_ptr& consumer)\r
+               boost::range::for_each(consumers_, [&](const safe_ptr<frame_consumer>& consumer)\r
                {\r
                        try\r
                        {\r
@@ -99,15 +99,16 @@ public:
        executor executor_;     \r
 \r
        size_t max_depth_;\r
-       std::deque<safe_ptr<read_frame>> buffer_;               \r
+       std::deque<safe_ptr<const read_frame>> buffer_;         \r
 \r
-       std::vector<frame_consumer_ptr> consumers_;\r
+       std::vector<safe_ptr<frame_consumer>> consumers_;\r
        \r
-       frame_processor_device_ptr frame_processor_;\r
+       safe_ptr<frame_processor_device> frame_processor_;\r
 \r
        const video_format_desc& fmt_;\r
 };\r
 \r
-frame_consumer_device::frame_consumer_device(const frame_processor_device_ptr& frame_processor, const video_format_desc& format_desc, const std::vector<frame_consumer_ptr>& consumers)\r
+frame_consumer_device::frame_consumer_device(frame_consumer_device&& other) : impl_(std::move(other.impl_)){}\r
+frame_consumer_device::frame_consumer_device(const safe_ptr<frame_processor_device>& frame_processor, const video_format_desc& format_desc, const std::vector<safe_ptr<frame_consumer>>& consumers)\r
        : impl_(new implementation(frame_processor, format_desc, consumers)){}\r
 }}
\ No newline at end of file
index 91a81c100f33b17dc435e455a8b611285ec5c5fb..2501b5588260b6877c9449e686944c75c75c6505 100644 (file)
@@ -9,16 +9,15 @@
 namespace caspar { namespace core {\r
 \r
 class frame_processor_device;\r
-typedef std::shared_ptr<frame_processor_device> frame_processor_device_ptr;\r
 \r
 class frame_consumer_device : boost::noncopyable\r
 {\r
 public:\r
-       frame_consumer_device(const frame_processor_device_ptr& frame_processor, const video_format_desc& format_desc, const std::vector<frame_consumer_ptr>& consumers);\r
+       frame_consumer_device(frame_consumer_device&& other);\r
+       frame_consumer_device(const safe_ptr<frame_processor_device>& frame_processor, const video_format_desc& format_desc, const std::vector<safe_ptr<frame_consumer>>& consumers);\r
 private:\r
        struct implementation;\r
        std::shared_ptr<implementation> impl_;\r
 };\r
-typedef std::shared_ptr<frame_consumer_device> frame_consumer_device_ptr;\r
 \r
 }}
\ No newline at end of file
index f29fbff8cee600f1e02ff33ca34fe302f19caa24..f20d57da8b872cd764eb7b2ecba49abc9a7210c7 100644 (file)
@@ -44,7 +44,7 @@ struct consumer::implementation : public sf::SoundStream, boost::noncopyable
                Stop();\r
        }\r
        \r
-       void send(const safe_ptr<read_frame>& frame)\r
+       void send(const safe_ptr<const read_frame>& frame)\r
        {                               \r
                input_.push(frame->audio_data()); \r
 \r
@@ -112,8 +112,9 @@ struct consumer::implementation : public sf::SoundStream, boost::noncopyable
        boost::circular_buffer<std::vector<short>> container_;\r
 };\r
 \r
+consumer::consumer(consumer&& other) : impl_(std::move(other.impl_)){}\r
 consumer::consumer(const video_format_desc&) : impl_(new implementation()){}\r
-void consumer::send(const safe_ptr<read_frame>& frame){impl_->send(frame);}\r
+void consumer::send(const safe_ptr<const read_frame>& frame){impl_->send(frame);}\r
 frame_consumer::sync_mode consumer::synchronize(){return impl_->synchronize();}\r
 size_t consumer::buffer_depth() const{return impl_->buffer_depth();}\r
 }}}\r
index 0118c0598175824ed106af216c2af66af05e3ffe..171254fdd0db8054dec1d0efa862f420c555b42a 100644 (file)
@@ -26,9 +26,10 @@ namespace caspar { namespace core { namespace oal {
 class consumer : public frame_consumer\r
 {\r
 public:        \r
+       consumer(consumer&& other);\r
        explicit consumer(const video_format_desc& format_desc);\r
        \r
-       virtual void send(const safe_ptr<read_frame>&);\r
+       virtual void send(const safe_ptr<const read_frame>&);\r
        virtual sync_mode synchronize();\r
        virtual size_t buffer_depth() const;\r
 private:\r
index a390759b95249845611d86979c8096f550242e1d..5c86e2937f47aa1ff24ec5156e8407a38d5190fe 100644 (file)
@@ -150,9 +150,9 @@ struct consumer::implementation : boost::noncopyable
                return std::make_pair(width, height);\r
        }\r
 \r
-       void render(const safe_ptr<read_frame>& frame)\r
+       void render(const safe_ptr<const read_frame>& frame)\r
        {                                               \r
-               auto ptr = pbos_.front().end_write();\r
+               auto ptr = pbos_.front().map_write();\r
                std::copy_n(frame->pixel_data().begin(), frame->pixel_data().size(), reinterpret_cast<char*>(ptr));\r
 \r
                GL(glClear(GL_COLOR_BUFFER_BIT));       \r
@@ -164,12 +164,12 @@ struct consumer::implementation : boost::noncopyable
                                glTexCoord2f(0.0f,        0.0f);        glVertex2f(-wSize_,  hSize_);\r
                glEnd();\r
 \r
-               pbos_.back().begin_write();\r
+               pbos_.back().unmap_write();\r
 \r
                std::rotate(pbos_.begin(), pbos_.begin() + 1, pbos_.end());\r
        }\r
                \r
-       void send(const safe_ptr<read_frame>& frame)\r
+       void send(const safe_ptr<const read_frame>& frame)\r
        {\r
                active_ = executor_.begin_invoke([=]\r
                {\r
@@ -215,9 +215,10 @@ struct consumer::implementation : boost::noncopyable
        sf::Window window_;\r
 };\r
 \r
+consumer::consumer(consumer&& other) : impl_(std::move(other.impl_)){}\r
 consumer::consumer(const video_format_desc& format_desc, unsigned int screen_index, stretch stretch, bool windowed)\r
 : impl_(new implementation(format_desc, screen_index, stretch, windowed)){}\r
-void consumer::send(const safe_ptr<read_frame>& frame){impl_->send(frame);}\r
+void consumer::send(const safe_ptr<const read_frame>& frame){impl_->send(frame);}\r
 frame_consumer::sync_mode consumer::synchronize(){return impl_->synchronize();}\r
 size_t consumer::buffer_depth() const{return impl_->buffer_depth();}\r
 }}}\r
index 524e58054b9f03a1fc1e1f06e71c610d60deff8f..a5ec84c510e097c9b91490d1906c5d2f5b876b95 100644 (file)
@@ -36,9 +36,10 @@ enum stretch
 class consumer : public frame_consumer\r
 {\r
 public:        \r
+       consumer(consumer&& other);\r
        explicit consumer(const video_format_desc& format_desc, unsigned int screen_index = 0, stretch stretch = stretch::fill, bool windowed = false);\r
        \r
-       virtual void send(const safe_ptr<read_frame>&);\r
+       virtual void send(const safe_ptr<const read_frame>&);\r
        virtual sync_mode synchronize();\r
        virtual size_t buffer_depth() const;\r
 private:\r
index 722be679c09ca0b95a47fb7557546280930ae74a..7731c402dee62cb4bcaa09aa7e3cb34300ab6bb7 100644 (file)
       <PrecompiledHeaderFile Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">../../stdAfx.h</PrecompiledHeaderFile>\r
       <PrecompiledHeaderFile Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">../../stdAfx.h</PrecompiledHeaderFile>\r
     </ClCompile>\r
-    <ClCompile Include="producer\frame_producer.cpp">\r
-      <PrecompiledHeaderFile Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">../StdAfx.h</PrecompiledHeaderFile>\r
-      <PrecompiledHeaderFile Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">../StdAfx.h</PrecompiledHeaderFile>\r
-    </ClCompile>\r
     <ClCompile Include="producer\image\image_loader.cpp">\r
       <PrecompiledHeaderFile Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">../../StdAfx.h</PrecompiledHeaderFile>\r
       <PrecompiledHeaderFile Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">../../StdAfx.h</PrecompiledHeaderFile>\r
index 2f50212febf20fd9a7456cfffb700db37a8928b4..b3719eb4c08a2b22315bac6846bd48c028f7c862 100644 (file)
     <ClCompile Include="producer\ffmpeg\input.cpp">\r
       <Filter>Source\channel\producer\ffmpeg\io</Filter>\r
     </ClCompile>\r
-    <ClCompile Include="producer\frame_producer.cpp">\r
-      <Filter>Source\channel\producer</Filter>\r
-    </ClCompile>\r
     <ClCompile Include="format\pixel_format.cpp">\r
       <Filter>Source\channel\format</Filter>\r
     </ClCompile>\r
index 6283303f0f526393b442ce918391ab142c019c58..3178dde58ab13f0315cbf7f1cabbb3a4757f7e1d 100644 (file)
@@ -12,7 +12,7 @@
 \r
 namespace caspar { namespace core {\r
        \r
-struct composite_frame::implementation\r
+struct composite_frame::implementation : public draw_frame_decorator\r
 {      \r
        implementation(std::vector<safe_ptr<draw_frame>>&& frames) : frames_(std::move(frames))\r
        {               \r
@@ -38,22 +38,17 @@ struct composite_frame::implementation
                });\r
        }\r
        \r
-       void begin_write()\r
+       void prepare()\r
        {\r
-               boost::range::for_each(frames_, std::bind(&draw_frame::begin_write, std::placeholders::_1));\r
+               boost::range::for_each(frames_, std::bind(&draw_frame_decorator::prepare, std::placeholders::_1));\r
        }\r
-\r
-       void end_write()\r
-       {\r
-               boost::range::for_each(frames_, std::bind(&draw_frame::end_write, std::placeholders::_1));\r
-       }\r
-       \r
+               \r
        void draw(frame_shader& shader)\r
        {\r
-               boost::range::for_each(frames_, std::bind(&draw_frame::draw, std::placeholders::_1, std::ref(shader)));\r
+               boost::range::for_each(frames_, std::bind(&draw_frame_decorator::draw, std::placeholders::_1, std::ref(shader)));\r
        }\r
 \r
-       const std::vector<short>& audio_data()\r
+       const std::vector<short>& audio_data() const\r
        {\r
                static std::vector<short> no_audio;\r
                return !audio_data_.empty() ? audio_data_ : (!frames_.empty() ? frames_.front()->audio_data() : no_audio);\r
@@ -88,8 +83,7 @@ composite_frame::composite_frame(safe_ptr<draw_frame>&& frame1, safe_ptr<draw_fr
        impl_.reset(new implementation(std::move(frames)));\r
 }\r
 \r
-void composite_frame::begin_write(){impl_->begin_write();}\r
-void composite_frame::end_write(){impl_->end_write();} \r
+void composite_frame::prepare(){impl_->prepare();}\r
 void composite_frame::draw(frame_shader& shader){impl_->draw(shader);}\r
 const std::vector<short>& composite_frame::audio_data() const {return impl_->audio_data();}\r
 \r
index 27ffc93b0e7c3a8463f5feddfdc9ba264a403fc9..302ceb0ca53f25d3dd16ae90a2a65b21ac7e8345 100644 (file)
@@ -30,8 +30,7 @@ public:
        virtual const std::vector<short>& audio_data() const;\r
 \r
 private:       \r
-       virtual void begin_write();\r
-       virtual void end_write();\r
+       virtual void prepare();\r
        virtual void draw(frame_shader& shader);\r
 \r
        struct implementation;\r
index 48d97dd850c01e02131c0754bc4f1fa0798714a9..7a4146ffbca80754f3f9d5a323135235963ae1ae 100644 (file)
 \r
 namespace caspar { namespace core {\r
                \r
+struct draw_frame_decorator;\r
+\r
 class draw_frame : boost::noncopyable\r
 {      \r
+       friend struct draw_frame_decorator;\r
+       friend class frame_renderer;\r
 public:\r
        virtual ~draw_frame(){}\r
 \r
        virtual const std::vector<short>& audio_data() const = 0;               \r
-       virtual void begin_write() = 0;\r
-       virtual void end_write() = 0;\r
-       virtual void draw(frame_shader& shader) = 0;\r
 \r
        static safe_ptr<draw_frame> eof()\r
        {\r
@@ -33,8 +34,7 @@ public:
                                static std::vector<short> audio_data;\r
                                return audio_data;\r
                        }\r
-                       virtual void begin_write(){}\r
-                       virtual void end_write(){}\r
+                       virtual void prepare(){}\r
                        virtual void draw(frame_shader&){}\r
                };\r
                static safe_ptr<draw_frame> frame = make_safe<eof_frame>();\r
@@ -50,13 +50,22 @@ public:
                                static std::vector<short> audio_data;\r
                                return audio_data;\r
                        }\r
-                       virtual void begin_write(){}\r
-                       virtual void end_write(){}\r
+                       virtual void prepare(){}\r
                        virtual void draw(frame_shader&){}\r
                };\r
                static safe_ptr<draw_frame> frame = make_safe<empty_frame>();\r
                return frame;\r
        }\r
+private:\r
+       virtual void prepare() = 0;\r
+       virtual void draw(frame_shader& shader) = 0;\r
+};\r
+\r
+struct draw_frame_decorator\r
+{\r
+protected:\r
+       static void prepare(const safe_ptr<draw_frame>& frame) {frame->prepare();}\r
+       static void draw(const safe_ptr<draw_frame>& frame, frame_shader& shader) {frame->draw(shader);}\r
 };\r
 \r
 \r
index c3d9ebd2d8a4f92e85b46a79d91e7cb1c114fdcd..79aefceac21d1a624348db6bccfe56e87dc34662 100644 (file)
@@ -13,9 +13,6 @@
 #include "../../common/concurrency/executor.h"\r
 #include "../../common/gl/utility.h"\r
 \r
-#include <Glee.h>\r
-#include <SFML/Window.hpp>\r
-\r
 #include <tbb/concurrent_queue.h>\r
 #include <tbb/concurrent_unordered_map.h>\r
 #include <tbb/concurrent_vector.h>\r
@@ -35,22 +32,22 @@ struct frame_processor_device::implementation : boost::noncopyable
                executor_.start();\r
                executor_.invoke([=]\r
                {\r
-                       ogl_context_.reset(new sf::Context());\r
-                       ogl_context_->SetActive(true);\r
-\r
                        renderer_.reset(new frame_renderer(format_desc));\r
                });\r
        }\r
                                \r
-       void send(const safe_ptr<draw_frame>& frame)\r
+       void send(safe_ptr<draw_frame>&& frame)\r
        {                       \r
-               auto future = executor_.begin_invoke([=]{return renderer_->render(frame);});    \r
+               auto future = executor_.begin_invoke([=]() -> safe_ptr<const read_frame>\r
+               {\r
+                       return renderer_->render(safe_ptr<draw_frame>(frame));\r
+               });     \r
                output_.push(std::move(future)); // Blocks\r
        }\r
 \r
-       safe_ptr<read_frame> receive()\r
+       safe_ptr<const read_frame> receive()\r
        {\r
-               boost::shared_future<safe_ptr<read_frame>> future;\r
+               boost::shared_future<safe_ptr<const read_frame>> future;\r
 \r
                if(!output_.try_pop(future))\r
                {\r
@@ -79,20 +76,19 @@ struct frame_processor_device::implementation : boost::noncopyable
                {\r
                        executor_.begin_invoke([=]\r
                        {\r
-                               frame->reset();\r
+                               frame->audio_data().clear();\r
                                pool->push(frame);\r
                        });\r
                });\r
 \r
-               return safe_ptr<write_frame>::from_shared(frame);\r
+               return safe_ptr<write_frame>(frame);\r
        }\r
                                \r
        executor executor_;     \r
 \r
-       std::unique_ptr<sf::Context> ogl_context_;\r
        std::unique_ptr<frame_renderer> renderer_;      \r
                                \r
-       tbb::concurrent_bounded_queue<boost::shared_future<safe_ptr<read_frame>>> output_;      \r
+       tbb::concurrent_bounded_queue<boost::shared_future<safe_ptr<const read_frame>>> output_;        \r
 \r
        tbb::concurrent_unordered_map<pixel_format_desc, tbb::concurrent_bounded_queue<std::shared_ptr<write_frame>>, std::hash<pixel_format_desc>> pools_;\r
        \r
@@ -100,9 +96,10 @@ struct frame_processor_device::implementation : boost::noncopyable
        long underrun_count_;\r
 };\r
        \r
+frame_processor_device::frame_processor_device(frame_processor_device&& other) : impl_(std::move(other.impl_)){}\r
 frame_processor_device::frame_processor_device(const video_format_desc& format_desc) : impl_(new implementation(format_desc)){}\r
-void frame_processor_device::send(const safe_ptr<draw_frame>& frame){impl_->send(std::move(frame));}\r
-safe_ptr<read_frame> frame_processor_device::receive(){return impl_->receive();}\r
+void frame_processor_device::send(safe_ptr<draw_frame>&& frame){impl_->send(std::move(frame));}\r
+safe_ptr<const read_frame> frame_processor_device::receive(){return impl_->receive();}\r
 const video_format_desc& frame_processor_device::get_video_format_desc() const { return impl_->fmt_; }\r
 \r
 safe_ptr<write_frame> frame_processor_device::create_frame(const pixel_format_desc& desc){ return impl_->create_frame(desc); }         \r
index d899087434312b9e07d7b154e8ceb744354cc34b..af71f871adeaa42e51bd51310937b038c96b9873 100644 (file)
@@ -32,10 +32,11 @@ namespace caspar { namespace core {
 class frame_processor_device : boost::noncopyable\r
 {\r
 public:\r
+       frame_processor_device(frame_processor_device&& other);\r
        frame_processor_device(const video_format_desc& format_desc);\r
                \r
-       void send(const safe_ptr<draw_frame>& frame);\r
-       safe_ptr<read_frame> receive();\r
+       void send(safe_ptr<draw_frame>&& frame);\r
+       safe_ptr<const read_frame> receive();\r
        \r
        safe_ptr<write_frame> create_frame(const pixel_format_desc& desc);              \r
        safe_ptr<write_frame> create_frame(size_t width, size_t height);                        \r
@@ -46,6 +47,5 @@ private:
        struct implementation;\r
        std::shared_ptr<implementation> impl_;\r
 };\r
-typedef std::shared_ptr<frame_processor_device> frame_processor_device_ptr;\r
 \r
 }}
\ No newline at end of file
index 76450f8cc821b76504d0f01290cd7a47a8c858d5..02e4f3472282ea0b6fa39b514fdbd8cf575ea0d0 100644 (file)
@@ -5,8 +5,6 @@
 #include "frame_shader.h"\r
 #include "write_frame.h"\r
 #include "read_frame.h"\r
-#include "draw_frame.h"\r
-#include "read_frame.h"\r
 \r
 #include "../format/video_format.h"\r
 \r
@@ -15,6 +13,7 @@
 #include "../../common/gl/frame_buffer_object.h"\r
 \r
 #include <Glee.h>\r
+#include <SFML/Window.hpp>\r
 \r
 #include <tbb/concurrent_queue.h>\r
 \r
 \r
 namespace caspar { namespace core {\r
 \r
+struct ogl_context\r
+{\r
+       ogl_context(){context_.SetActive(true);};\r
+       sf::Context context_;\r
+};\r
+\r
 struct frame_renderer::implementation : boost::noncopyable\r
 {              \r
        implementation(const video_format_desc& format_desc) : shader_(format_desc), format_desc_(format_desc),\r
-               reading_(create_reading()), fbo_(format_desc.width, format_desc.height), writing_(draw_frame::empty()), drawing_(draw_frame::empty())\r
+               fbo_(format_desc.width, format_desc.height), writing_(draw_frame::empty()), reading_(create_reading())\r
        {       \r
                GL(glEnable(GL_POLYGON_STIPPLE));\r
                GL(glEnable(GL_TEXTURE_2D));\r
@@ -36,35 +41,24 @@ struct frame_renderer::implementation : boost::noncopyable
                GL(glDisable(GL_DEPTH_TEST));\r
                GL(glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA));                  \r
                GL(glViewport(0, 0, format_desc.width, format_desc.height));\r
-               reading_->begin_read();\r
+               reading_->unmap();\r
        }\r
                                \r
-       safe_ptr<read_frame> render(const safe_ptr<draw_frame>& frame)\r
-       {\r
-               safe_ptr<read_frame> result = create_reading();\r
-               try\r
-               {\r
-                       drawing_ = writing_;\r
-                       writing_ = frame;\r
-                                               \r
-                       writing_->begin_write();\r
-                                               \r
-                       reading_->end_read();\r
+       safe_ptr<const read_frame> render(safe_ptr<draw_frame>&& frame)\r
+       {                                                               \r
+               frame->prepare(); // Start transfer from system memory to texture. End in next tick.\r
                                                \r
-                       GL(glClear(GL_COLOR_BUFFER_BIT));\r
+               reading_->map(); // Map texture to system memory.\r
+               auto result = reading_;\r
                                                \r
-                       drawing_->draw(shader_);\r
-                               \r
-                       result.swap(reading_);\r
-                       reading_->begin_read();\r
-                       reading_->audio_data(drawing_->audio_data());\r
+               GL(glClear(GL_COLOR_BUFFER_BIT));\r
                                                \r
-                       drawing_ = draw_frame::empty();\r
-               }\r
-               catch(...)\r
-               {\r
-                       CASPAR_LOG_CURRENT_EXCEPTION();\r
-               }\r
+               writing_->draw(shader_); // Draw to frame buffer. Maps texture to system memory when done.\r
+               writing_ = frame;                               \r
+\r
+               reading_ = create_reading();\r
+               reading_->unmap(); // Start transfer from frame buffer to texture. End in next tick.\r
+               reading_->audio_data(writing_->audio_data());                                           \r
 \r
                return result;\r
        }\r
@@ -75,21 +69,21 @@ struct frame_renderer::implementation : boost::noncopyable
                if(!pool_.try_pop(frame))               \r
                        frame = std::make_shared<read_frame>(format_desc_.width, format_desc_.height);\r
                frame = std::shared_ptr<read_frame>(frame.get(), [=](read_frame*){pool_.push(frame);});\r
-               return safe_ptr<read_frame>::from_shared(frame);\r
+               return safe_ptr<read_frame>(frame);\r
        }\r
-       \r
-       const video_format_desc format_desc_;\r
+\r
+       const ogl_context context_;\r
        const gl::fbo fbo_;\r
+       const video_format_desc format_desc_;\r
 \r
        tbb::concurrent_bounded_queue<std::shared_ptr<read_frame>> pool_;\r
        \r
        safe_ptr<read_frame>    reading_;       \r
        safe_ptr<draw_frame>    writing_;\r
-       safe_ptr<draw_frame>    drawing_;\r
        \r
        frame_shader shader_;\r
 };\r
        \r
 frame_renderer::frame_renderer(const video_format_desc& format_desc) : impl_(new implementation(format_desc)){}\r
-safe_ptr<read_frame> frame_renderer::render(const safe_ptr<draw_frame>& frame){return impl_->render(std::move(frame));}\r
+safe_ptr<const read_frame> frame_renderer::render(safe_ptr<draw_frame>&& frame){return impl_->render(std::move(frame));}\r
 }}
\ No newline at end of file
index b47d8a20ecebaa74ef0294a92a324721dabaa258..b579e9cee557785b7e101d65e65cebb6dbe234e3 100644 (file)
@@ -36,7 +36,7 @@ class frame_renderer : boost::noncopyable
 public:\r
        frame_renderer(const video_format_desc& format_desc_);\r
                \r
-       safe_ptr<read_frame> render(const safe_ptr<draw_frame>& frame);\r
+       safe_ptr<const read_frame> render(safe_ptr<draw_frame>&& frame);\r
 private:\r
        struct implementation;\r
        std::shared_ptr<implementation> impl_;\r
index 1041c0c05fed847988b09a17e4ef19dccd2af43f..fafc5617738bb383b243364750363095db27063d 100644 (file)
@@ -14,11 +14,6 @@ class transform_frame;
 class composite_frame;\r
 \r
 class frame_shader;\r
-typedef std::shared_ptr<frame_shader> frame_shader_ptr;\r
-\r
 class frame_renderer;\r
-typedef std::shared_ptr<frame_renderer> frame_renderer_ptr;\r
-\r
 class frame_processor_device;\r
-typedef std::shared_ptr<frame_processor_device> frame_processor_device_ptr;\r
 }}
\ No newline at end of file
index 42a928842ef6a8572487e4cf48600981a9b13b87..eefcee205c35f13b1abfbdaa477016ca9c30eb2b 100644 (file)
@@ -34,7 +34,7 @@ read_frame::read_frame(size_t width, size_t height) : impl_(singleton_pool<imple
 const boost::iterator_range<const unsigned char*> read_frame::pixel_data() const{return impl_->pixel_data();}\r
 const std::vector<short>& read_frame::audio_data() const { return impl_->audio_data_; }\r
 void read_frame::audio_data(const std::vector<short>& audio_data) { impl_->audio_data_ = audio_data; }\r
-void read_frame::begin_read(){impl_->pbo_.begin_read();}\r
-void read_frame::end_read(){impl_->pbo_.end_read();}\r
+void read_frame::unmap(){impl_->pbo_.unmap_read();}\r
+void read_frame::map(){impl_->pbo_.map_read();}\r
 \r
 }}
\ No newline at end of file
index 8d5c659369b6439ba1c31b22c19929fee8c7c839..899a25d193f3a0c13c4e5fa2d9d1399c5c1357f2 100644 (file)
@@ -22,15 +22,14 @@ public:
        explicit read_frame(size_t width, size_t height);\r
        \r
        const boost::iterator_range<const unsigned char*> pixel_data() const;\r
-       const std::vector<short>& audio_data() const;\r
 \r
-private:\r
-       friend class frame_renderer;\r
-       \r
-       void begin_read();\r
-       void end_read();\r
+       const std::vector<short>& audio_data() const;\r
        void audio_data(const std::vector<short>& audio_data);\r
+       \r
+       void unmap();\r
+       void map();\r
 \r
+private:\r
        struct implementation;\r
        std::shared_ptr<implementation> impl_;\r
 };\r
index 3acf65ee4cb24cda60dffe1013b51c89636e6bb3..72f36174a3648286c872e465b9223eead3281493 100644 (file)
 \r
 namespace caspar { namespace core {\r
                                                                                                                                                                                                                                                                                                                \r
-struct transform_frame::implementation\r
+struct transform_frame::implementation : public draw_frame_decorator\r
 {\r
        implementation(const safe_ptr<draw_frame>& frame) : frame_(frame), audio_volume_(255){}\r
        implementation(const safe_ptr<draw_frame>& frame, std::vector<short>&& audio_data) : frame_(frame), audio_volume_(255), override_audio_data_(std::move(audio_data)){}\r
        implementation(safe_ptr<draw_frame>&& frame) : frame_(std::move(frame)), audio_volume_(255){}\r
        \r
-       void begin_write(){frame_->begin_write();}\r
-       void end_write(){frame_->end_write();}\r
+       void prepare(){draw_frame_decorator::prepare(frame_);}\r
 \r
        void draw(frame_shader& shader)\r
        {\r
                shader.begin(transform_);\r
-               frame_->draw(shader);\r
+               draw_frame_decorator::draw(frame_, shader);\r
                shader.end();\r
        }\r
 \r
@@ -86,8 +85,7 @@ transform_frame& transform_frame::operator=(transform_frame&& other)
        temp.swap(*this);\r
        return *this;\r
 }\r
-void transform_frame::begin_write(){impl_->begin_write();}\r
-void transform_frame::end_write(){impl_->end_write();} \r
+void transform_frame::prepare(){impl_->prepare();}     \r
 void transform_frame::draw(frame_shader& shader){impl_->draw(shader);}\r
 void transform_frame::audio_volume(unsigned char volume){impl_->audio_volume(volume);}\r
 void transform_frame::translate(double x, double y){impl_->transform_.pos = boost::make_tuple(x, y);}\r
index febe647dec57d99e5f76d53d5d45b80a2eb45fc9..f5a34e74794fab8731b1892f927af9f33885ae3f 100644 (file)
@@ -42,8 +42,7 @@ public:
 \r
 private:\r
 \r
-       virtual void begin_write();\r
-       virtual void end_write();\r
+       virtual void prepare();\r
        virtual void draw(frame_shader& shader);\r
 \r
        struct implementation;\r
index b3217ef7c2c01c7a46995ae07d7cf9d66cf21433..80fa7508083733458b84ca6d4a4011f01fe707c2 100644 (file)
@@ -25,17 +25,12 @@ struct write_frame::implementation : boost::noncopyable
                {\r
                        return gl::pbo(plane.width, plane.height, mapping[plane.channels-1]);\r
                });\r
-               end_write();\r
+               boost::range::for_each(pbos_, std::mem_fn(&gl::pbo::map_write));\r
        }\r
        \r
-       void begin_write()\r
+       void prepare()\r
        {\r
-               boost::range::for_each(pbos_, std::mem_fn(&gl::pbo::begin_write));\r
-       }\r
-\r
-       void end_write()\r
-       {\r
-               boost::range::for_each(pbos_, std::mem_fn(&gl::pbo::end_write));\r
+               boost::range::for_each(pbos_, std::mem_fn(&gl::pbo::unmap_write));\r
        }\r
 \r
        void draw(frame_shader& shader)\r
@@ -46,6 +41,7 @@ struct write_frame::implementation : boost::noncopyable
                        pbos_[n].bind_texture();\r
                }\r
                shader.render(desc_);\r
+               boost::range::for_each(pbos_, std::mem_fn(&gl::pbo::map_write));\r
        }\r
 \r
        boost::iterator_range<unsigned char*> pixel_data(size_t index)\r
@@ -62,13 +58,7 @@ struct write_frame::implementation : boost::noncopyable
                auto ptr = static_cast<const unsigned char*>(pbos_[index].data());\r
                return boost::iterator_range<const unsigned char*>(ptr, ptr+pbos_[index].size());\r
        }\r
-\r
-       void reset()\r
-       {\r
-               end_write();\r
-               audio_data_.clear();\r
-       }\r
-                       \r
+                               \r
        std::vector<gl::pbo> pbos_;\r
        std::vector<short> audio_data_;\r
        const pixel_format_desc desc_;\r
@@ -83,9 +73,7 @@ write_frame& write_frame::operator=(write_frame&& other)
        temp.swap(*this);\r
        return *this;\r
 }\r
-void write_frame::reset(){impl_->reset();}\r
-void write_frame::begin_write(){impl_->begin_write();}\r
-void write_frame::end_write(){impl_->end_write();}     \r
+void write_frame::prepare(){impl_->prepare();} \r
 void write_frame::draw(frame_shader& shader){impl_->draw(shader);}\r
 boost::iterator_range<unsigned char*> write_frame::pixel_data(size_t index){return impl_->pixel_data(index);}\r
 const boost::iterator_range<const unsigned char*> write_frame::pixel_data(size_t index) const {return impl_->pixel_data(index);}\r
index 6a2b4274af5aeaeca590de81e3b872274e4a641d..092bccfa08fa965152fd40270287266feba25267 100644 (file)
@@ -29,9 +29,7 @@ public:
        void swap(write_frame& other);\r
 \r
        write_frame& operator=(write_frame&& other);\r
-\r
-       void reset();\r
-\r
+       \r
        boost::iterator_range<unsigned char*> pixel_data(size_t index = 0);\r
        const boost::iterator_range<const unsigned char*> pixel_data(size_t index = 0) const;\r
        \r
@@ -40,8 +38,7 @@ public:
        \r
 private:\r
                \r
-       void begin_write();\r
-       void end_write();\r
+       void prepare();\r
        void draw(frame_shader& shader);\r
 \r
        struct implementation;\r
index 4ae506d6f0f7659846d72d7cd5af3d5021ebd6b4..c41a307cdcbac9591903210fcc178f1971f60b29 100644 (file)
@@ -66,15 +66,15 @@ unsigned int get_pixel_color_value(const std::wstring& parameter)
 class color_producer : public frame_producer\r
 {\r
 public:\r
-       explicit color_producer(const std::wstring& color) : color_str_(color), color_value_(get_pixel_color_value(color)), frame_(draw_frame::empty()){}\r
        color_producer(color_producer&& other) : frame_(std::move(other.frame_)), color_value_(std::move(other.color_value_)), color_str_(std::move(other.color_str_)){}\r
+       explicit color_producer(const std::wstring& color) : color_str_(color), color_value_(get_pixel_color_value(color)), frame_(draw_frame::empty()){}\r
        \r
        safe_ptr<draw_frame> receive()\r
        { \r
                return frame_;\r
        }\r
 \r
-       void initialize(const frame_processor_device_ptr& frame_processor)\r
+       void initialize(const safe_ptr<frame_processor_device>& frame_processor)\r
        {\r
                auto frame = std::move(frame_processor->create_frame());\r
                __stosd(reinterpret_cast<unsigned long*>(frame->pixel_data().begin()), color_value_, frame->pixel_data().size() / sizeof(unsigned long));\r
index e3dc7d66dcd94e8595fb8d04222bcf1ccc1b12f5..7c9d2fa2ae2078066ca8533ae9278320c791564c 100644 (file)
@@ -76,7 +76,7 @@ public:
                }\r
        }\r
                \r
-       void initialize(const frame_processor_device_ptr& frame_processor)\r
+       void initialize(const safe_ptr<frame_processor_device>& frame_processor)\r
        {\r
                format_desc_ = frame_processor->get_video_format_desc();\r
                video_transformer_->initialize(frame_processor);\r
@@ -186,7 +186,7 @@ public:
        ffmpeg_producer(const std::wstring& filename, const  std::vector<std::wstring>& params) : impl_(new ffmpeg_producer_impl(filename, params)){}\r
        ffmpeg_producer(ffmpeg_producer&& other) : impl_(std::move(other.impl_)){}\r
        virtual safe_ptr<draw_frame> receive(){return impl_->receive();}\r
-       virtual void initialize(const frame_processor_device_ptr& frame_processor){impl_->initialize(frame_processor);}\r
+       virtual void initialize(const safe_ptr<frame_processor_device>& frame_processor){impl_->initialize(frame_processor);}\r
        virtual std::wstring print() const{return impl_->print();}\r
 private:\r
        std::shared_ptr<ffmpeg_producer_impl> impl_;\r
index acbfb3f5c9f80ec8d14acff39128ae92ca4b81be..cc2f7422f13bd4a4f06d9aea23f357353ea72806 100644 (file)
@@ -141,12 +141,12 @@ struct video_transformer::implementation : boost::noncopyable
                }       \r
        }\r
 \r
-       void initialize(const frame_processor_device_ptr& frame_processor)\r
+       void initialize(const safe_ptr<frame_processor_device>& frame_processor)\r
        {\r
-               frame_processor_ = frame_processor;\r
+               frame_processor_ = frame_processor.get_shared();\r
        }\r
        \r
-       frame_processor_device_ptr frame_processor_;\r
+       std::shared_ptr<frame_processor_device> frame_processor_;\r
        std::shared_ptr<SwsContext> sws_context_;\r
 \r
        AVCodecContext* codec_context_;\r
@@ -159,5 +159,5 @@ struct video_transformer::implementation : boost::noncopyable
 \r
 video_transformer::video_transformer(AVCodecContext* codec_context) : impl_(new implementation(codec_context)){}\r
 safe_ptr<draw_frame> video_transformer::execute(const std::shared_ptr<AVFrame>& decoded_frame){return impl_->execute(decoded_frame);}\r
-void video_transformer::initialize(const frame_processor_device_ptr& frame_processor){impl_->initialize(frame_processor); }\r
+void video_transformer::initialize(const safe_ptr<frame_processor_device>& frame_processor){impl_->initialize(frame_processor); }\r
 }}}
\ No newline at end of file
index 372232dee6dce0f602f269a9643e46122c648792..78df2d592b3e7c578ab3d7c81b0f53a258cd212b 100644 (file)
@@ -14,7 +14,7 @@ class video_transformer : boost::noncopyable
 public:\r
        video_transformer(AVCodecContext* codec_context);\r
        safe_ptr<draw_frame> execute(const std::shared_ptr<AVFrame>& video_packet);     \r
-       void initialize(const frame_processor_device_ptr& frame_processor);\r
+       void initialize(const safe_ptr<frame_processor_device>& frame_processor);\r
 private:\r
        struct implementation;\r
        std::shared_ptr<implementation> impl_;\r
index df13fadf65e4368699e198943e871dfe976e26e8..909e9c54a5412ace9aec9b820db8f5d229160d9e 100644 (file)
@@ -142,10 +142,10 @@ public:
                return flash_producer_->receive();\r
        }\r
                \r
-       void initialize(const frame_processor_device_ptr& frame_processor)\r
+       void initialize(const safe_ptr<frame_processor_device>& frame_processor)\r
        {\r
-               frame_processor_ = frame_processor;\r
-               flash_producer_->initialize(frame_processor_);\r
+               frame_processor_ = frame_processor.get_shared();\r
+               flash_producer_->initialize(frame_processor);\r
        }\r
 \r
        std::wstring print() const\r
@@ -155,25 +155,23 @@ public:
 \r
        safe_ptr<flash_producer> flash_producer_;\r
        template_version::type ver_;\r
-       frame_processor_device_ptr frame_processor_;\r
+       std::shared_ptr<frame_processor_device> frame_processor_;\r
 };\r
        \r
-safe_ptr<cg_producer> get_default_cg_producer(const channel_ptr& channel, int render_layer)\r
-{\r
-       if(!channel)\r
-               BOOST_THROW_EXCEPTION(null_argument() << msg_info("channel"));\r
-       \r
+safe_ptr<cg_producer> get_default_cg_producer(const safe_ptr<channel>& channel, int render_layer)\r
+{      \r
        auto producer = std::dynamic_pointer_cast<cg_producer>(channel->foreground(render_layer).get().get_shared());\r
        if(producer == nullptr)\r
        {\r
                producer = std::make_shared<cg_producer>();             \r
-               channel->load(render_layer, safe_ptr<frame_producer>::from_shared(producer), load_option::auto_play); \r
+               channel->load(render_layer, safe_ptr<frame_producer>(producer), load_option::auto_play); \r
        }\r
        \r
-       return safe_ptr<cg_producer>::from_shared(producer);\r
+       return safe_ptr<cg_producer>(producer);\r
 }\r
 \r
 cg_producer::cg_producer() : impl_(new implementation()){}\r
+cg_producer::cg_producer(cg_producer&& other) : impl_(std::move(other.impl_)){}\r
 safe_ptr<draw_frame> cg_producer::receive(){return impl_->receive();}\r
 void cg_producer::clear(){impl_->clear();}\r
 void cg_producer::add(int layer, const std::wstring& template_name,  bool play_on_load, const std::wstring& startFromLabel, const std::wstring& data){impl_->add(layer, template_name, play_on_load, startFromLabel, data);}\r
@@ -183,6 +181,6 @@ void cg_producer::stop(int layer, unsigned int mix_out_duration){impl_->stop(lay
 void cg_producer::next(int layer){impl_->next(layer);}\r
 void cg_producer::update(int layer, const std::wstring& data){impl_->update(layer, data);}\r
 void cg_producer::invoke(int layer, const std::wstring& label){impl_->invoke(layer, label);}\r
-void cg_producer::initialize(const frame_processor_device_ptr& frame_processor){impl_->initialize(frame_processor);}\r
+void cg_producer::initialize(const safe_ptr<frame_processor_device>& frame_processor){impl_->initialize(frame_processor);}\r
 std::wstring cg_producer::print() const{return impl_->print();}\r
 }}}
\ No newline at end of file
index 3cadd526de46f5a3ab36eb00bb6650d7e62c783d..ab29d08c859ac9751f9e4341da917a9918bba8f4 100644 (file)
@@ -12,10 +12,10 @@ public:
        static const unsigned int DEFAULT_LAYER = 5000;\r
 \r
        cg_producer();\r
-       cg_producer(cg_producer&& other) : impl_(std::move(other.impl_)){}\r
+       cg_producer(cg_producer&& other);\r
        \r
        virtual safe_ptr<draw_frame> receive();\r
-       virtual void initialize(const frame_processor_device_ptr& frame_processor);\r
+       virtual void initialize(const safe_ptr<frame_processor_device>& frame_processor);\r
 \r
        void clear();\r
        void add(int layer, const std::wstring& template_name,  bool play_on_load, const std::wstring& start_from_label = TEXT(""), const std::wstring& data = TEXT(""));\r
@@ -33,6 +33,6 @@ private:
        std::shared_ptr<implementation> impl_;\r
 };\r
 \r
-safe_ptr<cg_producer> get_default_cg_producer(const channel_ptr& channel, int layer_index = cg_producer::DEFAULT_LAYER);\r
+safe_ptr<cg_producer> get_default_cg_producer(const safe_ptr<channel>& channel, int layer_index = cg_producer::DEFAULT_LAYER);\r
 \r
 }}}
\ No newline at end of file
index ec4de6e10b29ffc97bf28a6018691b3ab41e7ea7..31f1fbfd502debb90d2c8fd60210969a45aa3d58 100644 (file)
@@ -256,12 +256,12 @@ struct flash_producer::implementation
                \r
        safe_ptr<draw_frame> receive()\r
        {               \r
-               return ((frame_buffer_.try_pop(last_frame_) || !is_empty_) && last_frame_) ? safe_ptr<draw_frame>::from_shared(last_frame_) : draw_frame::empty();\r
+               return ((frame_buffer_.try_pop(last_frame_) || !is_empty_) && last_frame_) ? safe_ptr<draw_frame>(last_frame_) : draw_frame::empty();\r
        }\r
 \r
-       void initialize(const frame_processor_device_ptr& frame_processor)\r
+       void initialize(const safe_ptr<frame_processor_device>& frame_processor)\r
        {\r
-               frame_processor_ = frame_processor;\r
+               frame_processor_ = frame_processor.get_shared();\r
                auto format_desc = frame_processor_->get_video_format_desc();\r
                bmp_frame_ = std::make_shared<bitmap>(format_desc.width, format_desc.height);\r
                start(false);\r
@@ -288,13 +288,14 @@ struct flash_producer::implementation
        executor executor_;\r
        int invalid_count_;\r
 \r
-       frame_processor_device_ptr frame_processor_;\r
+       std::shared_ptr<frame_processor_device> frame_processor_;\r
 };\r
 \r
+flash_producer::flash_producer(flash_producer&& other) : impl_(std::move(other.impl_)){}\r
 flash_producer::flash_producer(const std::wstring& filename) : impl_(new implementation(this, filename)){}\r
 safe_ptr<draw_frame> flash_producer::receive(){return impl_->receive();}\r
 void flash_producer::param(const std::wstring& param){impl_->param(param);}\r
-void flash_producer::initialize(const frame_processor_device_ptr& frame_processor) { impl_->initialize(frame_processor);}\r
+void flash_producer::initialize(const safe_ptr<frame_processor_device>& frame_processor) { impl_->initialize(frame_processor);}\r
 std::wstring flash_producer::print() const {return impl_->print();}\r
 \r
 std::wstring flash_producer::find_template(const std::wstring& template_name)\r
index ff44621faf92a11d905e559a25a76a991714d1b1..2fd6ecd84d7da36189804938f147376bd1d289aa 100644 (file)
@@ -35,12 +35,12 @@ class FlashAxContainer;
 class flash_producer : public frame_producer\r
 {\r
 public:\r
+       flash_producer(flash_producer&& other);\r
 \r
        flash_producer(const std::wstring& filename);\r
-       flash_producer(flash_producer&& other) : impl_(std::move(other.impl_)){}\r
 \r
        virtual safe_ptr<draw_frame> receive();\r
-       virtual void initialize(const frame_processor_device_ptr& frame_processor);\r
+       virtual void initialize(const safe_ptr<frame_processor_device>& frame_processor);\r
        virtual std::wstring print() const;\r
 \r
        void param(const std::wstring& param);\r
diff --git a/core/producer/frame_producer.cpp b/core/producer/frame_producer.cpp
deleted file mode 100644 (file)
index 259e2d6..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-/*\r
-* copyright (c) 2010 Sveriges Television AB <info@casparcg.com>\r
-*\r
-*  This file is part of CasparCG.\r
-*\r
-*    CasparCG is free software: you can redistribute it and/or modify\r
-*    it under the terms of the GNU General Public License as published by\r
-*    the Free Software Foundation, either version 3 of the License, or\r
-*    (at your option) any later version.\r
-*\r
-*    CasparCG is distributed in the hope that it will be useful,\r
-*    but WITHOUT ANY WARRANTY; without even the implied warranty of\r
-*    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
-*    GNU General Public License for more details.\r
-\r
-*    You should have received a copy of the GNU General Public License\r
-*    along with CasparCG.  If not, see <http://www.gnu.org/licenses/>.\r
-*\r
-*/\r
-#include "../stdafx.h"\r
-\r
-#include "frame_producer.h"\r
-\r
-namespace caspar { namespace core {\r
-       \r
-struct empty_frame_producer : public frame_producer\r
-{\r
-       virtual safe_ptr<draw_frame> receive(){return draw_frame::eof();}\r
-       virtual void initialize(const frame_processor_device_ptr&){}\r
-       virtual std::wstring print() const { return L"empty";}\r
-};\r
-\r
-safe_ptr<frame_producer> frame_producer::empty()\r
-{\r
-       static auto empty_producer = std::make_shared<empty_frame_producer>();\r
-       return safe_ptr<frame_producer>::from_shared(empty_producer);\r
-}\r
-\r
-inline std::wostream& operator<<(std::wostream& out, const frame_producer& producer)\r
-{\r
-       out << producer.print().c_str();\r
-       return out;\r
-}\r
-\r
-}}
\ No newline at end of file
index b6aa43b493f290f071bc0f6fd4c16f03feab4fbe..0e16262c7ce0d7e41ee54835000371d6599f8998 100644 (file)
@@ -64,19 +64,33 @@ public:
        virtual void set_leading_producer(const safe_ptr<frame_producer>& /*producer*/) {}\r
        \r
        ////////////////////////////////////////////////////////////////////////////////////////////////////\r
-       /// \fn virtual void :::initialize(const frame_processor_device_ptr& frame_processor) = 0;\r
+       /// \fn virtual void :::initialize(const safe_ptr<frame_processor_device>& frame_processor) = 0;\r
        ///\r
        /// \brief      Provides the frame frame_processor used to create frames and initializes the producer. \r
        ///\r
        /// \param      frame_processor The frame frame_processor. \r
        ////////////////////////////////////////////////////////////////////////////////////////////////////\r
-       virtual void initialize(const frame_processor_device_ptr& frame_processor) = 0;\r
+       virtual void initialize(const safe_ptr<frame_processor_device>& frame_processor) = 0;\r
 \r
-       static safe_ptr<frame_producer> empty();\r
+       static safe_ptr<frame_producer> empty()\r
+       {\r
+               struct empty_frame_producer : public frame_producer\r
+               {\r
+                       virtual safe_ptr<draw_frame> receive(){return draw_frame::eof();}\r
+                       virtual void initialize(const safe_ptr<frame_processor_device>&){}\r
+                       virtual std::wstring print() const { return L"empty";}\r
+               };\r
+               static safe_ptr<frame_producer> producer = make_safe<empty_frame_producer>();\r
+               return producer;\r
+       }\r
 \r
        virtual std::wstring print() const = 0;\r
 };\r
 \r
-inline std::wostream& operator<<(std::wostream& out, const frame_producer& producer);\r
+inline std::wostream& operator<<(std::wostream& out, const frame_producer& producer)\r
+{\r
+       out << producer.print().c_str();\r
+       return out;\r
+}\r
 \r
 }}\r
index d8c225c190537937f8eee7ec0325f0b498aef153..0f975bc9c4a9e94e96adf7d224f85272f623daca 100644 (file)
@@ -40,7 +40,7 @@ std::vector<safe_ptr<draw_frame>> receive(std::map<int, layer>& layers)
 \r
 struct frame_producer_device::implementation : boost::noncopyable\r
 {      \r
-       implementation(const frame_processor_device_ptr& frame_processor)  : frame_processor_(frame_processor)\r
+       implementation(const safe_ptr<frame_processor_device>& frame_processor)  : frame_processor_(frame_processor)\r
        {\r
                executor_.start();\r
                executor_.begin_invoke([=]{tick();});\r
@@ -131,14 +131,16 @@ struct frame_producer_device::implementation : boost::noncopyable
                        return it != layers_.end() ? it->second.background() : frame_producer::empty();\r
                });\r
        }\r
+\r
        mutable executor executor_;\r
                                \r
-       frame_processor_device_ptr frame_processor_;\r
+       safe_ptr<frame_processor_device> frame_processor_;\r
                                                \r
        std::map<int, layer> layers_;           \r
 };\r
 \r
-frame_producer_device::frame_producer_device(const frame_processor_device_ptr& frame_processor) : impl_(new implementation(frame_processor)){}\r
+frame_producer_device::frame_producer_device(frame_producer_device&& other) : impl_(std::move(other.impl_)){}\r
+frame_producer_device::frame_producer_device(const safe_ptr<frame_processor_device>& frame_processor) : impl_(new implementation(frame_processor)){}\r
 void frame_producer_device::load(int render_layer, const safe_ptr<frame_producer>& producer, load_option::type option){impl_->load(render_layer, producer, option);}\r
 void frame_producer_device::pause(int render_layer){impl_->pause(render_layer);}\r
 void frame_producer_device::play(int render_layer){impl_->play(render_layer);}\r
index 7017187e45e184e5f3186fdf4b0f98315d2b6693..5b50aa7a7d2bb3d159aa79d9a7b5c400a313a4ca 100644 (file)
@@ -15,7 +15,8 @@ namespace caspar { namespace core {
 class frame_producer_device : boost::noncopyable\r
 {      \r
 public:\r
-       frame_producer_device(const frame_processor_device_ptr& frame_processor);\r
+       frame_producer_device(frame_producer_device&& other);\r
+       frame_producer_device(const safe_ptr<frame_processor_device>& frame_processor);\r
        \r
        void load       (int render_layer, const safe_ptr<frame_producer>& producer, load_option::type option = load_option::none);     \r
        void pause      (int render_layer);\r
index a23d06f589c4a054d07895e986f6240bace83407..e4cec3ba3dcc3e305cff7ebaaee5af9ba58cdcf7 100644 (file)
@@ -23,9 +23,9 @@ struct image_producer : public frame_producer
        \r
        safe_ptr<draw_frame> receive(){return frame_;}\r
 \r
-       void initialize(const frame_processor_device_ptr& frame_processor)\r
+       void initialize(const safe_ptr<frame_processor_device>& frame_processor)\r
        {\r
-               frame_processor_ = frame_processor;\r
+               frame_processor_ = frame_processor.get_shared();\r
                auto bitmap = load_image(filename_);\r
                FreeImage_FlipVertical(bitmap.get());\r
                auto frame = frame_processor->create_frame(FreeImage_GetWidth(bitmap.get()), FreeImage_GetHeight(bitmap.get()));\r
@@ -38,7 +38,7 @@ struct image_producer : public frame_producer
                return L"image_producer. filename: " + filename_;\r
        }\r
        \r
-       frame_processor_device_ptr frame_processor_;\r
+       std::shared_ptr<frame_processor_device> frame_processor_;\r
        std::wstring filename_;\r
        safe_ptr<draw_frame> frame_;\r
 };\r
index 5645f4e0ffbfc0cd1f2bf7bb49d0db96aa436e1c..d66bacd3e4d3a532c308a27ad5cfd6cc3bae0aa9 100644 (file)
 //             return receive();       \r
 //     }\r
 //     \r
-//     void initialize(const frame_processor_device_ptr& frame_processor)\r
+//     void initialize(const safe_ptr<frame_processor_device>& frame_processor)\r
 //     {\r
 //             frame_processor_ = frame_processor;\r
 //             format_desc_ = frame_processor_->get_video_format_desc();\r
 //\r
 //     std::wstring filename_;\r
 //\r
-//     frame_processor_device_ptr frame_processor_;\r
+//     safe_ptr<frame_processor_device> frame_processor_;\r
 //};\r
 //\r
 //safe_ptr<frame_producer> create_image_scroll_producer(const std::vector<std::wstring>& params)\r
index 90c66e757f1f4f0b34a154c9f32c033b6339b981..fc063480db746bc99e7224136e4d821072cd0768 100644 (file)
@@ -93,7 +93,7 @@ struct transition_producer::implementation : boost::noncopyable
                        try\r
                        {\r
                                auto following = producer->get_following_producer();\r
-                               following->initialize(frame_processor_);\r
+                               following->initialize(safe_ptr<frame_processor_device>(frame_processor_));\r
                                following->set_leading_producer(producer);\r
                                producer = following;\r
                        }\r
@@ -146,10 +146,10 @@ struct transition_producer::implementation : boost::noncopyable
                return composite_frame(std::move(my_src_frame), std::move(my_dest_frame));\r
        }\r
                \r
-       void initialize(const frame_processor_device_ptr& frame_processor)\r
+       void initialize(const safe_ptr<frame_processor_device>& frame_processor)\r
        {\r
                dest_producer_->initialize(frame_processor);\r
-               frame_processor_ = frame_processor;\r
+               frame_processor_ = frame_processor.get_shared();\r
        }\r
 \r
        std::wstring print() const\r
@@ -166,14 +166,15 @@ struct transition_producer::implementation : boost::noncopyable
        unsigned short                          current_frame_;\r
        \r
        const transition_info           info_;\r
-       frame_processor_device_ptr      frame_processor_;\r
+       std::shared_ptr<frame_processor_device> frame_processor_;\r
 };\r
 \r
+transition_producer::transition_producer(transition_producer&& other) : impl_(std::move(other.impl_)){}\r
 transition_producer::transition_producer(const safe_ptr<frame_producer>& dest, const transition_info& info) : impl_(new implementation(dest, info)){}\r
 safe_ptr<draw_frame> transition_producer::receive(){return impl_->receive();}\r
 safe_ptr<frame_producer> transition_producer::get_following_producer() const{return impl_->get_following_producer();}\r
 void transition_producer::set_leading_producer(const safe_ptr<frame_producer>& producer) { impl_->set_leading_producer(producer); }\r
-void transition_producer::initialize(const frame_processor_device_ptr& frame_processor) { impl_->initialize(frame_processor);}\r
+void transition_producer::initialize(const safe_ptr<frame_processor_device>& frame_processor) { impl_->initialize(frame_processor);}\r
 std::wstring transition_producer::print() const { return impl_->print();}\r
 \r
 }}\r
index 3d53284fe3d968ba211be0914ff21e52b7cf5076..38d23e9203a2fb162768510fa6e9b1cf291f805c 100644 (file)
@@ -60,13 +60,15 @@ struct transition_info
 class transition_producer : public frame_producer\r
 {\r
 public:\r
+       transition_producer(transition_producer&& other);\r
+\r
        transition_producer(const safe_ptr<frame_producer>& destination, const transition_info& info);\r
-       transition_producer(transition_producer&& other) : impl_(std::move(other.impl_)){}\r
+\r
        safe_ptr<draw_frame> receive();\r
 \r
        safe_ptr<frame_producer> get_following_producer() const;\r
        void set_leading_producer(const safe_ptr<frame_producer>& producer);\r
-       virtual void initialize(const frame_processor_device_ptr& frame_processor);\r
+       virtual void initialize(const safe_ptr<frame_processor_device>& frame_processor);\r
        virtual std::wstring print() const;\r
 private:\r
        struct implementation;\r
index f53226cacbbc8934fb4287c781a676476619ee33..7c31089c00d9b20e74f540dc095026f39f915bb3 100644 (file)
@@ -55,8 +55,8 @@ namespace amcp {
                void SetClientInfo(IO::ClientInfoPtr& s){pClientInfo_ = s;}\r
                IO::ClientInfoPtr GetClientInfo(){return pClientInfo_;}\r
 \r
-               void SetChannel(const channel_ptr& pChannel){pChannel_ = pChannel;}\r
-               channel_ptr GetChannel(){return pChannel_;}\r
+               void SetChannel(const std::shared_ptr<channel>& pChannel){pChannel_ = pChannel;}\r
+               std::shared_ptr<channel> GetChannel(){return pChannel_;}\r
 \r
                void SetChannelIndex(unsigned int channelIndex){channelIndex_ = channelIndex;}\r
                unsigned int GetChannelIndex(){return channelIndex_;}\r
@@ -81,7 +81,7 @@ namespace amcp {
                unsigned int channelIndex_;\r
                int layerIndex_;\r
                IO::ClientInfoPtr pClientInfo_;\r
-               channel_ptr pChannel_;\r
+               std::shared_ptr<channel> pChannel_;\r
                AMCPCommandScheduling scheduling_;\r
                std::wstring replyString_;\r
        };\r
index eb55d948a87ada18f802154ca6a6f41e1ec12250..219e02b0c974e7bd888f09a3e29f27d4ecb5c6f2 100644 (file)
@@ -157,7 +157,7 @@ void AMCPCommand::SendReply()
 \r
 void AMCPCommand::Clear() \r
 {\r
-       pChannel_.reset();\r
+       pChannel_->clear();\r
        pClientInfo_.reset();\r
        channelIndex_ = 0;\r
        _parameters.clear();\r
@@ -447,7 +447,7 @@ bool CGCommand::DoExecuteAdd() {
                std::wstring filename = _parameters[2];\r
                filename.append(extension);\r
 \r
-               flash::get_default_cg_producer(GetChannel(), GetLayerIndex(flash::cg_producer::DEFAULT_LAYER))->add(layer, filename, bDoStart, label, (pDataString!=0) ? pDataString : TEXT(""));\r
+               flash::get_default_cg_producer(safe_ptr<channel>(GetChannel()), GetLayerIndex(flash::cg_producer::DEFAULT_LAYER))->add(layer, filename, bDoStart, label, (pDataString!=0) ? pDataString : TEXT(""));\r
                SetReplyString(TEXT("202 CG OK\r\n"));\r
        }\r
        else\r
@@ -468,7 +468,7 @@ bool CGCommand::DoExecutePlay()
                        return false;\r
                }\r
                int layer = _ttoi(_parameters[1].c_str());\r
-               flash::get_default_cg_producer(GetChannel(), GetLayerIndex(flash::cg_producer::DEFAULT_LAYER))->play(layer);\r
+               flash::get_default_cg_producer(safe_ptr<channel>(GetChannel()), GetLayerIndex(flash::cg_producer::DEFAULT_LAYER))->play(layer);\r
        }\r
        else\r
        {\r
@@ -490,7 +490,7 @@ bool CGCommand::DoExecuteStop()
                        return false;\r
                }\r
                int layer = _ttoi(_parameters[1].c_str());\r
-               flash::get_default_cg_producer(GetChannel(), GetLayerIndex(flash::cg_producer::DEFAULT_LAYER))->stop(layer, 0);\r
+               flash::get_default_cg_producer(safe_ptr<channel>(GetChannel()), GetLayerIndex(flash::cg_producer::DEFAULT_LAYER))->stop(layer, 0);\r
        }\r
        else \r
        {\r
@@ -512,7 +512,7 @@ bool CGCommand::DoExecuteNext()
                        return false;\r
                }\r
                int layer = _ttoi(_parameters[1].c_str());\r
-               flash::get_default_cg_producer(GetChannel(), GetLayerIndex(flash::cg_producer::DEFAULT_LAYER))->next(layer);\r
+               flash::get_default_cg_producer(safe_ptr<channel>(GetChannel()), GetLayerIndex(flash::cg_producer::DEFAULT_LAYER))->next(layer);\r
        }\r
        else \r
        {\r
@@ -534,7 +534,7 @@ bool CGCommand::DoExecuteRemove()
                        return false;\r
                }\r
                int layer = _ttoi(_parameters[1].c_str());\r
-               flash::get_default_cg_producer(GetChannel(), GetLayerIndex(flash::cg_producer::DEFAULT_LAYER))->remove(layer);\r
+               flash::get_default_cg_producer(safe_ptr<channel>(GetChannel()), GetLayerIndex(flash::cg_producer::DEFAULT_LAYER))->remove(layer);\r
        }\r
        else \r
        {\r
@@ -548,7 +548,7 @@ bool CGCommand::DoExecuteRemove()
 \r
 bool CGCommand::DoExecuteClear() \r
 {\r
-       flash::get_default_cg_producer(GetChannel(), GetLayerIndex(flash::cg_producer::DEFAULT_LAYER))->clear();\r
+       flash::get_default_cg_producer(safe_ptr<channel>(GetChannel()), GetLayerIndex(flash::cg_producer::DEFAULT_LAYER))->clear();\r
        SetReplyString(TEXT("202 CG OK\r\n"));\r
        return true;\r
 }\r
@@ -564,7 +564,7 @@ bool CGCommand::DoExecuteUpdate()
                }\r
                int layer = _ttoi(_parameters[1].c_str());\r
                //TODO: Implement indirect data loading from file. Same as in Add\r
-               flash::get_default_cg_producer(GetChannel(), GetLayerIndex(flash::cg_producer::DEFAULT_LAYER))->update(layer, _parameters[2]);\r
+               flash::get_default_cg_producer(safe_ptr<channel>(GetChannel()), GetLayerIndex(flash::cg_producer::DEFAULT_LAYER))->update(layer, _parameters[2]);\r
        }\r
        else \r
        {\r
@@ -586,7 +586,7 @@ bool CGCommand::DoExecuteInvoke()
                        return false;\r
                }\r
                int layer = _ttoi(_parameters[1].c_str());\r
-               flash::get_default_cg_producer(GetChannel(), GetLayerIndex(flash::cg_producer::DEFAULT_LAYER))->invoke(layer, _parameters[2]);\r
+               flash::get_default_cg_producer(safe_ptr<channel>(GetChannel()), GetLayerIndex(flash::cg_producer::DEFAULT_LAYER))->invoke(layer, _parameters[2]);\r
        }\r
        else \r
        {\r
@@ -725,7 +725,7 @@ bool CinfCommand::DoExecute()
        return false;\r
 }\r
 \r
-void GenerateChannelInfo(int index, const channel_ptr& pChannel, std::wstringstream& replyString)\r
+void GenerateChannelInfo(int index, const safe_ptr<channel>& pChannel, std::wstringstream& replyString)\r
 {\r
        replyString << index << TEXT(" ") << pChannel->get_video_format_desc().name  << TEXT("\r\n") << (pChannel->foreground(0).get()->print());\r
 }\r
index efb3128db0333420584e9d5af2f35827756c169f..9833990a0bdcac740517077ec00666923c276746 100644 (file)
@@ -102,10 +102,10 @@ class CinfCommand : public AMCPCommandBase<false, AddToQueue, 1>
 class InfoCommand : public AMCPCommandBase<false, AddToQueue, 0>\r
 {\r
 public:\r
-       InfoCommand(const std::vector<channel_ptr>& channels) : channels_(channels){}\r
+       InfoCommand(const std::vector<safe_ptr<channel>>& channels) : channels_(channels){}\r
        bool DoExecute();\r
 private:\r
-       const std::vector<channel_ptr>& channels_;\r
+       const std::vector<safe_ptr<channel>>& channels_;\r
 };\r
 \r
 class VersionCommand : public AMCPCommandBase<false, AddToQueue, 0>\r
index f79fbe2727c01d2f6988e35fa6d9e02a382c798c..8eacc63e70080c9b6dc92077a801609932b804f2 100644 (file)
@@ -46,12 +46,12 @@ using IO::ClientInfoPtr;
 \r
 const std::wstring AMCPProtocolStrategy::MessageDelimiter = TEXT("\r\n");\r
 \r
-inline channel_ptr GetChannelSafe(unsigned int index, const std::vector<channel_ptr>& channels)\r
+inline std::shared_ptr<channel> GetChannelSafe(unsigned int index, const std::vector<safe_ptr<channel>>& channels)\r
 {\r
-       return index < channels.size() ? channels[index] : nullptr;\r
+       return index < channels.size() ? channels[index].get_shared() : nullptr;\r
 }\r
 \r
-AMCPProtocolStrategy::AMCPProtocolStrategy(const std::vector<channel_ptr>& channels) : channels_(channels) {\r
+AMCPProtocolStrategy::AMCPProtocolStrategy(const std::vector<safe_ptr<channel>>& channels) : channels_(channels) {\r
        AMCPCommandQueuePtr pGeneralCommandQueue(new AMCPCommandQueue());\r
        if(!pGeneralCommandQueue->Start()) {\r
                CASPAR_LOG(error) << "Failed to start the general command-queue";\r
@@ -62,7 +62,7 @@ AMCPProtocolStrategy::AMCPProtocolStrategy(const std::vector<channel_ptr>& chann
                commandQueues_.push_back(pGeneralCommandQueue);\r
 \r
 \r
-       channel_ptr pChannel;\r
+       std::shared_ptr<channel> pChannel;\r
        unsigned int index = -1;\r
        //Create a commandpump for each channel\r
        while((pChannel = GetChannelSafe(++index, channels_)) != 0) {\r
@@ -256,7 +256,7 @@ AMCPCommandPtr AMCPProtocolStrategy::InterpretCommandString(const std::wstring&
                                        goto ParseFinnished;\r
                                }\r
 \r
-                               channel_ptr pChannel = GetChannelSafe(channelIndex, channels_);\r
+                               std::shared_ptr<channel> pChannel = GetChannelSafe(channelIndex, channels_);\r
                                if(pChannel == 0) {\r
                                        goto ParseFinnished;\r
                                }\r
@@ -354,7 +354,7 @@ std::size_t AMCPProtocolStrategy::TokenizeMessage(const std::wstring& message, s
                        switch(message[charIndex])\r
                        {\r
                        case TEXT('\\'):\r
-                currentToken += TEXT("\\");\r
+                               currentToken += TEXT("\\");\r
                                break;\r
                        case TEXT('\"'):\r
                                currentToken += TEXT("\"");\r
index e95c3ecba6859339e8ea74c8e34e5e02b5d80488..1b976d72927b69e8ad74f2b0943a6290a6b50298 100644 (file)
@@ -43,7 +43,7 @@ class AMCPProtocolStrategy : public IO::IProtocolStrategy, boost::noncopyable
        AMCPProtocolStrategy& operator=(const AMCPProtocolStrategy&);\r
 \r
 public:\r
-       AMCPProtocolStrategy(const std::vector<channel_ptr>& channels);\r
+       AMCPProtocolStrategy(const std::vector<safe_ptr<channel>>& channels);\r
        virtual ~AMCPProtocolStrategy();\r
 \r
        virtual void Parse(const TCHAR* pData, int charCount, IO::ClientInfoPtr pClientInfo);\r
@@ -62,7 +62,7 @@ private:
 \r
        bool QueueCommand(AMCPCommandPtr);\r
 \r
-       std::vector<channel_ptr> channels_;\r
+       std::vector<safe_ptr<channel>> channels_;\r
        std::vector<AMCPCommandQueuePtr> commandQueues_;\r
        static const std::wstring MessageDelimiter;\r
 };\r
index 300033589ee0860a2a91505fc3c94ebf80d6b3db..6d59984c438250f8f6639e05ed9bc04e9da8a5ca 100644 (file)
@@ -40,11 +40,8 @@ namespace caspar { namespace core { namespace cii {
 const std::wstring CIIProtocolStrategy::MessageDelimiter = TEXT("\r\n");\r
 const TCHAR CIIProtocolStrategy::TokenDelimiter = TEXT('\\');\r
 \r
-CIIProtocolStrategy::CIIProtocolStrategy(const std::vector<channel_ptr>& channels) \r
+CIIProtocolStrategy::CIIProtocolStrategy(const std::vector<safe_ptr<channel>>& channels) : pChannel_(channels.at(0))\r
 {\r
-       if(channels.empty())\r
-               BOOST_THROW_EXCEPTION(invalid_argument() << arg_name_info("channels"));\r
-       pChannel_ = channels[0];\r
        executor_.start();\r
 }\r
 \r
index c577c95470b29970bb0f7515fa40b29b69a61842..81d714792b6ad92b7f6159adb8f799ccc6f96395 100644 (file)
@@ -35,14 +35,14 @@ namespace caspar { namespace core { namespace cii {
 class CIIProtocolStrategy : public IO::IProtocolStrategy\r
 {\r
 public:\r
-       CIIProtocolStrategy(const std::vector<channel_ptr>& channels);\r
+       CIIProtocolStrategy(const std::vector<safe_ptr<channel>>& channels);\r
 \r
        void Parse(const TCHAR* pData, int charCount, IO::ClientInfoPtr pClientInfo);\r
        UINT GetCodepage() {return 28591;}      //ISO 8859-1\r
 \r
        void SetProfile(const std::wstring& profile) {currentProfile_ = profile;}\r
 \r
-       channel_ptr GetChannel() const{return this->pChannel_;}\r
+       safe_ptr<channel> GetChannel() const{return this->pChannel_;}\r
 \r
        void DisplayMediaFile(const std::wstring& filename);\r
        void DisplayTemplate(const std::wstring& titleName);\r
@@ -86,7 +86,7 @@ private:
        std::wstring currentMessage_;\r
 \r
        std::wstring currentProfile_;\r
-       channel_ptr pChannel_;\r
+       safe_ptr<channel> pChannel_;\r
 };\r
 \r
 }}}
\ No newline at end of file
index 802c1151d9d1e4f7b6980e34cac4b0075e598ba4..4a059f558dccdc4575288ed4c9aafa43604de5c2 100644 (file)
 \r
 namespace caspar { namespace core { namespace CLK {\r
        \r
-CLKProtocolStrategy::CLKProtocolStrategy(const std::vector<channel_ptr>& channels) \r
-       : currentState_(ExpectingNewCommand), bClockLoaded_(false) \r
-{      \r
-       if(channels.empty())\r
-               BOOST_THROW_EXCEPTION(invalid_argument() << arg_name_info("channels"));\r
-       pChannel_ = channels[0];\r
-}\r
+CLKProtocolStrategy::CLKProtocolStrategy(const std::vector<safe_ptr<channel>>& channels) \r
+       : currentState_(ExpectingNewCommand), bClockLoaded_(false), pChannel_(channels.at(0))\r
+{}\r
 \r
 void CLKProtocolStrategy::Parse(const TCHAR* pData, int charCount, IO::ClientInfoPtr pClientInfo) \r
 {\r
index 1fbb4065f0249dfac7c1ea2c954320fe308473e6..6cd2c777d839a22bd21acf7cee43f3a22dea9bf1 100644 (file)
@@ -30,7 +30,7 @@ namespace caspar { namespace core { namespace CLK {
 class CLKProtocolStrategy : public IO::IProtocolStrategy\r
 {\r
 public:\r
-       CLKProtocolStrategy(const std::vector<channel_ptr>& channels);\r
+       CLKProtocolStrategy(const std::vector<safe_ptr<channel>>& channels);\r
 \r
        void Parse(const TCHAR* pData, int charCount, IO::ClientInfoPtr pClientInfo);\r
        UINT GetCodepage() { return 28591; }    //ISO 8859-1\r
@@ -49,7 +49,7 @@ private:
        CLKCommand currentCommand_;\r
        std::wstringstream currentCommandString_;\r
 \r
-       channel_ptr pChannel_;\r
+       safe_ptr<channel> pChannel_;\r
 \r
        bool bClockLoaded_;\r
 };\r
index 1e2f17a23d1a86ef28230673b8dce427e1505df1..ca0245b295499ca8bd9a34ecdb5d910fd5284d86 100644 (file)
@@ -77,13 +77,12 @@ struct server::implementation : boost::noncopyable
                        auto format_desc = video_format_desc::get(widen(xml_channel.second.get("videomode", "PAL")));           \r
                        if(format_desc.format == video_format::invalid)\r
                                BOOST_THROW_EXCEPTION(caspar_exception() << msg_info("Invalid videomode."));\r
-                       std::vector<frame_consumer_ptr> consumers;\r
+                       std::vector<safe_ptr<frame_consumer>> consumers;\r
 \r
                        BOOST_FOREACH(auto& xml_consumer, xml_channel.second.get_child("consumers"))\r
                        {\r
                                try\r
                                {\r
-                                       frame_consumer_ptr pConsumer;\r
                                        std::string name = xml_consumer.first;\r
                                        if(name == "ogl")\r
                                        {                       \r
@@ -99,19 +98,16 @@ struct server::implementation : boost::noncopyable
                                                        stretch = ogl::stretch::uniform_to_fill;\r
 \r
                                                bool windowed = xml_consumer.second.get("windowed", false);\r
-                                               pConsumer = std::make_shared<ogl::consumer>(format_desc, device, stretch, windowed);\r
+                                               consumers.push_back(ogl::consumer(format_desc, device, stretch, windowed));\r
                                        }\r
                                #ifndef DISABLE_BLUEFISH\r
                                        else if(name == "bluefish")                                     \r
-                                               pConsumer = std::make_shared<bluefish::consumer>(format_desc, xml_consumer.second.get("device", 0), xml_consumer.second.get("embedded-audio", false));                                  \r
+                                               consumers.push_back(bluefish::consumer(format_desc, xml_consumer.second.get("device", 0), xml_consumer.second.get("embedded-audio", false)));                                   \r
                                #endif\r
                                        else if(name == "decklink")\r
-                                               pConsumer = std::make_shared<decklink::decklink_consumer>(format_desc, xml_consumer.second.get("internalkey", false));\r
+                                               consumers.push_back(make_safe<decklink::decklink_consumer>(format_desc, xml_consumer.second.get("internalkey", false)));\r
                                        else if(name == "audio")\r
-                                               pConsumer = std::make_shared<oal::consumer>(format_desc);\r
-\r
-                                       if(pConsumer)                                   \r
-                                               consumers.push_back(pConsumer);                                 \r
+                                               consumers.push_back(oal::consumer(format_desc));                        \r
                                }\r
                                catch(...)\r
                                {\r
@@ -119,10 +115,10 @@ struct server::implementation : boost::noncopyable
                                }\r
                        }\r
                        \r
-                       auto processor_device = std::make_shared<frame_processor_device>(format_desc);\r
-                       auto producer_device = std::make_shared<frame_producer_device>(processor_device);\r
-                       auto consumer_device = std::make_shared<frame_consumer_device>(processor_device, format_desc, consumers);\r
-                       channels_.push_back(std::make_shared<channel>(producer_device, processor_device, consumer_device));\r
+                       auto processor_device = make_safe<frame_processor_device>(format_desc);\r
+                       auto producer_device = make_safe<frame_producer_device>(processor_device);\r
+                       auto consumer_device = make_safe<frame_consumer_device>(processor_device, format_desc, consumers);\r
+                       channels_.push_back(channel(producer_device, processor_device, consumer_device));\r
                }\r
        }\r
                \r
@@ -140,7 +136,7 @@ struct server::implementation : boost::noncopyable
                                {                                       \r
                                        unsigned int port = xml_controller.second.get<unsigned int>("port");\r
                                        port = port != 0 ? port : 5250;\r
-                                       auto asyncserver = std::make_shared<IO::AsyncEventServer>(create_protocol(protocol), port);\r
+                                       auto asyncserver = make_safe<IO::AsyncEventServer>(create_protocol(protocol), port);\r
                                        asyncserver->Start();\r
                                        async_servers_.push_back(asyncserver);\r
                                }\r
@@ -154,21 +150,21 @@ struct server::implementation : boost::noncopyable
                }\r
        }\r
 \r
-       IO::ProtocolStrategyPtr create_protocol(const std::string& name) const\r
+       safe_ptr<IO::IProtocolStrategy> create_protocol(const std::string& name) const\r
        {\r
                if(name == "AMCP")\r
-                       return std::make_shared<amcp::AMCPProtocolStrategy>(channels_);\r
+                       return make_safe<amcp::AMCPProtocolStrategy>(channels_);\r
                else if(name == "CII")\r
-                       return std::make_shared<cii::CIIProtocolStrategy>(channels_);\r
+                       return make_safe<cii::CIIProtocolStrategy>(channels_);\r
                else if(name == "CLOCK")\r
-                       return std::make_shared<CLK::CLKProtocolStrategy>(channels_);\r
+                       return make_safe<CLK::CLKProtocolStrategy>(channels_);\r
                \r
                BOOST_THROW_EXCEPTION(invalid_configuration() << arg_name_info("name") << arg_value_info(name) << msg_info("Invalid protocol"));\r
        }\r
 \r
-       std::vector<IO::AsyncEventServerPtr> async_servers_;\r
+       std::vector<safe_ptr<IO::AsyncEventServer>> async_servers_;\r
        \r
-       std::vector<channel_ptr> channels_;\r
+       std::vector<safe_ptr<channel>> channels_;\r
 \r
        int logLevel_;\r
 \r
@@ -209,7 +205,7 @@ const std::wstring& server::data_folder()
        return server::implementation::data_folder_;\r
 }\r
 \r
-const std::vector<channel_ptr> server::get_channels() const\r
+const std::vector<safe_ptr<channel>> server::get_channels() const\r
 {\r
        return impl_->channels_;\r
 }\r
index 52b2e41f089eb7a5de17c188d3bfd91d84507637..0079360341d00c32cdef0c8f78b5405ecb73bb2b 100644 (file)
@@ -24,7 +24,7 @@ public:
        static const std::wstring& template_folder();           \r
        static const std::wstring& data_folder();\r
 \r
-       const std::vector<channel_ptr> get_channels() const;\r
+       const std::vector<safe_ptr<channel>> get_channels() const;\r
 \r
 private:\r
        struct implementation;\r