]> git.sesse.net Git - casparcg/commitdiff
2.0.0.2:
authorronag <ronag@362d55ac-95cf-4e76-9f9a-cbaa9c17b72d>
Tue, 2 Nov 2010 15:27:07 +0000 (15:27 +0000)
committerronag <ronag@362d55ac-95cf-4e76-9f9a-cbaa9c17b72d>
Tue, 2 Nov 2010 15:27:07 +0000 (15:27 +0000)
- Fixed crash bug in AMCP, where invalid layer string crashed the server.
- Refactored gpu related code.
- Updated layer_test.

git-svn-id: https://casparcg.svn.sourceforge.net/svnroot/casparcg/server/branches/2.0.0.2@212 362d55ac-95cf-4e76-9f9a-cbaa9c17b72d

13 files changed:
common/gl/gl_check.h
core/consumer/ogl/ogl_consumer.cpp
core/frame/gpu_composite_frame.cpp
core/frame/gpu_composite_frame.h
core/frame/gpu_frame.cpp
core/frame/gpu_frame_processor.cpp
core/producer/transition/transition_producer.cpp
core/protocol/amcp/AMCPProtocolStrategy.cpp
core/renderer/layer.cpp
core/renderer/layer.h
test/mock/mock_frame_producer.h [new file with mode: 0644]
test/test.vcxproj
test/test.vcxproj.filters

index c8c10a98050ba903621a26a77ef951ba7584f56d..00d78c0f6ac8a128828f8fe734984e27cbb51c1d 100644 (file)
@@ -109,14 +109,14 @@ inline void SMFL_GLCheckError(const std::string& expr, const std::string& File,
        \r
 #define CASPAR_GL_EXPR_STR(expr) #expr\r
 \r
-#define CASPAR_GL_CHECK(expr) \\r
+#define GL(expr) \\r
        do \\r
        { \\r
                (expr);  \\r
                caspar::common::gl::SMFL_GLCheckError(CASPAR_GL_EXPR_STR(expr), __FILE__, __LINE__);\\r
        }while(0);\r
 #else\r
-#define CASPAR_GL_CHECK(expr) expr\r
+#define GL(expr) expr\r
 #endif\r
 \r
 }}}
\ No newline at end of file
index ae9be4b79745a32d200a111e1e6a1c02348fe8ec..968d25fc7953f8f5cf6af0bd518a060f9da9233a 100644 (file)
@@ -121,11 +121,11 @@ struct consumer::implementation : boost::noncopyable
                image_.Create(format_desc_.width, format_desc_.height);\r
                sprite_.SetImage(image_);\r
                \r
-               CASPAR_GL_CHECK(glGenBuffersARB(2, pbos_));\r
-               CASPAR_GL_CHECK(glBindBuffer(GL_PIXEL_UNPACK_BUFFER_ARB, pbos_[0]));\r
-               CASPAR_GL_CHECK(glBufferDataARB(GL_PIXEL_UNPACK_BUFFER_ARB, format_desc_.size, 0, GL_STREAM_DRAW));\r
-               CASPAR_GL_CHECK(glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, pbos_[1]));\r
-               CASPAR_GL_CHECK(glBufferDataARB(GL_PIXEL_UNPACK_BUFFER_ARB, format_desc_.size, 0, GL_STREAM_DRAW));             \r
+               GL(glGenBuffersARB(2, pbos_));\r
+               GL(glBindBuffer(GL_PIXEL_UNPACK_BUFFER_ARB, pbos_[0]));\r
+               GL(glBufferDataARB(GL_PIXEL_UNPACK_BUFFER_ARB, format_desc_.size, 0, GL_STREAM_DRAW));\r
+               GL(glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, pbos_[1]));\r
+               GL(glBufferDataARB(GL_PIXEL_UNPACK_BUFFER_ARB, format_desc_.size, 0, GL_STREAM_DRAW));          \r
 \r
                pbo_index_ = 0;\r
        }\r
@@ -170,22 +170,22 @@ struct consumer::implementation : boost::noncopyable
                window_.Clear();\r
        \r
                image_.Bind();\r
-               CASPAR_GL_CHECK(glBindBuffer(GL_PIXEL_UNPACK_BUFFER, pbos_[pbo_index_]));       \r
-               CASPAR_GL_CHECK(glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, format_desc_.width, format_desc_.height, GL_BGRA, GL_UNSIGNED_BYTE, 0));\r
+               GL(glBindBuffer(GL_PIXEL_UNPACK_BUFFER, pbos_[pbo_index_]));    \r
+               GL(glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, format_desc_.width, format_desc_.height, GL_BGRA, GL_UNSIGNED_BYTE, 0));\r
 \r
                window_.Draw(sprite_);\r
 \r
                // Update\r
                int nextPboIndex = pbo_index_ ^ 1;\r
 \r
-               CASPAR_GL_CHECK(glBindBuffer(GL_PIXEL_UNPACK_BUFFER, pbos_[nextPboIndex]));\r
-               CASPAR_GL_CHECK(glBufferData(GL_PIXEL_UNPACK_BUFFER, format_desc_.size, NULL, GL_STREAM_DRAW));\r
+               GL(glBindBuffer(GL_PIXEL_UNPACK_BUFFER, pbos_[nextPboIndex]));\r
+               GL(glBufferData(GL_PIXEL_UNPACK_BUFFER, format_desc_.size, NULL, GL_STREAM_DRAW));\r
                GLubyte* ptr = static_cast<GLubyte*>(glMapBuffer(GL_PIXEL_UNPACK_BUFFER, GL_WRITE_ONLY));\r
 \r
                if(ptr != NULL)                 \r
                {\r
                        common::copy(ptr, frame->data(), frame->size());\r
-                       CASPAR_GL_CHECK(glUnmapBuffer(GL_PIXEL_UNPACK_BUFFER));\r
+                       GL(glUnmapBuffer(GL_PIXEL_UNPACK_BUFFER));\r
                }\r
 \r
                // Swap\r
index cb08e71a2b59ff72ffda1ffb261e68cebea3769c..17b8faaae9228dd378e2ae28a0b1ff5590bd51a9 100644 (file)
@@ -4,6 +4,8 @@
 #include "../../common/gl/gl_check.h"\r
 #include "../../common/utility/memory.h"\r
 \r
+#include <boost/range/algorithm.hpp>\r
+\r
 #include <algorithm>\r
 #include <numeric>\r
 \r
@@ -15,29 +17,32 @@ struct gpu_composite_frame::implementation : boost::noncopyable
 \r
        void write_lock()\r
        {\r
-               std::for_each(frames_.begin(), frames_.end(), std::mem_fn(&gpu_frame::write_lock));             \r
+               boost::range::for_each(frames_, std::mem_fn(&gpu_frame::write_lock));           \r
        }\r
 \r
        bool write_unlock()\r
        {\r
-               return std::all_of(frames_.begin(), frames_.end(), std::mem_fn(&gpu_frame::write_unlock));                      \r
+               return std::all_of(frames_.begin(), frames_.end(), \r
+                                                       std::mem_fn(&gpu_frame::write_unlock));                 \r
        }\r
        \r
        void read_lock(GLenum mode)\r
        {       \r
-               std::for_each(frames_.begin(), frames_.end(), std::bind(&gpu_frame::read_lock, std::placeholders::_1, mode));           \r
+               boost::range::for_each(frames_, std::bind(&gpu_frame::read_lock, \r
+                                                                                                       std::placeholders::_1, mode));          \r
        }\r
 \r
        bool read_unlock()\r
        {\r
-               return std::all_of(frames_.begin(), frames_.end(), std::mem_fn(&gpu_frame::read_unlock));               \r
+               return std::all_of(frames_.begin(), frames_.end(), \r
+                                                       std::mem_fn(&gpu_frame::read_unlock));          \r
        }\r
 \r
        void draw()\r
        {\r
                glPushMatrix();\r
                glTranslated(self_->x()*2.0, self_->y()*2.0, 0.0);\r
-               std::for_each(frames_.begin(), frames_.end(), std::mem_fn(&gpu_frame::draw));\r
+               boost::range::for_each(frames_, std::mem_fn(&gpu_frame::draw));\r
                glPopMatrix();\r
        }\r
                \r
@@ -50,7 +55,9 @@ struct gpu_composite_frame::implementation : boost::noncopyable
                else\r
                {\r
                        for(size_t n = 0; n < frame->audio_data().size(); ++n)\r
-                               self_->audio_data()[n] = static_cast<short>(static_cast<int>(self_->audio_data()[n]) + static_cast<int>(frame->audio_data()[n]) & 0xFFFF);                              \r
+                               self_->audio_data()[n] = static_cast<short>(\r
+                                       static_cast<int>(self_->audio_data()[n]) + \r
+                                       static_cast<int>(frame->audio_data()[n]) & 0xFFFF);                             \r
                }\r
        }\r
 \r
@@ -66,7 +73,8 @@ struct gpu_composite_frame::implementation : boost::noncopyable
 \r
 #pragma warning (disable : 4355)\r
 \r
-gpu_composite_frame::gpu_composite_frame(size_t width, size_t height) : gpu_frame(width, height), impl_(new implementation(this)){}\r
+gpu_composite_frame::gpu_composite_frame() \r
+       : gpu_frame(0, 0), impl_(new implementation(this)){}\r
 void gpu_composite_frame::write_lock(){impl_->write_lock();}\r
 bool gpu_composite_frame::write_unlock(){return impl_->write_unlock();}        \r
 void gpu_composite_frame::read_lock(GLenum mode){impl_->read_lock(mode);}\r
@@ -75,9 +83,11 @@ void gpu_composite_frame::draw(){impl_->draw();}
 unsigned char* gpu_composite_frame::data(){return impl_->data();}\r
 void gpu_composite_frame::add(const gpu_frame_ptr& frame){impl_->add(frame);}\r
 \r
-gpu_frame_ptr gpu_composite_frame::interlace(const gpu_frame_ptr& frame1 ,const gpu_frame_ptr& frame2, video_mode mode)\r
+gpu_frame_ptr gpu_composite_frame::interlace(const gpu_frame_ptr& frame1,\r
+                                                                                               const gpu_frame_ptr& frame2, \r
+                                                                                               video_mode mode)\r
 {                      \r
-       auto result = std::make_shared<gpu_composite_frame>(frame1->width(), frame1->height());\r
+       auto result = std::make_shared<gpu_composite_frame>();\r
        result->add(frame1);\r
        result->add(frame2);\r
        if(mode == video_mode::upper)\r
index 504768369b3ea0d40158571a4885a00d68f11b73..dc77548116e3369c4a0975eb0d705a801ef5115b 100644 (file)
@@ -11,20 +11,20 @@ namespace caspar { namespace core {
 class gpu_composite_frame : public gpu_frame\r
 {\r
 public:\r
-       gpu_composite_frame(size_t width, size_t height);\r
+       gpu_composite_frame();\r
+                                               \r
+       void add(const gpu_frame_ptr& frame);\r
 \r
+       static gpu_frame_ptr interlace(const gpu_frame_ptr& frame1,\r
+                                                                       const gpu_frame_ptr& frame2, video_mode mode);\r
+       \r
+private:\r
+       virtual unsigned char* data();\r
        virtual void write_lock();\r
        virtual bool write_unlock();\r
        virtual void read_lock(GLenum mode);\r
        virtual bool read_unlock();\r
        virtual void draw();\r
-                                       \r
-       void add(const gpu_frame_ptr& frame);\r
-\r
-       static gpu_frame_ptr interlace(const gpu_frame_ptr& frame1 ,const gpu_frame_ptr& frame2, video_mode mode);\r
-       \r
-private:\r
-       virtual unsigned char* data();\r
 \r
        struct implementation;\r
        std::shared_ptr<implementation> impl_;\r
index a7f788fbe65d711b770233d8203b2d2fbfd57f77..7bcbf6db36c151e81db05354b9523c7316ad83aa 100644 (file)
@@ -7,65 +7,66 @@
 namespace caspar { namespace core {\r
        \r
 GLubyte progressive_pattern[] = {\r
-    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,\r
-    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,\r
-    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,\r
-    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,\r
-    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,\r
-    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,\r
-    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,\r
-    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,\r
-    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,\r
-    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,\r
-    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,\r
-    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,\r
-    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,\r
-    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,\r
-    0xff, 0xff, 0xFF, 0xff, 0xff, 0xff, 0xff, 0xff,\r
-    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff};\r
+       0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,\r
+       0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,\r
+       0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,\r
+       0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,\r
+       0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,\r
+       0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,\r
+       0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,\r
+       0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,\r
+       0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,\r
+       0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,\r
+       0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,\r
+       0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,\r
+       0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,\r
+       0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,\r
+       0xff, 0xff, 0xFF, 0xff, 0xff, 0xff, 0xff, 0xff,\r
+       0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff};\r
        \r
 GLubyte upper_pattern[] = {\r
-    0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00,\r
-    0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00,\r
-    0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00,\r
-    0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00,\r
-    0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00,\r
-    0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00,\r
-    0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00,\r
-    0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00,\r
-    0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00,\r
-    0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00,\r
-    0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00,\r
-    0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00,\r
-    0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00,\r
-    0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00,\r
-    0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00,\r
-    0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00};\r
+       0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00,\r
+       0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00,\r
+       0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00,\r
+       0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00,\r
+       0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00,\r
+       0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00,\r
+       0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00,\r
+       0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00,\r
+       0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00,\r
+       0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00,\r
+       0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00,\r
+       0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00,\r
+       0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00,\r
+       0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00,\r
+       0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00,\r
+       0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00};\r
                \r
 GLubyte lower_pattern[] = {\r
                                                        0x00, 0x00, 0x00, 0x00,\r
-    0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00,\r
-    0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00,\r
-    0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00,\r
-    0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00,\r
-    0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00,\r
-    0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00,\r
-    0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00,\r
-    0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00,\r
-    0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00,\r
-    0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00,\r
-    0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00,\r
-    0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00,\r
-    0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00,\r
-    0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00,\r
-    0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00,\r
+       0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00,\r
+       0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00,\r
+       0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00,\r
+       0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00,\r
+       0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00,\r
+       0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00,\r
+       0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00,\r
+       0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00,\r
+       0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00,\r
+       0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00,\r
+       0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00,\r
+       0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00,\r
+       0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00,\r
+       0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00,\r
+       0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00,\r
        0xff, 0xff, 0xff, 0xff};\r
-\r
+                                                                                                                                                                                                                                                                                                               \r
 struct gpu_frame::implementation : boost::noncopyable\r
 {\r
        implementation(size_t width, size_t height) \r
-               : pbo_(0), data_(nullptr), width_(width), height_(height), size_(width*height*4), \r
-               reading_(false), texture_(0), alpha_(1.0f), x_(0.0f), y_(0.0f), mode_(video_mode::progressive)\r
+               : pbo_(0), data_(nullptr), width_(width), height_(height), \r
+                       size_(width*height*4), reading_(false), texture_(0), alpha_(1.0f), \r
+                       x_(0.0f), y_(0.0f), mode_(video_mode::progressive)\r
        {       \r
        }\r
 \r
@@ -80,7 +81,7 @@ struct gpu_frame::implementation : boost::noncopyable
        GLuint pbo()\r
        {               \r
                if(pbo_ == 0)\r
-                       CASPAR_GL_CHECK(glGenBuffers(1, &pbo_));\r
+                       GL(glGenBuffers(1, &pbo_));\r
                return pbo_;\r
        }\r
 \r
@@ -88,55 +89,58 @@ struct gpu_frame::implementation : boost::noncopyable
        {\r
                if(texture_ == 0)\r
                {\r
-                       CASPAR_GL_CHECK(glGenTextures(1, &texture_));\r
+                       GL(glGenTextures(1, &texture_));\r
 \r
-                       CASPAR_GL_CHECK(glBindTexture(GL_TEXTURE_2D, texture_));\r
+                       GL(glBindTexture(GL_TEXTURE_2D, texture_));\r
 \r
-                       CASPAR_GL_CHECK(glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR));\r
-                       CASPAR_GL_CHECK(glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR));\r
-                       CASPAR_GL_CHECK(glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE));\r
-                       CASPAR_GL_CHECK(glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE));\r
+                       GL(glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR));\r
+                       GL(glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR));\r
+                       GL(glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE));\r
+                       GL(glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE));\r
 \r
-                       CASPAR_GL_CHECK(glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, width_, height_, 0, GL_BGRA, GL_UNSIGNED_BYTE, NULL));\r
+                       GL(glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, width_, height_, 0, GL_BGRA, \r
+                                                               GL_UNSIGNED_BYTE, NULL));\r
                }\r
 \r
-               CASPAR_GL_CHECK(glBindBuffer(GL_PIXEL_UNPACK_BUFFER, pbo()));\r
+               GL(glBindBuffer(GL_PIXEL_UNPACK_BUFFER, pbo()));\r
                if(data_ != nullptr)\r
                {\r
-                       CASPAR_GL_CHECK(glUnmapBuffer(GL_PIXEL_UNPACK_BUFFER));\r
+                       GL(glUnmapBuffer(GL_PIXEL_UNPACK_BUFFER));\r
                        data_ = nullptr;\r
                }\r
-               CASPAR_GL_CHECK(glBindTexture(GL_TEXTURE_2D, texture_));\r
-               CASPAR_GL_CHECK(glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, width_, height_, GL_BGRA, GL_UNSIGNED_BYTE, NULL));\r
-               CASPAR_GL_CHECK(glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0));\r
+               GL(glBindTexture(GL_TEXTURE_2D, texture_));\r
+               GL(glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, width_, height_, GL_BGRA, \r
+                                                       GL_UNSIGNED_BYTE, NULL));\r
+               GL(glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0));\r
        }\r
 \r
        bool write_unlock()\r
        {\r
                if(data_ != nullptr)\r
                        return false;\r
-               CASPAR_GL_CHECK(glBindBuffer(GL_PIXEL_UNPACK_BUFFER, pbo()));\r
-               CASPAR_GL_CHECK(glBufferData(GL_PIXEL_UNPACK_BUFFER, size_, NULL, GL_STREAM_DRAW));\r
+               GL(glBindBuffer(GL_PIXEL_UNPACK_BUFFER, pbo()));\r
+               GL(glBufferData(GL_PIXEL_UNPACK_BUFFER, size_, NULL, GL_STREAM_DRAW));\r
                void* ptr = glMapBuffer(GL_PIXEL_UNPACK_BUFFER, GL_WRITE_ONLY);\r
-               CASPAR_GL_CHECK(glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0));\r
+               GL(glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0));\r
                data_ = reinterpret_cast<unsigned char*>(ptr);\r
                if(!data_)\r
-                       BOOST_THROW_EXCEPTION(invalid_operation() << msg_info("glMapBuffer failed"));\r
+                       BOOST_THROW_EXCEPTION(invalid_operation() \r
+                                                                       << msg_info("glMapBuffer failed"));\r
                return true;\r
        }\r
        \r
        void read_lock(GLenum mode)\r
        {       \r
-               CASPAR_GL_CHECK(glReadBuffer(mode));\r
-               CASPAR_GL_CHECK(glBindBuffer(GL_PIXEL_PACK_BUFFER, pbo()));\r
+               GL(glReadBuffer(mode));\r
+               GL(glBindBuffer(GL_PIXEL_PACK_BUFFER, pbo()));\r
                if(data_ != nullptr)    \r
                {       \r
-                       CASPAR_GL_CHECK(glUnmapBuffer(GL_PIXEL_PACK_BUFFER));   \r
+                       GL(glUnmapBuffer(GL_PIXEL_PACK_BUFFER));        \r
                        data_ = nullptr;\r
                }\r
-               CASPAR_GL_CHECK(glBufferData(GL_PIXEL_PACK_BUFFER, size_, NULL, GL_STREAM_READ));       \r
-               CASPAR_GL_CHECK(glReadPixels(0, 0, width_, height_, GL_BGRA, GL_UNSIGNED_BYTE, NULL));\r
-               CASPAR_GL_CHECK(glBindBuffer(GL_PIXEL_PACK_BUFFER, 0));\r
+               GL(glBufferData(GL_PIXEL_PACK_BUFFER, size_, NULL, GL_STREAM_READ));    \r
+               GL(glReadPixels(0, 0, width_, height_, GL_BGRA, GL_UNSIGNED_BYTE, NULL));\r
+               GL(glBindBuffer(GL_PIXEL_PACK_BUFFER, 0));\r
                reading_ = true;\r
        }\r
 \r
@@ -144,9 +148,9 @@ struct gpu_frame::implementation : boost::noncopyable
        {\r
                if(data_ != nullptr || !reading_)\r
                        return false;\r
-               CASPAR_GL_CHECK(glBindBuffer(GL_PIXEL_PACK_BUFFER, pbo()));\r
+               GL(glBindBuffer(GL_PIXEL_PACK_BUFFER, pbo()));\r
                void* ptr = glMapBuffer(GL_PIXEL_PACK_BUFFER, GL_READ_ONLY);   \r
-               CASPAR_GL_CHECK(glBindBuffer(GL_PIXEL_PACK_BUFFER, 0));\r
+               GL(glBindBuffer(GL_PIXEL_PACK_BUFFER, 0));\r
                data_ = reinterpret_cast<unsigned char*>(ptr);\r
                if(!data_)\r
                        BOOST_THROW_EXCEPTION(std::bad_alloc());\r
@@ -167,7 +171,7 @@ struct gpu_frame::implementation : boost::noncopyable
                else if(mode_ == video_mode::lower)\r
                        glPolygonStipple(lower_pattern);\r
 \r
-               CASPAR_GL_CHECK(glBindTexture(GL_TEXTURE_2D, texture_));\r
+               GL(glBindTexture(GL_TEXTURE_2D, texture_));\r
                glBegin(GL_QUADS);\r
                        glTexCoord2f(0.0f, 0.0f); glVertex2f(-1.0f, -1.0f);\r
                        glTexCoord2f(1.0f, 0.0f); glVertex2f( 1.0f, -1.0f);\r
@@ -188,9 +192,9 @@ struct gpu_frame::implementation : boost::noncopyable
        {\r
                audio_data_.clear();\r
                alpha_ = 1.0f;\r
-               x_ = 0.0f;\r
-               y_ = 0.0f;\r
-               mode_ = video_mode::progressive;\r
+               x_     = 0.0f;\r
+               y_     = 0.0f;\r
+               mode_  = video_mode::progressive;\r
        }\r
 \r
        gpu_frame* self_;\r
@@ -209,7 +213,8 @@ struct gpu_frame::implementation : boost::noncopyable
        video_mode mode_;\r
 };\r
 \r
-gpu_frame::gpu_frame(size_t width, size_t height) : impl_(new implementation(width, height)){}\r
+gpu_frame::gpu_frame(size_t width, size_t height) \r
+       : impl_(new implementation(width, height)){}\r
 void gpu_frame::write_lock(){impl_->write_lock();}\r
 bool gpu_frame::write_unlock(){return impl_->write_unlock();}  \r
 void gpu_frame::read_lock(GLenum mode){impl_->read_lock(mode);}\r
@@ -219,7 +224,7 @@ unsigned char* gpu_frame::data(){return impl_->data();}
 size_t gpu_frame::size() const { return impl_->size_; }\r
 size_t gpu_frame::width() const { return impl_->width_;}\r
 size_t gpu_frame::height() const { return impl_->height_;}\r
-const std::vector<short>& gpu_frame::audio_data() const { return impl_->audio_data_; } \r
+const std::vector<short>& gpu_frame::audio_data() const{return impl_->audio_data_;}    \r
 std::vector<short>& gpu_frame::audio_data() { return impl_->audio_data_; }\r
 void gpu_frame::reset(){impl_->reset();}\r
 double gpu_frame::alpha() const{ return impl_->alpha_;}\r
index 5c260de85909986045212a53607abf7affce9741..82d674e73e5283ff0c8c4c2e95c9956f2c15d662 100644 (file)
 \r
 namespace caspar { namespace core {\r
        \r
-class frame_buffer : boost::noncopyable\r
-{\r
-public:\r
-       frame_buffer(size_t width, size_t height)\r
-       {\r
-               CASPAR_GL_CHECK(glGenTextures(1, &texture_));   \r
-\r
-               CASPAR_GL_CHECK(glBindTexture(GL_TEXTURE_2D, texture_));\r
-\r
-               CASPAR_GL_CHECK(glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST));\r
-               CASPAR_GL_CHECK(glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR));\r
-               //CASPAR_GL_CHECK(glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE));\r
-               //CASPAR_GL_CHECK(glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE));\r
-\r
-               CASPAR_GL_CHECK(glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, width, height, 0, GL_BGRA, GL_UNSIGNED_BYTE, NULL));\r
-\r
-               glGenFramebuffersEXT(1, &fbo_);\r
-               \r
-               glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fbo_);\r
-               glBindTexture(GL_TEXTURE_2D, texture_);\r
-               glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, texture_, 0);\r
-       }\r
-\r
-       ~frame_buffer()\r
-       {\r
-               glDeleteFramebuffersEXT(1, &fbo_);\r
-       }\r
-               \r
-       GLuint handle() { return fbo_; }\r
-       GLenum attachement() { return GL_COLOR_ATTACHMENT0_EXT; }\r
-       \r
-private:\r
-       GLuint texture_;\r
-       GLuint fbo_;\r
-};\r
-typedef std::shared_ptr<frame_buffer> frame_buffer_ptr;\r
-\r
 struct gpu_frame_processor::implementation : boost::noncopyable\r
 {      \r
-       implementation(const frame_format_desc& format_desc) : format_desc_(format_desc)\r
+       implementation(const frame_format_desc& format_desc) \r
+               : format_desc_(format_desc), index_(0)\r
        {               \r
                input_.set_capacity(2);\r
                executor_.start();\r
@@ -78,21 +42,32 @@ struct gpu_frame_processor::implementation : boost::noncopyable
                {\r
                        ogl_context_.reset(new sf::Context());\r
                        ogl_context_->SetActive(true);\r
-                       CASPAR_GL_CHECK(glEnable(GL_POLYGON_STIPPLE));\r
-                       CASPAR_GL_CHECK(glEnable(GL_TEXTURE_2D));\r
-                       CASPAR_GL_CHECK(glEnable(GL_BLEND));\r
-                       CASPAR_GL_CHECK(glDisable(GL_DEPTH_TEST));\r
-                       CASPAR_GL_CHECK(glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA));                     \r
-                       CASPAR_GL_CHECK(glClearColor(0.0, 0.0, 0.0, 0.0));\r
-                       CASPAR_GL_CHECK(glViewport(0, 0, format_desc_.width, format_desc_.height));\r
-                       glLoadIdentity();        \r
+                       GL(glEnable(GL_POLYGON_STIPPLE));\r
+                       GL(glEnable(GL_TEXTURE_2D));\r
+                       GL(glEnable(GL_BLEND));\r
+                       GL(glDisable(GL_DEPTH_TEST));\r
+                       GL(glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA));                  \r
+                       GL(glClearColor(0.0, 0.0, 0.0, 0.0));\r
+                       GL(glViewport(0, 0, format_desc_.width, format_desc_.height));\r
+                       glLoadIdentity();       \r
+                                               \r
+                       // Create and bind a framebuffer\r
+                       GL(glGenTextures(1, &render_texture_)); \r
+                       GL(glBindTexture(GL_TEXTURE_2D, render_texture_));                      \r
+                       GL(glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, format_desc_.width, \r
+                                                               format_desc_.height, 0, GL_BGRA, \r
+                                                               GL_UNSIGNED_BYTE, NULL));\r
+                       GL(glGenFramebuffersEXT(1, &fbo_));             \r
+                       GL(glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fbo_));\r
+                       GL(glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, \r
+                                                                                       GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, \r
+                                                                                       render_texture_, 0));\r
                        \r
-                       reading_.resize(2, std::make_shared<gpu_composite_frame>(format_desc_.width, format_desc_.height));\r
-                       writing_.resize(2, std::make_shared<gpu_composite_frame>(format_desc_.width, format_desc_.height));\r
-                       fbo_ = std::make_shared<frame_buffer>(format_desc_.width, format_desc_.height);\r
-                       output_frame_ = std::make_shared<gpu_frame>(format_desc_.width, format_desc_.height);\r
-                       index_ = 0;\r
+                       writing_.resize(2, std::make_shared<gpu_composite_frame>());\r
+                       output_frame_ = std::make_shared<gpu_frame>(format_desc_.width, \r
+                                                                                                                       format_desc_.height);\r
                });\r
+               // Fill pipeline\r
                composite(std::vector<gpu_frame_ptr>());\r
                composite(std::vector<gpu_frame_ptr>());\r
                composite(std::vector<gpu_frame_ptr>());\r
@@ -100,6 +75,7 @@ struct gpu_frame_processor::implementation : boost::noncopyable
 \r
        ~implementation()\r
        {\r
+               glDeleteFramebuffersEXT(1, &fbo_);\r
                executor_.stop();\r
        }\r
                        \r
@@ -107,45 +83,46 @@ struct gpu_frame_processor::implementation : boost::noncopyable
        {\r
                boost::range::remove_erase(frames, nullptr);\r
                boost::range::remove_erase(frames, gpu_frame::null());\r
-               auto composite_frame = std::make_shared<gpu_composite_frame>(format_desc_.width, format_desc_.height);\r
-               boost::range::for_each(frames, std::bind(&gpu_composite_frame::add, composite_frame, std::placeholders::_1));\r
-               input_.push(composite_frame);\r
+               auto composite_frame = std::make_shared<gpu_composite_frame>();\r
+               boost::range::for_each(frames, std::bind(&gpu_composite_frame::add, \r
+                                                                                                       composite_frame, \r
+                                                                                                       std::placeholders::_1));\r
 \r
+               input_.push(composite_frame);\r
                executor_.begin_invoke([=]\r
                {\r
                        try\r
                        {\r
-                               gpu_composite_frame_ptr frame;\r
+                               gpu_frame_ptr frame;\r
                                input_.pop(frame);\r
 \r
                                index_ = (index_ + 1) % 2;\r
                                int next_index = (index_ + 1) % 2;\r
 \r
-                               // 2. Start asynchronous DMA transfer to video memory\r
-                               // Lock frames and give pointer ownership to OpenGL             \r
-                               writing_[index_] = std::move(reading_[index_]);         \r
+                               // 1. Start asynchronous DMA transfer to video memory.\r
+                               writing_[index_] = std::move(frame);            \r
+                               // Lock frame and give pointer ownership to OpenGL.\r
                                writing_[index_]->write_lock();\r
                                \r
-                               // 1. Copy to page-locked memory\r
-                               reading_[next_index] = std::move(frame);\r
-                                                               \r
-                               // 4. Output to external buffer\r
+                               // 3. Output to external buffer.\r
                                if(output_frame_->read_unlock())\r
                                        output_.push(output_frame_);\r
                \r
-                               // 3. Draw to framebuffer and start asynchronous DMA transfer to page-locked memory                             \r
-                               // Clear framebuffer\r
+                               // Clear framebuffer.\r
                                glClear(GL_COLOR_BUFFER_BIT);   \r
+\r
+                               // 2. Draw to framebuffer and start asynchronous DMA transfer \r
+                               // to page-locked memory.\r
                                writing_[next_index]->draw();\r
                                \r
                                // Create an output frame\r
-                               output_frame_ = create_frame(format_desc_.width, format_desc_.height);\r
+                               output_frame_ = create_output_frame();\r
                        \r
-                               // Read from framebuffer into page-locked memory\r
+                               // Read from framebuffer into page-locked memory.\r
                                output_frame_->read_lock(GL_COLOR_ATTACHMENT0_EXT);\r
                                output_frame_->audio_data() = std::move(writing_[next_index]->audio_data());\r
 \r
-                               // Return frames to pool\r
+                               // Return frames to pool.\r
                                writing_[next_index] = nullptr;\r
                        }\r
                        catch(...)\r
@@ -154,11 +131,25 @@ struct gpu_frame_processor::implementation : boost::noncopyable
                        }\r
                });     \r
        }\r
+\r
+       gpu_frame_ptr create_output_frame()\r
+       {\r
+               gpu_frame_ptr frame;\r
+               if(!reading_pool_.try_pop(frame))\r
+                       frame = std::make_shared<gpu_frame>(format_desc_.width, \r
+                                                                                                       format_desc_.height);\r
+\r
+               return gpu_frame_ptr(frame.get(), [=](gpu_frame*)\r
+               {\r
+                       frame->reset();\r
+                       reading_pool_.push(frame);\r
+               });\r
+       }\r
                        \r
        gpu_frame_ptr create_frame(size_t width, size_t height)\r
        {\r
                size_t key = width | (height << 16);\r
-               auto& pool = reading_frame_pools_[key];\r
+               auto& pool = writing_pools_[key];\r
                \r
                gpu_frame_ptr frame;\r
                if(!pool.try_pop(frame))\r
@@ -175,10 +166,10 @@ struct gpu_frame_processor::implementation : boost::noncopyable
                {\r
                        frame->write_unlock();\r
                        frame->reset();\r
-                       reading_frame_pools_[key].push(frame);\r
+                       writing_pools_[key].push(frame);\r
                };\r
 \r
-               return gpu_frame_ptr(frame.get(), [=](gpu_frame*)\r
+               return gpu_frame_ptr(frame.get(), [=](gpu_frame*)                                                       \r
                {\r
                        executor_.begin_invoke(destructor);\r
                });\r
@@ -189,16 +180,15 @@ struct gpu_frame_processor::implementation : boost::noncopyable
                output_.pop(frame);\r
        }\r
                        \r
-       tbb::concurrent_unordered_map<size_t, tbb::concurrent_bounded_queue<gpu_frame_ptr>> reading_frame_pools_;\r
-\r
-       frame_buffer_ptr fbo_;\r
+       typedef tbb::concurrent_bounded_queue<gpu_frame_ptr> gpu_frame_queue;\r
+       tbb::concurrent_unordered_map<size_t, gpu_frame_queue> writing_pools_;\r
+       gpu_frame_queue reading_pool_;  \r
 \r
-       tbb::concurrent_bounded_queue<gpu_composite_frame_ptr> input_;\r
-       tbb::concurrent_bounded_queue<gpu_frame_ptr> output_;   \r
+       gpu_frame_queue input_;\r
+       std::vector<gpu_frame_ptr> writing_;\r
+       gpu_frame_queue output_;        \r
 \r
        size_t index_;\r
-       std::vector<gpu_composite_frame_ptr> reading_;\r
-       std::vector<gpu_composite_frame_ptr> writing_;\r
 \r
        gpu_frame_ptr output_frame_;                    \r
        frame_format_desc format_desc_;\r
@@ -206,6 +196,9 @@ struct gpu_frame_processor::implementation : boost::noncopyable
        std::unique_ptr<sf::Context> ogl_context_;\r
        \r
        common::executor executor_;\r
+\r
+       GLuint render_texture_;\r
+       GLuint fbo_;\r
 };\r
        \r
 gpu_frame_processor::gpu_frame_processor(const frame_format_desc& format_desc) : impl_(new implementation(format_desc)){}\r
index 0dcc110f336125d09149dd4f90462f90c24e5c89..58ca77579137913e952178600d90a5387397ed8b 100644 (file)
@@ -106,7 +106,7 @@ struct transition_producer::implementation : boost::noncopyable
                        src_frame->audio_data()[n] = static_cast<short>((static_cast<int>(src_frame->audio_data()[n])*(256-volume))>>8);\r
                                \r
                float alpha = static_cast<float>(current_frame_)/static_cast<float>(info_.duration);\r
-               auto composite = std::make_shared<gpu_composite_frame>(format_desc_.width, format_desc_.height);\r
+               auto composite = std::make_shared<gpu_composite_frame>();\r
                composite->add(src_frame);\r
                composite->add(dest_frame);\r
                if(info_.type == transition_type::mix)\r
index 9d38e6b4b0e797cab439820603e8dcd05e7e6803..a49b27f8ae7f173bd730b1965e9cdd27d8371715 100644 (file)
@@ -243,11 +243,19 @@ AMCPCommandPtr AMCPProtocolStrategy::InterpretCommandString(const std::wstring&
                                std::vector<std::wstring> split;\r
                                boost::split(split, str, boost::is_any_of("-"));\r
                                        \r
-                               int channelIndex = boost::lexical_cast<int>(split[0]) - 1;\r
-\r
+                               int channelIndex = -1;\r
                                int layerIndex = -1;\r
-                               if(split.size() > 1)\r
-                                       layerIndex = boost::lexical_cast<int>(split[1]);\r
+                               try\r
+                               {\r
+                                       channelIndex = boost::lexical_cast<int>(split[0]) - 1;\r
+\r
+                                       if(split.size() > 1)\r
+                                               layerIndex = boost::lexical_cast<int>(split[1]);\r
+                               }\r
+                               catch(...)\r
+                               {\r
+                                       goto ParseFinnished;\r
+                               }\r
 \r
                                renderer::render_device_ptr pChannel = GetChannelSafe(channelIndex, channels_);\r
                                if(pChannel == 0) {\r
index f531b87fd25a8fca9b5150e7796c3cd636f98b8d..cd854c1649a16fa5960aeb42daba871117b8656f 100644 (file)
@@ -35,7 +35,7 @@ struct layer::implementation
                if(background_ != nullptr)\r
                {\r
                        background_->set_leading_producer(active_);\r
-                       active_ = background_;\r
+                       active_     = background_;\r
                        background_ = nullptr;\r
                }\r
 \r
@@ -49,13 +49,13 @@ struct layer::implementation
 \r
        void stop()\r
        {\r
-               active_ = nullptr;\r
+               active_     = nullptr;\r
                last_frame_ = nullptr;\r
        }\r
 \r
        void clear()\r
        {\r
-               active_ = nullptr;\r
+               active_     = nullptr;\r
                background_ = nullptr;\r
                last_frame_ = nullptr;\r
        }\r
@@ -94,19 +94,12 @@ struct layer::implementation
 \r
 layer::layer() : impl_(new implementation()){}\r
 layer::layer(layer&& other) : impl_(std::move(other.impl_)){other.impl_ = nullptr;}\r
-layer::layer(const layer& other) : impl_(new implementation(*other.impl_)) {}\r
 layer& layer::operator=(layer&& other)\r
 {\r
        impl_ = std::move(other.impl_); \r
        other.impl_ = nullptr;\r
        return *this;\r
 }\r
-layer& layer::operator=(const layer& other)\r
-{\r
-       layer temp(other);\r
-       impl_.swap(temp.impl_);\r
-       return *this;\r
-}\r
 void layer::load(const frame_producer_ptr& frame_producer, load_option option){return impl_->load(frame_producer, option);}    \r
 void layer::play(){impl_->play();}\r
 void layer::pause(){impl_->pause();}\r
index b3f944183e04d8c9202bfbdb8ed6d2562ce02909..ef25788f268864487b97aa45fd3d6239a4caacea 100644 (file)
@@ -13,14 +13,14 @@ enum load_option
                        \r
 class layer\r
 {\r
+       layer(const layer& other);\r
+       layer& operator=(const layer& other);\r
 public:\r
        layer();\r
        layer(layer&& other);\r
-       layer(const layer& other);\r
        layer& operator=(layer&& other);\r
-       layer& operator=(const layer& other);\r
 \r
-       void load(const frame_producer_ptr& pProducer, load_option option = load_option::none); \r
+       void load(const frame_producer_ptr& producer, load_option option = load_option::none);  \r
        void play();\r
        void pause();\r
        void stop();\r
diff --git a/test/mock/mock_frame_producer.h b/test/mock/mock_frame_producer.h
new file mode 100644 (file)
index 0000000..ebf9671
--- /dev/null
@@ -0,0 +1,43 @@
+#pragma once\r
+\r
+#include <core/frame/gpu_frame.h>\r
+#include <core/producer/frame_producer.h>\r
+#include <common/exception/exceptions.h>\r
+\r
+using namespace caspar;\r
+using namespace caspar::core;\r
+\r
+class mock_frame_producer : public frame_producer\r
+{\r
+public:\r
+       mock_frame_producer(bool null = false, bool throws = false) \r
+               : null_(null), throws_(throws){}\r
+       gpu_frame_ptr get_frame()\r
+       { \r
+               if(throws_)\r
+                       BOOST_THROW_EXCEPTION(caspar_exception());\r
+               if(leading_)\r
+                       return leading_->get_frame();\r
+               if(!null_)\r
+                       return std::make_shared<gpu_frame>(0, 0);\r
+               return nullptr;\r
+       }\r
+       std::shared_ptr<frame_producer> get_following_producer() const \r
+       { return following_; }\r
+       void set_leading_producer(const std::shared_ptr<frame_producer>& leading) \r
+       { leading_ = leading; }\r
+       const frame_format_desc& get_frame_format_desc() const\r
+       { \r
+               static frame_format_desc format;\r
+               return format();\r
+       }\r
+       void initialize(const frame_factory_ptr& factory)\r
+       {}\r
+       void set_following_producer(const std::shared_ptr<frame_producer>& following)\r
+       {following_ = following;}\r
+private:\r
+       std::shared_ptr<frame_producer> following_;\r
+       std::shared_ptr<frame_producer> leading_;\r
+       bool null_;\r
+       bool throws_;\r
+};
\ No newline at end of file
index 9d5b822ab67651e3bdff3986a0da42f871c4460c..23bd65c68b1be8e97cf2df991ec1861e5d71deea 100644 (file)
     </ProjectConfiguration>\r
   </ItemGroup>\r
   <ItemGroup>\r
-    <ClCompile Include="core\renderer\display_device.cpp">\r
-      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">NotUsing</PrecompiledHeader>\r
-    </ClCompile>\r
-    <ClCompile Include="core\renderer\layer_test.cpp">\r
-      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">NotUsing</PrecompiledHeader>\r
-      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">NotUsing</PrecompiledHeader>\r
-    </ClCompile>\r
-    <ClCompile Include="core\renderer\render_device.cpp">\r
-      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">NotUsing</PrecompiledHeader>\r
-    </ClCompile>\r
     <ClCompile Include="main.cpp">\r
       <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">NotUsing</PrecompiledHeader>\r
       <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">NotUsing</PrecompiledHeader>\r
     </ClCompile>\r
+    <ClCompile Include="renderer\layer_test.cpp" />\r
   </ItemGroup>\r
   <ItemGroup>\r
     <ProjectReference Include="..\common\common.vcxproj">\r
@@ -34,6 +25,9 @@
       <Project>{79388c20-6499-4bf6-b8b9-d8c33d7d4ddd}</Project>\r
     </ProjectReference>\r
   </ItemGroup>\r
+  <ItemGroup>\r
+    <ClInclude Include="mock\mock_frame_producer.h" />\r
+  </ItemGroup>\r
   <PropertyGroup Label="Globals">\r
     <ProjectGuid>{8002D74D-4E89-4BD6-8CE8-0FE4DF14CA5D}</ProjectGuid>\r
     <Keyword>Win32Proj</Keyword>\r
index b607fb2a23d0567d5ccca7b23461dd22b34f969d..6b0544b29bbb508f3191ae257469f315fdcb1122 100644 (file)
@@ -4,25 +4,24 @@
     <Filter Include="Source">\r
       <UniqueIdentifier>{d4a5c843-0e41-4d98-9056-b7f0de0d49a7}</UniqueIdentifier>\r
     </Filter>\r
-    <Filter Include="Source\core">\r
-      <UniqueIdentifier>{6b116fc0-5f04-4952-a54b-06b208d13b1d}</UniqueIdentifier>\r
-    </Filter>\r
-    <Filter Include="Source\core\renderer">\r
+    <Filter Include="Source\renderer">\r
       <UniqueIdentifier>{f7f271e6-1741-4d8e-8903-73f6b6363ef4}</UniqueIdentifier>\r
     </Filter>\r
+    <Filter Include="Source\mock">\r
+      <UniqueIdentifier>{420ab80e-66c8-477b-b8c6-d8f4ceb08102}</UniqueIdentifier>\r
+    </Filter>\r
   </ItemGroup>\r
   <ItemGroup>\r
-    <ClCompile Include="core\renderer\layer_test.cpp">\r
-      <Filter>Source\core\renderer</Filter>\r
-    </ClCompile>\r
     <ClCompile Include="main.cpp">\r
       <Filter>Source</Filter>\r
     </ClCompile>\r
-    <ClCompile Include="core\renderer\display_device.cpp">\r
-      <Filter>Source\core\renderer</Filter>\r
-    </ClCompile>\r
-    <ClCompile Include="core\renderer\render_device.cpp">\r
-      <Filter>Source\core\renderer</Filter>\r
+    <ClCompile Include="renderer\layer_test.cpp">\r
+      <Filter>Source\renderer</Filter>\r
     </ClCompile>\r
   </ItemGroup>\r
+  <ItemGroup>\r
+    <ClInclude Include="mock\mock_frame_producer.h">\r
+      <Filter>Source\mock</Filter>\r
+    </ClInclude>\r
+  </ItemGroup>\r
 </Project>
\ No newline at end of file