中文亚洲精品无码_熟女乱子伦免费_人人超碰人人爱国产_亚洲熟妇女综合网

當(dāng)前位置: 首頁 > news >正文

云服務(wù)器是什么站長工具seo綜合查詢推廣

云服務(wù)器是什么,站長工具seo綜合查詢推廣,軟件上傳網(wǎng)站,干凈簡約的網(wǎng)站一、前言 本章主要講述,如何獲取設(shè)備名稱以及guid,采集設(shè)備的采集格式識別,設(shè)備的插拔 設(shè)備列表以及屬性的獲取使用的directshow(后續(xù)的MediaFoundation無法獲取OBS攝像頭) 設(shè)備的插拔使用的是QT 捕獲系統(tǒng)消息,捕獲到設(shè)備插拔后&a…

一、前言

? ? ? ? 本章主要講述,如何獲取設(shè)備名稱以及guid,采集設(shè)備的采集格式識別,設(shè)備的插拔

? ? ? ? 設(shè)備列表以及屬性的獲取使用的directshow(后續(xù)的MediaFoundation無法獲取OBS攝像頭)

? ? ? ? 設(shè)備的插拔使用的是QT 捕獲系統(tǒng)消息,捕獲到設(shè)備插拔后,重新獲取下設(shè)備列表(這里并沒有動態(tài)的添加或者刪除,考慮的主要是維護(hù)UI顯示時(shí) 設(shè)備順序的一致性)

二、設(shè)備列表的獲取

????????ICreateDevEnum 接口,創(chuàng)建特定的類(如視頻捕獲設(shè)備,音頻捕獲設(shè)備,視頻壓縮等)的一個(gè)枚舉器 ,可以使用CLSID_SystemDeviceEnum來得到該指針。

CreateDevEnum::CreateClassEnumerator(
REFCLSID clsidDeviceClass, //設(shè)備類別
IEnumMoniker **ppEnumMoniker, //輸出參數(shù),IEnumMoniker ××
DWORD dwFlags?
);

????????IEnumMoniker?接口,? 表示特定的設(shè)備枚舉類

? ? ? ??IMoniker::Enum 方法獲取指向 IEnumMoniker 實(shí)現(xiàn)的指針,該實(shí)現(xiàn)可以通過名字對象的組件向前或向后枚舉。

????????IRunningObjectTable::EnumRunning 方法返回一個(gè)指向 IEnumMoniker 實(shí)現(xiàn)的指針,該實(shí)現(xiàn)可以枚舉在運(yùn)行對象表中注冊的名字對象。

????????IEnumMoniker::Next? 此方法檢索枚舉序列中下一個(gè)設(shè)備是否存在

struct CameraDevice
{int                  nIndex;                    // indexstd::string          uid;                       // 硬件層uniqueId mac中為BuiltInMicrophoneDevice  std::string          name;                      // 設(shè)備名稱
};std::map<std::string, CameraDevice> VideoCoreDevice::getVideoDeviceList()
{if(!m_pDevEnum){::CoCreateInstance(CLSID_SystemDeviceEnum, NULL, CLSCTX_INPROC, IID_ICreateDevEnum, (void**)&m_pDevEnum);}std::map<std::string, CameraDevice> devices;if (!m_bCoUninitializeIsRequired){goto END;}HRESULT hr = m_pDevEnum->CreateClassEnumerator(CLSID_VideoInputDeviceCategory, &m_pMonikerDevEnum, 0);if (hr != NOERROR){std::cout << "CreateClassEnumerator failed" << std::endl;goto END;}m_pMonikerDevEnum->Reset();ULONG cFetched;IMoniker* pM;int index = 0;while (S_OK == m_pMonikerDevEnum->Next(1, &pM, &cFetched)) {IPropertyBag* pBag;hr = pM->BindToStorage(0, 0, IID_IPropertyBag, (void**)&pBag);if (S_OK == hr) {// Find the description or friendly name.VARIANT varName;VariantInit(&varName);hr = pBag->Read(L"Description", &varName, 0);if (FAILED(hr)) {hr = pBag->Read(L"FriendlyName", &varName, 0);}if (SUCCEEDED(hr)) {// ignore all VFW driversif ((wcsstr(varName.bstrVal, (L"(VFW)")) == NULL) &&(_wcsnicmp(varName.bstrVal, (L"Google Camera Adapter"), 21) != 0)) {// Found a valid device.{char device_name[256] = { 0 };char unique_name[256] = { 0 };char product_name[256] = { 0 };int convResult = WideCharToMultiByte(CP_UTF8, 0, varName.bstrVal, -1, (char*)device_name, sizeof(device_name), NULL, NULL);if (convResult == 0){std::cout << "WideCharToMultiByte failed" << std::endl;goto END;}hr = pBag->Read(L"DevicePath", &varName, 0);if (FAILED(hr)){strncpy_s((char*)unique_name, sizeof(unique_name),(char*)device_name, convResult);}else{convResult = WideCharToMultiByte(CP_UTF8, 0, varName.bstrVal, -1, (char*)unique_name, sizeof(unique_name), NULL, NULL);if (convResult == 0){std::cout << "WideCharToMultiByte failed" << std::endl;goto END;}}GetProductId(unique_name, product_name, sizeof(product_name));CameraDevice camera;camera.nIndex = index;camera.name = device_name;camera.uid = unique_name;devices.insert(std::make_pair(camera.uid, camera));}++index;  // increase the number of valid devices}}VariantClear(&varName);pBag->Release();pM->Release();}}END:return devices;
}// 不同獲取方式得到的ID不一致,通過處理得到相同的ID
void GetProductId(const char* devicePath, char* productUniqueIdUTF8, uint32_t productUniqueIdUTF8Length)
{*productUniqueIdUTF8 = '\0';char* startPos = strstr((char*)devicePath, "\\\\?\\");if (!startPos) {strncpy_s((char*)productUniqueIdUTF8, productUniqueIdUTF8Length, "", 1);std::cout << "Failed to get the product Id" << std::endl;return;}startPos += 4;char* pos = strchr(startPos, '&');if (!pos || pos >= (char*)devicePath + strlen((char*)devicePath)) {strncpy_s((char*)productUniqueIdUTF8, productUniqueIdUTF8Length, "", 1);std::cout << "Failed to get the product Id" << std::endl;return;}// Find the second occurrence.pos = strchr(pos + 1, '&');uint32_t bytesToCopy = (uint32_t)(pos - startPos);if (pos && (bytesToCopy < productUniqueIdUTF8Length) &&bytesToCopy <= kVideoCaptureProductIdLength) {strncpy_s((char*)productUniqueIdUTF8, productUniqueIdUTF8Length,(char*)startPos, bytesToCopy);}else{strncpy_s((char*)productUniqueIdUTF8, productUniqueIdUTF8Length, "", 1);std::cout << "Failed to get the product Id" << std::endl;}
}

三、設(shè)備的插拔檢測

? ? ? ? 目前使用的是Qt::nativeEventFilter 過濾設(shè)備插拔信息,然后去響應(yīng)設(shè)備列表

// 頭文件
#pragma once
#include <QWidget>
#include <QUuid>
#include <QAbstractNativeEventFilter>
#include <Windows.h>
#include <QHash>class VideoNotificationClient : public QAbstractNativeEventFilter, public QWidget
{
public:class Listener{public:virtual void onDeviceAdded(const std::string& uid) = 0;virtual void onDeviceRemoved(const std::string& uid) = 0;};public:void initialized();void uninstallFilter();bool nativeEventFilter(const QByteArray& eventType, void* message, long* result) override;public:VideoNotificationClient(VideoNotificationClient::Listener* listener);~VideoNotificationClient();private:bool                                                     m_bInitialized;QHash<QUuid, HDEVNOTIFY>                                 m_hSevNotifys;VideoNotificationClient::Listener*                       m_pListener;
};
//源文件
#include "VideoNotificationClient.h"
#include <QDebug>
#include <iostream>
#include <Windows.h>
#include <Dbt.h>
#include <devguid.h>
//具體的設(shè)備guid如usbiodef需要initguid
#include <initguid.h>
//USB設(shè)備
//GUID_DEVINTERFACE_USB_DEVICE
#include <usbiodef.h>
//HID人機(jī)交互設(shè)備-鼠標(biāo)鍵盤等
#include <hidclass.h>
//GUID_DEVINTERFACE_KEYBOARD
#include <ntddkbd.h>
//GUID_DEVINTERFACE_MOUSE
#include <ntddmou.h>
#include <QCoreApplication>
#pragma comment(lib, "user32.lib")
#pragma comment(lib, "setupapi.lib")static const GUID GUID_DEVINTERFACE_LIST[] =
{// GUID_DEVINTERFACE_CAMERA_DEVICE { 0x65E8773D, 0x8F56, 0x11D0, { 0xA3, 0xB9, 0x00, 0xA0, 0xC9, 0x22, 0x31, 0x96 } },// GUID_DEVINTERFACE_USB_DEVICE  { 0xA5DCBF10, 0x6530, 0x11D2, { 0x90, 0x1F, 0x00, 0xC0, 0x4F, 0xB9, 0x51, 0xED } },// GUID_DEVINTERFACE_DISK  { 0x53f56307, 0xb6bf, 0x11d0, { 0x94, 0xf2, 0x00, 0xa0, 0xc9, 0x1e, 0xfb, 0x8b } },// GUID_DEVINTERFACE_HID,   { 0x4D1E55B2, 0xF16F, 0x11CF, { 0x88, 0xCB, 0x00, 0x11, 0x11, 0x00, 0x00, 0x30 } },// GUID_NDIS_LAN_CLASS  { 0xad498944, 0x762f, 0x11d0, { 0x8d, 0xcb, 0x00, 0xc0, 0x4f, 0xc3, 0x35, 0x8c } },// GUID_DEVINTERFACE_COMPORT{ 0x86e0d1e0, 0x8089, 0x11d0, { 0x9c, 0xe4, 0x08, 0x00, 0x3e, 0x30, 0x1f, 0x73 } },// GUID_DEVINTERFACE_SERENUM_BUS_ENUMERATOR{ 0x4D36E978, 0xE325, 0x11CE, { 0xBF, 0xC1, 0x08, 0x00, 0x2B, 0xE1, 0x03, 0x18 } },// GUID_DEVINTERFACE_PARALLEL{ 0x97F76EF0, 0xF883, 0x11D0, { 0xAF, 0x1F, 0x00, 0x00, 0xF8, 0x00, 0x84, 0x5C } },// GUID_DEVINTERFACE_PARCLASS{ 0x811FC6A5, 0xF728, 0x11D0, { 0xA5, 0x37, 0x00, 0x00, 0xF8, 0x75, 0x3E, 0xD1 } }
};VideoNotificationClient::VideoNotificationClient(VideoNotificationClient::Listener *listener): QWidget(nullptr), m_bInitialized(false), m_pListener(listener)
{this->hide();qApp->installNativeEventFilter(this);
}VideoNotificationClient::~VideoNotificationClient()
{uninstallFilter();qApp->removeNativeEventFilter(this);
} void VideoNotificationClient::initialized()
{HANDLE winid = (HANDLE)this->winId();if (!winid){return;}//注冊插拔事件HDEVNOTIFY hDevNotify;DEV_BROADCAST_DEVICEINTERFACE NotifacationFiler;ZeroMemory(&NotifacationFiler, sizeof(DEV_BROADCAST_DEVICEINTERFACE));NotifacationFiler.dbcc_size = sizeof(DEV_BROADCAST_DEVICEINTERFACE);NotifacationFiler.dbcc_devicetype = DBT_DEVTYP_DEVICEINTERFACE;for (int i = 0; i < sizeof(GUID_DEVINTERFACE_LIST) / sizeof(GUID); i++){NotifacationFiler.dbcc_classguid = GUID_DEVINTERFACE_LIST[i];hDevNotify = RegisterDeviceNotification(winid, &NotifacationFiler, DEVICE_NOTIFY_WINDOW_HANDLE);if (!hDevNotify){qDebug() << "注冊失敗" << endl;m_bInitialized = false;return;}m_hSevNotifys.insert(QUuid(NotifacationFiler.dbcc_classguid), hDevNotify);}m_bInitialized = true;}void VideoNotificationClient::uninstallFilter()
{for (HDEVNOTIFY handle : qAsConst(m_hSevNotifys)){::UnregisterDeviceNotification(handle);}m_hSevNotifys.clear();
}bool VideoNotificationClient::nativeEventFilter(const QByteArray& eventType, void* message, long* result)
{Q_UNUSED(result);MSG* msg = reinterpret_cast<MSG*>(message);int msgType = msg->message;if (msgType == WM_DEVICECHANGE){PDEV_BROADCAST_HDR lpdb = (PDEV_BROADCAST_HDR)msg->lParam;switch (msg->wParam) {case DBT_DEVICEARRIVAL:if (lpdb->dbch_devicetype = DBT_DEVTYP_DEVICEINTERFACE){PDEV_BROADCAST_DEVICEINTERFACE pDevInf = (PDEV_BROADCAST_DEVICEINTERFACE)lpdb;GUID cameraGuid = { 0x65E8773D, 0x8F56, 0x11D0, { 0xA3, 0xB9, 0x00, 0xA0, 0xC9, 0x22, 0x31, 0x96 } };if (cameraGuid == pDevInf->dbcc_classguid){QString devicePath = QString::fromWCharArray(pDevInf->dbcc_name);QStringList parts = devicePath.split('#');if (parts.length() != 4){qDebug() << "camera logic error";return false;}QString usbPortStr = parts[2];QStringList usbPortParts = usbPortStr.split('&');if (usbPortParts.length() != 4){qDebug() << "camera logic error";return false;}   if ("0000" != usbPortParts[3]){return false;}devicePath = devicePath.toLower();m_pListener->onDeviceAdded(devicePath.toStdString());//emit cameraPlugged(true, devicePath);}}break;case DBT_DEVICEREMOVECOMPLETE:if (lpdb->dbch_devicetype = DBT_DEVTYP_DEVICEINTERFACE){PDEV_BROADCAST_DEVICEINTERFACE pDevInf = (PDEV_BROADCAST_DEVICEINTERFACE)lpdb;GUID cameraGuid = { 0x65E8773D, 0x8F56, 0x11D0, { 0xA3, 0xB9, 0x00, 0xA0, 0xC9, 0x22, 0x31, 0x96 } };if (cameraGuid == pDevInf->dbcc_classguid){// USB拔出馬上觸發(fā)QString devicePath = QString::fromWCharArray(pDevInf->dbcc_name);QStringList parts = devicePath.split('#');if (parts.length() != 4){qDebug() << "camera logic error";return false;}QString usbPortStr = parts[2];QStringList usbPortParts = usbPortStr.split('&');if (usbPortParts.length() != 4){qDebug() << "camera logic error";return false;}if ("0000" != usbPortParts[3]){return false;}devicePath = devicePath.toLower();m_pListener->onDeviceRemoved(devicePath.toStdString());}}break;}}return false;
}

四、設(shè)備插拔庫設(shè)計(jì)

項(xiàng)目完整代碼,在后續(xù)的文章中給出

// camra
struct CameraDevice
{int                  nIndex = 0;                     // indexstd::string          uid = "";                       // 硬件層uniqueId mac中為BuiltInMicrophoneDevice  std::string          name = "";                      // 設(shè)備名稱
};// IVideoCore
class VIDEODEVICE_SHARED_EXPORT IVideoCore
{
public:static IVideoCore* getInstance();virtual void addListener(IVideoDeviceListner* listner) = 0;virtual void removeListener(IVideoDeviceListner* listner) = 0;virtual std::map<std::string, CameraDevice> getVideoDevicesList() = 0;
};// IVideoDevice
class VIDEODEVICE_SHARED_EXPORT IVideoDevice
{
public:virtual bool initlized() = 0;virtual std::map<std::string, CameraDevice> getVideoDevicesList() = 0;virtual void addListener(IVideoDeviceListner* listener) = 0;virtual void removeListener(IVideoDeviceListner* listener) = 0;};// IVideoDeviceListner
class VIDEODEVICE_SHARED_EXPORT IVideoDeviceListner
{
public:virtual void onDeviceAdded(CameraDevice device) = 0;virtual void onDeviceRemoved(CameraDevice device) = 0;virtual void onDeviceListUpdate(std::map<std::string, CameraDevice> cameraList) = 0;
};class VideoNotificationClient 
{
public:class Listener{public:virtual void onDeviceAdded(const std::string& uid) = 0;virtual void onDeviceRemoved(const std::string& uid) = 0;};
}

http://www.risenshineclean.com/news/4866.html

相關(guān)文章:

  • 本地服務(wù)器網(wǎng)站建設(shè)google推廣怎么做
  • 網(wǎng)站別人給我做的備案 我能更改嗎外包推廣服務(wù)
  • 用jsp和mysql做網(wǎng)站短視頻怎么賺錢
  • 二字順口名字公司廣告優(yōu)化師的工作內(nèi)容
  • 網(wǎng)站導(dǎo)航廣告怎么做什么軟件比百度搜索好
  • wordpress share黑帽seo365t技術(shù)
  • 朝陽區(qū)規(guī)劃網(wǎng)站汽車網(wǎng)站建設(shè)方案
  • 高中生做網(wǎng)站網(wǎng)頁阿里云萬網(wǎng)域名查詢
  • 做動態(tài)網(wǎng)站時(shí)測試服務(wù)器不成功網(wǎng)站seo的主要優(yōu)化內(nèi)容
  • 做微商推廣有哪些好的分類信息網(wǎng)站seo關(guān)鍵詞優(yōu)化推廣外包
  • 免費(fèi)咨詢問題的網(wǎng)站好的搜索引擎推薦
  • 用wordpress開發(fā)網(wǎng)站錦繡大地seo官網(wǎng)
  • 服裝網(wǎng)站建設(shè)任務(wù)表網(wǎng)站權(quán)重一般有幾個(gè)等級
  • 外面網(wǎng)站怎么做怎么創(chuàng)建一個(gè)屬于自己的網(wǎng)站
  • 圣誕節(jié)網(wǎng)站怎么做百度反饋中心
  • 做網(wǎng)站的公司有怎么創(chuàng)建私人網(wǎng)站
  • 怎么做網(wǎng)站訊息it培訓(xùn)機(jī)構(gòu)培訓(xùn)費(fèi)用
  • 分析網(wǎng)站建設(shè)流程seo流量排行榜神器
  • 網(wǎng)絡(luò)營銷工具分析百度搜索關(guān)鍵詞排名優(yōu)化技術(shù)
  • 茂名專業(yè)網(wǎng)站制作公司seo的公司排名
  • 為什么凡科網(wǎng)做的網(wǎng)站無法搜索網(wǎng)站收錄入口申請查詢
  • 建立b2b企業(yè)網(wǎng)站百度網(wǎng)盤登陸入口
  • 建設(shè)高效的政府門戶網(wǎng)站深圳seo專家
  • 國內(nèi)移動端網(wǎng)站做的最好的抖音seo排名優(yōu)化
  • 帝國cms怎么做音樂網(wǎng)站如何查看一個(gè)網(wǎng)站的訪問量
  • 做金融網(wǎng)站有哪些要求網(wǎng)上的推廣公司
  • 外匯網(wǎng)站怎么做優(yōu)外匯網(wǎng)站怎么樣推廣自己的公司
  • 買東西哪個(gè)平臺質(zhì)量好seo助手
  • 無錫網(wǎng)站建設(shè)推廣重慶公司seo
  • 自助建站系統(tǒng)凡科百度權(quán)重高的發(fā)帖網(wǎng)站