X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=core%2Fmixer%2Fmixer.cpp;h=c5b5e1fb31f71fad85dc306bd3c24080d909dcab;hb=e2a3cc199deb51ffa09469b1570624fa9a6b25c8;hp=8562dbb8d1da122b2fe3678f5a6f7ca662721d95;hpb=c77152657f7864ca78a9638948272193e1a88faf;p=casparcg diff --git a/core/mixer/mixer.cpp b/core/mixer/mixer.cpp index 8562dbb8d..c5b5e1fb3 100644 --- a/core/mixer/mixer.cpp +++ b/core/mixer/mixer.cpp @@ -39,6 +39,7 @@ #include #include #include +#include #include #include @@ -56,12 +57,15 @@ namespace caspar { namespace core { struct mixer::impl : boost::noncopyable { int channel_index_; - spl::shared_ptr graph_; + spl::shared_ptr graph_; tbb::atomic current_mix_time_; - audio_mixer audio_mixer_; + spl::shared_ptr monitor_subject_ = spl::make_shared("/mixer"); + audio_mixer audio_mixer_ { graph_ }; spl::shared_ptr image_mixer_; + + bool straighten_alpha_ = false; - executor executor_ { L"mixer " + boost::lexical_cast(channel_index_) }; + executor executor_ { L"mixer " + boost::lexical_cast(channel_index_) }; public: impl(int channel_index, spl::shared_ptr graph, spl::shared_ptr image_mixer) @@ -71,9 +75,10 @@ public: { graph_->set_color("mix-time", diagnostics::color(1.0f, 0.0f, 0.9f, 0.8f)); current_mix_time_ = 0; + audio_mixer_.monitor_output().attach_parent(monitor_subject_); } - const_frame operator()(std::map frames, const video_format_desc& format_desc) + const_frame operator()(std::map frames, const video_format_desc& format_desc, const core::audio_channel_layout& channel_layout) { caspar::timer frame_timer; @@ -81,6 +86,8 @@ public: { try { + CASPAR_SCOPED_CONTEXT_MSG(L" '" + executor_.name() + L"' "); + detail::set_current_aspect_ratio( static_cast(format_desc.square_width) / static_cast(format_desc.square_height)); @@ -92,12 +99,12 @@ public: frame.second.accept(*image_mixer_); } - auto image = (*image_mixer_)(format_desc); - auto audio = audio_mixer_(format_desc); + auto image = (*image_mixer_)(format_desc, straighten_alpha_); + auto audio = audio_mixer_(format_desc, channel_layout); auto desc = core::pixel_format_desc(core::pixel_format::bgra); desc.planes.push_back(core::pixel_format_desc::plane(format_desc.width, format_desc.height, 4)); - return const_frame(std::move(image), std::move(audio), this, desc); + return const_frame(std::move(image), std::move(audio), this, desc, channel_layout); } catch(...) { @@ -129,6 +136,22 @@ public: }, task_priority::high_priority); } + void set_straight_alpha_output(bool value) + { + executor_.begin_invoke([=] + { + straighten_alpha_ = value; + }, task_priority::high_priority); + } + + bool get_straight_alpha_output() + { + return executor_.invoke([=] + { + return straighten_alpha_; + }, task_priority::high_priority); + } + std::future info() const { boost::property_tree::wptree info; @@ -150,8 +173,11 @@ mixer::mixer(int channel_index, spl::shared_ptr graph, spl:: : impl_(new impl(channel_index, std::move(graph), std::move(image_mixer))){} void mixer::set_master_volume(float volume) { impl_->set_master_volume(volume); } float mixer::get_master_volume() { return impl_->get_master_volume(); } +void mixer::set_straight_alpha_output(bool value) { impl_->set_straight_alpha_output(value); } +bool mixer::get_straight_alpha_output() { return impl_->get_straight_alpha_output(); } std::future mixer::info() const{return impl_->info();} std::future mixer::delay_info() const{ return impl_->delay_info(); } -const_frame mixer::operator()(std::map frames, const video_format_desc& format_desc){ return (*impl_)(std::move(frames), format_desc); } -mutable_frame mixer::create_frame(const void* tag, const core::pixel_format_desc& desc) {return impl_->image_mixer_->create_frame(tag, desc);} +const_frame mixer::operator()(std::map frames, const video_format_desc& format_desc, const core::audio_channel_layout& channel_layout){ return (*impl_)(std::move(frames), format_desc, channel_layout); } +mutable_frame mixer::create_frame(const void* tag, const core::pixel_format_desc& desc, const core::audio_channel_layout& channel_layout) {return impl_->image_mixer_->create_frame(tag, desc, channel_layout);} +monitor::subject& mixer::monitor_output() { return *impl_->monitor_subject_; } }}