X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=core%2Fproducer%2Fframe_producer.cpp;h=f881d2adbb6d36353912b8cfb8b56b3c12e23335;hb=5bad7c1c1348fe338b748cff8dbc448155d3ae85;hp=da08185ac5ef7e66d22c0db298098c6f153a2410;hpb=04b14225786105cc6fb61bf26f8ba09f80ef9e7e;p=casparcg diff --git a/core/producer/frame_producer.cpp b/core/producer/frame_producer.cpp index da08185ac..f881d2adb 100644 --- a/core/producer/frame_producer.cpp +++ b/core/producer/frame_producer.cpp @@ -34,16 +34,36 @@ namespace caspar { namespace core { std::vector g_factories; -const safe_ptr& frame_producer::empty() // nothrow +class last_frame_producer : public frame_producer { - struct empty_frame_producer : public frame_producer + const std::wstring print_; + const safe_ptr frame_; + const int64_t nb_frames_; +public: + last_frame_producer(const safe_ptr& producer) + : print_(producer->print()) + , frame_(producer->last_frame() != basic_frame::eof() ? producer->last_frame() : basic_frame::empty()) + , nb_frames_(producer->nb_frames()) { - virtual safe_ptr receive(int){return basic_frame::empty();} - virtual safe_ptr last_frame() const{return basic_frame::empty();} - virtual void set_frame_factory(const safe_ptr&){} - virtual int64_t nb_frames() const {return 0;} - virtual std::wstring print() const { return L"empty";} - }; + } + + virtual safe_ptr receive(int){return frame_;} + virtual safe_ptr last_frame() const{return frame_;} + virtual std::wstring print() const{return L"dummy[" + print_ + L"]";} + virtual int64_t nb_frames() const {return nb_frames_;} +}; + +struct empty_frame_producer : public frame_producer +{ + virtual safe_ptr receive(int){return basic_frame::empty();} + virtual safe_ptr last_frame() const{return basic_frame::empty();} + virtual void set_frame_factory(const safe_ptr&){} + virtual int64_t nb_frames() const {return 0;} + virtual std::wstring print() const { return L"empty";} +}; + +const safe_ptr& frame_producer::empty() // nothrow +{ static safe_ptr producer = make_safe(); return producer; } @@ -55,11 +75,13 @@ safe_ptr receive_and_follow(safe_ptr& producer, int { CASPAR_LOG(info) << producer->print() << " End Of File."; auto following = producer->get_following_producer(); - following->set_leading_producer(producer); - producer = std::move(following); - - if(producer == frame_producer::empty()) - return basic_frame::eof(); + if(following != frame_producer::empty()) + { + following->set_leading_producer(producer); + producer = std::move(following); + } + else + producer = make_safe(producer); return receive_and_follow(producer, hints); }