]> git.sesse.net Git - casparcg/blob - core/video_channel.cpp
git-svn-id: https://casparcg.svn.sourceforge.net/svnroot/casparcg/server/branches...
[casparcg] / core / video_channel.cpp
1 /*\r
2 * copyright (c) 2010 Sveriges Television AB <info@casparcg.com>\r
3 *\r
4 *  This file is part of CasparCG.\r
5 *\r
6 *    CasparCG is free software: you can redistribute it and/or modify\r
7 *    it under the terms of the GNU General Public License as published by\r
8 *    the Free Software Foundation, either version 3 of the License, or\r
9 *    (at your option) any later version.\r
10 *\r
11 *    CasparCG is distributed in the hope that it will be useful,\r
12 *    but WITHOUT ANY WARRANTY; without even the implied warranty of\r
13 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
14 *    GNU General Public License for more details.\r
15 \r
16 *    You should have received a copy of the GNU General Public License\r
17 *    along with CasparCG.  If not, see <http://www.gnu.org/licenses/>.\r
18 *\r
19 */\r
20 \r
21 #include "StdAfx.h"\r
22 \r
23 #include "video_channel.h"\r
24 \r
25 #include "video_format.h"\r
26 \r
27 #include "consumer/output.h"\r
28 #include "mixer/mixer.h"\r
29 #include "producer/stage.h"\r
30 \r
31 #include <common/concurrency/governor.h>\r
32 #include <common/diagnostics/graph.h>\r
33 \r
34 #include "mixer/gpu/ogl_device.h"\r
35 \r
36 #include <agents_extras.h>\r
37 \r
38 #include <boost/timer.hpp>\r
39 \r
40 #ifdef _MSC_VER\r
41 #pragma warning(disable : 4355)\r
42 #endif\r
43 \r
44 using namespace Concurrency;\r
45 \r
46 namespace caspar { namespace core {\r
47 \r
48 struct video_channel::implementation : boost::noncopyable\r
49 {\r
50         unbounded_buffer<stage::target_element_t>       stage_frames_;\r
51         unbounded_buffer<mixer::target_element_t>       mixer_frames_;\r
52         \r
53         const video_format_desc                         format_desc_;\r
54         \r
55         governor                                                        governor_;\r
56         safe_ptr<caspar::core::output>          output_;\r
57         safe_ptr<caspar::core::mixer>           mixer_;\r
58         safe_ptr<caspar::core::stage>           stage_;\r
59 \r
60         safe_ptr<diagnostics::graph>            graph_;\r
61         boost::timer                                            frame_timer_;\r
62         boost::timer                                            tick_timer_;\r
63         boost::timer                                            output_timer_;\r
64         \r
65 public:\r
66         implementation(int index, const video_format_desc& format_desc, ogl_device& ogl)  \r
67                 : format_desc_(format_desc)\r
68                 , governor_(2)\r
69                 , output_(new caspar::core::output(mixer_frames_, format_desc))\r
70                 , mixer_(new caspar::core::mixer(stage_frames_, mixer_frames_, format_desc, ogl))\r
71                 , stage_(new caspar::core::stage(stage_frames_, governor_))     \r
72         {\r
73                 graph_->add_guide("produce-time", 0.5f);        \r
74                 graph_->set_color("produce-time", diagnostics::color(0.0f, 1.0f, 0.0f));\r
75                 graph_->set_color("tick-time", diagnostics::color(0.0f, 0.6f, 0.9f));   \r
76                 graph_->set_color("output-time", diagnostics::color(1.0f, 0.5f, 0.0f));\r
77                 graph_->set_color("mix-time", diagnostics::color(1.0f, 1.0f, 0.9f));\r
78                 graph_->set_text(print());\r
79                 diagnostics::register_graph(graph_);\r
80 \r
81                 CASPAR_LOG(info) << print() << " Successfully Initialized.";\r
82         }\r
83                         \r
84         std::wstring print() const\r
85         {\r
86                 return L"video_channel";\r
87         }\r
88 };\r
89 \r
90 video_channel::video_channel(int index, const video_format_desc& format_desc, ogl_device& ogl) : impl_(new implementation(index, format_desc, ogl)){}\r
91 video_channel::video_channel(video_channel&& other) : impl_(std::move(other.impl_)){}\r
92 safe_ptr<stage> video_channel::stage() { return impl_->stage_;} \r
93 safe_ptr<mixer> video_channel::mixer() { return impl_->mixer_;} \r
94 safe_ptr<output> video_channel::output() { return impl_->output_;} \r
95 video_format_desc video_channel::get_video_format_desc() const{return impl_->format_desc_;}\r
96 std::wstring video_channel::print() const { return impl_->print();}\r
97 \r
98 }}