\r
auto it = tweens.find(name);\r
if(it == tweens.end())\r
- {\r
- CASPAR_LOG(warning) << L"Invalid tween: " << name << L" fallback to \"linear\".";\r
it = tweens.find(L"linear");\r
- }\r
-\r
+ \r
return [=](double t, double b, double c, double d)\r
{\r
return it->second(t, b, c, d, params);\r
const int index_;\r
video_format_desc format_desc_;\r
\r
- safe_ptr<frame_mixer_device> mixer_;\r
+ safe_ptr<mixer::frame_mixer_device> mixer_;\r
safe_ptr<frame_consumer_device> consumer_;\r
safe_ptr<frame_producer_device> producer_;\r
\r
: index_(index)\r
, format_desc_(format_desc)\r
, consumer_(new frame_consumer_device(format_desc))\r
- , mixer_(new frame_mixer_device(format_desc))\r
+ , mixer_(new mixer::frame_mixer_device(format_desc))\r
, producer_(new frame_producer_device(format_desc_)) \r
, mixer_connection_(mixer_->connect([=](const safe_ptr<const read_frame>& frame){consumer_->send(frame);}))\r
, producer_connection_(producer_->connect([=](const std::vector<safe_ptr<basic_frame>>& frames){mixer_->send(frames);}))\r
mixer_connection_.disconnect();\r
\r
consumer_->set_video_format_desc(format_desc_);\r
- mixer_ = make_safe<frame_mixer_device>(format_desc_);\r
+ mixer_ = make_safe<mixer::frame_mixer_device>(format_desc_);\r
producer_ = make_safe<frame_producer_device>(format_desc_);\r
\r
mixer_connection_ = mixer_->connect([=](const safe_ptr<const read_frame>& frame){consumer_->send(frame);});\r
channel::channel(int index, const video_format_desc& format_desc) : impl_(new implementation(index, format_desc)){}\r
channel::channel(channel&& other) : impl_(std::move(other.impl_)){}\r
const safe_ptr<frame_producer_device>& channel::producer() { return impl_->producer_;} \r
-const safe_ptr<frame_mixer_device>& channel::mixer() { return impl_->mixer_;} \r
+const safe_ptr<mixer::frame_mixer_device>& channel::mixer() { return impl_->mixer_;} \r
const safe_ptr<frame_consumer_device>& channel::consumer() { return impl_->consumer_;} \r
const video_format_desc& channel::get_video_format_desc() const{return impl_->format_desc_;}\r
void channel::set_video_format_desc(const video_format_desc& format_desc){impl_->set_video_format_desc(format_desc);}\r
channel(channel&& other);\r
\r
const safe_ptr<frame_producer_device>& producer();\r
- const safe_ptr<frame_mixer_device>& mixer();\r
+ const safe_ptr<mixer::frame_mixer_device>& mixer();\r
const safe_ptr<frame_consumer_device>& consumer();\r
\r
const video_format_desc& get_video_format_desc() const;\r
\r
#include <core/producer/frame/audio_transform.h>\r
\r
-namespace caspar { namespace core {\r
+namespace caspar { namespace mixer {\r
\r
struct audio_mixer::implementation\r
{\r
std::vector<short> audio_data_;\r
- std::stack<audio_transform> transform_stack_;\r
+ std::stack<core::audio_transform> transform_stack_;\r
\r
- std::map<int, audio_transform> prev_audio_transforms_;\r
- std::map<int, audio_transform> next_audio_transforms_;\r
+ std::map<int, core::audio_transform> prev_audio_transforms_;\r
+ std::map<int, core::audio_transform> next_audio_transforms_;\r
\r
public:\r
implementation()\r
{\r
- transform_stack_.push(audio_transform());\r
+ transform_stack_.push(core::audio_transform());\r
}\r
\r
- void begin(const basic_frame& frame)\r
+ void begin(const core::basic_frame& frame)\r
{\r
transform_stack_.push(transform_stack_.top()*frame.get_audio_transform());\r
}\r
\r
- void visit(const write_frame& frame)\r
+ void visit(const core::write_frame& frame)\r
{\r
if(!transform_stack_.top().get_has_audio())\r
return;\r
}\r
\r
\r
- void begin(const audio_transform& transform)\r
+ void begin(const core::audio_transform& transform)\r
{\r
transform_stack_.push(transform_stack_.top()*transform);\r
}\r
};\r
\r
audio_mixer::audio_mixer() : impl_(new implementation()){}\r
-void audio_mixer::begin(const basic_frame& frame){impl_->begin(frame);}\r
-void audio_mixer::visit(write_frame& frame){impl_->visit(frame);}\r
+void audio_mixer::begin(const core::basic_frame& frame){impl_->begin(frame);}\r
+void audio_mixer::visit(core::write_frame& frame){impl_->visit(frame);}\r
void audio_mixer::end(){impl_->end();}\r
std::vector<short> audio_mixer::begin_pass(){return impl_->begin_pass();} \r
void audio_mixer::end_pass(){impl_->end_pass();}\r
#pragma once\r
\r
#include <core/producer/frame/frame_visitor.h>\r
+#include <core/producer/frame/audio_transform.h>\r
\r
#include <boost/noncopyable.hpp>\r
\r
-namespace caspar { namespace core {\r
-\r
-class audio_transform;\r
-\r
+namespace caspar { namespace mixer {\r
+ \r
class audio_mixer : public core::frame_visitor, boost::noncopyable\r
{\r
public:\r
audio_mixer();\r
\r
- virtual void begin(const basic_frame& frame);\r
- virtual void visit(write_frame& frame);\r
+ virtual void begin(const core::basic_frame& frame);\r
+ virtual void visit(core::write_frame& frame);\r
virtual void end();\r
\r
std::vector<short> begin_pass();\r
\r
#include <unordered_map>\r
\r
-namespace caspar { namespace core {\r
+namespace caspar { namespace mixer {\r
\r
template<typename T>\r
class tweened_transform\r
\r
struct frame_mixer_device::implementation : boost::noncopyable\r
{ \r
- const video_format_desc format_desc_;\r
+ const core::video_format_desc format_desc_;\r
\r
safe_ptr<diagnostics::graph> diag_;\r
timer perf_timer_;\r
\r
output_t output_;\r
\r
- std::unordered_map<int, tweened_transform<image_transform>> image_transforms_;\r
- std::unordered_map<int, tweened_transform<audio_transform>> audio_transforms_;\r
+ std::unordered_map<int, tweened_transform<core::image_transform>> image_transforms_;\r
+ std::unordered_map<int, tweened_transform<core::audio_transform>> audio_transforms_;\r
\r
- tweened_transform<image_transform> root_image_transform_;\r
- tweened_transform<audio_transform> root_audio_transform_;\r
+ tweened_transform<core::image_transform> root_image_transform_;\r
+ tweened_transform<core::audio_transform> root_audio_transform_;\r
\r
executor executor_;\r
public:\r
- implementation( const video_format_desc& format_desc) \r
+ implementation(const core::video_format_desc& format_desc) \r
: format_desc_(format_desc)\r
, diag_(diagnostics::create_graph(narrow(print())))\r
, image_mixer_(format_desc)\r
return output_.connect(subscriber);\r
}\r
\r
- boost::unique_future<safe_ptr<const host_buffer>> mix_image(std::vector<safe_ptr<basic_frame>> frames)\r
+ boost::unique_future<safe_ptr<const host_buffer>> mix_image(std::vector<safe_ptr<core::basic_frame>> frames)\r
{\r
- frames.erase(std::remove(frames.begin(), frames.end(), basic_frame::empty()), frames.end());\r
- frames.erase(std::remove(frames.begin(), frames.end(), basic_frame::eof()), frames.end());\r
+ frames.erase(std::remove(frames.begin(), frames.end(), core::basic_frame::empty()), frames.end());\r
+ frames.erase(std::remove(frames.begin(), frames.end(), core::basic_frame::eof()), frames.end());\r
\r
auto image = image_mixer_.begin_pass();\r
BOOST_FOREACH(auto& frame, frames)\r
{\r
- if(format_desc_.mode != video_mode::progressive)\r
+ if(format_desc_.mode != core::video_mode::progressive)\r
{\r
- auto frame1 = make_safe<basic_frame>(frame);\r
- auto frame2 = make_safe<basic_frame>(frame);\r
+ auto frame1 = make_safe<core::basic_frame>(frame);\r
+ auto frame2 = make_safe<core::basic_frame>(frame);\r
\r
frame1->get_image_transform() = root_image_transform_.fetch_and_tick(1)*image_transforms_[frame->get_layer_index()].fetch_and_tick(1);\r
frame2->get_image_transform() = root_image_transform_.fetch_and_tick(1)*image_transforms_[frame->get_layer_index()].fetch_and_tick(1);\r
\r
if(frame1->get_image_transform() != frame2->get_image_transform())\r
- basic_frame::interlace(frame1, frame2, format_desc_.mode)->accept(image_mixer_);\r
+ core::basic_frame::interlace(frame1, frame2, format_desc_.mode)->accept(image_mixer_);\r
else\r
frame2->accept(image_mixer_);\r
}\r
else\r
{\r
- auto frame1 = make_safe<basic_frame>(frame);\r
+ auto frame1 = make_safe<core::basic_frame>(frame);\r
frame1->get_image_transform() = root_image_transform_.fetch_and_tick(1)*image_transforms_[frame->get_layer_index()].fetch_and_tick(1);\r
frame1->accept(image_mixer_);\r
}\r
return std::move(image);\r
}\r
\r
- std::vector<short> mix_audio(const std::vector<safe_ptr<basic_frame>>& frames)\r
+ std::vector<short> mix_audio(const std::vector<safe_ptr<core::basic_frame>>& frames)\r
{\r
auto audio = audio_mixer_.begin_pass();\r
BOOST_FOREACH(auto& frame, frames)\r
{\r
- int num = format_desc_.mode == video_mode::progressive ? 1 : 2;\r
+ int num = format_desc_.mode == core::video_mode::progressive ? 1 : 2;\r
\r
- auto frame1 = make_safe<basic_frame>(frame);\r
+ auto frame1 = make_safe<core::basic_frame>(frame);\r
frame1->get_audio_transform() = root_audio_transform_.fetch_and_tick(num)*audio_transforms_[frame->get_layer_index()].fetch_and_tick(num);\r
frame1->accept(audio_mixer_);\r
}\r
return audio;\r
}\r
\r
- void send(const std::vector<safe_ptr<basic_frame>>& frames)\r
+ void send(const std::vector<safe_ptr<core::basic_frame>>& frames)\r
{ \r
executor_.begin_invoke([=]\r
{ \r
diag_->set_value("input-buffer", static_cast<float>(executor_.size())/static_cast<float>(executor_.capacity()));\r
}\r
\r
- safe_ptr<write_frame> create_frame(void* tag, const pixel_format_desc& desc)\r
+ safe_ptr<core::write_frame> create_frame(void* tag, const core::pixel_format_desc& desc)\r
{\r
return make_safe<gpu_write_frame>(reinterpret_cast<int>(tag), desc, image_mixer_.create_buffers(desc));\r
}\r
\r
- void set_image_transform(const image_transform& transform, int mix_duration, const std::wstring& tween)\r
+ void set_image_transform(const core::image_transform& transform, int mix_duration, const std::wstring& tween)\r
{\r
executor_.invoke([&]\r
{\r
auto src = root_image_transform_.fetch();\r
auto dst = transform;\r
- root_image_transform_ = tweened_transform<image_transform>(src, dst, mix_duration, tween);\r
+ root_image_transform_ = tweened_transform<core::image_transform>(src, dst, mix_duration, tween);\r
});\r
}\r
\r
- void set_audio_transform(const audio_transform& transform, int mix_duration, const std::wstring& tween)\r
+ void set_audio_transform(const core::audio_transform& transform, int mix_duration, const std::wstring& tween)\r
{\r
executor_.invoke([&]\r
{\r
auto src = root_audio_transform_.fetch();\r
auto dst = transform;\r
- root_audio_transform_ = tweened_transform<audio_transform>(src, dst, mix_duration, tween);\r
+ root_audio_transform_ = tweened_transform<core::audio_transform>(src, dst, mix_duration, tween);\r
});\r
}\r
\r
- void set_image_transform(int index, const image_transform& transform, int mix_duration, const std::wstring& tween)\r
+ void set_image_transform(int index, const core::image_transform& transform, int mix_duration, const std::wstring& tween)\r
{\r
executor_.invoke([&]\r
{\r
auto src = image_transforms_[index].fetch();\r
auto dst = transform;\r
- image_transforms_[index] = tweened_transform<image_transform>(src, dst, mix_duration, tween);\r
+ image_transforms_[index] = tweened_transform<core::image_transform>(src, dst, mix_duration, tween);\r
});\r
}\r
\r
- void set_audio_transform(int index, const audio_transform& transform, int mix_duration, const std::wstring& tween)\r
+ void set_audio_transform(int index, const core::audio_transform& transform, int mix_duration, const std::wstring& tween)\r
{\r
executor_.invoke([&]\r
{\r
auto src = audio_transforms_[index].fetch();\r
auto dst = transform;\r
- audio_transforms_[index] = tweened_transform<audio_transform>(src, dst, mix_duration, tween);\r
+ audio_transforms_[index] = tweened_transform<core::audio_transform>(src, dst, mix_duration, tween);\r
});\r
}\r
\r
- void apply_image_transform(const std::function<image_transform(const image_transform&)>& transform, int mix_duration, const std::wstring& tween)\r
+ void apply_image_transform(const std::function<core::image_transform(const core::image_transform&)>& transform, int mix_duration, const std::wstring& tween)\r
{\r
return executor_.invoke([&]\r
{\r
auto src = root_image_transform_.fetch();\r
auto dst = transform(src);\r
- root_image_transform_ = tweened_transform<image_transform>(src, dst, mix_duration, tween);\r
+ root_image_transform_ = tweened_transform<core::image_transform>(src, dst, mix_duration, tween);\r
});\r
}\r
\r
- void apply_audio_transform(const std::function<audio_transform(audio_transform)>& transform, int mix_duration, const std::wstring& tween)\r
+ void apply_audio_transform(const std::function<core::audio_transform(core::audio_transform)>& transform, int mix_duration, const std::wstring& tween)\r
{\r
return executor_.invoke([&]\r
{\r
auto src = root_audio_transform_.fetch();\r
auto dst = transform(src);\r
- root_audio_transform_ = tweened_transform<audio_transform>(src, dst, mix_duration, tween);\r
+ root_audio_transform_ = tweened_transform<core::audio_transform>(src, dst, mix_duration, tween);\r
});\r
}\r
\r
- void apply_image_transform(int index, const std::function<image_transform(image_transform)>& transform, int mix_duration, const std::wstring& tween)\r
+ void apply_image_transform(int index, const std::function<core::image_transform(core::image_transform)>& transform, int mix_duration, const std::wstring& tween)\r
{\r
executor_.invoke([&]\r
{\r
auto src = image_transforms_[index].fetch();\r
auto dst = transform(src);\r
- image_transforms_[index] = tweened_transform<image_transform>(src, dst, mix_duration, tween);\r
+ image_transforms_[index] = tweened_transform<core::image_transform>(src, dst, mix_duration, tween);\r
});\r
}\r
\r
- void apply_audio_transform(int index, const std::function<audio_transform(audio_transform)>& transform, int mix_duration, const std::wstring& tween)\r
+ void apply_audio_transform(int index, const std::function<core::audio_transform(core::audio_transform)>& transform, int mix_duration, const std::wstring& tween)\r
{\r
executor_.invoke([&]\r
{\r
auto src = audio_transforms_[index].fetch();\r
auto dst = transform(src);\r
- audio_transforms_[index] = tweened_transform<audio_transform>(src, dst, mix_duration, tween);\r
+ audio_transforms_[index] = tweened_transform<core::audio_transform>(src, dst, mix_duration, tween);\r
});\r
}\r
\r
executor_.invoke([&]\r
{\r
BOOST_FOREACH(auto& t, image_transforms_) \r
- t.second = tweened_transform<image_transform>(t.second.fetch(), image_transform(), mix_duration, tween); \r
- root_image_transform_ = tweened_transform<image_transform>(root_image_transform_.fetch(), image_transform(), mix_duration, tween);\r
+ t.second = tweened_transform<core::image_transform>(t.second.fetch(), core::image_transform(), mix_duration, tween); \r
+ root_image_transform_ = tweened_transform<core::image_transform>(root_image_transform_.fetch(), core::image_transform(), mix_duration, tween);\r
});\r
}\r
\r
executor_.invoke([&]\r
{\r
BOOST_FOREACH(auto& t, audio_transforms_)\r
- t.second = tweened_transform<audio_transform>(t.second.fetch(), audio_transform(), mix_duration, tween);\r
- root_audio_transform_ = tweened_transform<audio_transform>(root_audio_transform_.fetch(), audio_transform(), mix_duration, tween);\r
+ t.second = tweened_transform<core::audio_transform>(t.second.fetch(), core::audio_transform(), mix_duration, tween);\r
+ root_audio_transform_ = tweened_transform<core::audio_transform>(root_audio_transform_.fetch(), core::audio_transform(), mix_duration, tween);\r
});\r
}\r
\r
}\r
};\r
\r
-frame_mixer_device::frame_mixer_device(const video_format_desc& format_desc) : impl_(new implementation(format_desc)){}\r
+frame_mixer_device::frame_mixer_device(const core::video_format_desc& format_desc) : impl_(new implementation(format_desc)){}\r
frame_mixer_device::frame_mixer_device(frame_mixer_device&& other) : impl_(std::move(other.impl_)){}\r
boost::signals2::connection frame_mixer_device::connect(const output_t::slot_type& subscriber){return impl_->connect(subscriber);}\r
-void frame_mixer_device::send(const std::vector<safe_ptr<basic_frame>>& frames){impl_->send(frames);}\r
-const video_format_desc& frame_mixer_device::get_video_format_desc() const { return impl_->format_desc_; }\r
-safe_ptr<write_frame> frame_mixer_device::create_frame(void* tag, const pixel_format_desc& desc){ return impl_->create_frame(tag, desc); } \r
-safe_ptr<write_frame> frame_mixer_device::create_frame(void* tag, size_t width, size_t height, pixel_format::type pix_fmt)\r
+void frame_mixer_device::send(const std::vector<safe_ptr<core::basic_frame>>& frames){impl_->send(frames);}\r
+const core::video_format_desc& frame_mixer_device::get_video_format_desc() const { return impl_->format_desc_; }\r
+safe_ptr<core::write_frame> frame_mixer_device::create_frame(void* tag, const core::pixel_format_desc& desc){ return impl_->create_frame(tag, desc); } \r
+safe_ptr<core::write_frame> frame_mixer_device::create_frame(void* tag, size_t width, size_t height, core::pixel_format::type pix_fmt)\r
{\r
// Create bgra frame\r
- pixel_format_desc desc;\r
+ core::pixel_format_desc desc;\r
desc.pix_fmt = pix_fmt;\r
- desc.planes.push_back( pixel_format_desc::plane(width, height, 4));\r
+ desc.planes.push_back( core::pixel_format_desc::plane(width, height, 4));\r
return create_frame(tag, desc);\r
}\r
\r
-safe_ptr<write_frame> frame_mixer_device::create_frame(void* tag, pixel_format::type pix_fmt)\r
+safe_ptr<core::write_frame> frame_mixer_device::create_frame(void* tag, core::pixel_format::type pix_fmt)\r
{\r
// Create bgra frame with output resolution\r
- pixel_format_desc desc;\r
+ core::pixel_format_desc desc;\r
desc.pix_fmt = pix_fmt;\r
- desc.planes.push_back( pixel_format_desc::plane(get_video_format_desc().width, get_video_format_desc().height, 4));\r
+ desc.planes.push_back( core::pixel_format_desc::plane(get_video_format_desc().width, get_video_format_desc().height, 4));\r
return create_frame(tag, desc);\r
}\r
-void frame_mixer_device::set_image_transform(const image_transform& transform, int mix_duration, const std::wstring& tween){impl_->set_image_transform(transform, mix_duration, tween);}\r
-void frame_mixer_device::set_image_transform(int index, const image_transform& transform, int mix_duration, const std::wstring& tween){impl_->set_image_transform(index, transform, mix_duration, tween);}\r
-void frame_mixer_device::set_audio_transform(const audio_transform& transform, int mix_duration, const std::wstring& tween){impl_->set_audio_transform(transform, mix_duration, tween);}\r
-void frame_mixer_device::set_audio_transform(int index, const audio_transform& transform, int mix_duration, const std::wstring& tween){impl_->set_audio_transform(index, transform, mix_duration, tween);}\r
-void frame_mixer_device::apply_image_transform(const std::function<image_transform(image_transform)>& transform, int mix_duration, const std::wstring& tween){impl_->apply_image_transform(transform, mix_duration, tween);}\r
-void frame_mixer_device::apply_image_transform(int index, const std::function<image_transform(image_transform)>& transform, int mix_duration, const std::wstring& tween){impl_->apply_image_transform(index, transform, mix_duration, tween);}\r
-void frame_mixer_device::apply_audio_transform(const std::function<audio_transform(audio_transform)>& transform, int mix_duration, const std::wstring& tween){impl_->apply_audio_transform(transform, mix_duration, tween);}\r
-void frame_mixer_device::apply_audio_transform(int index, const std::function<audio_transform(audio_transform)>& transform, int mix_duration, const std::wstring& tween){impl_->apply_audio_transform(index, transform, mix_duration, tween);}\r
+void frame_mixer_device::set_image_transform(const core::image_transform& transform, int mix_duration, const std::wstring& tween){impl_->set_image_transform(transform, mix_duration, tween);}\r
+void frame_mixer_device::set_image_transform(int index, const core::image_transform& transform, int mix_duration, const std::wstring& tween){impl_->set_image_transform(index, transform, mix_duration, tween);}\r
+void frame_mixer_device::set_audio_transform(const core::audio_transform& transform, int mix_duration, const std::wstring& tween){impl_->set_audio_transform(transform, mix_duration, tween);}\r
+void frame_mixer_device::set_audio_transform(int index, const core::audio_transform& transform, int mix_duration, const std::wstring& tween){impl_->set_audio_transform(index, transform, mix_duration, tween);}\r
+void frame_mixer_device::apply_image_transform(const std::function<core::image_transform(core::image_transform)>& transform, int mix_duration, const std::wstring& tween){impl_->apply_image_transform(transform, mix_duration, tween);}\r
+void frame_mixer_device::apply_image_transform(int index, const std::function<core::image_transform(core::image_transform)>& transform, int mix_duration, const std::wstring& tween){impl_->apply_image_transform(index, transform, mix_duration, tween);}\r
+void frame_mixer_device::apply_audio_transform(const std::function<core::audio_transform(core::audio_transform)>& transform, int mix_duration, const std::wstring& tween){impl_->apply_audio_transform(transform, mix_duration, tween);}\r
+void frame_mixer_device::apply_audio_transform(int index, const std::function<core::audio_transform(core::audio_transform)>& transform, int mix_duration, const std::wstring& tween){impl_->apply_audio_transform(index, transform, mix_duration, tween);}\r
void frame_mixer_device::reset_image_transform(int mix_duration, const std::wstring& tween){impl_->reset_image_transform(mix_duration, tween);}\r
void frame_mixer_device::reset_audio_transform(int mix_duration, const std::wstring& tween){impl_->reset_audio_transform(mix_duration, tween);}\r
\r
*/\r
#pragma once\r
\r
+#include <core/consumer/frame/read_frame.h>\r
+#include <core/producer/frame/write_frame.h>\r
#include <core/producer/frame/frame_factory.h>\r
#include <core/producer/frame/pixel_format.h>\r
\r
\r
#include <functional>\r
\r
-namespace caspar { namespace core {\r
+namespace caspar { namespace mixer {\r
\r
-struct video_format_desc;\r
-class read_frame;\r
-class write_frame;\r
-\r
-class frame_mixer_device : public frame_factory\r
+class frame_mixer_device : public core::frame_factory\r
{\r
public:\r
- typedef boost::signals2::signal<void(const safe_ptr<const read_frame>&)> output_t;\r
+ typedef boost::signals2::signal<void(const safe_ptr<const core::read_frame>&)> output_t;\r
\r
boost::signals2::connection connect(const output_t::slot_type& subscriber);\r
\r
- frame_mixer_device(const video_format_desc& format_desc);\r
+ frame_mixer_device(const core::video_format_desc& format_desc);\r
frame_mixer_device(frame_mixer_device&& other); // nothrow\r
\r
- void send(const std::vector<safe_ptr<basic_frame>>& frames); // nothrow\r
+ void send(const std::vector<safe_ptr<core::basic_frame>>& frames); // nothrow\r
\r
- safe_ptr<write_frame> create_frame(void* tag, const pixel_format_desc& desc); \r
- safe_ptr<write_frame> create_frame(void* tag, size_t width, size_t height, pixel_format::type pix_fmt = pixel_format::bgra); \r
- safe_ptr<write_frame> create_frame(void* tag, pixel_format::type pix_fmt = pixel_format::bgra);\r
+ safe_ptr<core::write_frame> create_frame(void* tag, const core::pixel_format_desc& desc); \r
+ safe_ptr<core::write_frame> create_frame(void* tag, size_t width, size_t height, core::pixel_format::type pix_fmt = core::pixel_format::bgra); \r
+ safe_ptr<core::write_frame> create_frame(void* tag, core::pixel_format::type pix_fmt = core::pixel_format::bgra);\r
\r
- const video_format_desc& get_video_format_desc() const; // nothrow\r
+ const core::video_format_desc& get_video_format_desc() const; // nothrow\r
\r
- void set_image_transform(const image_transform& transform, int mix_duration = 0, const std::wstring& tween = L"linear");\r
- void set_image_transform(int index, const image_transform& transform, int mix_duration = 0, const std::wstring& tween = L"linear");\r
+ void set_image_transform(const core::image_transform& transform, int mix_duration = 0, const std::wstring& tween = L"linear");\r
+ void set_image_transform(int index, const core::image_transform& transform, int mix_duration = 0, const std::wstring& tween = L"linear");\r
\r
- void set_audio_transform(const audio_transform& transform, int mix_duration = 0, const std::wstring& tween = L"linear");\r
- void set_audio_transform(int index, const audio_transform& transform, int mix_duration = 0, const std::wstring& tween = L"linear");\r
+ void set_audio_transform(const core::audio_transform& transform, int mix_duration = 0, const std::wstring& tween = L"linear");\r
+ void set_audio_transform(int index, const core::audio_transform& transform, int mix_duration = 0, const std::wstring& tween = L"linear");\r
\r
- void apply_image_transform(const std::function<image_transform(image_transform)>& transform, int mix_duration = 0, const std::wstring& tween = L"linear");\r
- void apply_image_transform(int index, const std::function<image_transform(image_transform)>& transform, int mix_duration = 0, const std::wstring& tween = L"linear");\r
+ void apply_image_transform(const std::function<core::image_transform(core::image_transform)>& transform, int mix_duration = 0, const std::wstring& tween = L"linear");\r
+ void apply_image_transform(int index, const std::function<core::image_transform(core::image_transform)>& transform, int mix_duration = 0, const std::wstring& tween = L"linear");\r
\r
- void apply_audio_transform(const std::function<audio_transform(audio_transform)>& transform, int mix_duration = 0, const std::wstring& tween = L"linear");\r
- void apply_audio_transform(int index, const std::function<audio_transform(audio_transform)>& transform, int mix_duration = 0, const std::wstring& tween = L"linear");\r
+ void apply_audio_transform(const std::function<core::audio_transform(core::audio_transform)>& transform, int mix_duration = 0, const std::wstring& tween = L"linear");\r
+ void apply_audio_transform(int index, const std::function<core::audio_transform(core::audio_transform)>& transform, int mix_duration = 0, const std::wstring& tween = L"linear");\r
\r
void reset_image_transform(int mix_duration = 0, const std::wstring& tween = L"linear");\r
void reset_audio_transform(int mix_duration = 0, const std::wstring& tween = L"linear");\r
#include "device_buffer.h"\r
\r
#include <common/gl/gl_check.h>\r
-namespace caspar { namespace core {\r
+namespace caspar { namespace mixer {\r
\r
GLenum FORMAT[] = {0, GL_LUMINANCE, GL_LUMINANCE_ALPHA, GL_BGR, GL_BGRA};\r
GLenum INTERNAL_FORMAT[] = {0, GL_LUMINANCE8, GL_LUMINANCE8_ALPHA8, GL_RGB8, GL_RGBA8}; \r
\r
#include <memory>\r
\r
-namespace caspar { namespace core {\r
+namespace caspar { namespace mixer {\r
\r
class device_buffer : boost::noncopyable\r
{\r
\r
#include <common/gl/gl_check.h>\r
\r
-namespace caspar { namespace core {\r
+namespace caspar { namespace mixer {\r
\r
struct gpu_read_frame::implementation : boost::noncopyable\r
{\r
\r
#include <common/memory/safe_ptr.h>\r
\r
-namespace caspar { namespace core {\r
+namespace caspar { namespace mixer {\r
\r
class gpu_read_frame : public core::read_frame\r
{\r
\r
#include <boost/range/algorithm.hpp>\r
\r
-namespace caspar { namespace core {\r
+namespace caspar { namespace mixer {\r
\r
struct gpu_write_frame::implementation : boost::noncopyable\r
{ \r
std::vector<safe_ptr<host_buffer>> buffers_;\r
std::vector<short> audio_data_;\r
- const pixel_format_desc desc_;\r
+ const core::pixel_format_desc desc_;\r
int tag_;\r
\r
public:\r
- implementation(int tag, const pixel_format_desc& desc, const std::vector<safe_ptr<host_buffer>>& buffers) \r
+ implementation(int tag, const core::pixel_format_desc& desc, const std::vector<safe_ptr<host_buffer>>& buffers) \r
: desc_(desc)\r
, buffers_(buffers)\r
, tag_(tag){}\r
\r
- void accept(gpu_write_frame& self, frame_visitor& visitor)\r
+ void accept(gpu_write_frame& self, core::frame_visitor& visitor)\r
{\r
visitor.begin(self);\r
visitor.visit(self);\r
}\r
};\r
\r
-gpu_write_frame::gpu_write_frame(int tag, const pixel_format_desc& desc, const std::vector<safe_ptr<host_buffer>>& buffers) : impl_(new implementation(tag, desc, buffers)){}\r
+gpu_write_frame::gpu_write_frame(int tag, const core::pixel_format_desc& desc, const std::vector<safe_ptr<host_buffer>>& buffers) : impl_(new implementation(tag, desc, buffers)){}\r
gpu_write_frame::gpu_write_frame(gpu_write_frame&& other) : impl_(std::move(other.impl_)){}\r
void gpu_write_frame::swap(gpu_write_frame& other){impl_.swap(other.impl_);}\r
gpu_write_frame& gpu_write_frame::operator=(gpu_write_frame&& other)\r
temp.swap(*this);\r
return *this;\r
}\r
-void gpu_write_frame::accept(frame_visitor& visitor){impl_->accept(*this, visitor);}\r
+void gpu_write_frame::accept(core::frame_visitor& visitor){impl_->accept(*this, visitor);}\r
boost::iterator_range<unsigned char*> gpu_write_frame::image_data(size_t index){return impl_->image_data(index);}\r
std::vector<short>& gpu_write_frame::audio_data() { return impl_->audio_data_; }\r
const boost::iterator_range<const unsigned char*> gpu_write_frame::image_data(size_t index) const\r
return boost::iterator_range<const short*>(impl_->audio_data_.data(), impl_->audio_data_.data() + impl_->audio_data_.size());\r
}\r
int gpu_write_frame::tag() const {return impl_->tag_;}\r
-const pixel_format_desc& gpu_write_frame::get_pixel_format_desc() const{return impl_->desc_;}\r
+const core::pixel_format_desc& gpu_write_frame::get_pixel_format_desc() const{return impl_->desc_;}\r
std::vector<safe_ptr<host_buffer>>& gpu_write_frame::get_plane_buffers(){return impl_->buffers_;}\r
}}
\ No newline at end of file
\r
#include <common/memory/safe_ptr.h>\r
#include <core/producer/frame/write_frame.h>\r
+#include <core/producer/frame/pixel_format.h>\r
\r
#include "../gpu/host_buffer.h"\r
\r
#include <memory>\r
#include <vector>\r
\r
-namespace caspar { namespace core {\r
+namespace caspar { namespace mixer {\r
\r
-struct pixel_format_desc;\r
-\r
class gpu_write_frame : public core::write_frame\r
{\r
public: \r
- explicit gpu_write_frame(int tag, const pixel_format_desc& desc, const std::vector<safe_ptr<host_buffer>>& buffers);\r
+ explicit gpu_write_frame(int tag, const core::pixel_format_desc& desc, const std::vector<safe_ptr<host_buffer>>& buffers);\r
gpu_write_frame(gpu_write_frame&& other);\r
gpu_write_frame& operator=(gpu_write_frame&& other);\r
\r
void swap(gpu_write_frame& other);\r
\r
- const pixel_format_desc& get_pixel_format_desc() const;\r
+ const core::pixel_format_desc& get_pixel_format_desc() const;\r
std::vector<safe_ptr<host_buffer>>& get_plane_buffers();\r
\r
// core::write_frame\r
virtual const boost::iterator_range<const unsigned char*> image_data(size_t plane_index = 0) const;\r
virtual const boost::iterator_range<const short*> audio_data() const;\r
\r
- virtual void accept(frame_visitor& visitor);\r
+ virtual void accept(core::frame_visitor& visitor);\r
\r
virtual int tag() const;\r
\r
\r
#include <common/gl/gl_check.h>\r
\r
-namespace caspar { namespace core {\r
+namespace caspar { namespace mixer {\r
\r
struct host_buffer::implementation : boost::noncopyable\r
{ \r
\r
#include <memory>\r
\r
-namespace caspar { namespace core {\r
+namespace caspar { namespace mixer {\r
\r
class host_buffer : boost::noncopyable\r
{\r
\r
#include <boost/foreach.hpp>\r
\r
-namespace caspar { namespace core {\r
+namespace caspar { namespace mixer {\r
\r
ogl_device::ogl_device() : executor_(L"ogl_device")\r
{\r
\r
#include <SFML/Window/Context.hpp>\r
\r
-namespace caspar { namespace core {\r
+namespace caspar { namespace mixer {\r
\r
class ogl_device\r
{ \r
\r
#include <unordered_map>\r
\r
-namespace caspar { namespace core {\r
+namespace caspar { namespace mixer {\r
\r
class shader_program : boost::noncopyable\r
{\r
\r
struct image_kernel::implementation : boost::noncopyable\r
{ \r
- std::unordered_map<pixel_format::type, shader_program> shaders_;\r
+ std::unordered_map<core::pixel_format::type, shader_program> shaders_;\r
\r
public:\r
- std::unordered_map<pixel_format::type, shader_program>& shaders()\r
+ std::unordered_map<core::pixel_format::type, shader_program>& shaders()\r
{\r
GL(glEnable(GL_POLYGON_STIPPLE));\r
GL(glEnable(GL_BLEND));\r
"} " \r
" ";\r
\r
- shaders_[pixel_format::abgr] = shader_program(common_vertex, common_fragment +\r
+ shaders_[core::pixel_format::abgr] = shader_program(common_vertex, common_fragment +\r
\r
"void main() "\r
"{ "\r
" gl_FragColor = abgr.argb * gain; "\r
"} ");\r
\r
- shaders_[pixel_format::argb]= shader_program(common_vertex, common_fragment +\r
+ shaders_[core::pixel_format::argb]= shader_program(common_vertex, common_fragment +\r
\r
"void main() " \r
"{ "\r
" gl_FragColor = argb.grab * gl_Color * gain; "\r
"} ");\r
\r
- shaders_[pixel_format::bgra]= shader_program(common_vertex, common_fragment +\r
+ shaders_[core::pixel_format::bgra]= shader_program(common_vertex, common_fragment +\r
\r
"void main() "\r
"{ "\r
" gl_FragColor = bgra.rgba * gl_Color * gain; "\r
"} ");\r
\r
- shaders_[pixel_format::rgba] = shader_program(common_vertex, common_fragment +\r
+ shaders_[core::pixel_format::rgba] = shader_program(common_vertex, common_fragment +\r
\r
"void main() "\r
"{ "\r
" gl_FragColor = rgba.bgra * gl_Color * gain; "\r
"} ");\r
\r
- shaders_[pixel_format::ycbcr] = shader_program(common_vertex, common_fragment +\r
+ shaders_[core::pixel_format::ycbcr] = shader_program(common_vertex, common_fragment +\r
\r
"void main() "\r
"{ "\r
" gl_FragColor = ycbcra_to_bgra_sd(y, cb, cr, a) * gl_Color * gain;"\r
"} ");\r
\r
- shaders_[pixel_format::ycbcra] = shader_program(common_vertex, common_fragment +\r
+ shaders_[core::pixel_format::ycbcra] = shader_program(common_vertex, common_fragment +\r
\r
"void main() "\r
"{ "\r
\r
image_kernel::image_kernel() : impl_(new implementation()){}\r
\r
-void image_kernel::apply(const pixel_format_desc& pix_desc, const image_transform& transform)\r
+void image_kernel::apply(const core::pixel_format_desc& pix_desc, const core::image_transform& transform)\r
{\r
impl_->shaders()[pix_desc.pix_fmt].use();\r
\r
GL(glUniform1f(impl_->shaders()[pix_desc.pix_fmt].get_location("gain"), static_cast<GLfloat>(transform.get_gain())));\r
GL(glUniform1i(impl_->shaders()[pix_desc.pix_fmt].get_location("HD"), pix_desc.planes.at(0).height > 700 ? 1 : 0));\r
\r
- if(transform.get_mode() == video_mode::upper)\r
+ if(transform.get_mode() == core::video_mode::upper)\r
glPolygonStipple(upper_pattern);\r
- else if(transform.get_mode() == video_mode::lower)\r
+ else if(transform.get_mode() == core::video_mode::lower)\r
glPolygonStipple(lower_pattern);\r
else\r
glPolygonStipple(progressive_pattern);\r
\r
#include <memory>\r
\r
-namespace caspar { namespace core {\r
-\r
-struct pixel_format_desc;\r
-class image_transform;\r
-class image_transform;\r
+#include <core/producer/frame/pixel_format.h>\r
+#include <core/producer/frame/image_transform.h>\r
\r
+namespace caspar { namespace mixer {\r
+ \r
class image_kernel\r
{\r
public:\r
image_kernel();\r
- void apply(const pixel_format_desc& pix_desc, const image_transform& mode);\r
+ void apply(const core::pixel_format_desc& pix_desc, const core::image_transform& mode);\r
\r
private:\r
struct implementation;\r
#include <array>\r
#include <unordered_map>\r
\r
-namespace caspar { namespace core {\r
+namespace caspar { namespace mixer {\r
\r
struct image_mixer::implementation : boost::noncopyable\r
{ \r
- const video_format_desc format_desc_;\r
+ const core::video_format_desc format_desc_;\r
\r
- std::stack<image_transform> transform_stack_;\r
+ std::stack<core::image_transform> transform_stack_;\r
\r
GLuint fbo_;\r
std::array<std::shared_ptr<device_buffer>, 2> render_targets_;\r
safe_ptr<ogl_device> context_;\r
\r
public:\r
- implementation(const video_format_desc& format_desc) \r
+ implementation(const core::video_format_desc& format_desc) \r
: format_desc_(format_desc)\r
, context_(ogl_device::create())\r
{\r
\r
context_->begin_invoke([=]\r
{\r
- transform_stack_.push(image_transform());\r
- transform_stack_.top().set_mode(video_mode::progressive);\r
+ transform_stack_.push(core::image_transform());\r
+ transform_stack_.top().set_mode(core::video_mode::progressive);\r
\r
GL(glEnable(GL_TEXTURE_2D));\r
GL(glDisable(GL_DEPTH_TEST)); \r
glDeleteFramebuffersEXT(1, &fbo_);\r
}\r
\r
- void begin(const basic_frame& frame)\r
+ void begin(const core::basic_frame& frame)\r
{\r
transform_stack_.push(transform_stack_.top()*frame.get_image_transform());\r
}\r
\r
- void visit(write_frame& frame)\r
+ void visit(core::write_frame& frame)\r
{\r
auto gpu_frame = boost::polymorphic_downcast<gpu_write_frame*>(&frame);\r
auto& desc = gpu_frame->get_pixel_format_desc();\r
});\r
}\r
\r
- std::vector<safe_ptr<host_buffer>> create_buffers(const pixel_format_desc& format)\r
+ std::vector<safe_ptr<host_buffer>> create_buffers(const core::pixel_format_desc& format)\r
{\r
std::vector<safe_ptr<host_buffer>> buffers;\r
- std::transform(format.planes.begin(), format.planes.end(), std::back_inserter(buffers), [&](const pixel_format_desc::plane& plane) -> safe_ptr<host_buffer>\r
+ std::transform(format.planes.begin(), format.planes.end(), std::back_inserter(buffers), [&](const core::pixel_format_desc::plane& plane)\r
{\r
return context_->create_host_buffer(plane.size, host_buffer::write_only);\r
});\r
}\r
};\r
\r
-image_mixer::image_mixer(const video_format_desc& format_desc) : impl_(new implementation(format_desc)){}\r
-void image_mixer::begin(const basic_frame& frame){impl_->begin(frame);}\r
-void image_mixer::visit(write_frame& frame){impl_->visit(frame);}\r
+image_mixer::image_mixer(const core::video_format_desc& format_desc) : impl_(new implementation(format_desc)){}\r
+void image_mixer::begin(const core::basic_frame& frame){impl_->begin(frame);}\r
+void image_mixer::visit(core::write_frame& frame){impl_->visit(frame);}\r
void image_mixer::end(){impl_->end();}\r
boost::unique_future<safe_ptr<const host_buffer>> image_mixer::begin_pass(){ return impl_->begin_pass();}\r
void image_mixer::end_pass(){impl_->end_pass();}\r
-std::vector<safe_ptr<host_buffer>> image_mixer::create_buffers(const pixel_format_desc& format){return impl_->create_buffers(format);}\r
+std::vector<safe_ptr<host_buffer>> image_mixer::create_buffers(const core::pixel_format_desc& format){return impl_->create_buffers(format);}\r
\r
}}
\ No newline at end of file
#pragma once\r
\r
+#include <core/video_format.h>\r
#include <core/producer/frame/frame_visitor.h>\r
+#include <core/producer/frame/pixel_format.h>\r
\r
#include "../gpu/host_buffer.h"\r
\r
#include <memory>\r
#include <vector>\r
\r
-namespace caspar { namespace core {\r
-\r
-struct video_format_desc;\r
-struct pixel_format_desc; \r
-class image_transform;\r
-\r
+namespace caspar { namespace mixer {\r
+ \r
class image_mixer : public core::frame_visitor, boost::noncopyable\r
{\r
public:\r
- image_mixer(const video_format_desc& format_desc);\r
+ image_mixer(const core::video_format_desc& format_desc);\r
\r
- virtual void begin(const basic_frame& frame);\r
- virtual void visit(write_frame& frame);\r
+ virtual void begin(const core::basic_frame& frame);\r
+ virtual void visit(core::write_frame& frame);\r
virtual void end();\r
\r
boost::unique_future<safe_ptr<const host_buffer>> begin_pass();\r
void end_pass();\r
\r
- std::vector<safe_ptr<host_buffer>> create_buffers(const pixel_format_desc& format);\r
+ std::vector<safe_ptr<host_buffer>> create_buffers(const core::pixel_format_desc& format);\r
\r
private:\r
struct implementation;\r
CASPAR_LOG(info) << L"FFMPEG-avcodec " << get_avcodec_version();\r
CASPAR_LOG(info) << L"FFMPEG-swscale " << get_avformat_version();\r
CASPAR_LOG(info) << L"FFMPEG-avformat " << get_swscale_version();\r
- CASPAR_LOG(info) << L"OpenGL " << ogl_device::create()->invoke([]{return reinterpret_cast<const char*>(glGetString(GL_VERSION));})\r
- << L" " << ogl_device::create()->invoke([]{return reinterpret_cast<const char*>(glGetString(GL_VENDOR));});\r
+ CASPAR_LOG(info) << L"OpenGL " << mixer::ogl_device::create()->invoke([]{return reinterpret_cast<const char*>(glGetString(GL_VERSION));})\r
+ << L" " << mixer::ogl_device::create()->invoke([]{return reinterpret_cast<const char*>(glGetString(GL_VENDOR));});\r
\r
HKEY hkey; \r
DWORD dwType, dwSize;\r