update for linux.
This commit is contained in:
parent
1ce4afdc25
commit
2d78ddbd04
@ -32,7 +32,7 @@ set(OPENSSL_INCLUDE_DIR ${OpenSSL_ROOT}/include)
|
|||||||
set(OpenSSL_LIBRARY_DIRS ${OpenSSL_ROOT}/lib)
|
set(OpenSSL_LIBRARY_DIRS ${OpenSSL_ROOT}/lib)
|
||||||
set(OpenSSL_LIBRARIES libssl libcrypto)
|
set(OpenSSL_LIBRARIES libssl libcrypto)
|
||||||
|
|
||||||
set(FFmpeg_ROOT ${Libraries_ROOT}/ffmpeg-7.0.1-full_build-shared)
|
set(FFmpeg_ROOT ${Libraries_ROOT}/ffmpeg-7.0.2-full_build-shared)
|
||||||
set(FFmpeg_INCLUDE_DIR ${FFmpeg_ROOT}/include)
|
set(FFmpeg_INCLUDE_DIR ${FFmpeg_ROOT}/include)
|
||||||
set(FFmpeg_LIB_DIR ${FFmpeg_ROOT}/lib)
|
set(FFmpeg_LIB_DIR ${FFmpeg_ROOT}/lib)
|
||||||
|
|
||||||
|
@ -6,6 +6,13 @@
|
|||||||
#include <mfapi.h>
|
#include <mfapi.h>
|
||||||
#include <mfcaptureengine.h>
|
#include <mfcaptureengine.h>
|
||||||
|
|
||||||
|
struct DeviceDiscovery::Device {
|
||||||
|
Device(IMFMediaSource *source);
|
||||||
|
~Device();
|
||||||
|
IMFMediaSource *source = nullptr;
|
||||||
|
IMFSourceReader *reader = nullptr;
|
||||||
|
};
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
void SafeRelease(T **ppT) {
|
void SafeRelease(T **ppT) {
|
||||||
if (*ppT) {
|
if (*ppT) {
|
||||||
@ -17,6 +24,21 @@ void SafeRelease(T **ppT) {
|
|||||||
DeviceDiscovery::DeviceDiscovery() {
|
DeviceDiscovery::DeviceDiscovery() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static std::string deviceName(IMFActivate *device) {
|
||||||
|
std::string ret;
|
||||||
|
WCHAR *friendlyName = nullptr;
|
||||||
|
uint32_t nameLength = 0;
|
||||||
|
auto result = device->GetAllocatedString(MF_DEVSOURCE_ATTRIBUTE_FRIENDLY_NAME, &friendlyName, &nameLength);
|
||||||
|
|
||||||
|
if (SUCCEEDED(result)) {
|
||||||
|
ret = Amass::StringUtility::wstringToString(std::wstring(friendlyName, nameLength));
|
||||||
|
}
|
||||||
|
if (friendlyName != nullptr) {
|
||||||
|
CoTaskMemFree(friendlyName);
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
std::shared_ptr<DeviceDiscovery::Device> DeviceDiscovery::find(const std::string &deviceName, std::error_code &error) {
|
std::shared_ptr<DeviceDiscovery::Device> DeviceDiscovery::find(const std::string &deviceName, std::error_code &error) {
|
||||||
std::shared_ptr<Device> ret;
|
std::shared_ptr<Device> ret;
|
||||||
|
|
||||||
@ -45,7 +67,7 @@ std::shared_ptr<DeviceDiscovery::Device> DeviceDiscovery::find(const std::string
|
|||||||
|
|
||||||
int index = -1;
|
int index = -1;
|
||||||
for (int i = 0; i < count; i++) {
|
for (int i = 0; i < count; i++) {
|
||||||
auto name = this->deviceName(devices[i]);
|
auto name = ::deviceName(devices[i]);
|
||||||
LOG(info) << "device[" << i << "]: " << name;
|
LOG(info) << "device[" << i << "]: " << name;
|
||||||
if (name == deviceName) {
|
if (name == deviceName) {
|
||||||
index = i;
|
index = i;
|
||||||
@ -63,21 +85,6 @@ std::shared_ptr<DeviceDiscovery::Device> DeviceDiscovery::find(const std::string
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string DeviceDiscovery::deviceName(IMFActivate *device) {
|
|
||||||
std::string ret;
|
|
||||||
WCHAR *friendlyName = nullptr;
|
|
||||||
uint32_t nameLength = 0;
|
|
||||||
auto result = device->GetAllocatedString(MF_DEVSOURCE_ATTRIBUTE_FRIENDLY_NAME, &friendlyName, &nameLength);
|
|
||||||
|
|
||||||
if (SUCCEEDED(result)) {
|
|
||||||
ret = Amass::StringUtility::wstringToString(std::wstring(friendlyName, nameLength));
|
|
||||||
}
|
|
||||||
if (friendlyName != nullptr) {
|
|
||||||
CoTaskMemFree(friendlyName);
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
void DeviceDiscovery::enterOtaMode(const std::shared_ptr<Device> &device, std::error_code &error) {
|
void DeviceDiscovery::enterOtaMode(const std::shared_ptr<Device> &device, std::error_code &error) {
|
||||||
auto resolutions = deviceResolutions(device);
|
auto resolutions = deviceResolutions(device);
|
||||||
LOG(info) << "device resolutions:";
|
LOG(info) << "device resolutions:";
|
||||||
@ -144,7 +151,7 @@ std::vector<std::string> DeviceDiscovery::devices() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < count; i++) {
|
for (int i = 0; i < count; i++) {
|
||||||
auto name = this->deviceName(devices[i]);
|
auto name = ::deviceName(devices[i]);
|
||||||
ret.push_back(name);
|
ret.push_back(name);
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -12,12 +12,7 @@ class DeviceDiscovery {
|
|||||||
constexpr static int32_t OtaSpecificWidth = 96;
|
constexpr static int32_t OtaSpecificWidth = 96;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
struct Device {
|
struct Device;
|
||||||
Device(IMFMediaSource *source);
|
|
||||||
~Device();
|
|
||||||
IMFMediaSource *source = nullptr;
|
|
||||||
IMFSourceReader *reader = nullptr;
|
|
||||||
};
|
|
||||||
|
|
||||||
using Resolution = std::pair<int32_t, int32_t>;
|
using Resolution = std::pair<int32_t, int32_t>;
|
||||||
using Resolutions = std::vector<Resolution>;
|
using Resolutions = std::vector<Resolution>;
|
||||||
@ -27,7 +22,6 @@ public:
|
|||||||
std::vector<std::string> devices();
|
std::vector<std::string> devices();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
std::string deviceName(IMFActivate *device);
|
|
||||||
Resolutions deviceResolutions(const std::shared_ptr<Device> &source);
|
Resolutions deviceResolutions(const std::shared_ptr<Device> &source);
|
||||||
};
|
};
|
||||||
#endif // __DEVICEDISCOVERY_H__
|
#endif // __DEVICEDISCOVERY_H__
|
||||||
|
Loading…
Reference in New Issue
Block a user