1 /* Webcamoid, webcam capture application. 2 * Copyright (C) 2018 Gonzalo Exequiel Pedone 3 * 4 * Webcamoid is free software: you can redistribute it and/or modify 5 * it under the terms of the GNU General Public License as published by 6 * the Free Software Foundation, either version 3 of the License, or 7 * (at your option) any later version. 8 * 9 * Webcamoid is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details. 13 * 14 * You should have received a copy of the GNU General Public License 15 * along with Webcamoid. If not, see <http://www.gnu.org/licenses/>. 16 * 17 * Web-Site: http://webcamoid.github.io/ 18 */ 19 20 #ifndef PLATFORM_UTILS_H 21 #define PLATFORM_UTILS_H 22 23 #include <string> 24 #include <strmif.h> 25 26 #include "VCamUtils/src/image/videoformattypes.h" 27 #include "VCamUtils/src/logger/logger.h" 28 29 #define AkLogInterface(interface, instance) \ 30 AkLoggerLog("Returning ", #interface, "(", instance, ")") 31 32 #define AkLogMethod() \ 33 AkLoggerLog(AK_CUR_INTERFACE, "(", this, ")::", __FUNCTION__, "()") 34 35 namespace AkVCam 36 { 37 class VideoFormat; 38 39 BOOL isWow64(); 40 std::wstring tempPath(); 41 std::wstring programFilesPath(); 42 std::wstring moduleFileNameW(HINSTANCE hinstDLL); 43 std::string moduleFileName(HINSTANCE hinstDLL); 44 std::wstring errorToStringW(DWORD errorCode); 45 std::string errorToString(DWORD errorCode); 46 CLSID createClsidFromStr(const std::string &str); 47 CLSID createClsidFromStr(const std::wstring &str); 48 std::wstring createClsidWStrFromStr(const std::string &str); 49 std::wstring createClsidWStrFromStr(const std::wstring &str); 50 std::string stringFromIid(const IID &iid); 51 std::wstring wstringFromIid(const IID &iid); 52 std::string stringFromResult(HRESULT result); 53 std::string stringFromClsid(const CLSID &clsid); 54 wchar_t *wcharStrFromWStr(const std::wstring &wstr); 55 FourCC formatFromGuid(const GUID &guid); 56 const GUID &guidFromFormat(FourCC format); 57 DWORD compressionFromFormat(FourCC format); 58 bool isSubTypeSupported(const GUID &subType); 59 AM_MEDIA_TYPE *mediaTypeFromFormat(const VideoFormat &format); 60 VideoFormat formatFromMediaType(const AM_MEDIA_TYPE *mediaType); 61 bool isEqualMediaType(const AM_MEDIA_TYPE *mediaType1, 62 const AM_MEDIA_TYPE *mediaType2, 63 bool exact=false); 64 bool copyMediaType(AM_MEDIA_TYPE *dstMediaType, 65 const AM_MEDIA_TYPE *srcMediaType); 66 AM_MEDIA_TYPE *createMediaType(const AM_MEDIA_TYPE *mediaType); 67 void deleteMediaType(AM_MEDIA_TYPE **mediaType); 68 bool containsMediaType(const AM_MEDIA_TYPE *mediaType, 69 IEnumMediaTypes *mediaTypes); 70 std::string stringFromMajorType(const GUID &majorType); 71 std::string stringFromSubType(const GUID &subType); 72 std::string stringFromFormatType(const GUID &formatType); 73 std::string stringFromMediaType(const AM_MEDIA_TYPE *mediaType); 74 std::string stringFromMediaSample(IMediaSample *mediaSample); 75 LONG regGetValue(HKEY hkey, 76 LPCWSTR lpSubKey, 77 LPCWSTR lpValue, 78 DWORD dwFlags, 79 LPDWORD pdwType, 80 PVOID pvData, 81 LPDWORD pcbData); 82 std::vector<CLSID> listRegisteredCameras(HINSTANCE hinstDLL); 83 DWORD camerasCount(); 84 std::wstring createDevicePath(); 85 int cameraFromId(const std::wstring &path); 86 int cameraFromId(const CLSID &clsid); 87 bool cameraExists(const std::string &path); 88 bool cameraExists(const std::wstring &path); 89 std::wstring cameraDescription(DWORD cameraIndex); 90 std::wstring cameraPath(DWORD cameraIndex); 91 std::wstring cameraPath(const CLSID &clsid); 92 DWORD formatsCount(DWORD cameraIndex); 93 VideoFormat cameraFormat(DWORD cameraIndex, DWORD formatIndex); 94 std::vector<VideoFormat> cameraFormats(DWORD cameraIndex); 95 } 96 97 #endif // PLATFORM_UTILS_H 98