]> git.sesse.net Git - casparcg/blob - core/consumer/port.cpp
Merge branch '2.1.0' of https://github.com/CasparCG/Server into 2.1.0
[casparcg] / core / consumer / port.cpp
1 #include "../StdAfx.h"
2
3 #include "port.h"
4
5 #include "frame_consumer.h"
6 #include "../frame/frame.h"
7 #include <boost/lexical_cast.hpp>
8
9 namespace caspar { namespace core {
10
11 struct port::impl
12 {
13         monitor::subject                                        monitor_subject_;
14         std::shared_ptr<frame_consumer>         consumer_;
15         int                                                                     index_;
16         int                                                                     channel_index_;
17 public:
18         impl(int index, int channel_index, spl::shared_ptr<frame_consumer> consumer)
19                 : monitor_subject_("/port" + boost::lexical_cast<std::string>(index))
20                 , consumer_(std::move(consumer))
21                 , index_(index)
22                 , channel_index_(channel_index)
23         {
24                 consumer_->monitor_output().link_target(&monitor_subject_);
25         }
26         
27         void video_format_desc(const struct video_format_desc& format_desc)
28         {
29                 consumer_->initialize(format_desc, channel_index_);
30         }
31                 
32         boost::unique_future<bool> send(const_frame frame)
33         {
34                 monitor_subject_ << monitor::message("/type") % consumer_->name();
35                 return consumer_->send(std::move(frame));
36         }
37         std::wstring print() const
38         {
39                 return consumer_->print();
40         }
41
42         int index() const
43         {
44                 return index_;
45         }
46
47         int buffer_depth() const
48         {
49                 return consumer_->buffer_depth();
50         }
51
52         bool has_synchronization_clock() const
53         {
54                 return consumer_->has_synchronization_clock();
55         }
56
57         boost::property_tree::wptree info() const
58         {
59                 return consumer_->info();
60         }
61 };
62
63 port::port(int index, int channel_index, spl::shared_ptr<frame_consumer> consumer) : impl_(new impl(index, channel_index, std::move(consumer))){}
64 port::port(port&& other) : impl_(std::move(other.impl_)){}
65 port::~port(){}
66 port& port::operator=(port&& other){impl_ = std::move(other.impl_); return *this;}
67 boost::unique_future<bool> port::send(const_frame frame){return impl_->send(std::move(frame));} 
68 monitor::source& port::monitor_output() {return impl_->monitor_subject_;}
69 void port::video_format_desc(const struct video_format_desc& format_desc){impl_->video_format_desc(format_desc);}
70 int port::buffer_depth() const{return impl_->buffer_depth();}
71 std::wstring port::print() const{ return impl_->print();}
72 bool port::has_synchronization_clock() const{return impl_->has_synchronization_clock();}
73 boost::property_tree::wptree port::info() const{return impl_->info();}
74 }}