<ClInclude Include="config.h" />\r
<ClInclude Include="exception\exceptions.h" />\r
<ClInclude Include="exception\win32_exception.h" />\r
- <ClInclude Include="gl\frame_buffer_object.h" />\r
- <ClInclude Include="gl\shader_program.h" />\r
<ClInclude Include="gl\utility.h" />\r
- <ClInclude Include="gl\pixel_buffer_object.h" />\r
<ClInclude Include="io\AsyncEventServer.h" />\r
<ClInclude Include="io\ClientInfo.h" />\r
<ClInclude Include="io\ProtocolStrategy.h" />\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="gl\frame_buffer_object.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="gl\pixel_buffer_object.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="gl\shader_program.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="io\AsyncEventServer.cpp">\r
<PrecompiledHeaderFile Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">../StdAfx.h</PrecompiledHeaderFile>\r
<PrecompiledHeaderFile Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">../StdAfx.h</PrecompiledHeaderFile>\r
<ClCompile Include="exception\win32_exception.cpp">\r
<Filter>Source\exception</Filter>\r
</ClCompile>\r
- <ClCompile Include="gl\frame_buffer_object.cpp">\r
- <Filter>Source\gl</Filter>\r
- </ClCompile>\r
- <ClCompile Include="gl\pixel_buffer_object.cpp">\r
- <Filter>Source\gl</Filter>\r
- </ClCompile>\r
- <ClCompile Include="gl\shader_program.cpp">\r
- <Filter>Source\gl</Filter>\r
- </ClCompile>\r
<ClCompile Include="concurrency\Thread.cpp">\r
<Filter>Source\concurrency</Filter>\r
</ClCompile>\r
<ClInclude Include="utility\string_convert.h">\r
<Filter>Source\utility</Filter>\r
</ClInclude>\r
- <ClInclude Include="gl\pixel_buffer_object.h">\r
- <Filter>Source\gl</Filter>\r
- </ClInclude>\r
- <ClInclude Include="gl\frame_buffer_object.h">\r
- <Filter>Source\gl</Filter>\r
- </ClInclude>\r
<ClInclude Include="gl\utility.h">\r
<Filter>Source\gl</Filter>\r
</ClInclude>\r
<ClInclude Include="compiler\vs\disable_silly_warnings.h">\r
<Filter>Source\compiler\vs</Filter>\r
</ClInclude>\r
- <ClInclude Include="gl\shader_program.h">\r
- <Filter>Source\gl</Filter>\r
- </ClInclude>\r
<ClInclude Include="utility\singleton_pool.h">\r
<Filter>Source\utility</Filter>\r
</ClInclude>\r
class executor : boost::noncopyable\r
{\r
public:\r
+\r
+ enum stop_policy\r
+ {\r
+ wait,\r
+ no_wait\r
+ };\r
\r
explicit executor(const std::function<void()>& f = nullptr)\r
{\r
return;\r
thread_ = boost::thread(f_);\r
}\r
- \r
- void stop(bool wait = true) // noexcept\r
+ \r
+ void stop(stop_policy policy = wait) // noexcept\r
{\r
is_running_ = false; \r
execution_queue_.push([]{});\r
- if(wait && boost::this_thread::get_id() != thread_.get_id())\r
+ if(policy == wait && boost::this_thread::get_id() != thread_.get_id())\r
thread_.join();\r
}\r
\r
+++ /dev/null
-#include "../StdAfx.h"\r
-\r
-#include "frame_buffer_object.h"\r
-\r
-#include "../../common/gl/utility.h"\r
-\r
-#include <Glee.h>\r
-\r
-#include <memory>\r
-\r
-namespace caspar { namespace gl {\r
-\r
-struct frame_buffer_object::implementation\r
-{\r
-public:\r
- implementation(size_t width, size_t height, GLenum mode) : mode_(mode), width_(width), height_(height)\r
- {\r
- GL(glGenTextures(1, &texture_)); \r
- GL(glBindTexture(GL_TEXTURE_2D, texture_)); \r
- GL(glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, width, 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, mode_, GL_TEXTURE_2D, \r
- texture_, 0));\r
- GL(glReadBuffer(mode_));\r
- }\r
- \r
- ~implementation()\r
- {\r
- glDeleteFramebuffersEXT(1, &fbo_);\r
- glDeleteTextures(1, &texture_);\r
- }\r
-\r
- void bind_pixel_source()\r
- {\r
- GL(glReadBuffer(mode_));\r
- }\r
-\r
- GLuint texture_;\r
- GLuint fbo_;\r
- GLenum mode_;\r
- size_t width_;\r
- size_t height_;\r
-};\r
-\r
-frame_buffer_object::frame_buffer_object(size_t width, size_t height, GLenum mode) : impl_(new implementation(width, height, mode)){}\r
-void frame_buffer_object::bind_pixel_source() {impl_->bind_pixel_source();}\r
-size_t frame_buffer_object::width() const{return impl_->width_;}\r
-size_t frame_buffer_object::height() const{return impl_->height_;}\r
-}}
\ No newline at end of file
+++ /dev/null
-#pragma once\r
-\r
-#include <Glee.h>\r
-\r
-#include <memory>\r
-\r
-namespace caspar { namespace gl {\r
-\r
-class frame_buffer_object\r
-{\r
-public:\r
- frame_buffer_object(size_t width, size_t height, GLenum mode = GL_COLOR_ATTACHMENT0_EXT);\r
- void bind_pixel_source();\r
- size_t width() const;\r
- size_t height() const;\r
-private:\r
- struct implementation;\r
- std::shared_ptr<implementation> impl_;\r
-};\r
-typedef frame_buffer_object fbo;\r
-\r
-}}
\ No newline at end of file
+++ /dev/null
-////////////////////////////////////////////////////////////\r
-//\r
-// SFML - Simple and Fast Multimedia Library\r
-// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com)\r
-//\r
-// This software is provided 'as-is', without any express or implied warranty.\r
-// In no event will the authors be held liable for any damages arising from the use of this software.\r
-//\r
-// Permission is granted to anyone to use this software for any purpose,\r
-// including commercial applications, and to alter it and redistribute it freely,\r
-// subject to the following restrictions:\r
-//\r
-// 1. The origin of this software must not be misrepresented;\r
-// you must not claim that you wrote the original software.\r
-// If you use this software in a product, an acknowledgment\r
-// in the product documentation would be appreciated but is not required.\r
-//\r
-// 2. Altered source versions must be plainly marked as such,\r
-// and must not be misrepresented as being the original software.\r
-//\r
-// 3. This notice may not be removed or altered from any source distribution.\r
-//\r
-////////////////////////////////////////////////////////////\r
-\r
-#pragma once\r
-\r
-#include <Glee.h>\r
-\r
-#include "../exception/exceptions.h"\r
-#include "../log/log.h"\r
-\r
-#include <boost/lexical_cast.hpp>\r
-\r
-namespace caspar { namespace common { namespace gl {\r
- \r
-inline void SMFL_GLCheckError(const std::string& expr, const std::string& File, unsigned int Line)\r
-{\r
- // Get the last error\r
- GLenum ErrorCode = glGetError();\r
-\r
- if (ErrorCode != GL_NO_ERROR)\r
- {\r
- std::string Error = "unknown error";\r
- std::string Desc = "no description";\r
-\r
- // Decode the error code\r
- switch (ErrorCode)\r
- {\r
- case GL_INVALID_ENUM :\r
- {\r
- Error = "GL_INVALID_ENUM";\r
- Desc = "an unacceptable value has been specified for an enumerated argument";\r
- break;\r
- }\r
-\r
- case GL_INVALID_VALUE :\r
- {\r
- Error = "GL_INVALID_VALUE";\r
- Desc = "a numeric argument is out of range";\r
- break;\r
- }\r
-\r
- case GL_INVALID_OPERATION :\r
- {\r
- Error = "GL_INVALID_OPERATION";\r
- Desc = "the specified operation is not allowed in the current state";\r
- break;\r
- }\r
-\r
- case GL_STACK_OVERFLOW :\r
- {\r
- Error = "GL_STACK_OVERFLOW";\r
- Desc = "this command would cause a stack overflow";\r
- break;\r
- }\r
-\r
- case GL_STACK_UNDERFLOW :\r
- {\r
- Error = "GL_STACK_UNDERFLOW";\r
- Desc = "this command would cause a stack underflow";\r
- break;\r
- }\r
-\r
- case GL_OUT_OF_MEMORY :\r
- {\r
- Error = "GL_OUT_OF_MEMORY";\r
- Desc = "there is not enough memory left to execute the command";\r
- break;\r
- }\r
-\r
- case GL_INVALID_FRAMEBUFFER_OPERATION_EXT :\r
- {\r
- Error = "GL_INVALID_FRAMEBUFFER_OPERATION_EXT";\r
- Desc = "the object bound to FRAMEBUFFER_BINDING_EXT is not \"framebuffer complete\"";\r
- break;\r
- }\r
- }\r
-\r
- // Log the error\r
- CASPAR_LOG(error) << "An internal OpenGL call failed in "\r
- << File.substr(File.find_last_of("\\/") + 1).c_str() << " (" << Line << ") : "\r
- << Error.c_str() << ", " << Desc.c_str()\r
- << ", " << expr.c_str()\r
- << std::endl;\r
- }\r
-}\r
-\r
-#ifdef _DEBUG\r
- \r
-#define CASPAR_GL_EXPR_STR(expr) #expr\r
-\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 GL(expr) expr\r
-#endif\r
-\r
-}}}
\ No newline at end of file
+++ /dev/null
-#include "../StdAfx.h"\r
-\r
-#include "pixel_buffer_object.h"\r
-\r
-#include "../../common/exception/exceptions.h"\r
-#include "../../common/gl/utility.h"\r
-\r
-namespace caspar { namespace gl {\r
- \r
-struct pixel_buffer_object::implementation : boost::noncopyable\r
-{\r
- implementation(size_t width, size_t height, GLenum format) \r
- : width_(width), height_(height), pbo_(0), format_(format), data_(nullptr),\r
- texture_(0), writing_(false), reading_(false), mapped_(false)\r
- {\r
- switch(format)\r
- {\r
- case GL_RGBA:\r
- case GL_BGRA:\r
- internal_ = GL_RGBA8;\r
- size_ = width*height*4;\r
- break;\r
- case GL_BGR:\r
- internal_ = GL_RGB8;\r
- size_ = width*height*3;\r
- break;\r
- case GL_LUMINANCE_ALPHA:\r
- internal_ = GL_LUMINANCE_ALPHA;\r
- size_ = width*height*2;\r
- break;\r
- case GL_LUMINANCE:\r
- case GL_ALPHA:\r
- internal_ = GL_LUMINANCE;\r
- size_ = width*height*1;\r
- break;\r
- default:\r
- BOOST_THROW_EXCEPTION(invalid_argument() << msg_info("Unsupported format.") << arg_name_info("format"));\r
- }\r
- if(width < 1 || height < 1)\r
- BOOST_THROW_EXCEPTION(invalid_argument() << msg_info("Invalid dimensions.") << arg_name_info("width/height"));\r
- }\r
-\r
- ~implementation()\r
- {\r
- if(pbo_ != 0)\r
- glDeleteBuffers(1, &pbo_);\r
- if(texture_ != 0)\r
- glDeleteTextures(1, &texture_);\r
- } \r
-\r
- void bind_pbo(GLenum mode)\r
- {\r
- if(pbo_ == 0)\r
- GL(glGenBuffers(1, &pbo_));\r
- GL(glBindBuffer(mode, pbo_));\r
- }\r
-\r
- void unbind_pbo(GLenum mode)\r
- {\r
- GL(glBindBuffer(mode, 0));\r
- }\r
- \r
- void bind_texture()\r
- {\r
- if(texture_ == 0)\r
- {\r
- GL(glGenTextures(1, &texture_));\r
-\r
- GL(glBindTexture(GL_TEXTURE_2D, texture_));\r
-\r
- GL(glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST));\r
- GL(glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST));\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
- GL(glTexImage2D(GL_TEXTURE_2D, 0, internal_, width_, height_, 0, format_, GL_UNSIGNED_BYTE, NULL));\r
- }\r
- GL(glBindTexture(GL_TEXTURE_2D, texture_));\r
- }\r
-\r
- void unmap_write()\r
- {\r
- bind_pbo(GL_PIXEL_UNPACK_BUFFER);\r
- if(mapped_)\r
- GL(glUnmapBuffer(GL_PIXEL_UNPACK_BUFFER));\r
- mapped_ = false;\r
- bind_texture();\r
- GL(glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, width_, height_, format_, GL_UNSIGNED_BYTE, NULL));\r
- unbind_pbo(GL_PIXEL_UNPACK_BUFFER);\r
- writing_ = true;\r
- }\r
-\r
- void* map_write()\r
- {\r
- if(mapped_)\r
- {\r
- if(!writing_)\r
- return data_;\r
- else\r
- BOOST_THROW_EXCEPTION(invalid_operation() << msg_info("Buffer is already mapped."));\r
- }\r
-\r
- bind_pbo(GL_PIXEL_UNPACK_BUFFER);\r
- GL(glBufferData(GL_PIXEL_UNPACK_BUFFER, size_, NULL, GL_STREAM_DRAW));\r
- data_= glMapBuffer(GL_PIXEL_UNPACK_BUFFER, GL_WRITE_ONLY);\r
- unbind_pbo(GL_PIXEL_UNPACK_BUFFER); \r
- if(!data_)\r
- BOOST_THROW_EXCEPTION(invalid_operation() << msg_info("glMapBuffer failed"));\r
- writing_ = false;\r
- mapped_ = true;\r
- return data_;\r
- }\r
- \r
- void unmap_read()\r
- { \r
- bind_pbo(GL_PIXEL_PACK_BUFFER);\r
- if(mapped_)\r
- GL(glUnmapBuffer(GL_PIXEL_PACK_BUFFER)); \r
- mapped_ = false;\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
- unbind_pbo(GL_PIXEL_PACK_BUFFER);\r
- reading_ = true;\r
- }\r
-\r
- void* map_read()\r
- {\r
- if(mapped_)\r
- {\r
- if(!reading_)\r
- return data_;\r
- else\r
- BOOST_THROW_EXCEPTION(invalid_operation() << msg_info("Buffer is already mapped."));\r
- }\r
-\r
- bind_pbo(GL_PIXEL_PACK_BUFFER);\r
- data_ = glMapBuffer(GL_PIXEL_PACK_BUFFER, GL_READ_ONLY); \r
- unbind_pbo(GL_PIXEL_PACK_BUFFER);\r
- if(!data_)\r
- BOOST_THROW_EXCEPTION(std::bad_alloc());\r
- reading_ = false;\r
- mapped_ = true;\r
- return data_;\r
- }\r
-\r
- void is_smooth(bool smooth)\r
- {\r
- if(smooth)\r
- {\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
- }\r
- else\r
- {\r
- GL(glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST));\r
- GL(glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST));\r
- }\r
- }\r
- \r
- GLuint pbo_;\r
- GLuint texture_;\r
- size_t width_;\r
- size_t height_;\r
- size_t size_;\r
-\r
- bool mapped_;\r
- bool writing_;\r
- bool reading_;\r
-\r
- GLint internal_;\r
- GLenum format_;\r
- void* data_;\r
-};\r
-\r
-pixel_buffer_object::pixel_buffer_object(){}\r
-pixel_buffer_object::pixel_buffer_object(pixel_buffer_object&& other) : impl_(std::move(other.impl_)){}\r
-pixel_buffer_object::pixel_buffer_object(size_t width, size_t height, GLenum format) \r
- : impl_(new implementation(width, height, format)){}\r
-pixel_buffer_object& pixel_buffer_object::operator=(pixel_buffer_object&& other)\r
-{\r
- impl_ = std::move(other.impl_);\r
- return *this;\r
-}\r
-void pixel_buffer_object::create(size_t width, size_t height, GLenum format)\r
-{\r
- impl_.reset(new implementation(width, height, format));\r
-}\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::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
-size_t pixel_buffer_object::size() const {return impl_->size_;}\r
-bool pixel_buffer_object::is_reading() const { return impl_->reading_;}\r
-bool pixel_buffer_object::is_writing() const { return impl_->writing_;}\r
-void pixel_buffer_object::is_smooth(bool smooth){impl_->is_smooth(smooth);}\r
-}}
\ No newline at end of file
+++ /dev/null
-#pragma once\r
-\r
-#include <memory>\r
-\r
-#include <boost/noncopyable.hpp>\r
-\r
-#include <Glee.h>\r
-\r
-#include <boost/tuple/tuple.hpp>\r
-#include <boost/thread/future.hpp>\r
-\r
-namespace caspar { namespace gl {\r
- \r
-class pixel_buffer_object : boost::noncopyable\r
-{\r
-public:\r
- pixel_buffer_object();\r
- pixel_buffer_object(pixel_buffer_object&& other);\r
- pixel_buffer_object(size_t width, size_t height, GLenum format = GL_BGRA);\r
- pixel_buffer_object& operator=(pixel_buffer_object&& other);\r
- void create(size_t width, size_t height, GLenum format = GL_BGRA);\r
- ~pixel_buffer_object(){}\r
-\r
- void unmap_write();\r
- void* map_write();\r
-\r
- void unmap_read();\r
- void* map_read();\r
-\r
- void is_smooth(bool smooth);\r
-\r
- void* data();\r
- const void* data() const;\r
-\r
- void bind_texture();\r
-\r
- size_t width() const;\r
- size_t height() const;\r
- size_t size() const;\r
-\r
- bool is_reading() const;\r
- bool is_writing() const;\r
- \r
-private:\r
- struct implementation;\r
- std::shared_ptr<implementation> impl_;\r
-};\r
-typedef std::shared_ptr<pixel_buffer_object> pixel_buffer_object_ptr;\r
-\r
-typedef pixel_buffer_object pbo;\r
-typedef pixel_buffer_object_ptr pbo_ptr;\r
-}}
\ No newline at end of file
+++ /dev/null
-#include "../StdAfx.h"\r
-\r
-#include "shader_program.h"\r
-\r
-#include "../exception/exceptions.h"\r
-#include "utility.h"\r
-\r
-#include <Glee.h>\r
-\r
-#include <boost/noncopyable.hpp>\r
-\r
-namespace caspar { namespace gl {\r
-\r
-shader_program& shader_program::operator=(shader_program&& other) \r
-{\r
- program_ = other.program_; \r
- other.program_ = 0; \r
- return *this;\r
-}\r
-\r
-shader_program::shader_program(const std::string& vertex_source_str, const std::string& fragment_source_str) : program_(0)\r
-{\r
- GLint success;\r
- \r
- const char* vertex_source = vertex_source_str.c_str();\r
- \r
- auto vertex_shader = glCreateShaderObjectARB(GL_VERTEX_SHADER_ARB);\r
- \r
- GL(glShaderSourceARB(vertex_shader, 1, &vertex_source, NULL));\r
- GL(glCompileShaderARB(vertex_shader));\r
-\r
- GL(glGetObjectParameterivARB(vertex_shader, GL_OBJECT_COMPILE_STATUS_ARB, &success));\r
- if (success == GL_FALSE)\r
- {\r
- char info[2048];\r
- GL(glGetInfoLogARB(vertex_shader, sizeof(info), 0, info));\r
- GL(glDeleteObjectARB(vertex_shader));\r
- std::stringstream str;\r
- str << "Failed to compile vertex shader:" << std::endl << info << std::endl;\r
- BOOST_THROW_EXCEPTION(gl::gl_error() << msg_info(str.str()));\r
- }\r
- \r
- const char* fragment_source = fragment_source_str.c_str();\r
- \r
- auto fragmemt_shader = glCreateShaderObjectARB(GL_FRAGMENT_SHADER_ARB);\r
- \r
- GL(glShaderSourceARB(fragmemt_shader, 1, &fragment_source, NULL));\r
- GL(glCompileShaderARB(fragmemt_shader));\r
-\r
- GL(glGetObjectParameterivARB(fragmemt_shader, GL_OBJECT_COMPILE_STATUS_ARB, &success));\r
- if (success == GL_FALSE)\r
- {\r
- char info[2048];\r
- GL(glGetInfoLogARB(fragmemt_shader, sizeof(info), 0, info));\r
- GL(glDeleteObjectARB(fragmemt_shader));\r
- std::stringstream str;\r
- str << "Failed to compile fragment shader:" << std::endl << info << std::endl;\r
- BOOST_THROW_EXCEPTION(gl::gl_error() << msg_info(str.str()));\r
- }\r
- \r
- program_ = glCreateProgramObjectARB();\r
- \r
- GL(glAttachObjectARB(program_, vertex_shader));\r
- GL(glAttachObjectARB(program_, fragmemt_shader));\r
-\r
- GL(glLinkProgramARB(program_));\r
- \r
- GL(glDeleteObjectARB(vertex_shader));\r
- GL(glDeleteObjectARB(fragmemt_shader));\r
-\r
- GL(glGetObjectParameterivARB(program_, GL_OBJECT_LINK_STATUS_ARB, &success));\r
- if (success == GL_FALSE)\r
- {\r
- char info[2048];\r
- GL(glGetInfoLogARB(program_, sizeof(info), 0, info));\r
- GL(glDeleteObjectARB(program_));\r
- std::stringstream str;\r
- str << "Failed to link shader program:" << std::endl << info << std::endl;\r
- BOOST_THROW_EXCEPTION(gl::gl_error() << msg_info(str.str()));\r
- }\r
- GL(glUseProgramObjectARB(program_));\r
- glUniform1i(glGetUniformLocation(program_, "plane[0]"), 0);\r
- glUniform1i(glGetUniformLocation(program_, "plane[1]"), 1);\r
- glUniform1i(glGetUniformLocation(program_, "plane[2]"), 2);\r
- glUniform1i(glGetUniformLocation(program_, "plane[3]"), 3);\r
-}\r
-\r
-shader_program::~shader_program()\r
-{\r
- glDeleteProgram(program_);\r
-}\r
-\r
-void shader_program::use()\r
-{ \r
- GL(glUseProgramObjectARB(program_)); \r
-}\r
-\r
-}}
\ No newline at end of file
+++ /dev/null
-\r
-#include <Glee.h>\r
-\r
-#include <boost/noncopyable.hpp>\r
-\r
-#include <memory>\r
-\r
-namespace caspar { namespace gl {\r
- \r
-class shader_program : boost::noncopyable\r
-{\r
-public:\r
- shader_program() : program_(0){}\r
- shader_program(shader_program&& other) : program_(other.program_){}\r
- shader_program& operator=(shader_program&& other);\r
-\r
- shader_program(const std::string& vertex_source_str, const std::string& fragment_source_str);\r
- ~shader_program();\r
-\r
- void use();\r
-\r
- GLuint program() { return program_; }\r
- \r
-private:\r
- GLuint program_;\r
-};\r
-typedef std::shared_ptr<shader_program> shader_program_ptr;\r
-\r
-}}
\ No newline at end of file
std::vector<size_t> depths;\r
boost::range::transform(consumers_, std::back_inserter(depths), std::mem_fn(&frame_consumer::buffer_depth));\r
max_depth_ = *boost::range::max_element(depths);\r
- input_.set_capacity(3);\r
executor_.start();\r
- executor_.begin_invoke([=]{tick();});\r
}\r
\r
- void tick()\r
+ void tick(const frame_type& frame)\r
{\r
- frame_type frame;\r
- input_.pop(frame);\r
- \r
buffer_.push_back(frame);\r
\r
clock_sync clock;\r
\r
void consume(frame_type&& frame)\r
{ \r
- input_.push(std::move(frame));\r
- executor_.begin_invoke([=]{tick();});\r
+ if(executor_.size() < 3)\r
+ executor_.begin_invoke([=]{tick(frame);});\r
+ else\r
+ executor_.invoke([=]{tick(frame);});\r
}\r
\r
- tbb::concurrent_bounded_queue<frame_type> input_;\r
-\r
executor executor_; \r
\r
size_t max_depth_;\r
{\r
sf::Event e;\r
while(window_.GetEvent(e)){}\r
- window_.SetActive();\r
render(frame);\r
window_.Display();\r
});\r
<ClInclude Include="processor\image_kernel.h" />\r
<ClInclude Include="processor\image_processor.h" />\r
<ClInclude Include="processor\fwd.h" />\r
+ <ClInclude Include="processor\ogl_device.h" />\r
<ClInclude Include="processor\read_frame.h" />\r
<ClInclude Include="processor\draw_frame.h" />\r
<ClInclude Include="processor\write_frame.h" />\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="processor\ogl_device.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="processor\read_frame.cpp">\r
<PrecompiledHeaderFile Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">../StdAfx.h</PrecompiledHeaderFile>\r
<PrecompiledHeaderFile Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">../StdAfx.h</PrecompiledHeaderFile>\r
<Filter Include="Source\channel\processor\audio">\r
<UniqueIdentifier>{e3d8bd98-8cb9-4f4a-8cf0-bd455ce9138d}</UniqueIdentifier>\r
</Filter>\r
+ <Filter Include="Source\channel\processor\ogl">\r
+ <UniqueIdentifier>{219e5733-b365-4231-8c79-fd689c46c488}</UniqueIdentifier>\r
+ </Filter>\r
</ItemGroup>\r
<ItemGroup>\r
<ClInclude Include="StdAfx.h">\r
<ClInclude Include="processor\image_kernel.h">\r
<Filter>Source\channel\processor\image</Filter>\r
</ClInclude>\r
- <ClInclude Include="processor\device_buffer.h">\r
- <Filter>Source\channel\processor\image</Filter>\r
+ <ClInclude Include="processor\ogl_device.h">\r
+ <Filter>Source\channel\processor\ogl</Filter>\r
</ClInclude>\r
<ClInclude Include="processor\host_buffer.h">\r
- <Filter>Source\channel\processor\image</Filter>\r
+ <Filter>Source\channel\processor\ogl</Filter>\r
+ </ClInclude>\r
+ <ClInclude Include="processor\device_buffer.h">\r
+ <Filter>Source\channel\processor\ogl</Filter>\r
</ClInclude>\r
</ItemGroup>\r
<ItemGroup>\r
<ClCompile Include="processor\image_kernel.cpp">\r
<Filter>Source\channel\processor\image</Filter>\r
</ClCompile>\r
- <ClCompile Include="processor\device_buffer.cpp">\r
- <Filter>Source\channel\processor\image</Filter>\r
+ <ClCompile Include="processor\ogl_device.cpp">\r
+ <Filter>Source\channel\processor\ogl</Filter>\r
</ClCompile>\r
<ClCompile Include="processor\host_buffer.cpp">\r
- <Filter>Source\channel\processor\image</Filter>\r
+ <Filter>Source\channel\processor\ogl</Filter>\r
+ </ClCompile>\r
+ <ClCompile Include="processor\device_buffer.cpp">\r
+ <Filter>Source\channel\processor\ogl</Filter>\r
</ClCompile>\r
</ItemGroup>\r
<ItemGroup>\r
\r
~implementation()\r
{\r
- glDeleteTextures(1, &id_);\r
+ GL(glDeleteTextures(1, &id_));\r
}\r
\r
void bind()\r
\r
void attach(int index)\r
{\r
- GL(glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0_EXT + index, GL_TEXTURE_2D, id_, 0));\r
+ GL(glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + index, GL_TEXTURE_2D, id_, 0));\r
}\r
\r
GLuint id_;\r
void device_buffer::unbind(){impl_->unbind();}\r
void device_buffer::read(host_buffer& source){impl_->read(source);}\r
void device_buffer::write(host_buffer& target){impl_->write(target);}\r
-GLuint device_buffer::id() const { return impl_->id_; }\r
\r
}}
\ No newline at end of file
void attach(int index);\r
void read(host_buffer& source);\r
void write(host_buffer& target);\r
-\r
- GLuint id() const;\r
-\r
+ \r
private:\r
struct implementation;\r
std::shared_ptr<implementation> impl_;\r
\r
struct frame_processor_device::implementation : boost::noncopyable\r
{ \r
- implementation(const video_format_desc& format_desc) : fmt_(format_desc), image_processor_(format_desc)\r
- {\r
- for(size_t n = 0; n < 3; ++n)\r
- {\r
- image_buffer_.push(std::move(image_processor_.begin_pass()));\r
- image_processor_.end_pass();\r
- \r
- audio_buffer_.push(std::move(audio_processor_.begin_pass()));\r
- audio_processor_.end_pass();\r
- }\r
- }\r
+ implementation(const video_format_desc& format_desc) : fmt_(format_desc), image_processor_(format_desc){}\r
\r
safe_ptr<const read_frame> process(safe_ptr<draw_frame>&& frame)\r
{ \r
- image_buffer_.push(std::move(image_processor_.begin_pass()));\r
+ auto image = image_processor_.begin_pass();\r
frame->process_image(image_processor_);\r
image_processor_.end_pass();\r
\r
- audio_buffer_.push(std::move(audio_processor_.begin_pass()));\r
+ auto audio = audio_processor_.begin_pass();\r
frame->process_audio(audio_processor_);\r
audio_processor_.end_pass();\r
- \r
- auto image = image_buffer_.front().get();\r
- auto audio = audio_buffer_.front();\r
-\r
- image_buffer_.pop();\r
- audio_buffer_.pop();\r
\r
- return make_safe<const read_frame>(std::move(image), std::move(audio));\r
+ return make_safe<const read_frame>(std::move(image.get()), std::move(audio));\r
}\r
\r
safe_ptr<write_frame> create_frame(const pixel_format_desc& desc)\r
\r
audio_processor audio_processor_;\r
image_processor image_processor_;\r
-\r
- std::queue<boost::unique_future<safe_ptr<const host_buffer>>> image_buffer_;\r
- std::queue<std::vector<short>> audio_buffer_;\r
- \r
+ \r
const video_format_desc fmt_;\r
};\r
\r
\r
~implementation()\r
{\r
- glDeleteBuffers(1, &pbo_);\r
+ GL(glDeleteBuffers(1, &pbo_));\r
}\r
\r
void map()\r
{\r
std::unordered_map<pixel_format::type, shader_program>& shaders()\r
{\r
+ GL(glEnable(GL_POLYGON_STIPPLE));\r
+ GL(glEnable(GL_BLEND));\r
+ GL(glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)); \r
+\r
if(shaders_.empty())\r
{\r
std::string common_vertex = \r
#include "image_processor.h"\r
#include "image_kernel.h"\r
\r
+#include "ogl_device.h"\r
#include "host_buffer.h"\r
#include "device_buffer.h"\r
\r
\r
namespace caspar { namespace core {\r
\r
-class ogl_context\r
-{ \r
-public:\r
- \r
- ogl_context()\r
- {\r
- executor_.start();\r
- invoke([=]\r
- {\r
- context_.reset(new sf::Context());\r
- context_->SetActive(true);\r
- });\r
- }\r
-\r
- template<typename Func>\r
- auto begin_invoke(Func&& func) -> boost::unique_future<decltype(func())> // noexcept\r
- { \r
- return executor_.begin_invoke(std::forward<Func>(func));\r
- }\r
- \r
- template<typename Func>\r
- auto invoke(Func&& func) -> decltype(func())\r
- {\r
- return executor_.invoke(std::forward<Func>(func));\r
- }\r
- \r
- safe_ptr<device_buffer> create_device_buffer(size_t width, size_t height, size_t stride)\r
- {\r
- auto pool = &device_pools_[stride][((width << 12) & 0x00FFF000) | ((height << 0) & 0x00000FFF)];\r
- std::shared_ptr<device_buffer> buffer;\r
- if(!pool->try_pop(buffer)) \r
- {\r
- executor_.invoke([&]\r
- {\r
- buffer = std::make_shared<device_buffer>(width, height, stride);\r
- }); \r
- }\r
- \r
- return safe_ptr<device_buffer>(buffer.get(), [=](device_buffer*){pool->push(buffer);});\r
- }\r
- \r
- safe_ptr<host_buffer> create_host_buffer(size_t size, host_buffer::usage_t usage)\r
- {\r
- auto pool = &host_pools_[usage][size];\r
- std::shared_ptr<host_buffer> buffer;\r
- if(!pool->try_pop(buffer))\r
- {\r
- executor_.invoke([&]\r
- {\r
- buffer = std::make_shared<host_buffer>(size, usage);\r
- if(usage == host_buffer::write_only)\r
- buffer->map();\r
- else\r
- buffer->unmap();\r
- }); \r
- }\r
-\r
- return safe_ptr<host_buffer>(buffer.get(), [=](host_buffer*)\r
- {\r
- executor_.begin_invoke([=]\r
- {\r
- if(usage == host_buffer::write_only)\r
- buffer->map();\r
- else\r
- buffer->unmap();\r
- pool->push(buffer);\r
- });\r
- });\r
- }\r
-private:\r
- executor executor_;\r
- std::unique_ptr<sf::Context> context_;\r
- \r
- std::array<tbb::concurrent_unordered_map<size_t, tbb::concurrent_bounded_queue<std::shared_ptr<device_buffer>>>, 4> device_pools_;\r
- std::array<tbb::concurrent_unordered_map<size_t, tbb::concurrent_bounded_queue<std::shared_ptr<host_buffer>>>, 2> host_pools_;\r
-};\r
-\r
image_transform& image_transform::operator*=(const image_transform &other)\r
{\r
alpha *= other.alpha;\r
uv.get<1>() += other.uv.get<1>();\r
uv.get<2>() += other.uv.get<2>();\r
uv.get<3>() += other.uv.get<3>();\r
+ pos.get<0>() += other.pos.get<0>();\r
+ pos.get<1>() += other.pos.get<1>();\r
return *this;\r
}\r
\r
transform_stack_.top().mode = video_mode::progressive;\r
transform_stack_.top().uv = boost::make_tuple(0.0, 1.0, 1.0, 0.0);\r
\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(glDisable(GL_DEPTH_TEST)); \r
\r
render_targets_[0] = context_.create_device_buffer(format_desc.width, format_desc.height, 4);\r
render_targets_[1] = context_.create_device_buffer(format_desc.width, format_desc.height, 4);\r
\r
void begin(const image_transform& transform)\r
{\r
- context_.begin_invoke([=]\r
- {\r
- glPushMatrix();\r
- transform_stack_.push(transform_stack_.top()*transform);\r
-\r
- glColor4d(1.0, 1.0, 1.0, transform_stack_.top().alpha);\r
- glTranslated(transform.pos.get<0>()*2.0, transform.pos.get<1>()*2.0, 0.0);\r
- });\r
+ transform_stack_.push(transform_stack_.top()*transform);\r
}\r
\r
void render(const pixel_format_desc& desc, std::vector<safe_ptr<host_buffer>>& buffers)\r
{\r
+ auto transform = transform_stack_.top();\r
context_.begin_invoke([=]\r
{\r
+ GL(glLoadIdentity());\r
+ GL(glTranslated(transform.pos.get<0>()*2.0, transform.pos.get<1>()*2.0, 0.0));\r
+ GL(glColor4d(1.0, 1.0, 1.0, transform.alpha));\r
GL(glViewport(0, 0, format_desc_.width, format_desc_.height));\r
- kernel_.use(desc.pix_fmt, transform_stack_.top().mode);\r
+ kernel_.use(desc.pix_fmt, transform.mode);\r
\r
std::vector<safe_ptr<device_buffer>> device_buffers;\r
for(size_t n = 0; n < buffers.size(); ++n)\r
device_buffers[n]->bind();\r
}\r
\r
- auto t = transform_stack_.top();\r
+ auto t = transform;\r
glBegin(GL_QUADS);\r
glTexCoord2d(t.uv.get<0>(), t.uv.get<3>()); glVertex2d(-1.0, -1.0);\r
glTexCoord2d(t.uv.get<2>(), t.uv.get<3>()); glVertex2d( 1.0, -1.0);\r
\r
void end()\r
{\r
- context_.begin_invoke([=]\r
- {\r
- transform_stack_.pop();\r
- glColor4d(1.0, 1.0, 1.0, transform_stack_.top().alpha);\r
- glPopMatrix();\r
- });\r
+ transform_stack_.pop();\r
}\r
\r
boost::unique_future<safe_ptr<const host_buffer>> begin_pass()\r
\r
const video_format_desc format_desc_;\r
\r
- ogl_context context_;\r
+ ogl_device context_;\r
\r
std::stack<image_transform> transform_stack_;\r
\r
--- /dev/null
+#include "../stdafx.h"\r
+\r
+#include "ogl_device.h"\r
+\r
+#include <Glee.h>\r
+#include <SFML/Window.hpp>\r
+\r
+namespace caspar { namespace core {\r
+\r
+ogl_device::ogl_device()\r
+{\r
+ executor_.start();\r
+ invoke([=]\r
+ {\r
+ context_.reset(new sf::Context());\r
+ context_->SetActive(true);\r
+ });\r
+}\r
+ \r
+safe_ptr<device_buffer> ogl_device::create_device_buffer(size_t width, size_t height, size_t stride)\r
+{\r
+ auto pool = &device_pools_[stride][((width << 16) & 0xFFFF0000) | (height & 0x0000FFFF)];\r
+ std::shared_ptr<device_buffer> buffer;\r
+ if(!pool->try_pop(buffer)) \r
+ {\r
+ executor_.invoke([&]\r
+ {\r
+ buffer = std::make_shared<device_buffer>(width, height, stride);\r
+ }); \r
+ }\r
+ \r
+ return safe_ptr<device_buffer>(buffer.get(), [=](device_buffer*){pool->push(buffer);});\r
+}\r
+ \r
+safe_ptr<host_buffer> ogl_device::create_host_buffer(size_t size, host_buffer::usage_t usage)\r
+{\r
+ auto pool = &host_pools_[usage][size];\r
+ std::shared_ptr<host_buffer> buffer;\r
+ if(!pool->try_pop(buffer))\r
+ {\r
+ executor_.invoke([&]\r
+ {\r
+ buffer = std::make_shared<host_buffer>(size, usage);\r
+ if(usage == host_buffer::write_only)\r
+ buffer->map();\r
+ else\r
+ buffer->unmap();\r
+ }); \r
+ }\r
+\r
+ return safe_ptr<host_buffer>(buffer.get(), [=](host_buffer*)\r
+ {\r
+ executor_.begin_invoke([=]\r
+ {\r
+ if(usage == host_buffer::write_only)\r
+ buffer->map();\r
+ else\r
+ buffer->unmap();\r
+ pool->push(buffer);\r
+ });\r
+ });\r
+}\r
+\r
+}}
\ No newline at end of file
--- /dev/null
+#pragma once\r
+\r
+#include "host_buffer.h"\r
+#include "device_buffer.h"\r
+\r
+#include <common/concurrency/executor.h>\r
+#include <common/utility/safe_ptr.h>\r
+\r
+#include <tbb/concurrent_unordered_map.h>\r
+#include <tbb/concurrent_queue.h>\r
+\r
+#include <boost/thread/future.hpp>\r
+\r
+#include <array>\r
+\r
+namespace caspar { namespace core {\r
+\r
+class ogl_device\r
+{ \r
+public:\r
+ \r
+ ogl_device();\r
+\r
+ template<typename Func>\r
+ auto begin_invoke(Func&& func) -> boost::unique_future<decltype(func())> // noexcept\r
+ { \r
+ return executor_.begin_invoke(std::forward<Func>(func));\r
+ }\r
+ \r
+ template<typename Func>\r
+ auto invoke(Func&& func) -> decltype(func())\r
+ {\r
+ return executor_.invoke(std::forward<Func>(func));\r
+ }\r
+ \r
+ safe_ptr<device_buffer> create_device_buffer(size_t width, size_t height, size_t stride);\r
+ safe_ptr<host_buffer> create_host_buffer(size_t size, host_buffer::usage_t usage);\r
+private:\r
+ executor executor_;\r
+ std::unique_ptr<sf::Context> context_;\r
+ \r
+ std::array<tbb::concurrent_unordered_map<size_t, tbb::concurrent_bounded_queue<std::shared_ptr<device_buffer>>>, 4> device_pools_;\r
+ std::array<tbb::concurrent_unordered_map<size_t, tbb::concurrent_bounded_queue<std::shared_ptr<host_buffer>>>, 2> host_pools_;\r
+};\r
+\r
+}}
\ No newline at end of file
struct ffmpeg_producer_impl\r
{\r
public:\r
- ffmpeg_producer_impl(const std::wstring& filename, const std::vector<std::wstring>& params) : filename_(filename), last_frame_(draw_frame(draw_frame::empty())), underrun_count_(0),\r
+ ffmpeg_producer_impl(const std::wstring& filename, const std::vector<std::wstring>& params) : filename_(filename), last_frame_(draw_frame(draw_frame::empty())),\r
input_(filename), video_decoder_(input_.get_video_codec_context().get()), audio_decoder_(input_.get_audio_codec_context().get())\r
{ \r
input_.set_loop(std::find(params.begin(), params.end(), L"LOOP") != params.end());\r
ouput_channel_.push(std::move(transform));\r
} \r
\r
- if(ouput_channel_.empty() && video_packet.empty() && audio_packet.empty())\r
- {\r
- if(underrun_count_++ == 0)\r
- CASPAR_LOG(warning) << print() << "### Started File read underrun.";\r
-\r
- return last_frame_;\r
- }\r
- else if(underrun_count_ > 0)\r
- {\r
- CASPAR_LOG(trace) << print() << "### Ended file read underrun with " << underrun_count_ << " ticks.";\r
- underrun_count_ = 0;\r
- }\r
+ if(ouput_channel_.empty() && video_packet.empty() && audio_packet.empty()) \r
+ return last_frame_; \r
}\r
\r
auto result = last_frame_;\r
return L"ffmpeg[" + boost::filesystem::wpath(filename_).filename() + L"]";\r
}\r
\r
- size_t underrun_count_;\r
- \r
- input input_; \r
- audio_decoder audio_decoder_;\r
- video_decoder video_decoder_;\r
+ input input_; \r
+ audio_decoder audio_decoder_;\r
+ video_decoder video_decoder_;\r
\r
- std::deque<safe_ptr<write_frame>> video_frame_channel_; \r
- std::deque<std::vector<short>> audio_chunk_channel_;\r
+ std::deque<safe_ptr<write_frame>> video_frame_channel_; \r
+ std::deque<std::vector<short>> audio_chunk_channel_;\r
\r
std::queue<safe_ptr<draw_frame>> ouput_channel_;\r
\r
- const std::wstring filename_;\r
+ const std::wstring filename_;\r
\r
safe_ptr<draw_frame> last_frame_;\r
\r
- video_format_desc format_desc_;\r
+ video_format_desc format_desc_;\r
};\r
\r
class ffmpeg_producer : public frame_producer\r
}\r
}\r
else if(!loop_ || av_seek_frame(format_context_.get(), -1, 0, AVSEEK_FLAG_BACKWARD) < 0) // TODO: av_seek_frame does not work for all formats\r
- executor_.stop(false);\r
+ executor_.stop(executor::no_wait);\r
}\r
}\r
\r
#include "bitmap.h"\r
\r
#include "../../format/video_format.h"\r
-#include "../../server.h"\r
\r
#include "../../processor/draw_frame.h"\r
\r
#include <common/concurrency/executor.h>\r
\r
#include <boost/filesystem.hpp>\r
-#include <boost/thread.hpp>\r
-\r
-#include <tbb/atomic.h>\r
\r
#include <type_traits>\r
\r
namespace caspar { namespace core { namespace flash {\r
\r
-using namespace boost::assign;\r
-\r
// NOTE: This is needed in order to make CComObject work since this is not a real ATL project.\r
CComModule _AtlModule;\r
extern __declspec(selectany) CAtlModule* _pAtlModule = &_AtlModule;\r
public:\r
flash_renderer(const safe_ptr<frame_processor_device>& frame_processor, const std::wstring& filename) \r
: last_frame_(draw_frame::empty()), current_frame_(draw_frame::empty()), frame_processor_(frame_processor), filename_(filename),\r
- format_desc_(frame_processor->get_video_format_desc()), bmp_frame_(std::make_shared<bitmap>(format_desc_.width, format_desc_.height))\r
+ format_desc_(frame_processor->get_video_format_desc()), bmp_frame_(format_desc_.width, format_desc_.height)\r
\r
{\r
CASPAR_LOG(info) << print() << L" Started";\r
\r
if(ax_->IsReadyToRender() && ax_->InvalidRectangle())\r
{\r
- std::fill_n(bmp_frame_->data(), bmp_frame_->size(), 0); \r
- ax_->DrawControl(bmp_frame_->hdc());\r
+ std::fill_n(bmp_frame_.data(), bmp_frame_.size(), 0); \r
+ ax_->DrawControl(bmp_frame_.hdc());\r
\r
auto frame = frame_processor_->create_frame();\r
- std::copy(bmp_frame_->data(), bmp_frame_->data() + bmp_frame_->size(), frame->image_data().begin());\r
+ std::copy(bmp_frame_.data(), bmp_frame_.data() + bmp_frame_.size(), frame->image_data().begin());\r
current_frame_ = frame;\r
}\r
return current_frame_;\r
const std::wstring filename_;\r
const safe_ptr<frame_processor_device> frame_processor_;\r
const video_format_desc format_desc_;\r
- const safe_ptr<bitmap> bmp_frame_; \r
+ bitmap bmp_frame_; \r
\r
CComPtr<FlashAxContainer> ax_;\r
tbb::concurrent_bounded_queue<std::shared_ptr<draw_frame>> frame_buffer_; \r
auto frame = draw_frame::empty();\r
if(renderer_ && renderer_->try_pop(frame)) // Only render again if frame was removed from buffer. \r
executor_.begin_invoke([this]{render_frame();}); \r
- \r
- assert(executor_.size() < 8);\r
- \r
return frame;\r
}\r
\r
void load(const safe_ptr<frame_producer>& frame_producer, bool autoplay)\r
{ \r
background_ = frame_producer;\r
- CASPAR_LOG(info) << print() << " " << foreground_->print() << " => background";\r
+ CASPAR_LOG(info) << print() << " " << frame_producer->print() << " => background";\r
if(autoplay)\r
play(); \r
}\r
catch(...)\r
{\r
CASPAR_LOG_CURRENT_EXCEPTION();\r
- CASPAR_LOG(warning) << print() << L" empty => background{" << background_->print() << "}";\r
+ CASPAR_LOG(warning) << print() << L" empty => background";\r
background_ = frame_producer::empty();\r
}\r
}\r
foreground_ = background_;\r
background_ = frame_producer::empty();\r
is_paused_ = false;\r
- CASPAR_LOG(info) << print() << L" background{" << foreground_->print() << "} => foreground";\r
+ CASPAR_LOG(info) << print() << L" background => foreground";\r
}\r
\r
void pause()\r
following->set_leading_producer(foreground_);\r
foreground_ = following;\r
if(foreground_ != frame_producer::empty())\r
- CASPAR_LOG(info) << print() << L" [EOF] following{" << foreground_->print() << "} => foreground{" << foreground_->print() << "}";\r
+ CASPAR_LOG(info) << print() << L" [EOF] " << foreground_->print() << " => foreground";\r
else\r
- CASPAR_LOG(info) << print() << L" [EOF] empty => foreground{" << foreground_->print() << "}";\r
+ CASPAR_LOG(info) << print() << L" [EOF] empty => foreground";\r
last_frame_ = receive();\r
}\r
}\r
catch(...)\r
{\r
CASPAR_LOG_CURRENT_EXCEPTION();\r
- CASPAR_LOG(warning) << print() << L" empty -> foreground{" << foreground_->print() << "]";\r
+ CASPAR_LOG(warning) << print() << L" empty => foreground";\r
foreground_ = frame_producer::empty();\r
last_frame_ = draw_frame::empty();\r
}\r
}\r
\r
safe_ptr<draw_frame> receive()\r
+ {\r
+ return render_frame();\r
+ }\r
+\r
+ safe_ptr<draw_frame> render_frame()\r
{\r
if(current_frame_++ >= info_.duration)\r
return draw_frame::eof();\r
\r
tbb::parallel_invoke\r
(\r
- [&]{dest = receive(dest_producer_);},\r
- [&]{source = receive(source_producer_);}\r
+ [&]{dest = render_sub_frame(dest_producer_);},\r
+ [&]{source = render_sub_frame(source_producer_);}\r
);\r
\r
return compose(dest, source);\r
}\r
\r
- safe_ptr<draw_frame> receive(safe_ptr<frame_producer>& producer)\r
+ safe_ptr<draw_frame> render_sub_frame(safe_ptr<frame_producer>& producer)\r
{\r
if(producer == frame_producer::empty())\r
return draw_frame::eof();\r
CASPAR_LOG(warning) << "Failed to initialize following producer.";\r
}\r
\r
- return receive(producer);\r
+ return render_sub_frame(producer);\r
}\r
return frame;\r
}\r