From 65199f18ae5ec831d809ea73b6e9dd01f530b4c5 Mon Sep 17 00:00:00 2001 From: ronag Date: Thu, 10 Nov 2011 16:36:02 +0000 Subject: [PATCH] git-svn-id: https://casparcg.svn.sourceforge.net/svnroot/casparcg/server/branches/2.0.0.2@1554 362d55ac-95cf-4e76-9f9a-cbaa9c17b72d --- common/diagnostics/graph.cpp | 185 +++++++++--------- common/diagnostics/graph.h | 12 +- core/video_channel.cpp | 3 +- .../bluefish/consumer/bluefish_consumer.cpp | 5 +- .../decklink/consumer/decklink_consumer.cpp | 5 +- modules/decklink/interop/DeckLinkAPI_h.h | 2 +- modules/decklink/interop/DeckLinkAPI_i.c | 2 +- .../decklink/producer/decklink_producer.cpp | 5 +- modules/ffmpeg/producer/ffmpeg_producer.cpp | 4 +- modules/flash/producer/flash_producer.cpp | 7 +- modules/oal/consumer/oal_consumer.cpp | 6 +- modules/ogl/consumer/ogl_consumer.cpp | 3 +- protocol/amcp/AMCPCommandsImpl.cpp | 19 ++ protocol/amcp/AMCPCommandsImpl.h | 6 + protocol/amcp/AMCPProtocolStrategy.cpp | 1 + shell/casparcg.config | 11 +- shell/shell.vcxproj | 2 +- version.tmpl | 2 +- 18 files changed, 161 insertions(+), 119 deletions(-) diff --git a/common/diagnostics/graph.cpp b/common/diagnostics/graph.cpp index db6eff790..0b4348e0b 100644 --- a/common/diagnostics/graph.cpp +++ b/common/diagnostics/graph.cpp @@ -48,7 +48,7 @@ struct drawable : public sf::Drawable class context : public drawable { - sf::RenderWindow window_; + std::unique_ptr window_; std::list> drawables_; @@ -71,31 +71,51 @@ public: get_instance().do_register_drawable(drawable); }); } - + + static void show(bool value) + { + begin_invoke([=] + { + get_instance().do_show(value); + }); + } + private: context() : executor_(L"diagnostics") { - executor_.begin_invoke([this] - { - SetThreadPriority(GetCurrentThread(), BELOW_NORMAL_PRIORITY_CLASS); - window_.Create(sf::VideoMode(600, 1000), "CasparCG Diagnostics"); - window_.SetPosition(0, 0); - window_.SetActive(); - glEnable(GL_BLEND); - glEnable(GL_LINE_SMOOTH); - glHint(GL_LINE_SMOOTH_HINT, GL_NICEST); - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - tick(); - }); + } + + void do_show(bool value) + { + if(value) + { + if(!window_) + { + SetThreadPriority(GetCurrentThread(), BELOW_NORMAL_PRIORITY_CLASS); + window_.reset(new sf::RenderWindow(sf::VideoMode(600, 1000), "CasparCG Diagnostics")); + window_->SetPosition(0, 0); + window_->SetActive(); + glEnable(GL_BLEND); + glEnable(GL_LINE_SMOOTH); + glHint(GL_LINE_SMOOTH_HINT, GL_NICEST); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + tick(); + } + } + else + window_.reset(); } void tick() { + if(!window_) + return; + sf::Event e; - while(window_.GetEvent(e)){} + while(window_->GetEvent(e)){} glClear(GL_COLOR_BUFFER_BIT); - window_.Draw(*this); - window_.Display(); + window_->Draw(*this); + window_->Display(); boost::this_thread::sleep(boost::posix_time::milliseconds(20)); executor_.begin_invoke([this]{tick();}); } @@ -112,8 +132,8 @@ private: auto& drawable = *it; if(!drawable.unique()) { - drawable->SetScale(static_cast(window_.GetWidth()), static_cast(target_dy*window_.GetHeight())); - float target_y = std::max(last_y, static_cast(n * window_.GetHeight())*target_dy); + drawable->SetScale(static_cast(window_->GetWidth()), static_cast(target_dy*window_->GetHeight())); + float target_y = std::max(last_y, static_cast(n * window_->GetHeight())*target_dy); drawable->SetPosition(0.0f, target_y); target.Draw(*drawable); ++it; @@ -125,7 +145,8 @@ private: void do_register_drawable(const std::shared_ptr& drawable) { - drawables_.push_back(drawable); + if(std::find(drawables_.begin(), drawables_.end(), drawable) == drawables_.end()) + drawables_.push_back(drawable); } static context& get_instance() @@ -168,12 +189,13 @@ class line : public drawable boost::optional guide_; boost::circular_buffer> line_data_; - std::vector tick_data_; - bool tick_tag_; + boost::circular_buffer tick_data_; + bool tick_tag_; color c_; public: line(size_t res = 600) : line_data_(res) + , tick_data_(50) , tick_tag_(false) , c_(1.0f, 1.0f, 1.0f) { @@ -260,22 +282,19 @@ struct graph::implementation : public drawable std::map lines_; std::string name_; std::string text_; - - int counter_; - + implementation(const std::string& name) : name_(name) - , text_(name) - , counter_(0){} + , text_(name_){} - void update(const std::string& name, double value) + void set_text(const std::string& value) { - lines_[name].update(value); + text_ = value; } - void update_text(const std::string& value) + void update(const std::string& name, double value) { - text_ = value; + lines_[name].update(value); } void set(const std::string& name, double value) @@ -351,84 +370,74 @@ private: implementation& operator=(implementation&); }; -graph::graph(const std::string& name) : impl_(env::properties().get("configuration.diagnostics.graphs", true) ? new implementation(name) : nullptr) +graph::graph() : impl_(new implementation("")) { - if(impl_) - context::register_drawable(impl_); + } -void graph::update_value(const std::string& name, double value) +void graph::set_text(const std::string& value) { - if(impl_) + auto p = impl_; + context::begin_invoke([=] { - auto p = impl_; - context::begin_invoke([=] - { - p->update(name, value); - }); - } + p->set_text(value); + }); } -void graph::update_text(const std::string& value) +void graph::set_text(const std::wstring& value) { - if(impl_) - { - auto p = impl_; - context::begin_invoke([=] - { - p->update_text(value); - }); - } + set_text(narrow(value)); } -void graph::set_value(const std::string& name, double value) +void graph::update_value(const std::string& name, double value) { - if(impl_) - { - auto p = impl_; - context::begin_invoke([=] - { - p->set(name, value); - }); - } + auto p = impl_; + context::begin_invoke([=] + { + p->update(name, value); + }); } -void graph::set_color(const std::string& name, color c) +void graph::set_value(const std::string& name, double value) { - if(impl_) - { - auto p = impl_; - context::begin_invoke([=] - { - p->set_color(name, c); - }); - } + auto p = impl_; + context::begin_invoke([=] + { + p->set(name, value); + }); +} +void graph::set_color(const std::string& name, color c) +{ + auto p = impl_; + context::begin_invoke([=] + { + p->set_color(name, c); + }); } void graph::add_tag(const std::string& name) -{ - if(impl_) - { - auto p = impl_; - context::begin_invoke([=] - { - p->tag(name); - }); - } +{ + auto p = impl_; + context::begin_invoke([=] + { + p->tag(name); + }); } void graph::add_guide(const std::string& name, double value) { - if(impl_) - { - auto p = impl_; - context::begin_invoke([=] - { - p->guide(name, value); - }); - } + auto p = impl_; + context::begin_invoke([=] + { + p->guide(name, value); + }); +} + +void register_graph(const safe_ptr& graph) +{ + context::register_drawable(graph->impl_); } -safe_ptr create_graph(const std::string& name) +void show_graphs(bool value) { - return safe_ptr(new graph(name)); + context::show(value); } //namespace v2 diff --git a/common/diagnostics/graph.h b/common/diagnostics/graph.h index 0d9ef3d62..268d74cb5 100644 --- a/common/diagnostics/graph.h +++ b/common/diagnostics/graph.h @@ -51,11 +51,12 @@ struct color class graph { - friend safe_ptr create_graph(const std::string& name); - graph(const std::string& name); + friend void register_graph(const safe_ptr& graph); public: + graph(); + void set_text(const std::string& value); + void set_text(const std::wstring& value); void update_value(const std::string& name, double value); - void update_text(const std::string& value); void set_value(const std::string& name, double value); void set_color(const std::string& name, color c); void add_tag(const std::string& name); @@ -65,8 +66,9 @@ private: std::shared_ptr impl_; }; -safe_ptr create_graph(const std::string& name); - +void register_graph(const safe_ptr& graph); +void show_graphs(bool value); + //namespace v2 //{ // diff --git a/core/video_channel.cpp b/core/video_channel.cpp index 682c98958..10b4d5864 100644 --- a/core/video_channel.cpp +++ b/core/video_channel.cpp @@ -58,7 +58,6 @@ struct video_channel::implementation : boost::noncopyable public: implementation(int index, const video_format_desc& format_desc, ogl_device& ogl) : context_(index, ogl, format_desc) - , diag_(diagnostics::create_graph(narrow(print()))) , output_(new caspar::core::output(context_, [this]{restart();})) , mixer_(new caspar::core::mixer(context_)) , stage_(new caspar::core::stage(context_)) @@ -68,6 +67,8 @@ public: diag_->set_color("tick-time", diagnostics::color(0.0f, 0.6f, 0.9f)); diag_->set_color("output-time", diagnostics::color(1.0f, 0.5f, 0.0f)); diag_->set_color("mix-time", diagnostics::color(1.0f, 1.0f, 0.9f)); + diag_->set_text(print()); + diagnostics::register_graph(diag_); CASPAR_LOG(info) << print() << " Successfully Initialized."; context_.execution().begin_invoke([this]{tick();}); diff --git a/modules/bluefish/consumer/bluefish_consumer.cpp b/modules/bluefish/consumer/bluefish_consumer.cpp index 62e840670..315e8cc33 100644 --- a/modules/bluefish/consumer/bluefish_consumer.cpp +++ b/modules/bluefish/consumer/bluefish_consumer.cpp @@ -53,7 +53,7 @@ struct bluefish_consumer : boost::noncopyable const std::wstring model_name_; - std::shared_ptr graph_; + safe_ptr graph_; boost::timer frame_timer_; boost::timer tick_timer_; boost::timer sync_timer_; @@ -83,13 +83,14 @@ public: { executor_.set_capacity(core::consumer_buffer_depth()); - graph_ = diagnostics::create_graph(narrow(print())); graph_->add_guide("tick-time", 0.5); graph_->set_color("tick-time", diagnostics::color(0.0f, 0.6f, 0.9f)); graph_->add_guide("frame-time", 0.5f); graph_->set_color("frame-time", diagnostics::color(1.0f, 0.0f, 0.0f)); graph_->set_color("sync-time", diagnostics::color(0.5f, 1.0f, 0.2f)); graph_->set_color("input-buffer", diagnostics::color(1.0f, 1.0f, 0.0f)); + graph_->set_text(print()); + diagnostics::register_graph(graph_); //Setting output Video mode if(BLUE_FAIL(set_card_property(blue_, VIDEO_MODE, vid_fmt_))) diff --git a/modules/decklink/consumer/decklink_consumer.cpp b/modules/decklink/consumer/decklink_consumer.cpp index dcfbde7f3..e9c4227b1 100644 --- a/modules/decklink/consumer/decklink_consumer.cpp +++ b/modules/decklink/consumer/decklink_consumer.cpp @@ -156,7 +156,7 @@ struct decklink_consumer : public IDeckLinkVideoOutputCallback, public IDeckLink tbb::concurrent_bounded_queue> video_frame_buffer_; tbb::concurrent_bounded_queue> audio_frame_buffer_; - std::shared_ptr graph_; + safe_ptr graph_; boost::timer tick_timer_; public: @@ -179,12 +179,13 @@ public: video_frame_buffer_.set_capacity(1); audio_frame_buffer_.set_capacity(1); - graph_ = diagnostics::create_graph(narrow(print())); graph_->add_guide("tick-time", 0.5); graph_->set_color("tick-time", diagnostics::color(0.0f, 0.6f, 0.9f)); graph_->set_color("late-frame", diagnostics::color(0.6f, 0.3f, 0.3f)); graph_->set_color("dropped-frame", diagnostics::color(0.3f, 0.6f, 0.3f)); graph_->set_color("flushed-frame", diagnostics::color(0.4f, 0.3f, 0.8f)); + graph_->set_text(print()); + diagnostics::register_graph(graph_); enable_video(get_display_mode(output_, format_desc_.format, bmdFormat8BitBGRA, bmdVideoOutputFlagDefault)); diff --git a/modules/decklink/interop/DeckLinkAPI_h.h b/modules/decklink/interop/DeckLinkAPI_h.h index d88cbf46a..31336c46c 100644 --- a/modules/decklink/interop/DeckLinkAPI_h.h +++ b/modules/decklink/interop/DeckLinkAPI_h.h @@ -4,7 +4,7 @@ /* File created by MIDL compiler version 7.00.0555 */ -/* at Thu Nov 10 08:57:13 2011 +/* at Thu Nov 10 16:28:32 2011 */ /* Compiler settings for interop\DeckLinkAPI.idl: Oicf, W1, Zp8, env=Win32 (32b run), target_arch=X86 7.00.0555 diff --git a/modules/decklink/interop/DeckLinkAPI_i.c b/modules/decklink/interop/DeckLinkAPI_i.c index 9429f04e1..3284b293f 100644 --- a/modules/decklink/interop/DeckLinkAPI_i.c +++ b/modules/decklink/interop/DeckLinkAPI_i.c @@ -6,7 +6,7 @@ /* File created by MIDL compiler version 7.00.0555 */ -/* at Thu Nov 10 08:57:13 2011 +/* at Thu Nov 10 16:28:32 2011 */ /* Compiler settings for interop\DeckLinkAPI.idl: Oicf, W1, Zp8, env=Win32 (32b run), target_arch=X86 7.00.0555 diff --git a/modules/decklink/producer/decklink_producer.cpp b/modules/decklink/producer/decklink_producer.cpp index 178b0042c..176e79f56 100644 --- a/modules/decklink/producer/decklink_producer.cpp +++ b/modules/decklink/producer/decklink_producer.cpp @@ -82,7 +82,7 @@ class decklink_producer : boost::noncopyable, public IDeckLinkInputCallback const core::video_format_desc format_desc_; const size_t device_index_; - std::shared_ptr graph_; + safe_ptr graph_; boost::timer tick_timer_; boost::timer frame_timer_; @@ -108,13 +108,14 @@ public: { frame_buffer_.set_capacity(2); - graph_ = diagnostics::create_graph(narrow(print())); graph_->add_guide("tick-time", 0.5); graph_->set_color("tick-time", diagnostics::color(0.0f, 0.6f, 0.9f)); graph_->set_color("late-frame", diagnostics::color(0.6f, 0.3f, 0.3f)); graph_->set_color("frame-time", diagnostics::color(1.0f, 0.0f, 0.0f)); graph_->set_color("dropped-frame", diagnostics::color(0.3f, 0.6f, 0.3f)); graph_->set_color("output-buffer", diagnostics::color(0.0f, 1.0f, 0.0f)); + graph_->set_text(print()); + diagnostics::register_graph(graph_); auto display_mode = get_display_mode(input_, format_desc_.format, bmdFormat8BitYUV, bmdVideoInputFlagDefault); diff --git a/modules/ffmpeg/producer/ffmpeg_producer.cpp b/modules/ffmpeg/producer/ffmpeg_producer.cpp index 576f7a3cc..02083d5ba 100644 --- a/modules/ffmpeg/producer/ffmpeg_producer.cpp +++ b/modules/ffmpeg/producer/ffmpeg_producer.cpp @@ -79,7 +79,6 @@ struct ffmpeg_producer : public core::frame_producer public: explicit ffmpeg_producer(const safe_ptr& frame_factory, const std::wstring& filename, const std::wstring& filter, bool loop, int start, size_t length) : filename_(filename) - , graph_(diagnostics::create_graph("")) , frame_factory_(frame_factory) , format_desc_(frame_factory->get_video_format_desc()) , input_(graph_, filename_, loop, start, length) @@ -98,6 +97,7 @@ public: graph_->add_guide("frame-time", 0.5); graph_->set_color("frame-time", diagnostics::color(0.1f, 1.0f, 0.1f)); graph_->set_color("underflow", diagnostics::color(0.6f, 0.3f, 0.9f)); + diagnostics::register_graph(graph_); for(int n = 0; n < 3; ++n) frame_factory->create_frame(this, std::max(2, video_decoder_.width()), std::max(2, video_decoder_.height())); @@ -124,7 +124,7 @@ public: graph_->add_tag("underflow"); } - graph_->update_text(narrow(print())); + graph_->set_text(print()); return frame; } diff --git a/modules/flash/producer/flash_producer.cpp b/modules/flash/producer/flash_producer.cpp index 67a556423..c14158d2b 100644 --- a/modules/flash/producer/flash_producer.cpp +++ b/modules/flash/producer/flash_producer.cpp @@ -278,7 +278,7 @@ struct flash_producer : public core::frame_producer tbb::atomic fps_; - std::shared_ptr graph_; + safe_ptr graph_; tbb::concurrent_bounded_queue> frame_buffer_; @@ -303,9 +303,10 @@ public: fps_ = 0; - graph_ = diagnostics::create_graph(narrow(print())); graph_->set_color("output-buffer-count", diagnostics::color(1.0f, 1.0f, 0.0f)); graph_->set_color("underflow", diagnostics::color(0.6f, 0.3f, 0.9f)); + graph_->set_text(print()); + diagnostics::register_graph(graph_); frame_buffer_.set_capacity(frame_factory_->get_video_format_desc().fps > 30.0 ? 2 : 1); @@ -419,7 +420,7 @@ public: graph_->set_value("output-buffer-count", static_cast(frame_buffer_.size())/static_cast(frame_buffer_.capacity())); fps_.fetch_and_store(static_cast(context_->fps()*100.0)); - graph_->update_text(narrow(print())); + graph_->set_text(narrow(print())); render(renderer); } diff --git a/modules/oal/consumer/oal_consumer.cpp b/modules/oal/consumer/oal_consumer.cpp index 35ef456d0..524cdf0c7 100644 --- a/modules/oal/consumer/oal_consumer.cpp +++ b/modules/oal/consumer/oal_consumer.cpp @@ -54,8 +54,7 @@ struct oal_consumer : public core::frame_consumer, public sf::SoundStream int preroll_count_; public: oal_consumer() - : graph_(diagnostics::create_graph(narrow(print()))) - , container_(16) + : container_(16) , preroll_count_(0) { if(core::consumer_buffer_depth() < 3) @@ -63,6 +62,9 @@ public: graph_->add_guide("tick-time", 0.5); graph_->set_color("tick-time", diagnostics::color(0.0f, 0.6f, 0.9f)); + graph_->set_text(print()); + diagnostics::register_graph(graph_); + is_running_ = true; input_.set_capacity(core::consumer_buffer_depth()-2); } diff --git a/modules/ogl/consumer/ogl_consumer.cpp b/modules/ogl/consumer/ogl_consumer.cpp index 9550a5a1e..0f98c7db2 100644 --- a/modules/ogl/consumer/ogl_consumer.cpp +++ b/modules/ogl/consumer/ogl_consumer.cpp @@ -134,7 +134,6 @@ public: , screen_height_(format_desc.height) , square_width_(format_desc.square_width) , square_height_(format_desc.square_height) - , graph_(diagnostics::create_graph(narrow(print()))) , input_buffer_(core::consumer_buffer_depth()-1) , filter_(format_desc.field_mode == core::field_mode::progressive || !config.auto_deinterlace ? L"" : L"YADIF=0:-1", boost::assign::list_of(PIX_FMT_BGRA)) { @@ -143,6 +142,8 @@ public: graph_->add_guide("frame-time", 0.5); graph_->set_color("frame-time", diagnostics::color(1.0f, 0.0f, 0.0f)); graph_->set_color("dropped-frame", diagnostics::color(0.3f, 0.6f, 0.3f)); + graph_->set_text(print()); + diagnostics::register_graph(graph_); DISPLAY_DEVICE d_device = {sizeof(d_device), 0}; std::vector displayDevices; diff --git a/protocol/amcp/AMCPCommandsImpl.cpp b/protocol/amcp/AMCPCommandsImpl.cpp index aec863e88..5fad85a3b 100644 --- a/protocol/amcp/AMCPCommandsImpl.cpp +++ b/protocol/amcp/AMCPCommandsImpl.cpp @@ -30,6 +30,7 @@ #include #include +#include #include #include @@ -196,6 +197,24 @@ void AMCPCommand::Clear() _parameters.clear(); } +bool DiagnosticsCommand::DoExecute() +{ + try + { + diagnostics::show_graphs(boost::lexical_cast(_parameters.at(0))); + + SetReplyString(TEXT("202 DIAG OK\r\n")); + + return true; + } + catch(...) + { + CASPAR_LOG_CURRENT_EXCEPTION(); + SetReplyString(TEXT("502 DIAG FAILED\r\n")); + return false; + } +} + bool ParamCommand::DoExecute() { //Perform loading of the clip diff --git a/protocol/amcp/AMCPCommandsImpl.h b/protocol/amcp/AMCPCommandsImpl.h index ef5f53bda..f027be46b 100644 --- a/protocol/amcp/AMCPCommandsImpl.h +++ b/protocol/amcp/AMCPCommandsImpl.h @@ -30,6 +30,12 @@ std::wstring ListTemplates(); namespace amcp { +class DiagnosticsCommand : public AMCPCommandBase +{ + std::wstring print() const { return L"DiagnosticsCommand";} + bool DoExecute(); +}; + class ParamCommand : public AMCPCommandBase { std::wstring print() const { return L"ParamCommand";} diff --git a/protocol/amcp/AMCPProtocolStrategy.cpp b/protocol/amcp/AMCPProtocolStrategy.cpp index 03b32196f..c545088d6 100644 --- a/protocol/amcp/AMCPProtocolStrategy.cpp +++ b/protocol/amcp/AMCPProtocolStrategy.cpp @@ -311,6 +311,7 @@ AMCPCommandPtr AMCPProtocolStrategy::CommandFactory(const std::wstring& str) transform(s.begin(), s.end(), s.begin(), toupper); if (s == TEXT("MIXER")) return std::make_shared(); + else if(s == TEXT("DIAG")) return std::make_shared(); else if(s == TEXT("PARAM")) return std::make_shared(); else if(s == TEXT("SWAP")) return std::make_shared(); else if(s == TEXT("LOAD")) return std::make_shared(); diff --git a/shell/casparcg.config b/shell/casparcg.config index 5a136818e..655cefb3a 100644 --- a/shell/casparcg.config +++ b/shell/casparcg.config @@ -1,14 +1,11 @@ - C:\Documents and Settings\rona01\Desktop\CasparCG 2.0 Beta 1\server\media\ - C:\Documents and Settings\rona01\Desktop\CasparCG 2.0 Beta 1\server\log\ - C:\Documents and Settings\rona01\Desktop\CasparCG 2.0 Beta 1\server\data\ - C:\Documents and Settings\rona01\Desktop\CasparCG 2.0 Beta 1\server\templates\ + C:\Documents and Settings\rona01\Desktop\CasparCG 2.0 Beta 2\server\media\ + C:\Documents and Settings\rona01\Desktop\CasparCG 2.0 Beta 2\server\log\ + C:\Documents and Settings\rona01\Desktop\CasparCG 2.0 Beta 2\server\data\ + C:\Documents and Settings\rona01\Desktop\CasparCG 2.0 Beta 2\server\templates\ - - true - true diff --git a/shell/shell.vcxproj b/shell/shell.vcxproj index 1ec92e818..70012601b 100644 --- a/shell/shell.vcxproj +++ b/shell/shell.vcxproj @@ -251,7 +251,7 @@ copy "$(ProjectDir)casparcg.config" "$(OutDir)" MachineX86 UseLinkTimeCodeGeneration - false + true copy "$(SolutionDir)dlls\*.dll" "$(OutDir)" diff --git a/version.tmpl b/version.tmpl index fb713a1dd..8e10167c0 100644 --- a/version.tmpl +++ b/version.tmpl @@ -2,4 +2,4 @@ #define CASPAR_MAYOR L"0" #define CASPAR_MINOR L"2" #define CASPAR_REV L"$WCREV$" -#define CASPAR_TAG L"BETA 1" \ No newline at end of file +#define CASPAR_TAG L"BETA 2" -- 2.39.2