]> git.sesse.net Git - casparcg/blobdiff - core/producer/layer.cpp
#40 Fixed problem with LOAD command not working
[casparcg] / core / producer / layer.cpp
index b158510dbb7709bfdb1b6c35d51614f8c67da0d1..76473cc4eada0f3010e69cbb4d4ad0f7b4a6397a 100644 (file)
@@ -19,7 +19,7 @@
 * Author: Robert Nagy, ronag89@gmail.com
 */
 
-#include "../stdafx.h"
+#include "../StdAfx.h"
 
 #include "layer.h"
 
@@ -41,6 +41,7 @@ struct layer::impl
        spl::shared_ptr<frame_producer>         background_                     = frame_producer::empty();;
        boost::optional<int32_t>                        auto_play_delta_;
        bool                                                            is_paused_                      = false;
+       int64_t                                                         current_frame_age_      = 0;
 
 public:
        impl(int index) 
@@ -65,7 +66,13 @@ public:
                foreground_->paused(true);
                is_paused_ = true;
        }
-       
+
+       void resume()
+       {
+               foreground_->paused(false);
+               is_paused_ = false;
+       }
+
        void load(spl::shared_ptr<frame_producer> producer, bool preview, const boost::optional<int32_t>& auto_play_delta)
        {               
 //             background_->unsubscribe(background_event_subject_);
@@ -77,6 +84,7 @@ public:
                if(preview)
                {
                        play();
+                       receive(video_format::invalid);
                        foreground_->paused(true);
                        is_paused_ = true;
                }
@@ -114,7 +122,11 @@ public:
                {               
                        *monitor_subject_ << monitor::message("/paused") % is_paused_;
 
+                       caspar::timer produce_timer;
                        auto frame = foreground_->receive();
+                       auto produce_time = produce_timer.elapsed();
+
+                       *monitor_subject_ << monitor::message("/profiler/time") % produce_time % (1.0 / format_desc.fps);
                        
                        if(frame == core::draw_frame::late())
                                return foreground_->last_frame();
@@ -136,6 +148,8 @@ public:
 
                        //foreground_event_subject_ << monitor::event("type") % foreground_->name();
                        //background_event_subject_ << monitor::event("type") % background_->name();
+
+                       current_frame_age_ = frame.get_and_record_age_millis();
                                
                        return frame;
                }
@@ -157,11 +171,20 @@ public:
 
                info.add(L"nb_frames",   nb_frames == std::numeric_limits<int64_t>::max() ? -1 : nb_frames);
                info.add(L"frames-left", nb_frames == std::numeric_limits<int64_t>::max() ? -1 : (foreground_->nb_frames() - foreground_->frame_number() - (auto_play_delta_ ? *auto_play_delta_ : 0)));
+               info.add(L"frame-age", current_frame_age_);
                info.add_child(L"producer", foreground_->info());
                info.add_child(L"background.producer", background_->info());
                return info;
        }
 
+       boost::property_tree::wptree delay_info() const
+       {
+               boost::property_tree::wptree info;
+               info.add(L"producer", foreground_->print());
+               info.add(L"frame-age", current_frame_age_);
+               return info;
+       }
+
        void on_interaction(const interaction_event::ptr& event)
        {
                foreground_->on_interaction(event);
@@ -187,12 +210,14 @@ void layer::swap(layer& other)
 void layer::load(spl::shared_ptr<frame_producer> frame_producer, bool preview, const boost::optional<int32_t>& auto_play_delta){return impl_->load(std::move(frame_producer), preview, auto_play_delta);}      
 void layer::play(){impl_->play();}
 void layer::pause(){impl_->pause();}
+void layer::resume(){impl_->resume();}
 void layer::stop(){impl_->stop();}
 draw_frame layer::receive(const video_format_desc& format_desc) {return impl_->receive(format_desc);}
 spl::shared_ptr<frame_producer> layer::foreground() const { return impl_->foreground_;}
 spl::shared_ptr<frame_producer> layer::background() const { return impl_->background_;}
 boost::property_tree::wptree layer::info() const{return impl_->info();}
+boost::property_tree::wptree layer::delay_info() const{return impl_->delay_info();}
 monitor::subject& layer::monitor_output() {return *impl_->monitor_subject_;}
 void layer::on_interaction(const interaction_event::ptr& event) { impl_->on_interaction(event); }
 bool layer::collides(double x, double y) const { return impl_->collides(x, y); }
-}}
\ No newline at end of file
+}}