]> git.sesse.net Git - casparcg/blob - modules/screen/consumer/screen_consumer.cpp
2.1.0: -screen_consumer: Set key-only version on separate index.
[casparcg] / modules / screen / consumer / screen_consumer.cpp
1 /*\r
2 * Copyright (c) 2011 Sveriges Television AB <info@casparcg.com>\r
3 *\r
4 * This file is part of CasparCG (www.casparcg.com).\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 * Author: Robert Nagy, ronag89@gmail.com\r
20 */\r
21 \r
22 #include "screen_consumer.h"\r
23 \r
24 #include <GL/glew.h>\r
25 #include <SFML/Window.hpp>\r
26 \r
27 #include <common/diagnostics/graph.h>\r
28 #include <common/gl/gl_check.h>\r
29 #include <common/log.h>\r
30 #include <common/memory.h>\r
31 #include <common/array.h>\r
32 #include <common/memshfl.h>\r
33 #include <common/utf.h>\r
34 \r
35 #include <ffmpeg/producer/filter/filter.h>\r
36 \r
37 #include <core/video_format.h>\r
38 #include <core/frame/frame.h>\r
39 #include <core/consumer/frame_consumer.h>\r
40 \r
41 #include <boost/timer.hpp>\r
42 #include <boost/circular_buffer.hpp>\r
43 #include <boost/lexical_cast.hpp>\r
44 #include <boost/foreach.hpp>\r
45 #include <boost/property_tree/ptree.hpp>\r
46 #include <boost/thread.hpp>\r
47 \r
48 #include <tbb/atomic.h>\r
49 #include <tbb/concurrent_queue.h>\r
50 #include <tbb/parallel_for.h>\r
51 \r
52 #include <boost/assign.hpp>\r
53 \r
54 #include <asmlib.h>\r
55 \r
56 #include <algorithm>\r
57 #include <vector>\r
58 \r
59 #if defined(_MSC_VER)\r
60 #pragma warning (push)\r
61 #pragma warning (disable : 4244)\r
62 #endif\r
63 extern "C" \r
64 {\r
65         #define __STDC_CONSTANT_MACROS\r
66         #define __STDC_LIMIT_MACROS\r
67         #include <libavcodec/avcodec.h>\r
68         #include <libavutil/imgutils.h>\r
69 }\r
70 #if defined(_MSC_VER)\r
71 #pragma warning (pop)\r
72 #endif\r
73 \r
74 namespace caspar { namespace screen {\r
75                 \r
76 enum stretch\r
77 {\r
78         none,\r
79         uniform,\r
80         fill,\r
81         uniform_to_fill\r
82 };\r
83 \r
84 struct configuration\r
85 {\r
86         enum aspect_ratio\r
87         {\r
88                 aspect_4_3 = 0,\r
89                 aspect_16_9,\r
90                 aspect_invalid,\r
91         };\r
92                 \r
93         std::wstring    name;\r
94         int                             screen_index;\r
95         stretch                 stretch;\r
96         bool                    windowed;\r
97         bool                    auto_deinterlace;\r
98         bool                    key_only;\r
99         aspect_ratio    aspect; \r
100         bool                    vsync;\r
101 \r
102         configuration()\r
103                 : name(L"ogl")\r
104                 , screen_index(0)\r
105                 , stretch(fill)\r
106                 , windowed(true)\r
107                 , auto_deinterlace(true)\r
108                 , key_only(false)\r
109                 , aspect(aspect_invalid)\r
110                 , vsync(true)\r
111         {\r
112         }\r
113 };\r
114 \r
115 struct screen_consumer : boost::noncopyable\r
116 {               \r
117         const configuration                                     config_;\r
118         core::video_format_desc                         format_desc_;\r
119         int                                                                     channel_index_;\r
120 \r
121         GLuint                                                          texture_;\r
122         std::vector<GLuint>                                     pbos_;\r
123                         \r
124         float                                                           width_;\r
125         float                                                           height_;        \r
126         int                                                                     screen_x_;\r
127         int                                                                     screen_y_;\r
128         int                                                                     screen_width_;\r
129         int                                                                     screen_height_;\r
130         int                                                                     square_width_;\r
131         int                                                                     square_height_;                         \r
132         \r
133         sf::Window                                                      window_;\r
134         \r
135         spl::shared_ptr<diagnostics::graph>     graph_;\r
136         boost::timer                                            perf_timer_;\r
137         boost::timer                                            tick_timer_;\r
138 \r
139         tbb::concurrent_bounded_queue<core::const_frame>        frame_buffer_;\r
140 \r
141         boost::thread                                           thread_;\r
142         tbb::atomic<bool>                                       is_running_;\r
143         \r
144         ffmpeg::filter                                          filter_;\r
145 public:\r
146         screen_consumer(const configuration& config, const core::video_format_desc& format_desc, int channel_index) \r
147                 : config_(config)\r
148                 , format_desc_(format_desc)\r
149                 , channel_index_(channel_index)\r
150                 , texture_(0)\r
151                 , pbos_(2, 0)   \r
152                 , screen_width_(format_desc.width)\r
153                 , screen_height_(format_desc.height)\r
154                 , square_width_(format_desc.square_width)\r
155                 , square_height_(format_desc.square_height)\r
156                 , filter_(format_desc.field_mode == core::field_mode::progressive || !config.auto_deinterlace ? L"" : L"YADIF=0:-1", boost::assign::list_of(PIX_FMT_BGRA))\r
157         {               \r
158                 if(format_desc_.format == core::video_format::ntsc && config_.aspect == configuration::aspect_4_3)\r
159                 {\r
160                         // Use default values which are 4:3.\r
161                 }\r
162                 else\r
163                 {\r
164                         if(config_.aspect == configuration::aspect_16_9)\r
165                                 square_width_ = (format_desc.height*16)/9;\r
166                         else if(config_.aspect == configuration::aspect_4_3)\r
167                                 square_width_ = (format_desc.height*4)/3;\r
168                 }\r
169 \r
170                 frame_buffer_.set_capacity(2);\r
171                 \r
172                 graph_->set_color("tick-time", diagnostics::color(0.0f, 0.6f, 0.9f));   \r
173                 graph_->set_color("frame-time", diagnostics::color(0.1f, 1.0f, 0.1f));\r
174                 graph_->set_color("dropped-frame", diagnostics::color(0.3f, 0.6f, 0.3f));\r
175                 graph_->set_text(print());\r
176                 diagnostics::register_graph(graph_);\r
177                                                                         \r
178                 DISPLAY_DEVICE d_device = {sizeof(d_device), 0};                        \r
179                 std::vector<DISPLAY_DEVICE> displayDevices;\r
180                 for(int n = 0; EnumDisplayDevices(NULL, n, &d_device, NULL); ++n)\r
181                         displayDevices.push_back(d_device);\r
182 \r
183                 if(config_.screen_index >= displayDevices.size())\r
184                         CASPAR_LOG(warning) << print() << L" Invalid screen-index: " << config_.screen_index;\r
185                 \r
186                 DEVMODE devmode = {};\r
187                 if(!EnumDisplaySettings(displayDevices[config_.screen_index].DeviceName, ENUM_CURRENT_SETTINGS, &devmode))\r
188                         CASPAR_LOG(warning) << print() << L" Could not find display settings for screen-index: " << config_.screen_index;\r
189                 \r
190                 screen_x_               = devmode.dmPosition.x;\r
191                 screen_y_               = devmode.dmPosition.y;\r
192                 screen_width_   = config_.windowed ? square_width_ : devmode.dmPelsWidth;\r
193                 screen_height_  = config_.windowed ? square_height_ : devmode.dmPelsHeight;\r
194                 \r
195                 is_running_ = true;\r
196                 thread_ = boost::thread([this]{run();});\r
197         }\r
198         \r
199         ~screen_consumer()\r
200         {\r
201                 is_running_ = false;\r
202                 frame_buffer_.try_push(core::const_frame::empty());\r
203                 thread_.join();\r
204         }\r
205 \r
206         void init()\r
207         {\r
208                 window_.Create(sf::VideoMode(screen_width_, screen_height_, 32), u8(print()), config_.windowed ? sf::Style::Resize | sf::Style::Close : sf::Style::Fullscreen);\r
209                 window_.ShowMouseCursor(false);\r
210                 window_.SetPosition(screen_x_, screen_y_);\r
211                 window_.SetSize(screen_width_, screen_height_);\r
212                 window_.SetActive();\r
213                 \r
214                 if(!GLEW_VERSION_2_1 && glewInit() != GLEW_OK)\r
215                         BOOST_THROW_EXCEPTION(gl::ogl_exception() << msg_info("Failed to initialize GLEW."));\r
216 \r
217                 if(!GLEW_VERSION_2_1)\r
218                         BOOST_THROW_EXCEPTION(not_supported() << msg_info("Missing OpenGL 2.1 support."));\r
219 \r
220                 GL(glEnable(GL_TEXTURE_2D));\r
221                 GL(glDisable(GL_DEPTH_TEST));           \r
222                 GL(glClearColor(0.0, 0.0, 0.0, 0.0));\r
223                 GL(glViewport(0, 0, format_desc_.width, format_desc_.height));\r
224                 GL(glLoadIdentity());\r
225                                 \r
226                 calculate_aspect();\r
227                         \r
228                 GL(glGenTextures(1, &texture_));\r
229                 GL(glBindTexture(GL_TEXTURE_2D, texture_));\r
230                 GL(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR));\r
231                 GL(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR));\r
232                 GL(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP));\r
233                 GL(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP));\r
234                 GL(glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, format_desc_.width, format_desc_.height, 0, GL_BGRA, GL_UNSIGNED_BYTE, 0));\r
235                 GL(glBindTexture(GL_TEXTURE_2D, 0));\r
236                                         \r
237                 GL(glGenBuffers(2, pbos_.data()));\r
238                         \r
239                 glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, pbos_[0]);\r
240                 glBufferDataARB(GL_PIXEL_UNPACK_BUFFER_ARB, format_desc_.size, 0, GL_STREAM_DRAW_ARB);\r
241                 glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, pbos_[1]);\r
242                 glBufferDataARB(GL_PIXEL_UNPACK_BUFFER_ARB, format_desc_.size, 0, GL_STREAM_DRAW_ARB);\r
243                 glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, 0);\r
244                 \r
245                 auto wglSwapIntervalEXT = reinterpret_cast<void(APIENTRY*)(int)>(wglGetProcAddress("wglSwapIntervalEXT"));\r
246                 if(wglSwapIntervalEXT)\r
247                 {\r
248                         if(config_.vsync)\r
249                         {\r
250                                 wglSwapIntervalEXT(1);\r
251                                 CASPAR_LOG(info) << print() << " Enabled vsync.";\r
252                         }\r
253                         else\r
254                                 wglSwapIntervalEXT(0);\r
255                 }\r
256 \r
257                 CASPAR_LOG(info) << print() << " Successfully Initialized.";\r
258         }\r
259 \r
260         void uninit()\r
261         {               \r
262                 if(texture_)\r
263                         glDeleteTextures(1, &texture_);\r
264 \r
265                 BOOST_FOREACH(auto& pbo, pbos_)\r
266                 {\r
267                         if(pbo)\r
268                                 glDeleteBuffers(1, &pbo);\r
269                 }\r
270         }\r
271 \r
272         void run()\r
273         {\r
274                 try\r
275                 {\r
276                         init();\r
277 \r
278                         while(is_running_)\r
279                         {                       \r
280                                 try\r
281                                 {\r
282                                         sf::Event e;            \r
283                                         while(window_.GetEvent(e))\r
284                                         {\r
285                                                 if(e.Type == sf::Event::Resized)\r
286                                                         calculate_aspect();\r
287                                                 else if(e.Type == sf::Event::Closed)\r
288                                                         is_running_ = false;\r
289                                         }\r
290                         \r
291                                         auto frame = core::const_frame::empty();\r
292                                         frame_buffer_.pop(frame);\r
293                                         \r
294                                         perf_timer_.restart();\r
295                                         render(frame);\r
296                                         graph_->set_value("frame-time", perf_timer_.elapsed()*format_desc_.fps*0.5);    \r
297 \r
298                                         window_.Display();\r
299                                         \r
300                                         graph_->set_value("tick-time", tick_timer_.elapsed()*format_desc_.fps*0.5);     \r
301                                         tick_timer_.restart();\r
302                                 }\r
303                                 catch(...)\r
304                                 {\r
305                                         CASPAR_LOG_CURRENT_EXCEPTION();\r
306                                         is_running_ = false;\r
307                                 }\r
308                         }\r
309 \r
310                         uninit();\r
311                 }\r
312                 catch(...)\r
313                 {\r
314                         CASPAR_LOG_CURRENT_EXCEPTION();\r
315                 }\r
316         }\r
317         \r
318         spl::shared_ptr<AVFrame> get_av_frame()\r
319         {               \r
320                 spl::shared_ptr<AVFrame> av_frame(avcodec_alloc_frame(), av_free);      \r
321                 avcodec_get_frame_defaults(av_frame.get());\r
322                                                 \r
323                 av_frame->linesize[0]           = format_desc_.width*4;                 \r
324                 av_frame->format                        = PIX_FMT_BGRA;\r
325                 av_frame->width                         = format_desc_.width;\r
326                 av_frame->height                        = format_desc_.height;\r
327                 av_frame->interlaced_frame      = format_desc_.field_mode != core::field_mode::progressive;\r
328                 av_frame->top_field_first       = format_desc_.field_mode == core::field_mode::upper ? 1 : 0;\r
329 \r
330                 return av_frame;\r
331         }\r
332 \r
333         void render(core::const_frame frame)\r
334         {                       \r
335                 if(static_cast<int>(frame.image_data().size()) != format_desc_.size)\r
336                         return;\r
337                                         \r
338                 auto av_frame = get_av_frame();\r
339                 av_frame->data[0] = const_cast<uint8_t*>(frame.image_data().begin());\r
340 \r
341                 filter_.push(av_frame);\r
342                 auto frames = filter_.poll_all();\r
343 \r
344                 if(frames.empty())\r
345                         return;\r
346 \r
347                 av_frame = frames[0];\r
348                 \r
349                 GL(glBindTexture(GL_TEXTURE_2D, texture_));\r
350 \r
351                 GL(glBindBuffer(GL_PIXEL_UNPACK_BUFFER, pbos_[0]));\r
352                 GL(glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, format_desc_.width, format_desc_.height, GL_BGRA, GL_UNSIGNED_BYTE, 0));\r
353 \r
354                 GL(glBindBuffer(GL_PIXEL_UNPACK_BUFFER, pbos_[1]));\r
355                 GL(glBufferData(GL_PIXEL_UNPACK_BUFFER, format_desc_.size, 0, GL_STREAM_DRAW));\r
356 \r
357                 auto ptr = reinterpret_cast<char*>(GL2(glMapBuffer(GL_PIXEL_UNPACK_BUFFER, GL_WRITE_ONLY)));\r
358                 if(ptr)\r
359                 {\r
360                         if(config_.key_only)\r
361                         {\r
362                                 tbb::parallel_for(tbb::blocked_range<int>(0, format_desc_.height), [&](const tbb::blocked_range<int>& r)\r
363                                 {\r
364                                         for(int n = r.begin(); n != r.end(); ++n)\r
365                                                 aligned_memshfl(ptr+n*format_desc_.width*4, av_frame->data[0]+n*av_frame->linesize[0], format_desc_.width*4, 0x0F0F0F0F, 0x0B0B0B0B, 0x07070707, 0x03030303);\r
366                                 });\r
367                         }\r
368                         else\r
369                         {       \r
370                                 tbb::parallel_for(tbb::blocked_range<int>(0, format_desc_.height), [&](const tbb::blocked_range<int>& r)\r
371                                 {\r
372                                         for(int n = r.begin(); n != r.end(); ++n)\r
373                                                 A_memcpy(ptr+n*format_desc_.width*4, av_frame->data[0]+n*av_frame->linesize[0], format_desc_.width*4);\r
374                                 });\r
375                         }\r
376                         \r
377                         GL(glUnmapBuffer(GL_PIXEL_UNPACK_BUFFER)); // release the mapped buffer\r
378                 }\r
379 \r
380                 GL(glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0));\r
381                                 \r
382                 GL(glClear(GL_COLOR_BUFFER_BIT));                       \r
383                 glBegin(GL_QUADS);\r
384                                 glTexCoord2f(0.0f,        1.0f);        glVertex2f(-width_, -height_);\r
385                                 glTexCoord2f(1.0f,        1.0f);        glVertex2f( width_, -height_);\r
386                                 glTexCoord2f(1.0f,        0.0f);        glVertex2f( width_,  height_);\r
387                                 glTexCoord2f(0.0f,        0.0f);        glVertex2f(-width_,  height_);\r
388                 glEnd();\r
389                 \r
390                 GL(glBindTexture(GL_TEXTURE_2D, 0));\r
391 \r
392                 std::rotate(pbos_.begin(), pbos_.begin() + 1, pbos_.end());\r
393         }\r
394 \r
395         bool send(core::const_frame frame)\r
396         {\r
397                 if(!frame_buffer_.try_push(frame))\r
398                         graph_->set_tag("dropped-frame");\r
399                 return is_running_;\r
400         }\r
401                 \r
402         std::wstring print() const\r
403         {       \r
404                 return config_.name + L"[" + boost::lexical_cast<std::wstring>(channel_index_) + L"|" + format_desc_.name + L"]";\r
405         }\r
406         \r
407         void calculate_aspect()\r
408         {\r
409                 if(config_.windowed)\r
410                 {\r
411                         screen_height_ = window_.GetHeight();\r
412                         screen_width_ = window_.GetWidth();\r
413                 }\r
414                 \r
415                 GL(glViewport(0, 0, screen_width_, screen_height_));\r
416 \r
417                 std::pair<float, float> target_ratio = None();\r
418                 if(config_.stretch == fill)\r
419                         target_ratio = Fill();\r
420                 else if(config_.stretch == uniform)\r
421                         target_ratio = Uniform();\r
422                 else if(config_.stretch == uniform_to_fill)\r
423                         target_ratio = UniformToFill();\r
424 \r
425                 width_ = target_ratio.first;\r
426                 height_ = target_ratio.second;\r
427         }\r
428                 \r
429         std::pair<float, float> None()\r
430         {\r
431                 float width = static_cast<float>(square_width_)/static_cast<float>(screen_width_);\r
432                 float height = static_cast<float>(square_height_)/static_cast<float>(screen_height_);\r
433 \r
434                 return std::make_pair(width, height);\r
435         }\r
436 \r
437         std::pair<float, float> Uniform()\r
438         {\r
439                 float aspect = static_cast<float>(square_width_)/static_cast<float>(square_height_);\r
440                 float width = std::min(1.0f, static_cast<float>(screen_height_)*aspect/static_cast<float>(screen_width_));\r
441                 float height = static_cast<float>(screen_width_*width)/static_cast<float>(screen_height_*aspect);\r
442 \r
443                 return std::make_pair(width, height);\r
444         }\r
445 \r
446         std::pair<float, float> Fill()\r
447         {\r
448                 return std::make_pair(1.0f, 1.0f);\r
449         }\r
450 \r
451         std::pair<float, float> UniformToFill()\r
452         {\r
453                 float wr = static_cast<float>(square_width_)/static_cast<float>(screen_width_);\r
454                 float hr = static_cast<float>(square_height_)/static_cast<float>(screen_height_);\r
455                 float r_inv = 1.0f/std::min(wr, hr);\r
456 \r
457                 float width = wr*r_inv;\r
458                 float height = hr*r_inv;\r
459 \r
460                 return std::make_pair(width, height);\r
461         }\r
462 };\r
463 \r
464 \r
465 struct screen_consumer_proxy : public core::frame_consumer\r
466 {\r
467         const configuration config_;\r
468         std::unique_ptr<screen_consumer> consumer_;\r
469 \r
470 public:\r
471 \r
472         screen_consumer_proxy(const configuration& config)\r
473                 : config_(config){}\r
474         \r
475         // frame_consumer\r
476 \r
477         void initialize(const core::video_format_desc& format_desc, int channel_index) override\r
478         {\r
479                 consumer_.reset();\r
480                 consumer_.reset(new screen_consumer(config_, format_desc, channel_index));\r
481         }\r
482         \r
483         bool send(core::const_frame frame) override\r
484         {\r
485                 return consumer_->send(frame);\r
486         }\r
487         \r
488         std::wstring print() const override\r
489         {\r
490                 return consumer_ ? consumer_->print() : L"[screen_consumer]";\r
491         }\r
492 \r
493         std::wstring name() const override\r
494         {\r
495                 return L"screen";\r
496         }\r
497 \r
498         boost::property_tree::wptree info() const override\r
499         {\r
500                 boost::property_tree::wptree info;\r
501                 info.add(L"type", L"screen");\r
502                 info.add(L"key-only", config_.key_only);\r
503                 info.add(L"windowed", config_.windowed);\r
504                 info.add(L"auto-deinterlace", config_.auto_deinterlace);\r
505                 return info;\r
506         }\r
507 \r
508         bool has_synchronization_clock() const override\r
509         {\r
510                 return false;\r
511         }\r
512         \r
513         int buffer_depth() const override\r
514         {\r
515                 return 2;\r
516         }\r
517 \r
518         int index() const override\r
519         {\r
520                 return 600 + (config_.key_only ? 1 : 0);\r
521         }\r
522 };      \r
523 \r
524 spl::shared_ptr<core::frame_consumer> create_consumer(const std::vector<std::wstring>& params)\r
525 {\r
526         if(params.size() < 1 || params[0] != L"SCREEN")\r
527                 return core::frame_consumer::empty();\r
528         \r
529         configuration config;\r
530                 \r
531         auto device_it = std::find(params.begin(), params.end(), L"DEVICE");\r
532         if(device_it != params.end() && ++device_it != params.end())\r
533                 config.screen_index = boost::lexical_cast<int>(*device_it);\r
534                 \r
535         config.key_only = std::find(params.begin(), params.end(), L"WINDOWED") != params.end();\r
536         config.key_only = std::find(params.begin(), params.end(), L"KEY_ONLY") != params.end();\r
537 \r
538         auto name_it    = std::find(params.begin(), params.end(), L"NAME");\r
539         if(name_it != params.end() && ++name_it != params.end())\r
540                 config.name = *name_it;\r
541 \r
542         return spl::make_shared<screen_consumer_proxy>(config);\r
543 }\r
544 \r
545 spl::shared_ptr<core::frame_consumer> create_consumer(const boost::property_tree::wptree& ptree) \r
546 {\r
547         configuration config;\r
548         config.name                             = ptree.get(L"name",     config.name);\r
549         config.screen_index             = ptree.get(L"device",   config.screen_index+1)-1;\r
550         config.windowed                 = ptree.get(L"windowed", config.windowed);\r
551         config.key_only                 = ptree.get(L"key-only", config.key_only);\r
552         config.auto_deinterlace = ptree.get(L"auto-deinterlace", config.auto_deinterlace);\r
553         config.vsync                    = ptree.get(L"vsync", config.vsync);\r
554         \r
555         auto stretch_str = ptree.get(L"stretch", L"default");\r
556         if(stretch_str == L"uniform")\r
557                 config.stretch = stretch::uniform;\r
558         else if(stretch_str == L"uniform_to_fill")\r
559                 config.stretch = stretch::uniform_to_fill;\r
560 \r
561         auto aspect_str = ptree.get(L"aspect-ratio", L"default");\r
562         if(aspect_str == L"16:9")\r
563                 config.aspect = configuration::aspect_16_9;\r
564         else if(aspect_str == L"4:3")\r
565                 config.aspect = configuration::aspect_4_3;\r
566         \r
567         return spl::make_shared<screen_consumer_proxy>(config);\r
568 }\r
569 \r
570 }}