]> git.sesse.net Git - casparcg/commitdiff
Merged reference signal detection in decklink consumer from 2.0
authorHelge Norberg <helge.norberg@svt.se>
Thu, 12 Nov 2015 17:45:05 +0000 (18:45 +0100)
committerHelge Norberg <helge.norberg@svt.se>
Thu, 12 Nov 2015 17:45:05 +0000 (18:45 +0100)
modules/decklink/CMakeLists.txt
modules/decklink/consumer/decklink_consumer.cpp
modules/decklink/util/util.h

index c0a82bae8f825de39cbe0440379a22ee15e4bc49..a379f27428d6f37825c817293e2dc9308178e453 100644 (file)
@@ -66,6 +66,7 @@ source_group(sources ./*)
 source_group(sources\\consumer consumer/*)
 source_group(sources\\interop interop/*)
 source_group(sources\\producer producer/*)
+source_group(sources\\util util/*)
 
 if (MSVC)
        target_link_libraries(decklink
index 01e1afad8fb40e9e4776767e3827897b8624bc31..50b5d2c8c3dffe306b90fbed13890d7b1ca64435 100644 (file)
@@ -360,9 +360,10 @@ struct decklink_consumer : public IDeckLinkVideoOutputCallback, public IDeckLink
        tbb::concurrent_bounded_queue<core::const_frame>        audio_frame_buffer_;
        
        spl::shared_ptr<diagnostics::graph>                                     graph_;
-       tbb::atomic<int64_t>                                                            current_presentation_delay_;
        caspar::timer                                                                           tick_timer_;
        retry_task<bool>                                                                        send_completion_;
+       reference_signal_detector                                                       reference_signal_detector_      { output_ };
+       tbb::atomic<int64_t>                                                            current_presentation_delay_;
        tbb::atomic<int64_t>                                                            scheduled_frames_completed_;
        std::unique_ptr<key_video_context>                                      key_context_;
 
@@ -612,6 +613,8 @@ public:
 
                graph_->set_value("tick-time", tick_timer_.elapsed()*format_desc_.fps*0.5);
                tick_timer_.restart();
+
+               reference_signal_detector_.detect_change([this]() { return print(); });
        }
 
        std::future<bool> send(core::const_frame frame)
index 73988088eb3b3c2c29246ad4b0eb620368bfb98e..4ffce4b104f0d44a1cf5816582995e39c79b144b 100644 (file)
@@ -197,4 +197,39 @@ static std::wstring get_model_name(const T& device)
     return u16(pModelName);
 }
 
+class reference_signal_detector
+{
+       com_iface_ptr<IDeckLinkOutput>  output_;
+       BMDReferenceStatus                              last_reference_status_  = static_cast<BMDReferenceStatus>(-1);
+public:
+       reference_signal_detector(const com_iface_ptr<IDeckLinkOutput>& output)
+               : output_(output)
+       {
+       }
+
+       template<typename Print>
+       void detect_change(const Print& print)
+       {
+               BMDReferenceStatus reference_status;
+
+               if (output_->GetReferenceStatus(&reference_status) != S_OK)
+               {
+                       CASPAR_LOG(error) << print() << L" Reference signal: failed while querying status";
+               }
+               else if (reference_status != last_reference_status_)
+               {
+                       last_reference_status_ = reference_status;
+
+                       if (reference_status == 0)
+                               CASPAR_LOG(info) << print() << L" Reference signal: not detected.";
+                       else if (reference_status & bmdReferenceNotSupportedByHardware)
+                               CASPAR_LOG(info) << print() << L" Reference signal: not supported by hardware.";
+                       else if (reference_status & bmdReferenceLocked)
+                               CASPAR_LOG(info) << print() << L" Reference signal: locked.";
+                       else
+                               CASPAR_LOG(info) << print() << L" Reference signal: Unhandled enum bitfield: " << reference_status;
+               }
+       }
+};
+
 }}