]> git.sesse.net Git - casparcg/blobdiff - modules/bluefish/util/blue_velvet.cpp
3569308: added 720p30 and 720p29.976 as supported output resolutions (not supported...
[casparcg] / modules / bluefish / util / blue_velvet.cpp
index fbef2ef7a7f1d59e832a8e24ed71da12941af273..1195822494359a0798b01f95dba3421bb14c0ffd 100644 (file)
@@ -1,3 +1,24 @@
+/*\r
+* Copyright (c) 2011 Sveriges Television AB <info@casparcg.com>\r
+*\r
+* This file is part of CasparCG (www.casparcg.com).\r
+*\r
+* CasparCG is free software: you can redistribute it and/or modify\r
+* it under the terms of the GNU General Public License as published by\r
+* the Free Software Foundation, either version 3 of the License, or\r
+* (at your option) any later version.\r
+*\r
+* CasparCG is distributed in the hope that it will be useful,\r
+* but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+* GNU General Public License for more details.\r
+*\r
+* You should have received a copy of the GNU General Public License\r
+* along with CasparCG. If not, see <http://www.gnu.org/licenses/>.\r
+*\r
+* Author: Robert Nagy, ronag89@gmail.com\r
+*/\r
+\r
 #include "../StdAfx.h"\r
 \r
 #include "blue_velvet.h"\r
@@ -6,7 +27,7 @@
 \r
 #include <core/video_format.h>\r
 \r
-namespace caspar {\r
+namespace caspar { namespace bluefish {\r
        \r
 CBlueVelvet4* (*BlueVelvetFactory4)() = nullptr;\r
 void (*BlueVelvetDestroy)(CBlueVelvet4* pObj) = nullptr;\r
@@ -17,10 +38,16 @@ BLUE_UINT32 (*encode_hanc_frame_ex)(BLUE_UINT32 card_type, struct hanc_stream_in
 void blue_velvet_initialize()\r
 {\r
 #ifdef _DEBUG\r
-       auto module = LoadLibrary(L"BlueVelvet3_d.dll");\r
+       std::string module_str = "BlueVelvet3_d.dll";\r
 #else\r
-       auto module = LoadLibrary(L"BlueVelvet3.dll");\r
+       std::string module_str = "BlueVelvet3.dll";\r
 #endif\r
+\r
+       auto module = LoadLibrary(widen(module_str).c_str());\r
+       if(!module)\r
+               LoadLibrary(widen(std::string(getenv("SystemDrive")) + "\\Program Files\\Bluefish444\\Driver\\" + module_str).c_str());\r
+       if(!module)\r
+               LoadLibrary(widen(std::string(getenv("SystemDrive")) + "\\Program Files (x86)\\BlueFish444\\Driver\\" + module_str).c_str());\r
        if(!module)\r
                BOOST_THROW_EXCEPTION(file_not_found() << msg_info("Could not find BlueVelvet3.dll. Required drivers are not installed."));\r
        static std::shared_ptr<void> lib(module, FreeLibrary);\r
@@ -32,10 +59,16 @@ void blue_velvet_initialize()
 void blue_hanc_initialize()\r
 {\r
 #ifdef _DEBUG\r
-       auto module = LoadLibrary(L"BlueHancUtils_d.dll");\r
+       std::string module_str = "BlueHancUtils_d.dll";\r
 #else\r
-       auto module = LoadLibrary(L"BlueHancUtils.dll");\r
+       std::string module_str = "BlueHancUtils.dll";\r
 #endif\r
+       \r
+       auto module = LoadLibrary(widen(module_str).c_str());\r
+       if(!module)\r
+               LoadLibrary(widen(std::string(getenv("SystemDrive")) + "\\Program Files\\Bluefish444\\Driver\\" + module_str).c_str());\r
+       if(!module)\r
+               LoadLibrary(widen(std::string(getenv("SystemDrive")) + "\\Program Files (x86)\\BlueFish444\\Driver\\" + module_str).c_str());\r
        if(!module)\r
                BOOST_THROW_EXCEPTION(file_not_found() << msg_info("Could not find BlueHancUtils.dll. Required drivers are not installed."));\r
        static std::shared_ptr<void> lib(module, FreeLibrary);\r
@@ -45,8 +78,8 @@ void blue_hanc_initialize()
 \r
 void blue_initialize()\r
 {\r
-       blue_velvet_initialize();\r
        blue_hanc_initialize();\r
+       blue_velvet_initialize();\r
 }\r
 \r
 EVideoMode vid_fmt_from_video_format(const core::video_format::type& fmt) \r
@@ -58,9 +91,11 @@ EVideoMode vid_fmt_from_video_format(const core::video_format::type& fmt)
        case core::video_format::x576p2500:             return VID_FMT_INVALID; //not supported\r
        case core::video_format::x720p2500:             return VID_FMT_720P_2500;\r
        case core::video_format::x720p5000:             return VID_FMT_720P_5000;\r
+       case core::video_format::x720p2997:             return VID_FMT_720P_2997;\r
        case core::video_format::x720p5994:             return VID_FMT_720P_5994;\r
+       case core::video_format::x720p3000:             return VID_FMT_720P_3000;\r
        case core::video_format::x720p6000:             return VID_FMT_720P_6000;\r
-       case core::video_format::x1080p2397:    return VID_FMT_1080P_2397;\r
+       case core::video_format::x1080p2398:    return VID_FMT_1080P_2397;\r
        case core::video_format::x1080p2400:    return VID_FMT_1080P_2400;\r
        case core::video_format::x1080i5000:    return VID_FMT_1080I_5000;\r
        case core::video_format::x1080i5994:    return VID_FMT_1080I_5994;\r
@@ -68,6 +103,7 @@ EVideoMode vid_fmt_from_video_format(const core::video_format::type& fmt)
        case core::video_format::x1080p2500:    return VID_FMT_1080P_2500;\r
        case core::video_format::x1080p2997:    return VID_FMT_1080P_2997;\r
        case core::video_format::x1080p3000:    return VID_FMT_1080P_3000;\r
+       case core::video_format::x1080p5000:    return VID_FMT_1080P_5000;\r
        default:                                                                return VID_FMT_INVALID;\r
        }\r
 }\r
@@ -76,12 +112,16 @@ bool is_epoch_card(CBlueVelvet4& blue)
 {\r
        switch(blue.has_video_cardtype())\r
        {\r
-       case CRD_BLUE_EPOCH_2K:\r
        case CRD_BLUE_EPOCH_HORIZON:\r
-       case CRD_BLUE_EPOCH_2K_CORE:\r
-       case CRD_BLUE_EPOCH_2K_ULTRA:\r
        case CRD_BLUE_EPOCH_CORE:\r
        case CRD_BLUE_EPOCH_ULTRA:\r
+       case CRD_BLUE_EPOCH_2K_HORIZON:\r
+       case CRD_BLUE_EPOCH_2K_CORE:\r
+       case CRD_BLUE_EPOCH_2K_ULTRA:\r
+       case CRD_BLUE_CREATE_HD:\r
+       case CRD_BLUE_CREATE_2K:\r
+       case CRD_BLUE_CREATE_2K_ULTRA:\r
+       case CRD_BLUE_SUPER_NOVA:\r
                return true;\r
        default:\r
                return false;\r
@@ -141,7 +181,7 @@ EVideoMode get_video_mode(CBlueVelvet4& blue, const core::video_format_desc& for
                        vid_fmt = videoMode;                    \r
        }\r
        if(vid_fmt == VID_FMT_INVALID)\r
-               BOOST_THROW_EXCEPTION(bluefish_exception() << msg_info("Failed get videomode.") << arg_value_info(narrow(format_desc.name)));\r
+               BOOST_THROW_EXCEPTION(caspar_exception() << msg_info("video-mode not supported.") << arg_value_info(narrow(format_desc.name)));\r
 \r
        return vid_fmt;\r
 }\r
@@ -154,4 +194,14 @@ safe_ptr<CBlueVelvet4> create_blue()
        return safe_ptr<CBlueVelvet4>(BlueVelvetFactory4(), BlueVelvetDestroy);\r
 }\r
 \r
-}
\ No newline at end of file
+safe_ptr<CBlueVelvet4> create_blue(size_t device_index)\r
+{\r
+       auto blue = create_blue();\r
+       \r
+       if(BLUE_FAIL(blue->device_attach(device_index, FALSE))) \r
+               BOOST_THROW_EXCEPTION(caspar_exception() << msg_info("Failed to attach device."));\r
+\r
+       return blue;\r
+}\r
+\r
+}}
\ No newline at end of file