]> git.sesse.net Git - casparcg/blob - core/consumer/bluefish/BlueFishVideoConsumer.h
2.0.0.2:
[casparcg] / core / consumer / bluefish / BlueFishVideoConsumer.h
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 #pragma once\r
21 \r
22 #include "../../../common/concurrency/thread.h"\r
23 #include "BluefishException.h"\r
24 #include "BluefishFrameManager.h"\r
25 #include "../../consumer/frame_consumer.h"\r
26 #include "../../renderer/render_device.h"\r
27 #include <tbb/concurrent_queue.h>\r
28 #include <boost/thread.hpp>\r
29 \r
30 #define TIMEOUT                 1000\r
31 \r
32 class CBlueVelvet4;\r
33 \r
34 namespace caspar {\r
35         \r
36 namespace bluefish {\r
37 \r
38 typedef std::tr1::shared_ptr<CBlueVelvet4> BlueVelvetPtr;\r
39 \r
40 class BlueFishVideoConsumer : public frame_consumer\r
41 {\r
42         friend class BluefishPlaybackStrategy;\r
43 \r
44         BlueFishVideoConsumer(const frame_format_desc& format_desc);\r
45         BlueFishVideoConsumer(const BlueFishVideoConsumer&);\r
46         const BlueFishVideoConsumer& operator=(const BlueFishVideoConsumer&);\r
47 \r
48 public:\r
49         virtual ~BlueFishVideoConsumer();\r
50 \r
51         static int EnumerateDevices();\r
52         static frame_consumer_ptr Create(const frame_format_desc& format_desc, unsigned int deviceIndex);\r
53         \r
54         void display(const gpu_frame_ptr&);\r
55                 \r
56         const frame_format_desc& get_frame_format_desc() const { return format_desc_; }\r
57 \r
58 private:\r
59 \r
60         void Run();\r
61 \r
62         void EnableVideoOutput();\r
63         void DisableVideoOutput();\r
64         bool SetupDevice(unsigned int deviceIndex);\r
65         bool ReleaseDevice();\r
66 \r
67         bool DoSetupDevice(unsigned int deviceIndex);\r
68 \r
69         BlueVelvetPtr pSDK_;\r
70         std::shared_ptr<BluefishPlaybackStrategy> pPlayback_;\r
71         BluefishFrameManagerPtr pFrameManager_;\r
72         unsigned long m_bufferCount;\r
73         unsigned long m_length;\r
74         unsigned long m_actual;\r
75         unsigned long m_golden;\r
76 \r
77         unsigned long VidFmtFromFrameFormat(frame_format fmt);\r
78 \r
79         frame_format currentFormat_;\r
80         unsigned int _deviceIndex;\r
81         bool hasEmbeddedAudio_;\r
82         frame_format_desc format_desc_;\r
83         \r
84         std::exception_ptr pException_;\r
85         boost::thread thread_;\r
86         tbb::concurrent_bounded_queue<gpu_frame_ptr> frameBuffer_;\r
87 };\r
88 typedef std::tr1::shared_ptr<BlueFishVideoConsumer> BlueFishFrameConsumerPtr;\r
89 \r
90 }}\r