SCRIPT namespace replacements

This commit is contained in:
PJ Reiniger
2025-11-07 20:00:05 -05:00
committed by Peter Johnson
parent ae6c043632
commit 9aca8e0fd6
2622 changed files with 22275 additions and 22275 deletions

View File

@@ -63,22 +63,22 @@ static constexpr char const* kPropConnectVerbose = "connect_verbose";
static constexpr unsigned kPropConnectVerboseId = 0;
using namespace cs;
using namespace wpi::cs;
namespace cs {
namespace wpi::cs {
UsbCameraImpl::UsbCameraImpl(std::string_view name, wpi::Logger& logger,
UsbCameraImpl::UsbCameraImpl(std::string_view name, wpi::util::Logger& logger,
Notifier& notifier, Telemetry& telemetry,
std::string_view path)
: SourceImpl{name, logger, notifier, telemetry}, m_path{path} {
wpi::SmallVector<wchar_t, 128> wideStorage;
wpi::sys::windows::UTF8ToUTF16(m_path, wideStorage);
wpi::util::SmallVector<wchar_t, 128> wideStorage;
wpi::util::sys::windows::UTF8ToUTF16(m_path, wideStorage);
m_widePath = std::wstring{wideStorage.data(), wideStorage.size()};
m_deviceId = -1;
StartMessagePump();
}
UsbCameraImpl::UsbCameraImpl(std::string_view name, wpi::Logger& logger,
UsbCameraImpl::UsbCameraImpl(std::string_view name, wpi::util::Logger& logger,
Notifier& notifier, Telemetry& telemetry,
int deviceId)
: SourceImpl{name, logger, notifier, telemetry}, m_deviceId(deviceId) {
@@ -242,7 +242,7 @@ bool UsbCameraImpl::CheckDeviceChange(WPARAM wParam, DEV_BROADCAST_HDR* pHdr,
pDi = reinterpret_cast<DEV_BROADCAST_DEVICEINTERFACE_A*>(pHdr);
if (wpi::equals_lower(m_path, pDi->dbcc_name)) {
if (wpi::util::equals_lower(m_path, pDi->dbcc_name)) {
if (wParam == DBT_DEVICEARRIVAL) {
*connected = true;
return true;
@@ -268,8 +268,8 @@ void UsbCameraImpl::DeviceDisconnect() {
}
static bool IsPercentageProperty(std::string_view name) {
if (wpi::starts_with(name, "raw_")) {
name = wpi::substr(name, 4);
if (wpi::util::starts_with(name, "raw_")) {
name = wpi::util::substr(name, 4);
}
return name == "Brightness" || name == "Contrast" || name == "Saturation" ||
name == "Hue" || name == "Sharpness" || name == "Gain" ||
@@ -282,7 +282,7 @@ void UsbCameraImpl::ProcessFrame(IMFSample* videoSample,
return;
}
auto currentTime = wpi::Now();
auto currentTime = wpi::util::Now();
ComPtr<IMFMediaBuffer> buf;
@@ -378,7 +378,7 @@ LRESULT UsbCameraImpl::PumpMain(HWND hwnd, UINT uiMsg, WPARAM wParam,
// If path is empty, we attempted to connect with a device ID. Enumerate
// and check
CS_Status status = 0;
auto devices = cs::EnumerateUsbCameras(&status);
auto devices = wpi::cs::EnumerateUsbCameras(&status);
if (devices.size() > m_deviceId) {
// If has device ID, use the device ID from the event
// because of windows bug
@@ -386,8 +386,8 @@ LRESULT UsbCameraImpl::PumpMain(HWND hwnd, UINT uiMsg, WPARAM wParam,
DEV_BROADCAST_DEVICEINTERFACE_A* pDi =
reinterpret_cast<DEV_BROADCAST_DEVICEINTERFACE_A*>(parameter);
m_path = pDi->dbcc_name;
wpi::SmallVector<wchar_t, 128> wideStorage;
wpi::sys::windows::UTF8ToUTF16(m_path, wideStorage);
wpi::util::SmallVector<wchar_t, 128> wideStorage;
wpi::util::sys::windows::UTF8ToUTF16(m_path, wideStorage);
m_widePath = std::wstring{wideStorage.data(), wideStorage.size()};
} else {
// This device not found
@@ -425,22 +425,22 @@ LRESULT UsbCameraImpl::PumpMain(HWND hwnd, UINT uiMsg, WPARAM wParam,
return 0l;
}
static cs::VideoMode::PixelFormat GetFromGUID(const GUID& guid) {
static wpi::cs::VideoMode::PixelFormat GetFromGUID(const GUID& guid) {
// Compare GUID to one of the supported ones
if (IsEqualGUID(guid, MFVideoFormat_L8)) {
return cs::VideoMode::PixelFormat::kGray;
return wpi::cs::VideoMode::PixelFormat::kGray;
} else if (IsEqualGUID(guid, MFVideoFormat_L16)) {
return cs::VideoMode::PixelFormat::kY16;
return wpi::cs::VideoMode::PixelFormat::kY16;
} else if (IsEqualGUID(guid, MFVideoFormat_YUY2)) {
return cs::VideoMode::PixelFormat::kYUYV;
return wpi::cs::VideoMode::PixelFormat::kYUYV;
} else if (IsEqualGUID(guid, MFVideoFormat_MJPG)) {
return cs::VideoMode::PixelFormat::kMJPEG;
return wpi::cs::VideoMode::PixelFormat::kMJPEG;
} else if (IsEqualGUID(guid, MFVideoFormat_RGB565)) {
return cs::VideoMode::PixelFormat::kRGB565;
return wpi::cs::VideoMode::PixelFormat::kRGB565;
} else if (IsEqualGUID(guid, MFVideoFormat_UYVY)) {
return cs::VideoMode::PixelFormat::kUYVY;
return wpi::cs::VideoMode::PixelFormat::kUYVY;
} else {
return cs::VideoMode::PixelFormat::kUnknown;
return wpi::cs::VideoMode::PixelFormat::kUnknown;
}
}
@@ -713,7 +713,7 @@ void UsbCameraImpl::DeviceCacheProperty(
}
CS_StatusValue UsbCameraImpl::DeviceProcessCommand(
std::unique_lock<wpi::mutex>& lock, Message::Kind msgKind,
std::unique_lock<wpi::util::mutex>& lock, Message::Kind msgKind,
const Message* msg) {
if (msgKind == Message::kCmdSetMode ||
msgKind == Message::kCmdSetPixelFormat ||
@@ -736,8 +736,8 @@ CS_StatusValue UsbCameraImpl::DeviceProcessCommand(
{
std::scoped_lock lock(m_mutex);
m_path = msg->dataStr;
wpi::SmallVector<wchar_t, 128> wideStorage;
wpi::sys::windows::UTF8ToUTF16(m_path, wideStorage);
wpi::util::SmallVector<wchar_t, 128> wideStorage;
wpi::util::sys::windows::UTF8ToUTF16(m_path, wideStorage);
m_widePath = std::wstring{wideStorage.data(), wideStorage.size()};
}
DeviceDisconnect();
@@ -749,7 +749,7 @@ CS_StatusValue UsbCameraImpl::DeviceProcessCommand(
}
CS_StatusValue UsbCameraImpl::DeviceCmdSetProperty(
std::unique_lock<wpi::mutex>& lock, const Message& msg) {
std::unique_lock<wpi::util::mutex>& lock, const Message& msg) {
bool setString = (msg.kind == Message::kCmdSetPropertyStr);
int property = msg.data[0];
int value = msg.data[1];
@@ -826,7 +826,7 @@ ComPtr<IMFMediaType> UsbCameraImpl::DeviceCheckModeValid(
}
CS_StatusValue UsbCameraImpl::DeviceCmdSetMode(
std::unique_lock<wpi::mutex>& lock, const Message& msg) {
std::unique_lock<wpi::util::mutex>& lock, const Message& msg) {
VideoMode newMode;
if (msg.kind == Message::kCmdSetMode) {
newMode.pixelFormat = msg.data[0];
@@ -1021,19 +1021,19 @@ void UsbCameraImpl::DeviceCacheVideoModes() {
}
static void ParseVidAndPid(std::string_view path, int* pid, int* vid) {
auto vidIndex = wpi::find_lower(path, "vid_");
auto pidIndex = wpi::find_lower(path, "pid_");
auto vidIndex = wpi::util::find_lower(path, "vid_");
auto pidIndex = wpi::util::find_lower(path, "pid_");
if (vidIndex != std::string_view::npos) {
auto vidSlice = wpi::slice(path, vidIndex + 4, vidIndex + 8);
if (auto v = wpi::parse_integer<uint16_t>(vidSlice, 16)) {
auto vidSlice = wpi::util::slice(path, vidIndex + 4, vidIndex + 8);
if (auto v = wpi::util::parse_integer<uint16_t>(vidSlice, 16)) {
*vid = v.value();
}
}
if (pidIndex != std::string_view::npos) {
auto pidSlice = wpi::slice(path, pidIndex + 4, pidIndex + 8);
if (auto v = wpi::parse_integer<uint16_t>(pidSlice, 16)) {
auto pidSlice = wpi::util::slice(path, pidIndex + 4, pidIndex + 8);
if (auto v = wpi::util::parse_integer<uint16_t>(pidSlice, 16)) {
*pid = v.value();
}
}
@@ -1045,7 +1045,7 @@ std::vector<UsbCameraInfo> EnumerateUsbCameras(CS_Status* status) {
// Ensure we are initialized by grabbing the message pump
// GetMessagePump();
wpi::SmallString<128> storage;
wpi::util::SmallString<128> storage;
WCHAR buf[512];
ComPtr<IMFAttributes> pAttributes;
IMFActivate** ppDevices = nullptr;
@@ -1083,13 +1083,13 @@ std::vector<UsbCameraInfo> EnumerateUsbCameras(CS_Status* status) {
ppDevices[i]->GetString(MF_DEVSOURCE_ATTRIBUTE_FRIENDLY_NAME, buf,
sizeof(buf) / sizeof(WCHAR), &characters);
storage.clear();
wpi::sys::windows::UTF16ToUTF8(buf, characters, storage);
wpi::util::sys::windows::UTF16ToUTF8(buf, characters, storage);
info.name = std::string{storage};
ppDevices[i]->GetString(
MF_DEVSOURCE_ATTRIBUTE_SOURCE_TYPE_VIDCAP_SYMBOLIC_LINK, buf,
sizeof(buf) / sizeof(WCHAR), &characters);
storage.clear();
wpi::sys::windows::UTF16ToUTF8(buf, characters, storage);
wpi::util::sys::windows::UTF16ToUTF8(buf, characters, storage);
info.path = std::string{storage};
// Try to parse path from symbolic link
@@ -1117,7 +1117,7 @@ done:
CS_Source CreateUsbCameraDev(std::string_view name, int dev,
CS_Status* status) {
// First check if device exists
auto devices = cs::EnumerateUsbCameras(status);
auto devices = wpi::cs::EnumerateUsbCameras(status);
if (devices.size() > dev) {
return CreateUsbCameraPath(name, devices[dev].path, status);
}
@@ -1163,11 +1163,11 @@ UsbCameraInfo GetUsbCameraInfo(CS_Source source, CS_Status* status) {
}
info.path = static_cast<UsbCameraImpl&>(*data->source).GetPath();
wpi::SmallVector<char, 64> buf;
wpi::util::SmallVector<char, 64> buf;
info.name = static_cast<UsbCameraImpl&>(*data->source).GetDescription(buf);
ParseVidAndPid(info.path, &info.productId, &info.vendorId);
info.dev = -1; // We have lost dev information by this point in time.
return info;
}
} // namespace cs
} // namespace wpi::cs