]> git.sesse.net Git - casparcg/blob - core/video_channel.cpp
2.0.2: Added INFO TEMPLATE command, works for uncompressed templates.
[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 "mixer/gpu/ogl_device.h"\r
30 #include "producer/stage.h"\r
31 \r
32 #include <common/diagnostics/graph.h>\r
33 #include <common/env.h>\r
34 \r
35 #include <string>\r
36 \r
37 namespace caspar { namespace core {\r
38 \r
39 struct video_channel::implementation : boost::noncopyable\r
40 {\r
41         const int                                               index_;\r
42         video_format_desc                               format_desc_;\r
43         const safe_ptr<ogl_device>              ogl_;\r
44         safe_ptr<diagnostics::graph>    graph_;\r
45 \r
46         safe_ptr<caspar::core::output>  output_;\r
47         safe_ptr<caspar::core::mixer>   mixer_;\r
48         safe_ptr<caspar::core::stage>   stage_;\r
49         \r
50 public:\r
51         implementation(int index, const video_format_desc& format_desc, const safe_ptr<ogl_device>& ogl)  \r
52                 : index_(index)\r
53                 , format_desc_(format_desc)\r
54                 , ogl_(ogl)\r
55                 , output_(new caspar::core::output(graph_, format_desc, index))\r
56                 , mixer_(new caspar::core::mixer(graph_, output_, format_desc, ogl))\r
57                 , stage_(new caspar::core::stage(graph_, mixer_, format_desc))  \r
58         {\r
59                 graph_->set_text(print());\r
60                 diagnostics::register_graph(graph_);\r
61 \r
62                 for(int n = 0; n < std::max(1, env::properties().get("configuration.pipeline-tokens", 2)); ++n)\r
63                         stage_->spawn_token();\r
64 \r
65                 CASPAR_LOG(info) << print() << " Successfully Initialized.";\r
66         }\r
67         \r
68         void set_video_format_desc(const video_format_desc& format_desc)\r
69         {\r
70                 try\r
71                 {\r
72                         output_->set_video_format_desc(format_desc);\r
73                         mixer_->set_video_format_desc(format_desc);\r
74                         ogl_->gc();\r
75                 }\r
76                 catch(...)\r
77                 {\r
78                         output_->set_video_format_desc(format_desc_);\r
79                         mixer_->set_video_format_desc(format_desc_);\r
80                         throw;\r
81                 }\r
82                 format_desc_ = format_desc;\r
83         }\r
84                 \r
85         std::wstring print() const\r
86         {\r
87                 return L"video_channel[" + boost::lexical_cast<std::wstring>(index_) + L"|" +  format_desc_.name + L"]";\r
88         }\r
89 };\r
90 \r
91 video_channel::video_channel(int index, const video_format_desc& format_desc, const safe_ptr<ogl_device>& ogl) : impl_(new implementation(index, format_desc, ogl)){}\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 void video_channel::set_video_format_desc(const video_format_desc& format_desc){impl_->set_video_format_desc(format_desc);}\r
97 \r
98 }}