mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-19 00:41:43 +00:00
SCRIPT namespace replacements
This commit is contained in:
committed by
Peter Johnson
parent
ae6c043632
commit
9aca8e0fd6
@@ -10,39 +10,39 @@
|
||||
int main() {
|
||||
CS_Status status = 0;
|
||||
|
||||
for (const auto& caminfo : cs::EnumerateUsbCameras(&status)) {
|
||||
wpi::print("{}: {} ({})\n", caminfo.dev, caminfo.path, caminfo.name);
|
||||
for (const auto& caminfo : wpi::cs::EnumerateUsbCameras(&status)) {
|
||||
wpi::util::print("{}: {} ({})\n", caminfo.dev, caminfo.path, caminfo.name);
|
||||
if (!caminfo.otherPaths.empty()) {
|
||||
std::puts("Other device paths:");
|
||||
for (auto&& path : caminfo.otherPaths) {
|
||||
wpi::print(" {}\n", path);
|
||||
wpi::util::print(" {}\n", path);
|
||||
}
|
||||
}
|
||||
|
||||
cs::UsbCamera camera{"usbcam", caminfo.dev};
|
||||
wpi::cs::UsbCamera camera{"usbcam", caminfo.dev};
|
||||
|
||||
std::puts("Properties:");
|
||||
for (const auto& prop : camera.EnumerateProperties()) {
|
||||
wpi::print(" {}", prop.GetName());
|
||||
wpi::util::print(" {}", prop.GetName());
|
||||
switch (prop.GetKind()) {
|
||||
case cs::VideoProperty::kBoolean:
|
||||
wpi::print(" (bool): value={} default={}", prop.Get(),
|
||||
case wpi::cs::VideoProperty::kBoolean:
|
||||
wpi::util::print(" (bool): value={} default={}", prop.Get(),
|
||||
prop.GetDefault());
|
||||
break;
|
||||
case cs::VideoProperty::kInteger:
|
||||
wpi::print(" (int): value={} min={} max={} step={} default={}",
|
||||
case wpi::cs::VideoProperty::kInteger:
|
||||
wpi::util::print(" (int): value={} min={} max={} step={} default={}",
|
||||
prop.Get(), prop.GetMin(), prop.GetMax(), prop.GetStep(),
|
||||
prop.GetDefault());
|
||||
break;
|
||||
case cs::VideoProperty::kString:
|
||||
wpi::print(" (string): {}", prop.GetString());
|
||||
case wpi::cs::VideoProperty::kString:
|
||||
wpi::util::print(" (string): {}", prop.GetString());
|
||||
break;
|
||||
case cs::VideoProperty::kEnum: {
|
||||
wpi::print(" (enum): value={}", prop.Get());
|
||||
case wpi::cs::VideoProperty::kEnum: {
|
||||
wpi::util::print(" (enum): value={}", prop.Get());
|
||||
auto choices = prop.GetChoices();
|
||||
for (size_t i = 0; i < choices.size(); ++i) {
|
||||
if (!choices[i].empty()) {
|
||||
wpi::print("\n {}: {}", i, choices[i]);
|
||||
wpi::util::print("\n {}: {}", i, choices[i]);
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -57,20 +57,20 @@ int main() {
|
||||
for (const auto& mode : camera.EnumerateVideoModes()) {
|
||||
const char* pixelFormat;
|
||||
switch (mode.pixelFormat) {
|
||||
case cs::VideoMode::kMJPEG:
|
||||
case wpi::cs::VideoMode::kMJPEG:
|
||||
pixelFormat = "MJPEG";
|
||||
break;
|
||||
case cs::VideoMode::kYUYV:
|
||||
case wpi::cs::VideoMode::kYUYV:
|
||||
pixelFormat = "YUYV";
|
||||
break;
|
||||
case cs::VideoMode::kRGB565:
|
||||
case wpi::cs::VideoMode::kRGB565:
|
||||
pixelFormat = "RGB565";
|
||||
break;
|
||||
default:
|
||||
pixelFormat = "Unknown";
|
||||
break;
|
||||
}
|
||||
wpi::print(" PixelFormat:{} Width:{} Height:{} FPS:{}\n", pixelFormat,
|
||||
wpi::util::print(" PixelFormat:{} Width:{} Height:{} FPS:{}\n", pixelFormat,
|
||||
mode.width, mode.height, mode.fps);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,12 +11,12 @@
|
||||
#include "wpi/util/print.hpp"
|
||||
|
||||
int main() {
|
||||
cs::HttpCamera camera{"httpcam", "http://localhost:8081/?action=stream"};
|
||||
camera.SetVideoMode(cs::VideoMode::kMJPEG, 320, 240, 30);
|
||||
cs::CvSink cvsink{"cvsink"};
|
||||
wpi::cs::HttpCamera camera{"httpcam", "http://localhost:8081/?action=stream"};
|
||||
camera.SetVideoMode(wpi::cs::VideoMode::kMJPEG, 320, 240, 30);
|
||||
wpi::cs::CvSink cvsink{"cvsink"};
|
||||
cvsink.SetSource(camera);
|
||||
cs::CvSource cvsource{"cvsource", cs::VideoMode::kMJPEG, 320, 240, 30};
|
||||
cs::MjpegServer cvMjpegServer{"cvhttpserver", 8083};
|
||||
wpi::cs::CvSource cvsource{"cvsource", wpi::cs::VideoMode::kMJPEG, 320, 240, 30};
|
||||
wpi::cs::MjpegServer cvMjpegServer{"cvhttpserver", 8083};
|
||||
cvMjpegServer.SetSource(cvsource);
|
||||
|
||||
cv::Mat test;
|
||||
@@ -24,10 +24,10 @@ int main() {
|
||||
for (;;) {
|
||||
uint64_t time = cvsink.GrabFrame(test);
|
||||
if (time == 0) {
|
||||
wpi::print("error: {}\n", cvsink.GetError());
|
||||
wpi::util::print("error: {}\n", cvsink.GetError());
|
||||
continue;
|
||||
}
|
||||
wpi::print("got frame at time {} size ({}, {})\n", time, test.size().width,
|
||||
wpi::util::print("got frame at time {} size ({}, {})\n", time, test.size().width,
|
||||
test.size().height);
|
||||
cv::flip(test, flip, 0);
|
||||
cvsource.PutFrame(flip);
|
||||
|
||||
@@ -19,14 +19,14 @@ int main(int argc, char** argv) {
|
||||
}
|
||||
|
||||
int id;
|
||||
if (auto v = wpi::parse_integer<int>(argv[1], 10)) {
|
||||
if (auto v = wpi::util::parse_integer<int>(argv[1], 10)) {
|
||||
id = v.value();
|
||||
} else {
|
||||
std::fputs("Expected number for camera\n", stderr);
|
||||
return 2;
|
||||
}
|
||||
|
||||
cs::UsbCamera camera{"usbcam", id};
|
||||
wpi::cs::UsbCamera camera{"usbcam", id};
|
||||
|
||||
// Set prior to connect
|
||||
int arg = 2;
|
||||
@@ -36,7 +36,7 @@ int main(int argc, char** argv) {
|
||||
propName = argv[arg];
|
||||
} else {
|
||||
std::string_view propVal{argv[arg]};
|
||||
if (auto v = wpi::parse_integer<int>(propVal, 10)) {
|
||||
if (auto v = wpi::util::parse_integer<int>(propVal, 10)) {
|
||||
camera.GetProperty(propName).Set(v.value());
|
||||
} else {
|
||||
camera.GetProperty(propName).SetString(propVal);
|
||||
@@ -60,7 +60,7 @@ int main(int argc, char** argv) {
|
||||
propName = argv[arg];
|
||||
} else {
|
||||
std::string_view propVal{argv[arg]};
|
||||
if (auto v = wpi::parse_integer<int>(propVal, 10)) {
|
||||
if (auto v = wpi::util::parse_integer<int>(propVal, 10)) {
|
||||
camera.GetProperty(propName).Set(v.value());
|
||||
} else {
|
||||
camera.GetProperty(propName).SetString(propVal);
|
||||
@@ -72,26 +72,26 @@ int main(int argc, char** argv) {
|
||||
// Print settings
|
||||
std::puts("Properties:");
|
||||
for (const auto& prop : camera.EnumerateProperties()) {
|
||||
wpi::print(" {}", prop.GetName());
|
||||
wpi::util::print(" {}", prop.GetName());
|
||||
switch (prop.GetKind()) {
|
||||
case cs::VideoProperty::kBoolean:
|
||||
wpi::print(" (bool): value={} default={}", prop.Get(),
|
||||
case wpi::cs::VideoProperty::kBoolean:
|
||||
wpi::util::print(" (bool): value={} default={}", prop.Get(),
|
||||
prop.GetDefault());
|
||||
break;
|
||||
case cs::VideoProperty::kInteger:
|
||||
wpi::print(" (int): value={} min={} max={} step={} default={}",
|
||||
case wpi::cs::VideoProperty::kInteger:
|
||||
wpi::util::print(" (int): value={} min={} max={} step={} default={}",
|
||||
prop.Get(), prop.GetMin(), prop.GetMax(), prop.GetStep(),
|
||||
prop.GetDefault());
|
||||
break;
|
||||
case cs::VideoProperty::kString:
|
||||
wpi::print(" (string): {}", prop.GetString());
|
||||
case wpi::cs::VideoProperty::kString:
|
||||
wpi::util::print(" (string): {}", prop.GetString());
|
||||
break;
|
||||
case cs::VideoProperty::kEnum: {
|
||||
wpi::print(" (enum): value={}", prop.Get());
|
||||
case wpi::cs::VideoProperty::kEnum: {
|
||||
wpi::util::print(" (enum): value={}", prop.Get());
|
||||
auto choices = prop.GetChoices();
|
||||
for (size_t i = 0; i < choices.size(); ++i) {
|
||||
if (!choices[i].empty()) {
|
||||
wpi::print("\n {}: {}", i, choices[i]);
|
||||
wpi::util::print("\n {}: {}", i, choices[i]);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -8,14 +8,14 @@
|
||||
#include "wpi/util/print.hpp"
|
||||
|
||||
int main() {
|
||||
cs::UsbCamera camera{"usbcam", 0};
|
||||
camera.SetVideoMode(cs::VideoMode::kMJPEG, 320, 240, 30);
|
||||
cs::MjpegServer mjpegServer{"httpserver", 8081};
|
||||
wpi::cs::UsbCamera camera{"usbcam", 0};
|
||||
camera.SetVideoMode(wpi::cs::VideoMode::kMJPEG, 320, 240, 30);
|
||||
wpi::cs::MjpegServer mjpegServer{"httpserver", 8081};
|
||||
mjpegServer.SetSource(camera);
|
||||
cs::CvSink cvsink{"cvsink"};
|
||||
wpi::cs::CvSink cvsink{"cvsink"};
|
||||
cvsink.SetSource(camera);
|
||||
cs::CvSource cvsource{"cvsource", cs::VideoMode::kMJPEG, 320, 240, 30};
|
||||
cs::MjpegServer cvMjpegServer{"cvhttpserver", 8082};
|
||||
wpi::cs::CvSource cvsource{"cvsource", wpi::cs::VideoMode::kMJPEG, 320, 240, 30};
|
||||
wpi::cs::MjpegServer cvMjpegServer{"cvhttpserver", 8082};
|
||||
cvMjpegServer.SetSource(cvsource);
|
||||
|
||||
cv::Mat test;
|
||||
@@ -23,10 +23,10 @@ int main() {
|
||||
for (;;) {
|
||||
uint64_t time = cvsink.GrabFrame(test);
|
||||
if (time == 0) {
|
||||
wpi::print("error: {}\n", cvsink.GetError());
|
||||
wpi::util::print("error: {}\n", cvsink.GetError());
|
||||
continue;
|
||||
}
|
||||
wpi::print("got frame at time {} size ({}, {})\n", time, test.size().width,
|
||||
wpi::util::print("got frame at time {} size ({}, {})\n", time, test.size().width,
|
||||
test.size().height);
|
||||
cv::flip(test, flip, 0);
|
||||
cvsource.PutFrame(flip);
|
||||
|
||||
@@ -8,24 +8,24 @@
|
||||
#include "wpi/util/print.hpp"
|
||||
|
||||
int main() {
|
||||
wpi::print("hostname: {}\n", cs::GetHostname());
|
||||
wpi::util::print("hostname: {}\n", wpi::cs::GetHostname());
|
||||
std::puts("IPv4 network addresses:");
|
||||
for (const auto& addr : cs::GetNetworkInterfaces()) {
|
||||
wpi::print(" {}\n", addr);
|
||||
for (const auto& addr : wpi::cs::GetNetworkInterfaces()) {
|
||||
wpi::util::print(" {}\n", addr);
|
||||
}
|
||||
cs::UsbCamera camera{"usbcam", 0};
|
||||
camera.SetVideoMode(cs::VideoMode::kMJPEG, 320, 240, 30);
|
||||
cs::MjpegServer mjpegServer{"httpserver", 8081};
|
||||
wpi::cs::UsbCamera camera{"usbcam", 0};
|
||||
camera.SetVideoMode(wpi::cs::VideoMode::kMJPEG, 320, 240, 30);
|
||||
wpi::cs::MjpegServer mjpegServer{"httpserver", 8081};
|
||||
mjpegServer.SetSource(camera);
|
||||
|
||||
CS_Status status = 0;
|
||||
cs::AddListener(
|
||||
[&](const cs::RawEvent& event) {
|
||||
wpi::print("FPS={} MBPS={}\n", camera.GetActualFPS(),
|
||||
wpi::cs::AddListener(
|
||||
[&](const wpi::cs::RawEvent& event) {
|
||||
wpi::util::print("FPS={} MBPS={}\n", camera.GetActualFPS(),
|
||||
(camera.GetActualDataRate() / 1000000.0));
|
||||
},
|
||||
cs::RawEvent::kTelemetryUpdated, false, &status);
|
||||
cs::SetTelemetryPeriod(1.0);
|
||||
wpi::cs::RawEvent::kTelemetryUpdated, false, &status);
|
||||
wpi::cs::SetTelemetryPeriod(1.0);
|
||||
|
||||
std::getchar();
|
||||
}
|
||||
|
||||
@@ -24,15 +24,15 @@
|
||||
namespace gui = wpi::gui;
|
||||
|
||||
int main() {
|
||||
wpi::spinlock latestFrameMutex;
|
||||
wpi::util::spinlock latestFrameMutex;
|
||||
std::unique_ptr<cv::Mat> latestFrame;
|
||||
wpi::mutex freeListMutex;
|
||||
wpi::util::mutex freeListMutex;
|
||||
std::vector<std::unique_ptr<cv::Mat>> freeList;
|
||||
std::atomic<bool> stopCamera{false};
|
||||
|
||||
cs::UsbCamera camera{"usbcam", 0};
|
||||
camera.SetVideoMode(cs::VideoMode::kMJPEG, 640, 480, 30);
|
||||
cs::CvSink cvsink{"cvsink"};
|
||||
wpi::cs::UsbCamera camera{"usbcam", 0};
|
||||
camera.SetVideoMode(wpi::cs::VideoMode::kMJPEG, 640, 480, 30);
|
||||
wpi::cs::CvSink cvsink{"cvsink"};
|
||||
cvsink.SetSource(camera);
|
||||
|
||||
std::thread thr([&] {
|
||||
@@ -41,7 +41,7 @@ int main() {
|
||||
// get frame from camera
|
||||
uint64_t time = cvsink.GrabFrame(frame);
|
||||
if (time == 0) {
|
||||
wpi::print("error: {}\n", cvsink.GetError());
|
||||
wpi::util::print("error: {}\n", cvsink.GetError());
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@@ -6,5 +6,5 @@
|
||||
#include "wpi/util/print.hpp"
|
||||
|
||||
int main() {
|
||||
wpi::print("{}\n", cs::GetHostname());
|
||||
wpi::util::print("{}\n", wpi::cs::GetHostname());
|
||||
}
|
||||
|
||||
@@ -12,10 +12,10 @@
|
||||
#include "Notifier.hpp"
|
||||
#include "wpi/util/timestamp.h"
|
||||
|
||||
using namespace cs;
|
||||
using namespace wpi::cs;
|
||||
|
||||
ConfigurableSourceImpl::ConfigurableSourceImpl(std::string_view name,
|
||||
wpi::Logger& logger,
|
||||
wpi::util::Logger& logger,
|
||||
Notifier& notifier,
|
||||
Telemetry& telemetry,
|
||||
const VideoMode& mode)
|
||||
@@ -52,7 +52,7 @@ void ConfigurableSourceImpl::NumSinksEnabledChanged() {
|
||||
}
|
||||
|
||||
void ConfigurableSourceImpl::NotifyError(std::string_view msg) {
|
||||
PutError(msg, wpi::Now());
|
||||
PutError(msg, wpi::util::Now());
|
||||
}
|
||||
|
||||
int ConfigurableSourceImpl::CreateProperty(std::string_view name,
|
||||
@@ -106,7 +106,7 @@ void ConfigurableSourceImpl::SetEnumPropertyChoices(
|
||||
prop->value, {});
|
||||
}
|
||||
|
||||
namespace cs {
|
||||
namespace wpi::cs {
|
||||
static constexpr unsigned SourceMask = CS_SOURCE_CV | CS_SOURCE_RAW;
|
||||
|
||||
void NotifySourceError(CS_Source source, std::string_view msg,
|
||||
@@ -195,23 +195,23 @@ void SetSourceEnumPropertyChoices(CS_Source source, CS_Property property,
|
||||
.SetEnumPropertyChoices(propertyIndex, choices, status);
|
||||
}
|
||||
|
||||
} // namespace cs
|
||||
} // namespace wpi::cs
|
||||
|
||||
extern "C" {
|
||||
void CS_NotifySourceError(CS_Source source, const struct WPI_String* msg,
|
||||
CS_Status* status) {
|
||||
return cs::NotifySourceError(source, wpi::to_string_view(msg), status);
|
||||
return wpi::cs::NotifySourceError(source, wpi::util::to_string_view(msg), status);
|
||||
}
|
||||
|
||||
void CS_SetSourceConnected(CS_Source source, CS_Bool connected,
|
||||
CS_Status* status) {
|
||||
return cs::SetSourceConnected(source, connected, status);
|
||||
return wpi::cs::SetSourceConnected(source, connected, status);
|
||||
}
|
||||
|
||||
void CS_SetSourceDescription(CS_Source source,
|
||||
const struct WPI_String* description,
|
||||
CS_Status* status) {
|
||||
return cs::SetSourceDescription(source, wpi::to_string_view(description),
|
||||
return wpi::cs::SetSourceDescription(source, wpi::util::to_string_view(description),
|
||||
status);
|
||||
}
|
||||
|
||||
@@ -220,7 +220,7 @@ CS_Property CS_CreateSourceProperty(CS_Source source,
|
||||
enum CS_PropertyKind kind, int minimum,
|
||||
int maximum, int step, int defaultValue,
|
||||
int value, CS_Status* status) {
|
||||
return cs::CreateSourceProperty(source, wpi::to_string_view(name), kind,
|
||||
return wpi::cs::CreateSourceProperty(source, wpi::util::to_string_view(name), kind,
|
||||
minimum, maximum, step, defaultValue, value,
|
||||
status);
|
||||
}
|
||||
@@ -229,7 +229,7 @@ CS_Property CS_CreateSourcePropertyCallback(
|
||||
CS_Source source, const char* name, enum CS_PropertyKind kind, int minimum,
|
||||
int maximum, int step, int defaultValue, int value, void* data,
|
||||
void (*onChange)(void* data, CS_Property property), CS_Status* status) {
|
||||
return cs::CreateSourcePropertyCallback(
|
||||
return wpi::cs::CreateSourcePropertyCallback(
|
||||
source, name, kind, minimum, maximum, step, defaultValue, value,
|
||||
[=](CS_Property property) { onChange(data, property); }, status);
|
||||
}
|
||||
@@ -237,12 +237,12 @@ CS_Property CS_CreateSourcePropertyCallback(
|
||||
void CS_SetSourceEnumPropertyChoices(CS_Source source, CS_Property property,
|
||||
const struct WPI_String* choices,
|
||||
int count, CS_Status* status) {
|
||||
wpi::SmallVector<std::string, 8> vec;
|
||||
wpi::util::SmallVector<std::string, 8> vec;
|
||||
vec.reserve(count);
|
||||
for (int i = 0; i < count; ++i) {
|
||||
vec.emplace_back(wpi::to_string_view(&choices[i]));
|
||||
vec.emplace_back(wpi::util::to_string_view(&choices[i]));
|
||||
}
|
||||
return cs::SetSourceEnumPropertyChoices(source, property, vec, status);
|
||||
return wpi::cs::SetSourceEnumPropertyChoices(source, property, vec, status);
|
||||
}
|
||||
|
||||
} // extern "C"
|
||||
|
||||
@@ -15,11 +15,11 @@
|
||||
|
||||
#include "SourceImpl.hpp"
|
||||
|
||||
namespace cs {
|
||||
namespace wpi::cs {
|
||||
|
||||
class ConfigurableSourceImpl : public SourceImpl {
|
||||
protected:
|
||||
ConfigurableSourceImpl(std::string_view name, wpi::Logger& logger,
|
||||
ConfigurableSourceImpl(std::string_view name, wpi::util::Logger& logger,
|
||||
Notifier& notifier, Telemetry& telemetry,
|
||||
const VideoMode& mode);
|
||||
|
||||
@@ -48,6 +48,6 @@ class ConfigurableSourceImpl : public SourceImpl {
|
||||
std::atomic_bool m_connected{true};
|
||||
};
|
||||
|
||||
} // namespace cs
|
||||
} // namespace wpi::cs
|
||||
|
||||
#endif // CSCORE_CONFIGURABLESOURCEIMPL_HPP_
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
#include "Instance.hpp"
|
||||
#include "SourceImpl.hpp"
|
||||
|
||||
using namespace cs;
|
||||
using namespace wpi::cs;
|
||||
|
||||
Frame::Frame(SourceImpl& source, std::string_view error, Time time,
|
||||
WPI_TimestampSource timeSrc)
|
||||
@@ -802,8 +802,8 @@ void Frame::ReleaseFrame() {
|
||||
m_impl = nullptr;
|
||||
}
|
||||
|
||||
namespace cs {
|
||||
std::unique_ptr<Image> CreateImageFromBGRA(cs::SourceImpl* source, size_t width,
|
||||
namespace wpi::cs {
|
||||
std::unique_ptr<Image> CreateImageFromBGRA(wpi::cs::SourceImpl* source, size_t width,
|
||||
size_t height, size_t stride,
|
||||
const uint8_t* data) {
|
||||
cv::Mat finalImage{static_cast<int>(height), static_cast<int>(width), CV_8UC4,
|
||||
@@ -813,4 +813,4 @@ std::unique_ptr<Image> CreateImageFromBGRA(cs::SourceImpl* source, size_t width,
|
||||
cv::cvtColor(finalImage, dest->AsMat(), cv::COLOR_BGRA2BGR);
|
||||
return dest;
|
||||
}
|
||||
} // namespace cs
|
||||
} // namespace wpi::cs
|
||||
|
||||
@@ -17,11 +17,11 @@
|
||||
#include "wpi/util/SmallVector.hpp"
|
||||
#include "wpi/util/mutex.hpp"
|
||||
|
||||
namespace cs {
|
||||
namespace wpi::cs {
|
||||
|
||||
class SourceImpl;
|
||||
|
||||
std::unique_ptr<Image> CreateImageFromBGRA(cs::SourceImpl* source, size_t width,
|
||||
std::unique_ptr<Image> CreateImageFromBGRA(wpi::cs::SourceImpl* source, size_t width,
|
||||
size_t height, size_t stride,
|
||||
const uint8_t* data);
|
||||
|
||||
@@ -35,13 +35,13 @@ class Frame {
|
||||
struct Impl {
|
||||
explicit Impl(SourceImpl& source_) : source(source_) {}
|
||||
|
||||
wpi::recursive_mutex mutex;
|
||||
wpi::util::recursive_mutex mutex;
|
||||
std::atomic_int refcount{0};
|
||||
Time time{0};
|
||||
WPI_TimestampSource timeSource{WPI_TIMESRC_UNKNOWN};
|
||||
SourceImpl& source;
|
||||
std::string error;
|
||||
wpi::SmallVector<Image*, 4> images;
|
||||
wpi::util::SmallVector<Image*, 4> images;
|
||||
std::vector<int> compressionParams;
|
||||
};
|
||||
|
||||
@@ -250,6 +250,6 @@ class Frame {
|
||||
Impl* m_impl{nullptr};
|
||||
};
|
||||
|
||||
} // namespace cs
|
||||
} // namespace wpi::cs
|
||||
|
||||
#endif // CSCORE_FRAME_HPP_
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
#include "wpi/cs/cscore_c.h"
|
||||
#include "wpi/util/Synchronization.h"
|
||||
|
||||
namespace cs {
|
||||
namespace wpi::cs {
|
||||
|
||||
// Handle data layout:
|
||||
// Bits 0-15: Handle index
|
||||
@@ -19,7 +19,7 @@ class Handle {
|
||||
public:
|
||||
enum Type {
|
||||
kUndefined = 0,
|
||||
kProperty = wpi::kHandleTypeCSBase,
|
||||
kProperty = wpi::util::kHandleTypeCSBase,
|
||||
kSource,
|
||||
kSink,
|
||||
kListener,
|
||||
@@ -63,6 +63,6 @@ class Handle {
|
||||
CS_Handle m_handle;
|
||||
};
|
||||
|
||||
} // namespace cs
|
||||
} // namespace wpi::cs
|
||||
|
||||
#endif // CSCORE_HANDLE_HPP_
|
||||
|
||||
@@ -22,10 +22,10 @@
|
||||
#include "wpi/util/StringExtras.hpp"
|
||||
#include "wpi/util/timestamp.h"
|
||||
|
||||
using namespace cs;
|
||||
using namespace wpi::cs;
|
||||
|
||||
HttpCameraImpl::HttpCameraImpl(std::string_view name, CS_HttpCameraKind kind,
|
||||
wpi::Logger& logger, Notifier& notifier,
|
||||
wpi::util::Logger& logger, Notifier& notifier,
|
||||
Telemetry& telemetry)
|
||||
: SourceImpl{name, logger, notifier, telemetry}, m_kind{kind} {}
|
||||
|
||||
@@ -123,8 +123,8 @@ void HttpCameraImpl::StreamThreadMain() {
|
||||
}
|
||||
|
||||
// connect
|
||||
wpi::SmallString<64> boundary;
|
||||
wpi::HttpConnection* conn = DeviceStreamConnect(boundary);
|
||||
wpi::util::SmallString<64> boundary;
|
||||
wpi::net::HttpConnection* conn = DeviceStreamConnect(boundary);
|
||||
|
||||
if (!m_active) {
|
||||
break;
|
||||
@@ -150,10 +150,10 @@ void HttpCameraImpl::StreamThreadMain() {
|
||||
SetConnected(false);
|
||||
}
|
||||
|
||||
wpi::HttpConnection* HttpCameraImpl::DeviceStreamConnect(
|
||||
wpi::SmallVectorImpl<char>& boundary) {
|
||||
wpi::net::HttpConnection* HttpCameraImpl::DeviceStreamConnect(
|
||||
wpi::util::SmallVectorImpl<char>& boundary) {
|
||||
// Build the request
|
||||
wpi::HttpRequest req;
|
||||
wpi::net::HttpRequest req;
|
||||
{
|
||||
std::scoped_lock lock(m_mutex);
|
||||
if (m_locations.empty()) {
|
||||
@@ -164,20 +164,20 @@ wpi::HttpConnection* HttpCameraImpl::DeviceStreamConnect(
|
||||
if (m_nextLocation >= m_locations.size()) {
|
||||
m_nextLocation = 0;
|
||||
}
|
||||
req = wpi::HttpRequest{m_locations[m_nextLocation++], m_streamSettings};
|
||||
req = wpi::net::HttpRequest{m_locations[m_nextLocation++], m_streamSettings};
|
||||
m_streamSettingsUpdated = false;
|
||||
}
|
||||
|
||||
// Try to connect
|
||||
auto stream =
|
||||
wpi::TCPConnector::connect(req.host.c_str(), req.port, m_logger, 1);
|
||||
wpi::net::TCPConnector::connect(req.host.c_str(), req.port, m_logger, 1);
|
||||
|
||||
if (!m_active || !stream) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
auto connPtr = std::make_unique<wpi::HttpConnection>(std::move(stream), 1);
|
||||
wpi::HttpConnection* conn = connPtr.get();
|
||||
auto connPtr = std::make_unique<wpi::net::HttpConnection>(std::move(stream), 1);
|
||||
wpi::net::HttpConnection* conn = connPtr.get();
|
||||
|
||||
// update m_streamConn
|
||||
{
|
||||
@@ -195,8 +195,8 @@ wpi::HttpConnection* HttpCameraImpl::DeviceStreamConnect(
|
||||
}
|
||||
|
||||
// Parse Content-Type header to get the boundary
|
||||
auto [mediaType, contentType] = wpi::split(conn->contentType.str(), ';');
|
||||
mediaType = wpi::trim(mediaType);
|
||||
auto [mediaType, contentType] = wpi::util::split(conn->contentType.str(), ';');
|
||||
mediaType = wpi::util::trim(mediaType);
|
||||
if (mediaType != "multipart/x-mixed-replace") {
|
||||
SWARNING("\"{}\": unrecognized Content-Type \"{}\"", req.host.str(),
|
||||
mediaType);
|
||||
@@ -209,13 +209,13 @@ wpi::HttpConnection* HttpCameraImpl::DeviceStreamConnect(
|
||||
boundary.clear();
|
||||
while (!contentType.empty()) {
|
||||
std::string_view keyvalue;
|
||||
std::tie(keyvalue, contentType) = wpi::split(contentType, ';');
|
||||
contentType = wpi::ltrim(contentType);
|
||||
auto [key, value] = wpi::split(keyvalue, '=');
|
||||
if (wpi::trim(key) == "boundary") {
|
||||
value = wpi::trim(wpi::trim(value), '"'); // value may be quoted
|
||||
if (wpi::starts_with(value, "--")) {
|
||||
value = wpi::substr(value, 2);
|
||||
std::tie(keyvalue, contentType) = wpi::util::split(contentType, ';');
|
||||
contentType = wpi::util::ltrim(contentType);
|
||||
auto [key, value] = wpi::util::split(keyvalue, '=');
|
||||
if (wpi::util::trim(key) == "boundary") {
|
||||
value = wpi::util::trim(wpi::util::trim(value), '"'); // value may be quoted
|
||||
if (wpi::util::starts_with(value, "--")) {
|
||||
value = wpi::util::substr(value, 2);
|
||||
}
|
||||
boundary.append(value.begin(), value.end());
|
||||
}
|
||||
@@ -232,7 +232,7 @@ wpi::HttpConnection* HttpCameraImpl::DeviceStreamConnect(
|
||||
return conn;
|
||||
}
|
||||
|
||||
void HttpCameraImpl::DeviceStream(wpi::raw_istream& is,
|
||||
void HttpCameraImpl::DeviceStream(wpi::util::raw_istream& is,
|
||||
std::string_view boundary) {
|
||||
// Stored here so we reuse it from frame to frame
|
||||
std::string imageBuf;
|
||||
@@ -244,7 +244,7 @@ void HttpCameraImpl::DeviceStream(wpi::raw_istream& is,
|
||||
// streaming loop
|
||||
while (m_active && !is.has_error() && IsEnabled() && numErrors < 3 &&
|
||||
!m_streamSettingsUpdated) {
|
||||
if (!FindMultipartBoundary(is, boundary, nullptr)) {
|
||||
if (!wpi::net::FindMultipartBoundary(is, boundary, nullptr)) {
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -274,29 +274,29 @@ void HttpCameraImpl::DeviceStream(wpi::raw_istream& is,
|
||||
}
|
||||
}
|
||||
|
||||
bool HttpCameraImpl::DeviceStreamFrame(wpi::raw_istream& is,
|
||||
bool HttpCameraImpl::DeviceStreamFrame(wpi::util::raw_istream& is,
|
||||
std::string& imageBuf) {
|
||||
// Read the headers
|
||||
wpi::SmallString<64> contentTypeBuf;
|
||||
wpi::SmallString<64> contentLengthBuf;
|
||||
if (!ParseHttpHeaders(is, &contentTypeBuf, &contentLengthBuf)) {
|
||||
wpi::util::SmallString<64> contentTypeBuf;
|
||||
wpi::util::SmallString<64> contentLengthBuf;
|
||||
if (!wpi::net::ParseHttpHeaders(is, &contentTypeBuf, &contentLengthBuf)) {
|
||||
SWARNING("disconnected during headers");
|
||||
PutError("disconnected during headers", wpi::Now());
|
||||
PutError("disconnected during headers", wpi::util::Now());
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check the content type (if present)
|
||||
if (!contentTypeBuf.str().empty() &&
|
||||
!wpi::starts_with(contentTypeBuf, "image/jpeg")) {
|
||||
!wpi::util::starts_with(contentTypeBuf, "image/jpeg")) {
|
||||
auto errMsg = fmt::format("received unknown Content-Type \"{}\"",
|
||||
contentTypeBuf.str());
|
||||
SWARNING("{}", errMsg);
|
||||
PutError(errMsg, wpi::Now());
|
||||
PutError(errMsg, wpi::util::Now());
|
||||
return false;
|
||||
}
|
||||
|
||||
int width, height;
|
||||
if (auto v = wpi::parse_integer<unsigned int>(contentLengthBuf, 10)) {
|
||||
if (auto v = wpi::util::parse_integer<unsigned int>(contentLengthBuf, 10)) {
|
||||
// We know how big it is! Just get a frame of the right size and read
|
||||
// the data directly into it.
|
||||
unsigned int contentLength = v.value();
|
||||
@@ -308,21 +308,21 @@ bool HttpCameraImpl::DeviceStreamFrame(wpi::raw_istream& is,
|
||||
}
|
||||
if (!GetJpegSize(image->str(), &width, &height)) {
|
||||
SWARNING("did not receive a JPEG image");
|
||||
PutError("did not receive a JPEG image", wpi::Now());
|
||||
PutError("did not receive a JPEG image", wpi::util::Now());
|
||||
return false;
|
||||
}
|
||||
image->width = width;
|
||||
image->height = height;
|
||||
PutFrame(std::move(image), wpi::Now());
|
||||
PutFrame(std::move(image), wpi::util::Now());
|
||||
} else {
|
||||
// Ugh, no Content-Length? Read the blocks of the JPEG file.
|
||||
if (!ReadJpeg(is, imageBuf, &width, &height)) {
|
||||
SWARNING("did not receive a JPEG image");
|
||||
PutError("did not receive a JPEG image", wpi::Now());
|
||||
PutError("did not receive a JPEG image", wpi::util::Now());
|
||||
return false;
|
||||
}
|
||||
PutFrame(VideoMode::PixelFormat::kMJPEG, width, height, imageBuf,
|
||||
wpi::Now());
|
||||
wpi::util::Now());
|
||||
}
|
||||
|
||||
++m_frameCount;
|
||||
@@ -340,7 +340,7 @@ bool HttpCameraImpl::DeviceStreamFrame(wpi::raw_istream& is,
|
||||
|
||||
void HttpCameraImpl::SettingsThreadMain() {
|
||||
for (;;) {
|
||||
wpi::HttpRequest req;
|
||||
wpi::net::HttpRequest req;
|
||||
{
|
||||
std::unique_lock lock(m_mutex);
|
||||
m_settingsCond.wait(lock, [=, this] {
|
||||
@@ -351,7 +351,7 @@ void HttpCameraImpl::SettingsThreadMain() {
|
||||
}
|
||||
|
||||
// Build the request
|
||||
req = wpi::HttpRequest{m_locations[m_prefLocation], m_settings};
|
||||
req = wpi::net::HttpRequest{m_locations[m_prefLocation], m_settings};
|
||||
}
|
||||
|
||||
DeviceSendSettings(req);
|
||||
@@ -360,17 +360,17 @@ void HttpCameraImpl::SettingsThreadMain() {
|
||||
SDEBUG("Settings Thread exiting");
|
||||
}
|
||||
|
||||
void HttpCameraImpl::DeviceSendSettings(wpi::HttpRequest& req) {
|
||||
void HttpCameraImpl::DeviceSendSettings(wpi::net::HttpRequest& req) {
|
||||
// Try to connect
|
||||
auto stream =
|
||||
wpi::TCPConnector::connect(req.host.c_str(), req.port, m_logger, 1);
|
||||
wpi::net::TCPConnector::connect(req.host.c_str(), req.port, m_logger, 1);
|
||||
|
||||
if (!m_active || !stream) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto connPtr = std::make_unique<wpi::HttpConnection>(std::move(stream), 1);
|
||||
wpi::HttpConnection* conn = connPtr.get();
|
||||
auto connPtr = std::make_unique<wpi::net::HttpConnection>(std::move(stream), 1);
|
||||
wpi::net::HttpConnection* conn = connPtr.get();
|
||||
|
||||
// update m_settingsConn
|
||||
{
|
||||
@@ -394,7 +394,7 @@ CS_HttpCameraKind HttpCameraImpl::GetKind() const {
|
||||
|
||||
bool HttpCameraImpl::SetUrls(std::span<const std::string> urls,
|
||||
CS_Status* status) {
|
||||
std::vector<wpi::HttpLocation> locations;
|
||||
std::vector<wpi::net::HttpLocation> locations;
|
||||
for (const auto& url : urls) {
|
||||
bool error = false;
|
||||
std::string errorMsg;
|
||||
@@ -573,7 +573,7 @@ bool AxisCameraImpl::CacheProperties(CS_Status* status) const {
|
||||
return true;
|
||||
}
|
||||
|
||||
namespace cs {
|
||||
namespace wpi::cs {
|
||||
|
||||
CS_Source CreateHttpCamera(std::string_view name, std::string_view url,
|
||||
CS_HttpCameraKind kind, CS_Status* status) {
|
||||
@@ -645,49 +645,49 @@ std::vector<std::string> GetHttpCameraUrls(CS_Source source,
|
||||
return static_cast<HttpCameraImpl&>(*data->source).GetUrls();
|
||||
}
|
||||
|
||||
} // namespace cs
|
||||
} // namespace wpi::cs
|
||||
|
||||
extern "C" {
|
||||
|
||||
CS_Source CS_CreateHttpCamera(const struct WPI_String* name,
|
||||
const struct WPI_String* url,
|
||||
CS_HttpCameraKind kind, CS_Status* status) {
|
||||
return cs::CreateHttpCamera(wpi::to_string_view(name),
|
||||
wpi::to_string_view(url), kind, status);
|
||||
return wpi::cs::CreateHttpCamera(wpi::util::to_string_view(name),
|
||||
wpi::util::to_string_view(url), kind, status);
|
||||
}
|
||||
|
||||
CS_Source CS_CreateHttpCameraMulti(const struct WPI_String* name,
|
||||
const struct WPI_String* urls, int count,
|
||||
CS_HttpCameraKind kind, CS_Status* status) {
|
||||
wpi::SmallVector<std::string, 4> vec;
|
||||
wpi::util::SmallVector<std::string, 4> vec;
|
||||
vec.reserve(count);
|
||||
for (int i = 0; i < count; ++i) {
|
||||
vec.emplace_back(wpi::to_string_view(&urls[i]));
|
||||
vec.emplace_back(wpi::util::to_string_view(&urls[i]));
|
||||
}
|
||||
return cs::CreateHttpCamera(wpi::to_string_view(name), vec, kind, status);
|
||||
return wpi::cs::CreateHttpCamera(wpi::util::to_string_view(name), vec, kind, status);
|
||||
}
|
||||
|
||||
CS_HttpCameraKind CS_GetHttpCameraKind(CS_Source source, CS_Status* status) {
|
||||
return cs::GetHttpCameraKind(source, status);
|
||||
return wpi::cs::GetHttpCameraKind(source, status);
|
||||
}
|
||||
|
||||
void CS_SetHttpCameraUrls(CS_Source source, const struct WPI_String* urls,
|
||||
int count, CS_Status* status) {
|
||||
wpi::SmallVector<std::string, 4> vec;
|
||||
wpi::util::SmallVector<std::string, 4> vec;
|
||||
vec.reserve(count);
|
||||
for (int i = 0; i < count; ++i) {
|
||||
vec.emplace_back(wpi::to_string_view(&urls[i]));
|
||||
vec.emplace_back(wpi::util::to_string_view(&urls[i]));
|
||||
}
|
||||
cs::SetHttpCameraUrls(source, vec, status);
|
||||
wpi::cs::SetHttpCameraUrls(source, vec, status);
|
||||
}
|
||||
|
||||
WPI_String* CS_GetHttpCameraUrls(CS_Source source, int* count,
|
||||
CS_Status* status) {
|
||||
auto urls = cs::GetHttpCameraUrls(source, status);
|
||||
auto urls = wpi::cs::GetHttpCameraUrls(source, status);
|
||||
WPI_String* out = WPI_AllocateStringArray(urls.size());
|
||||
*count = urls.size();
|
||||
for (size_t i = 0; i < urls.size(); ++i) {
|
||||
cs::ConvertToC(&out[i], urls[i]);
|
||||
wpi::cs::ConvertToC(&out[i], urls[i]);
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
@@ -23,12 +23,12 @@
|
||||
#include "wpi/util/condition_variable.hpp"
|
||||
#include "wpi/util/raw_istream.hpp"
|
||||
|
||||
namespace cs {
|
||||
namespace wpi::cs {
|
||||
|
||||
class HttpCameraImpl : public SourceImpl {
|
||||
public:
|
||||
HttpCameraImpl(std::string_view name, CS_HttpCameraKind kind,
|
||||
wpi::Logger& logger, Notifier& notifier, Telemetry& telemetry);
|
||||
wpi::util::Logger& logger, Notifier& notifier, Telemetry& telemetry);
|
||||
~HttpCameraImpl() override;
|
||||
|
||||
void Start() override;
|
||||
@@ -99,14 +99,14 @@ class HttpCameraImpl : public SourceImpl {
|
||||
void StreamThreadMain();
|
||||
|
||||
// Functions used by StreamThreadMain()
|
||||
wpi::HttpConnection* DeviceStreamConnect(
|
||||
wpi::SmallVectorImpl<char>& boundary);
|
||||
void DeviceStream(wpi::raw_istream& is, std::string_view boundary);
|
||||
bool DeviceStreamFrame(wpi::raw_istream& is, std::string& imageBuf);
|
||||
wpi::net::HttpConnection* DeviceStreamConnect(
|
||||
wpi::util::SmallVectorImpl<char>& boundary);
|
||||
void DeviceStream(wpi::util::raw_istream& is, std::string_view boundary);
|
||||
bool DeviceStreamFrame(wpi::util::raw_istream& is, std::string& imageBuf);
|
||||
|
||||
// The camera settings thread
|
||||
void SettingsThreadMain();
|
||||
void DeviceSendSettings(wpi::HttpRequest& req);
|
||||
void DeviceSendSettings(wpi::net::HttpRequest& req);
|
||||
|
||||
// The monitor thread
|
||||
void MonitorThreadMain();
|
||||
@@ -122,31 +122,31 @@ class HttpCameraImpl : public SourceImpl {
|
||||
//
|
||||
|
||||
// The camera connections
|
||||
std::unique_ptr<wpi::HttpConnection> m_streamConn;
|
||||
std::unique_ptr<wpi::HttpConnection> m_settingsConn;
|
||||
std::unique_ptr<wpi::net::HttpConnection> m_streamConn;
|
||||
std::unique_ptr<wpi::net::HttpConnection> m_settingsConn;
|
||||
|
||||
CS_HttpCameraKind m_kind;
|
||||
|
||||
std::vector<wpi::HttpLocation> m_locations;
|
||||
std::vector<wpi::net::HttpLocation> m_locations;
|
||||
size_t m_nextLocation{0};
|
||||
int m_prefLocation{-1}; // preferred location
|
||||
|
||||
std::atomic_int m_frameCount{0};
|
||||
|
||||
wpi::condition_variable m_sinkEnabledCond;
|
||||
wpi::util::condition_variable m_sinkEnabledCond;
|
||||
|
||||
wpi::StringMap<std::string> m_settings;
|
||||
wpi::condition_variable m_settingsCond;
|
||||
wpi::util::StringMap<std::string> m_settings;
|
||||
wpi::util::condition_variable m_settingsCond;
|
||||
|
||||
wpi::StringMap<std::string> m_streamSettings;
|
||||
wpi::util::StringMap<std::string> m_streamSettings;
|
||||
std::atomic_bool m_streamSettingsUpdated{false};
|
||||
|
||||
wpi::condition_variable m_monitorCond;
|
||||
wpi::util::condition_variable m_monitorCond;
|
||||
};
|
||||
|
||||
class AxisCameraImpl : public HttpCameraImpl {
|
||||
public:
|
||||
AxisCameraImpl(std::string_view name, wpi::Logger& logger, Notifier& notifier,
|
||||
AxisCameraImpl(std::string_view name, wpi::util::Logger& logger, Notifier& notifier,
|
||||
Telemetry& telemetry)
|
||||
: HttpCameraImpl{name, CS_HTTP_AXIS, logger, notifier, telemetry} {}
|
||||
#if 0
|
||||
@@ -158,6 +158,6 @@ class AxisCameraImpl : public HttpCameraImpl {
|
||||
bool CacheProperties(CS_Status* status) const override;
|
||||
};
|
||||
|
||||
} // namespace cs
|
||||
} // namespace wpi::cs
|
||||
|
||||
#endif // CSCORE_HTTPCAMERAIMPL_HPP_
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
#include "default_init_allocator.hpp"
|
||||
#include "wpi/cs/cscore_cpp.hpp"
|
||||
|
||||
namespace cs {
|
||||
namespace wpi::cs {
|
||||
|
||||
class Frame;
|
||||
|
||||
@@ -129,6 +129,6 @@ class Image {
|
||||
int jpegQuality{-1};
|
||||
};
|
||||
|
||||
} // namespace cs
|
||||
} // namespace wpi::cs
|
||||
|
||||
#endif // CSCORE_IMAGE_HPP_
|
||||
|
||||
@@ -13,12 +13,12 @@
|
||||
#include "wpi/util/fs.hpp"
|
||||
#include "wpi/util/print.hpp"
|
||||
|
||||
using namespace cs;
|
||||
using namespace wpi::cs;
|
||||
|
||||
static void def_log_func(unsigned int level, const char* file,
|
||||
unsigned int line, const char* msg) {
|
||||
if (level == 20) {
|
||||
wpi::print(stderr, "CS: {}\n", msg);
|
||||
wpi::util::print(stderr, "CS: {}\n", msg);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ static void def_log_func(unsigned int level, const char* file,
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
wpi::print(stderr, "CS: {}: {} ({}:{})\n", levelmsg, msg,
|
||||
wpi::util::print(stderr, "CS: {}: {} ({}:{})\n", levelmsg, msg,
|
||||
// NOLINTNEXTLINE(build/include_what_you_use)
|
||||
fs::path{file}.filename().string(), line);
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
#include "UsbCameraListener.hpp"
|
||||
#include "wpi/util/Logger.hpp"
|
||||
|
||||
namespace cs {
|
||||
namespace wpi::cs {
|
||||
|
||||
struct SourceData {
|
||||
SourceData(CS_SourceKind kind_, std::shared_ptr<SourceImpl> source_)
|
||||
@@ -51,7 +51,7 @@ class Instance {
|
||||
|
||||
void Shutdown();
|
||||
|
||||
wpi::Logger logger;
|
||||
wpi::util::Logger logger;
|
||||
Notifier notifier;
|
||||
Telemetry telemetry;
|
||||
NetworkListener networkListener;
|
||||
@@ -62,7 +62,7 @@ class Instance {
|
||||
UnlimitedHandleResource<Handle, SinkData, Handle::kSink> m_sinks;
|
||||
|
||||
public:
|
||||
wpi::EventLoopRunner eventLoop;
|
||||
wpi::net::EventLoopRunner eventLoop;
|
||||
|
||||
std::pair<CS_Sink, std::shared_ptr<SinkData>> FindSink(const SinkImpl& sink);
|
||||
std::pair<CS_Source, std::shared_ptr<SourceData>> FindSource(
|
||||
@@ -87,16 +87,16 @@ class Instance {
|
||||
void DestroySink(CS_Sink handle);
|
||||
|
||||
std::span<CS_Source> EnumerateSourceHandles(
|
||||
wpi::SmallVectorImpl<CS_Source>& vec) {
|
||||
wpi::util::SmallVectorImpl<CS_Source>& vec) {
|
||||
return m_sources.GetAll(vec);
|
||||
}
|
||||
|
||||
std::span<CS_Sink> EnumerateSinkHandles(wpi::SmallVectorImpl<CS_Sink>& vec) {
|
||||
std::span<CS_Sink> EnumerateSinkHandles(wpi::util::SmallVectorImpl<CS_Sink>& vec) {
|
||||
return m_sinks.GetAll(vec);
|
||||
}
|
||||
|
||||
std::span<CS_Sink> EnumerateSourceSinks(CS_Source source,
|
||||
wpi::SmallVectorImpl<CS_Sink>& vec) {
|
||||
wpi::util::SmallVectorImpl<CS_Sink>& vec) {
|
||||
vec.clear();
|
||||
m_sinks.ForEach([&](CS_Sink sinkHandle, const SinkData& data) {
|
||||
if (source == data.sourceHandle.load()) {
|
||||
@@ -110,6 +110,6 @@ class Instance {
|
||||
Instance();
|
||||
};
|
||||
|
||||
} // namespace cs
|
||||
} // namespace wpi::cs
|
||||
|
||||
#endif // CSCORE_INSTANCE_HPP_
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#include "wpi/util/StringExtras.hpp"
|
||||
#include "wpi/util/raw_istream.hpp"
|
||||
|
||||
namespace cs {
|
||||
namespace wpi::cs {
|
||||
|
||||
// DHT data for MJPEG images that don't have it.
|
||||
static const unsigned char dhtData[] = {
|
||||
@@ -67,7 +67,7 @@ bool GetJpegSize(std::string_view data, int* width, int* height) {
|
||||
return false;
|
||||
}
|
||||
|
||||
data = wpi::substr(data, 2); // Get to the first block
|
||||
data = wpi::util::substr(data, 2); // Get to the first block
|
||||
for (;;) {
|
||||
if (data.size() < 4) {
|
||||
return false; // EOF
|
||||
@@ -92,7 +92,7 @@ bool GetJpegSize(std::string_view data, int* width, int* height) {
|
||||
return true;
|
||||
}
|
||||
// Go to the next block
|
||||
data = wpi::substr(data, bytes[2] * 256 + bytes[3] + 2);
|
||||
data = wpi::util::substr(data, bytes[2] * 256 + bytes[3] + 2);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -105,7 +105,7 @@ bool JpegNeedsDHT(const char* data, size_t* size, size_t* locSOF) {
|
||||
*locSOF = *size;
|
||||
|
||||
// Search until SOS for DHT tag
|
||||
sdata = wpi::substr(sdata, 2); // Get to the first block
|
||||
sdata = wpi::util::substr(sdata, 2); // Get to the first block
|
||||
for (;;) {
|
||||
if (sdata.size() < 4) {
|
||||
return false; // EOF
|
||||
@@ -124,7 +124,7 @@ bool JpegNeedsDHT(const char* data, size_t* size, size_t* locSOF) {
|
||||
*locSOF = sdata.data() - data; // SOF
|
||||
}
|
||||
// Go to the next block
|
||||
sdata = wpi::substr(sdata, bytes[2] * 256 + bytes[3] + 2);
|
||||
sdata = wpi::util::substr(sdata, bytes[2] * 256 + bytes[3] + 2);
|
||||
}
|
||||
|
||||
// Only add DHT if we also found SOF (insertion point)
|
||||
@@ -139,14 +139,14 @@ std::string_view JpegGetDHT() {
|
||||
return {reinterpret_cast<const char*>(dhtData), sizeof(dhtData)};
|
||||
}
|
||||
|
||||
static inline void ReadInto(wpi::raw_istream& is, std::string& buf,
|
||||
static inline void ReadInto(wpi::util::raw_istream& is, std::string& buf,
|
||||
size_t len) {
|
||||
size_t oldSize = buf.size();
|
||||
buf.resize(oldSize + len);
|
||||
is.read(&(*buf.begin()) + oldSize, len);
|
||||
}
|
||||
|
||||
bool ReadJpeg(wpi::raw_istream& is, std::string& buf, int* width, int* height) {
|
||||
bool ReadJpeg(wpi::util::raw_istream& is, std::string& buf, int* width, int* height) {
|
||||
// in case we don't get a SOF
|
||||
*width = 0;
|
||||
*height = 0;
|
||||
@@ -234,4 +234,4 @@ bool ReadJpeg(wpi::raw_istream& is, std::string& buf, int* width, int* height) {
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace cs
|
||||
} // namespace wpi::cs
|
||||
|
||||
@@ -8,11 +8,11 @@
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
|
||||
namespace wpi {
|
||||
namespace wpi::util {
|
||||
class raw_istream;
|
||||
} // namespace wpi
|
||||
|
||||
namespace cs {
|
||||
namespace wpi::cs {
|
||||
|
||||
bool IsJpeg(std::string_view data);
|
||||
|
||||
@@ -22,8 +22,8 @@ bool JpegNeedsDHT(const char* data, size_t* size, size_t* locSOF);
|
||||
|
||||
std::string_view JpegGetDHT();
|
||||
|
||||
bool ReadJpeg(wpi::raw_istream& is, std::string& buf, int* width, int* height);
|
||||
bool ReadJpeg(wpi::util::raw_istream& is, std::string& buf, int* width, int* height);
|
||||
|
||||
} // namespace cs
|
||||
} // namespace wpi::cs
|
||||
|
||||
#endif // CSCORE_JPEGUTIL_HPP_
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
#include "Log.hpp"
|
||||
|
||||
void cs::NamedLogV(wpi::Logger& logger, unsigned int level, const char* file,
|
||||
void wpi::cs::NamedLogV(wpi::util::Logger& logger, unsigned int level, const char* file,
|
||||
unsigned int line, std::string_view name,
|
||||
fmt::string_view format, fmt::format_args args) {
|
||||
fmt::memory_buffer out;
|
||||
|
||||
@@ -9,14 +9,14 @@
|
||||
|
||||
#include "wpi/util/Logger.hpp"
|
||||
|
||||
namespace cs {
|
||||
namespace wpi::cs {
|
||||
|
||||
void NamedLogV(wpi::Logger& logger, unsigned int level, const char* file,
|
||||
void NamedLogV(wpi::util::Logger& logger, unsigned int level, const char* file,
|
||||
unsigned int line, std::string_view name,
|
||||
fmt::string_view format, fmt::format_args args);
|
||||
|
||||
template <typename S, typename... Args>
|
||||
inline void NamedLog(wpi::Logger& logger, unsigned int level, const char* file,
|
||||
inline void NamedLog(wpi::util::Logger& logger, unsigned int level, const char* file,
|
||||
unsigned int line, std::string_view name, const S& format,
|
||||
Args&&... args) {
|
||||
if (logger.HasLogger() && level >= logger.min_level()) {
|
||||
@@ -25,7 +25,7 @@ inline void NamedLog(wpi::Logger& logger, unsigned int level, const char* file,
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace cs
|
||||
} // namespace wpi::cs
|
||||
|
||||
#define LOG(level, format, ...) \
|
||||
WPI_LOG(m_logger, level, format __VA_OPT__(, ) __VA_ARGS__)
|
||||
@@ -53,11 +53,11 @@ inline void NamedLog(wpi::Logger& logger, unsigned int level, const char* file,
|
||||
format __VA_OPT__(, ) __VA_ARGS__)
|
||||
|
||||
#define SERROR(format, ...) \
|
||||
SLOG(::wpi::WPI_LOG_ERROR, format __VA_OPT__(, ) __VA_ARGS__)
|
||||
SLOG(::wpi::util::WPI_LOG_ERROR, format __VA_OPT__(, ) __VA_ARGS__)
|
||||
#define SWARNING(format, ...) \
|
||||
SLOG(::wpi::WPI_LOG_WARNING, format __VA_OPT__(, ) __VA_ARGS__)
|
||||
SLOG(::wpi::util::WPI_LOG_WARNING, format __VA_OPT__(, ) __VA_ARGS__)
|
||||
#define SINFO(format, ...) \
|
||||
SLOG(::wpi::WPI_LOG_INFO, format __VA_OPT__(, ) __VA_ARGS__)
|
||||
SLOG(::wpi::util::WPI_LOG_INFO, format __VA_OPT__(, ) __VA_ARGS__)
|
||||
|
||||
#ifdef NDEBUG
|
||||
#define SDEBUG(format, ...) \
|
||||
@@ -77,15 +77,15 @@ inline void NamedLog(wpi::Logger& logger, unsigned int level, const char* file,
|
||||
} while (0)
|
||||
#else
|
||||
#define SDEBUG(format, ...) \
|
||||
SLOG(::wpi::WPI_LOG_DEBUG, format __VA_OPT__(, ) __VA_ARGS__)
|
||||
SLOG(::wpi::util::WPI_LOG_DEBUG, format __VA_OPT__(, ) __VA_ARGS__)
|
||||
#define SDEBUG1(format, ...) \
|
||||
SLOG(::wpi::WPI_LOG_DEBUG1, format __VA_OPT__(, ) __VA_ARGS__)
|
||||
SLOG(::wpi::util::WPI_LOG_DEBUG1, format __VA_OPT__(, ) __VA_ARGS__)
|
||||
#define SDEBUG2(format, ...) \
|
||||
SLOG(::wpi::WPI_LOG_DEBUG2, format __VA_OPT__(, ) __VA_ARGS__)
|
||||
SLOG(::wpi::util::WPI_LOG_DEBUG2, format __VA_OPT__(, ) __VA_ARGS__)
|
||||
#define SDEBUG3(format, ...) \
|
||||
SLOG(::wpi::WPI_LOG_DEBUG3, format __VA_OPT__(, ) __VA_ARGS__)
|
||||
SLOG(::wpi::util::WPI_LOG_DEBUG3, format __VA_OPT__(, ) __VA_ARGS__)
|
||||
#define SDEBUG4(format, ...) \
|
||||
SLOG(::wpi::WPI_LOG_DEBUG4, format __VA_OPT__(, ) __VA_ARGS__)
|
||||
SLOG(::wpi::util::WPI_LOG_DEBUG4, format __VA_OPT__(, ) __VA_ARGS__)
|
||||
#endif
|
||||
|
||||
#endif // CSCORE_LOG_HPP_
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
#include "wpi/util/fmt/raw_ostream.hpp"
|
||||
#include "wpi/util/print.hpp"
|
||||
|
||||
using namespace cs;
|
||||
using namespace wpi::cs;
|
||||
|
||||
// The boundary used for the M-JPEG stream.
|
||||
// It separates the multipart stream of pictures
|
||||
@@ -75,22 +75,22 @@ static const char* startRootPage =
|
||||
"<div class=\"settings\">\n";
|
||||
static const char* endRootPage = "</div></body></html>";
|
||||
|
||||
class MjpegServerImpl::ConnThread : public wpi::SafeThread {
|
||||
class MjpegServerImpl::ConnThread : public wpi::util::SafeThread {
|
||||
public:
|
||||
explicit ConnThread(std::string_view name, wpi::Logger& logger)
|
||||
explicit ConnThread(std::string_view name, wpi::util::Logger& logger)
|
||||
: m_name(name), m_logger(logger) {}
|
||||
|
||||
void Main() override;
|
||||
|
||||
bool ProcessCommand(wpi::raw_ostream& os, SourceImpl& source,
|
||||
bool ProcessCommand(wpi::util::raw_ostream& os, SourceImpl& source,
|
||||
std::string_view parameters, bool respond);
|
||||
void SendJSON(wpi::raw_ostream& os, SourceImpl& source, bool header);
|
||||
void SendHTMLHeadTitle(wpi::raw_ostream& os) const;
|
||||
void SendHTML(wpi::raw_ostream& os, SourceImpl& source, bool header);
|
||||
void SendStream(wpi::raw_socket_ostream& os);
|
||||
void SendJSON(wpi::util::raw_ostream& os, SourceImpl& source, bool header);
|
||||
void SendHTMLHeadTitle(wpi::util::raw_ostream& os) const;
|
||||
void SendHTML(wpi::util::raw_ostream& os, SourceImpl& source, bool header);
|
||||
void SendStream(wpi::net::raw_socket_ostream& os);
|
||||
void ProcessRequest();
|
||||
|
||||
std::unique_ptr<wpi::NetworkStream> m_stream;
|
||||
std::unique_ptr<wpi::net::NetworkStream> m_stream;
|
||||
std::shared_ptr<SourceImpl> m_source;
|
||||
bool m_streaming = false;
|
||||
bool m_noStreaming = false;
|
||||
@@ -102,7 +102,7 @@ class MjpegServerImpl::ConnThread : public wpi::SafeThread {
|
||||
|
||||
private:
|
||||
std::string m_name;
|
||||
wpi::Logger& m_logger;
|
||||
wpi::util::Logger& m_logger;
|
||||
|
||||
std::string_view GetName() { return m_name; }
|
||||
|
||||
@@ -134,10 +134,10 @@ class MjpegServerImpl::ConnThread : public wpi::SafeThread {
|
||||
// A browser should connect for each file and not serve files from its cache.
|
||||
// Using cached pictures would lead to showing old/outdated pictures.
|
||||
// Many browsers seem to ignore, or at least not always obey, those headers.
|
||||
static void SendHeader(wpi::raw_ostream& os, int code,
|
||||
static void SendHeader(wpi::util::raw_ostream& os, int code,
|
||||
std::string_view codeText, std::string_view contentType,
|
||||
std::string_view extra = {}) {
|
||||
wpi::print(os, "HTTP/1.0 {} {}\r\n", code, codeText);
|
||||
wpi::util::print(os, "HTTP/1.0 {} {}\r\n", code, codeText);
|
||||
os << "Connection: close\r\n"
|
||||
"Server: CameraServer/1.0\r\n"
|
||||
"Cache-Control: no-store, no-cache, must-revalidate, pre-check=0, "
|
||||
@@ -155,7 +155,7 @@ static void SendHeader(wpi::raw_ostream& os, int code,
|
||||
// Send error header and message
|
||||
// @param code HTTP error code (e.g. 404)
|
||||
// @param message Additional message text
|
||||
static void SendError(wpi::raw_ostream& os, int code,
|
||||
static void SendError(wpi::util::raw_ostream& os, int code,
|
||||
std::string_view message) {
|
||||
std::string_view codeText, extra, baseMessage;
|
||||
switch (code) {
|
||||
@@ -195,21 +195,21 @@ static void SendError(wpi::raw_ostream& os, int code,
|
||||
}
|
||||
|
||||
// Perform a command specified by HTTP GET parameters.
|
||||
bool MjpegServerImpl::ConnThread::ProcessCommand(wpi::raw_ostream& os,
|
||||
bool MjpegServerImpl::ConnThread::ProcessCommand(wpi::util::raw_ostream& os,
|
||||
SourceImpl& source,
|
||||
std::string_view parameters,
|
||||
bool respond) {
|
||||
wpi::SmallString<256> responseBuf;
|
||||
wpi::raw_svector_ostream response{responseBuf};
|
||||
wpi::util::SmallString<256> responseBuf;
|
||||
wpi::util::raw_svector_ostream response{responseBuf};
|
||||
// command format: param1=value1¶m2=value2...
|
||||
while (!parameters.empty()) {
|
||||
// split out next param and value
|
||||
std::string_view rawParam, rawValue;
|
||||
std::tie(rawParam, parameters) = wpi::split(parameters, '&');
|
||||
std::tie(rawParam, parameters) = wpi::util::split(parameters, '&');
|
||||
if (rawParam.empty()) {
|
||||
continue; // ignore "&&"
|
||||
}
|
||||
std::tie(rawParam, rawValue) = wpi::split(rawParam, '=');
|
||||
std::tie(rawParam, rawValue) = wpi::util::split(rawParam, '=');
|
||||
if (rawParam.empty() || rawValue.empty()) {
|
||||
continue; // ignore "param="
|
||||
}
|
||||
@@ -217,8 +217,8 @@ bool MjpegServerImpl::ConnThread::ProcessCommand(wpi::raw_ostream& os,
|
||||
|
||||
// unescape param
|
||||
bool error = false;
|
||||
wpi::SmallString<64> paramBuf;
|
||||
std::string_view param = wpi::UnescapeURI(rawParam, paramBuf, &error);
|
||||
wpi::util::SmallString<64> paramBuf;
|
||||
std::string_view param = wpi::net::UnescapeURI(rawParam, paramBuf, &error);
|
||||
if (error) {
|
||||
auto estr = fmt::format("could not unescape parameter \"{}\"", rawParam);
|
||||
SendError(os, 500, estr);
|
||||
@@ -227,8 +227,8 @@ bool MjpegServerImpl::ConnThread::ProcessCommand(wpi::raw_ostream& os,
|
||||
}
|
||||
|
||||
// unescape value
|
||||
wpi::SmallString<64> valueBuf;
|
||||
std::string_view value = wpi::UnescapeURI(rawValue, valueBuf, &error);
|
||||
wpi::util::SmallString<64> valueBuf;
|
||||
std::string_view value = wpi::net::UnescapeURI(rawValue, valueBuf, &error);
|
||||
if (error) {
|
||||
auto estr = fmt::format("could not unescape value \"{}\"", rawValue);
|
||||
SendError(os, 500, estr);
|
||||
@@ -239,9 +239,9 @@ bool MjpegServerImpl::ConnThread::ProcessCommand(wpi::raw_ostream& os,
|
||||
// Handle resolution, compression, and FPS. These are handled locally
|
||||
// rather than passed to the source.
|
||||
if (param == "resolution") {
|
||||
auto [widthStr, heightStr] = wpi::split(value, 'x');
|
||||
int width = wpi::parse_integer<int>(widthStr, 10).value_or(-1);
|
||||
int height = wpi::parse_integer<int>(heightStr, 10).value_or(-1);
|
||||
auto [widthStr, heightStr] = wpi::util::split(value, 'x');
|
||||
int width = wpi::util::parse_integer<int>(widthStr, 10).value_or(-1);
|
||||
int height = wpi::util::parse_integer<int>(heightStr, 10).value_or(-1);
|
||||
if (width < 0) {
|
||||
response << param << ": \"width is not an integer\"\r\n";
|
||||
SWARNING("HTTP parameter \"{}\" width \"{}\" is not an integer", param,
|
||||
@@ -261,7 +261,7 @@ bool MjpegServerImpl::ConnThread::ProcessCommand(wpi::raw_ostream& os,
|
||||
}
|
||||
|
||||
if (param == "fps") {
|
||||
if (auto v = wpi::parse_integer<int>(value, 10)) {
|
||||
if (auto v = wpi::util::parse_integer<int>(value, 10)) {
|
||||
m_fps = v.value();
|
||||
response << param << ": \"ok\"\r\n";
|
||||
} else {
|
||||
@@ -273,7 +273,7 @@ bool MjpegServerImpl::ConnThread::ProcessCommand(wpi::raw_ostream& os,
|
||||
}
|
||||
|
||||
if (param == "compression") {
|
||||
if (auto v = wpi::parse_integer<int>(value, 10)) {
|
||||
if (auto v = wpi::util::parse_integer<int>(value, 10)) {
|
||||
m_compression = v.value();
|
||||
response << param << ": \"ok\"\r\n";
|
||||
} else {
|
||||
@@ -303,8 +303,8 @@ bool MjpegServerImpl::ConnThread::ProcessCommand(wpi::raw_ostream& os,
|
||||
case CS_PROP_BOOLEAN:
|
||||
case CS_PROP_INTEGER:
|
||||
case CS_PROP_ENUM: {
|
||||
if (auto v = wpi::parse_integer<int>(value, 10)) {
|
||||
wpi::print(response, "{}: {}\r\n", param, v.value());
|
||||
if (auto v = wpi::util::parse_integer<int>(value, 10)) {
|
||||
wpi::util::print(response, "{}: {}\r\n", param, v.value());
|
||||
SDEBUG4("HTTP parameter \"{}\" value {}", param, value);
|
||||
source.SetProperty(prop, v.value(), &status);
|
||||
} else {
|
||||
@@ -335,13 +335,13 @@ bool MjpegServerImpl::ConnThread::ProcessCommand(wpi::raw_ostream& os,
|
||||
}
|
||||
|
||||
void MjpegServerImpl::ConnThread::SendHTMLHeadTitle(
|
||||
wpi::raw_ostream& os) const {
|
||||
wpi::util::raw_ostream& os) const {
|
||||
os << "<html><head><title>" << m_name << " CameraServer</title>"
|
||||
<< "<meta charset=\"UTF-8\">";
|
||||
}
|
||||
|
||||
// Send the root html file with controls for all the settable properties.
|
||||
void MjpegServerImpl::ConnThread::SendHTML(wpi::raw_ostream& os,
|
||||
void MjpegServerImpl::ConnThread::SendHTML(wpi::util::raw_ostream& os,
|
||||
SourceImpl& source, bool header) {
|
||||
if (header) {
|
||||
SendHeader(os, 200, "OK", "text/html");
|
||||
@@ -349,19 +349,19 @@ void MjpegServerImpl::ConnThread::SendHTML(wpi::raw_ostream& os,
|
||||
|
||||
SendHTMLHeadTitle(os);
|
||||
os << startRootPage;
|
||||
wpi::SmallVector<int, 32> properties_vec;
|
||||
wpi::util::SmallVector<int, 32> properties_vec;
|
||||
CS_Status status = 0;
|
||||
for (auto prop : source.EnumerateProperties(properties_vec, &status)) {
|
||||
wpi::SmallString<128> name_buf;
|
||||
wpi::util::SmallString<128> name_buf;
|
||||
auto name = source.GetPropertyName(prop, name_buf, &status);
|
||||
if (wpi::starts_with(name, "raw_")) {
|
||||
if (wpi::util::starts_with(name, "raw_")) {
|
||||
continue;
|
||||
}
|
||||
auto kind = source.GetPropertyKind(prop);
|
||||
wpi::print(os, "<p /><label for=\"{0}\">{0}</label>\n", name);
|
||||
wpi::util::print(os, "<p /><label for=\"{0}\">{0}</label>\n", name);
|
||||
switch (kind) {
|
||||
case CS_PROP_BOOLEAN:
|
||||
wpi::print(os,
|
||||
wpi::util::print(os,
|
||||
"<input id=\"{0}\" type=\"checkbox\" "
|
||||
"onclick=\"update('{0}', this.checked ? 1 : 0)\" ",
|
||||
name);
|
||||
@@ -376,12 +376,12 @@ void MjpegServerImpl::ConnThread::SendHTML(wpi::raw_ostream& os,
|
||||
auto min = source.GetPropertyMin(prop, &status);
|
||||
auto max = source.GetPropertyMax(prop, &status);
|
||||
auto step = source.GetPropertyStep(prop, &status);
|
||||
wpi::print(os,
|
||||
wpi::util::print(os,
|
||||
"<input type=\"range\" min=\"{1}\" max=\"{2}\" "
|
||||
"value=\"{3}\" id=\"{0}\" step=\"{4}\" "
|
||||
"oninput=\"updateInt('#{0}op', '{0}', value)\" />\n",
|
||||
name, min, max, valI, step);
|
||||
wpi::print(os, "<output for=\"{0}\" id=\"{0}op\">{1}</output>\n", name,
|
||||
wpi::util::print(os, "<output for=\"{0}\" id=\"{0}op\">{1}</output>\n", name,
|
||||
valI);
|
||||
break;
|
||||
}
|
||||
@@ -395,29 +395,29 @@ void MjpegServerImpl::ConnThread::SendHTML(wpi::raw_ostream& os,
|
||||
continue; // skip empty choices
|
||||
}
|
||||
// replace any non-printable characters in name with spaces
|
||||
wpi::SmallString<128> ch_name;
|
||||
wpi::util::SmallString<128> ch_name;
|
||||
for (char ch : *choice) {
|
||||
ch_name.push_back(wpi::isPrint(ch) ? ch : ' ');
|
||||
ch_name.push_back(wpi::util::isPrint(ch) ? ch : ' ');
|
||||
}
|
||||
wpi::print(os,
|
||||
wpi::util::print(os,
|
||||
"<input id=\"{0}{1}\" type=\"radio\" name=\"{0}\" "
|
||||
"value=\"{2}\" onclick=\"update('{0}', {1})\"",
|
||||
name, j, ch_name.str());
|
||||
if (j == valE) {
|
||||
os << " checked";
|
||||
}
|
||||
wpi::print(os, " /><label for=\"{}{}\">{}</label>\n", name, j,
|
||||
wpi::util::print(os, " /><label for=\"{}{}\">{}</label>\n", name, j,
|
||||
ch_name.str());
|
||||
}
|
||||
break;
|
||||
}
|
||||
case CS_PROP_STRING: {
|
||||
wpi::SmallString<128> strval_buf;
|
||||
wpi::print(os,
|
||||
wpi::util::SmallString<128> strval_buf;
|
||||
wpi::util::print(os,
|
||||
"<input type=\"text\" id=\"{0}box\" name=\"{0}\" "
|
||||
"value=\"{1}\" />\n",
|
||||
name, source.GetStringProperty(prop, strval_buf, &status));
|
||||
wpi::print(os,
|
||||
wpi::util::print(os,
|
||||
"<input type=\"button\" value =\"Submit\" "
|
||||
"onclick=\"update('{0}', {0}box.value)\" />\n",
|
||||
name);
|
||||
@@ -473,7 +473,7 @@ void MjpegServerImpl::ConnThread::SendHTML(wpi::raw_ostream& os,
|
||||
os << "unknown";
|
||||
break;
|
||||
}
|
||||
wpi::print(os, "</td><td>{}</td><td>{}</td><td>{}</td></tr>", mode.width,
|
||||
wpi::util::print(os, "</td><td>{}</td><td>{}</td><td>{}</td></tr>", mode.width,
|
||||
mode.height, mode.fps);
|
||||
}
|
||||
os << "</table>\n";
|
||||
@@ -482,14 +482,14 @@ void MjpegServerImpl::ConnThread::SendHTML(wpi::raw_ostream& os,
|
||||
}
|
||||
|
||||
// Send a JSON file which is contains information about the source parameters.
|
||||
void MjpegServerImpl::ConnThread::SendJSON(wpi::raw_ostream& os,
|
||||
void MjpegServerImpl::ConnThread::SendJSON(wpi::util::raw_ostream& os,
|
||||
SourceImpl& source, bool header) {
|
||||
if (header) {
|
||||
SendHeader(os, 200, "OK", "application/json");
|
||||
}
|
||||
|
||||
os << "{\n\"controls\": [\n";
|
||||
wpi::SmallVector<int, 32> properties_vec;
|
||||
wpi::util::SmallVector<int, 32> properties_vec;
|
||||
bool first = true;
|
||||
CS_Status status = 0;
|
||||
for (auto prop : source.EnumerateProperties(properties_vec, &status)) {
|
||||
@@ -499,27 +499,27 @@ void MjpegServerImpl::ConnThread::SendJSON(wpi::raw_ostream& os,
|
||||
os << ",\n";
|
||||
}
|
||||
os << '{';
|
||||
wpi::SmallString<128> name_buf;
|
||||
wpi::util::SmallString<128> name_buf;
|
||||
auto name = source.GetPropertyName(prop, name_buf, &status);
|
||||
auto kind = source.GetPropertyKind(prop);
|
||||
wpi::print(os, "\n\"name\": \"{}\"", name);
|
||||
wpi::print(os, ",\n\"id\": \"{}\"", prop);
|
||||
wpi::print(os, ",\n\"type\": \"{}\"", static_cast<int>(kind));
|
||||
wpi::print(os, ",\n\"min\": \"{}\"", source.GetPropertyMin(prop, &status));
|
||||
wpi::print(os, ",\n\"max\": \"{}\"", source.GetPropertyMax(prop, &status));
|
||||
wpi::print(os, ",\n\"step\": \"{}\"",
|
||||
wpi::util::print(os, "\n\"name\": \"{}\"", name);
|
||||
wpi::util::print(os, ",\n\"id\": \"{}\"", prop);
|
||||
wpi::util::print(os, ",\n\"type\": \"{}\"", static_cast<int>(kind));
|
||||
wpi::util::print(os, ",\n\"min\": \"{}\"", source.GetPropertyMin(prop, &status));
|
||||
wpi::util::print(os, ",\n\"max\": \"{}\"", source.GetPropertyMax(prop, &status));
|
||||
wpi::util::print(os, ",\n\"step\": \"{}\"",
|
||||
source.GetPropertyStep(prop, &status));
|
||||
wpi::print(os, ",\n\"default\": \"{}\"",
|
||||
wpi::util::print(os, ",\n\"default\": \"{}\"",
|
||||
source.GetPropertyDefault(prop, &status));
|
||||
os << ",\n\"value\": \"";
|
||||
switch (kind) {
|
||||
case CS_PROP_BOOLEAN:
|
||||
case CS_PROP_INTEGER:
|
||||
case CS_PROP_ENUM:
|
||||
wpi::print(os, "{}", source.GetProperty(prop, &status));
|
||||
wpi::util::print(os, "{}", source.GetProperty(prop, &status));
|
||||
break;
|
||||
case CS_PROP_STRING: {
|
||||
wpi::SmallString<128> strval_buf;
|
||||
wpi::util::SmallString<128> strval_buf;
|
||||
os << source.GetStringProperty(prop, strval_buf, &status);
|
||||
break;
|
||||
}
|
||||
@@ -542,11 +542,11 @@ void MjpegServerImpl::ConnThread::SendJSON(wpi::raw_ostream& os,
|
||||
os << ", ";
|
||||
}
|
||||
// replace any non-printable characters in name with spaces
|
||||
wpi::SmallString<128> ch_name;
|
||||
wpi::util::SmallString<128> ch_name;
|
||||
for (char ch : *choice) {
|
||||
ch_name.push_back(std::isprint(ch) ? ch : ' ');
|
||||
}
|
||||
wpi::print(os, "\"{}\": \"{}\"", j, ch_name.str());
|
||||
wpi::util::print(os, "\"{}\": \"{}\"", j, ch_name.str());
|
||||
}
|
||||
os << "}\n";
|
||||
}
|
||||
@@ -588,19 +588,19 @@ void MjpegServerImpl::ConnThread::SendJSON(wpi::raw_ostream& os,
|
||||
os << "unknown";
|
||||
break;
|
||||
}
|
||||
wpi::print(os, "\",\n\"width\": \"{}\"", mode.width);
|
||||
wpi::print(os, ",\n\"height\": \"{}\"", mode.height);
|
||||
wpi::print(os, ",\n\"fps\": \"{}\"", mode.fps);
|
||||
wpi::util::print(os, "\",\n\"width\": \"{}\"", mode.width);
|
||||
wpi::util::print(os, ",\n\"height\": \"{}\"", mode.height);
|
||||
wpi::util::print(os, ",\n\"fps\": \"{}\"", mode.fps);
|
||||
os << '}';
|
||||
}
|
||||
os << "\n]\n}\n";
|
||||
os.flush();
|
||||
}
|
||||
|
||||
MjpegServerImpl::MjpegServerImpl(std::string_view name, wpi::Logger& logger,
|
||||
MjpegServerImpl::MjpegServerImpl(std::string_view name, wpi::util::Logger& logger,
|
||||
Notifier& notifier, Telemetry& telemetry,
|
||||
std::string_view listenAddress, int port,
|
||||
std::unique_ptr<wpi::NetworkAcceptor> acceptor)
|
||||
std::unique_ptr<wpi::net::NetworkAcceptor> acceptor)
|
||||
: SinkImpl{name, logger, notifier, telemetry},
|
||||
m_listenAddress(listenAddress),
|
||||
m_port(port),
|
||||
@@ -663,7 +663,7 @@ void MjpegServerImpl::Stop() {
|
||||
}
|
||||
|
||||
// Send HTTP response and a stream of JPG-frames
|
||||
void MjpegServerImpl::ConnThread::SendStream(wpi::raw_socket_ostream& os) {
|
||||
void MjpegServerImpl::ConnThread::SendStream(wpi::net::raw_socket_ostream& os) {
|
||||
if (m_noStreaming) {
|
||||
SERROR("Too many simultaneous client streams");
|
||||
SendError(os, 503, "Too many simultaneous streams");
|
||||
@@ -672,8 +672,8 @@ void MjpegServerImpl::ConnThread::SendStream(wpi::raw_socket_ostream& os) {
|
||||
|
||||
os.SetUnbuffered();
|
||||
|
||||
wpi::SmallString<256> header;
|
||||
wpi::raw_svector_ostream oss{header};
|
||||
wpi::util::SmallString<256> header;
|
||||
wpi::util::raw_svector_ostream oss{header};
|
||||
|
||||
SendHeader(oss, 200, "OK", "multipart/x-mixed-replace;boundary=" BOUNDARY);
|
||||
os << oss.str();
|
||||
@@ -774,8 +774,8 @@ void MjpegServerImpl::ConnThread::SendStream(wpi::raw_socket_ostream& os) {
|
||||
double timestamp = lastFrameTime / 1000000.0;
|
||||
header.clear();
|
||||
oss << "\r\n--" BOUNDARY "\r\n" << "Content-Type: image/jpeg\r\n";
|
||||
wpi::print(oss, "Content-Length: {}\r\n", size);
|
||||
wpi::print(oss, "X-Timestamp: {}\r\n", timestamp);
|
||||
wpi::util::print(oss, "Content-Length: {}\r\n", size);
|
||||
wpi::util::print(oss, "X-Timestamp: {}\r\n", timestamp);
|
||||
oss << "\r\n";
|
||||
os << oss.str();
|
||||
if (addDHT) {
|
||||
@@ -792,11 +792,11 @@ void MjpegServerImpl::ConnThread::SendStream(wpi::raw_socket_ostream& os) {
|
||||
}
|
||||
|
||||
void MjpegServerImpl::ConnThread::ProcessRequest() {
|
||||
wpi::raw_socket_istream is{*m_stream};
|
||||
wpi::raw_socket_ostream os{*m_stream, true};
|
||||
wpi::net::raw_socket_istream is{*m_stream};
|
||||
wpi::net::raw_socket_ostream os{*m_stream, true};
|
||||
|
||||
// Read the request string from the stream
|
||||
wpi::SmallString<128> reqBuf;
|
||||
wpi::util::SmallString<128> reqBuf;
|
||||
std::string_view req = is.getline(reqBuf, 4096);
|
||||
if (is.has_error()) {
|
||||
SDEBUG("error getting request string");
|
||||
@@ -813,14 +813,14 @@ void MjpegServerImpl::ConnThread::ProcessRequest() {
|
||||
// compatibility, others are for Axis camera compatibility.
|
||||
if ((pos = req.find("POST /stream")) != std::string_view::npos) {
|
||||
kind = kStream;
|
||||
parameters = wpi::substr(wpi::substr(req, req.find('?', pos + 12)), 1);
|
||||
parameters = wpi::util::substr(wpi::util::substr(req, req.find('?', pos + 12)), 1);
|
||||
} else if ((pos = req.find("GET /?action=stream")) !=
|
||||
std::string_view::npos) {
|
||||
kind = kStream;
|
||||
parameters = wpi::substr(wpi::substr(req, req.find('&', pos + 19)), 1);
|
||||
parameters = wpi::util::substr(wpi::util::substr(req, req.find('&', pos + 19)), 1);
|
||||
} else if ((pos = req.find("GET /stream.mjpg")) != std::string_view::npos) {
|
||||
kind = kStream;
|
||||
parameters = wpi::substr(wpi::substr(req, req.find('?', pos + 16)), 1);
|
||||
parameters = wpi::util::substr(wpi::util::substr(req, req.find('?', pos + 16)), 1);
|
||||
} else if (req.find("GET /settings") != std::string_view::npos &&
|
||||
req.find(".json") != std::string_view::npos) {
|
||||
kind = kGetSettings;
|
||||
@@ -836,7 +836,7 @@ void MjpegServerImpl::ConnThread::ProcessRequest() {
|
||||
} else if ((pos = req.find("GET /?action=command")) !=
|
||||
std::string_view::npos) {
|
||||
kind = kCommand;
|
||||
parameters = wpi::substr(wpi::substr(req, req.find('&', pos + 20)), 1);
|
||||
parameters = wpi::util::substr(wpi::util::substr(req, req.find('&', pos + 20)), 1);
|
||||
} else if (req.find("GET / ") != std::string_view::npos || req == "GET /\n") {
|
||||
kind = kRootPage;
|
||||
} else {
|
||||
@@ -849,14 +849,14 @@ void MjpegServerImpl::ConnThread::ProcessRequest() {
|
||||
pos = parameters.find_first_not_of(
|
||||
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_"
|
||||
"-=&1234567890%./");
|
||||
parameters = wpi::substr(parameters, 0, pos);
|
||||
parameters = wpi::util::substr(parameters, 0, pos);
|
||||
SDEBUG("command parameters: \"{}\"", parameters);
|
||||
|
||||
// Read the rest of the HTTP request.
|
||||
// The end of the request is marked by a single, empty line
|
||||
wpi::SmallString<128> lineBuf;
|
||||
wpi::util::SmallString<128> lineBuf;
|
||||
for (;;) {
|
||||
if (wpi::starts_with(is.getline(lineBuf, 4096), "\n")) {
|
||||
if (wpi::util::starts_with(is.getline(lineBuf, 4096), "\n")) {
|
||||
break;
|
||||
}
|
||||
if (is.has_error()) {
|
||||
@@ -960,7 +960,7 @@ void MjpegServerImpl::ServerThreadMain() {
|
||||
std::scoped_lock lock(m_mutex);
|
||||
// Find unoccupied worker thread, or create one if necessary
|
||||
auto it = std::find_if(m_connThreads.begin(), m_connThreads.end(),
|
||||
[](const wpi::SafeThreadOwner<ConnThread>& owner) {
|
||||
[](const wpi::util::SafeThreadOwner<ConnThread>& owner) {
|
||||
auto thr = owner.GetThread();
|
||||
return !thr || !thr->m_stream;
|
||||
});
|
||||
@@ -974,7 +974,7 @@ void MjpegServerImpl::ServerThreadMain() {
|
||||
|
||||
auto nstreams =
|
||||
std::count_if(m_connThreads.begin(), m_connThreads.end(),
|
||||
[](const wpi::SafeThreadOwner<ConnThread>& owner) {
|
||||
[](const wpi::util::SafeThreadOwner<ConnThread>& owner) {
|
||||
auto thr = owner.GetThread();
|
||||
return thr && thr->m_streaming;
|
||||
});
|
||||
@@ -1013,7 +1013,7 @@ void MjpegServerImpl::SetSourceImpl(std::shared_ptr<SourceImpl> source) {
|
||||
}
|
||||
}
|
||||
|
||||
namespace cs {
|
||||
namespace wpi::cs {
|
||||
|
||||
CS_Sink CreateMjpegServer(std::string_view name, std::string_view listenAddress,
|
||||
int port, CS_Status* status) {
|
||||
@@ -1022,8 +1022,8 @@ CS_Sink CreateMjpegServer(std::string_view name, std::string_view listenAddress,
|
||||
CS_SINK_MJPEG,
|
||||
std::make_shared<MjpegServerImpl>(
|
||||
name, inst.logger, inst.notifier, inst.telemetry, listenAddress, port,
|
||||
std::unique_ptr<wpi::NetworkAcceptor>(
|
||||
new wpi::TCPAcceptor(port, listenAddress, inst.logger))));
|
||||
std::unique_ptr<wpi::net::NetworkAcceptor>(
|
||||
new wpi::net::TCPAcceptor(port, listenAddress, inst.logger))));
|
||||
}
|
||||
|
||||
std::string GetMjpegServerListenAddress(CS_Sink sink, CS_Status* status) {
|
||||
@@ -1044,25 +1044,25 @@ int GetMjpegServerPort(CS_Sink sink, CS_Status* status) {
|
||||
return static_cast<MjpegServerImpl&>(*data->sink).GetPort();
|
||||
}
|
||||
|
||||
} // namespace cs
|
||||
} // namespace wpi::cs
|
||||
|
||||
extern "C" {
|
||||
|
||||
CS_Sink CS_CreateMjpegServer(const struct WPI_String* name,
|
||||
const struct WPI_String* listenAddress, int port,
|
||||
CS_Status* status) {
|
||||
return cs::CreateMjpegServer(wpi::to_string_view(name),
|
||||
wpi::to_string_view(listenAddress), port,
|
||||
return wpi::cs::CreateMjpegServer(wpi::util::to_string_view(name),
|
||||
wpi::util::to_string_view(listenAddress), port,
|
||||
status);
|
||||
}
|
||||
|
||||
void CS_GetMjpegServerListenAddress(CS_Sink sink, WPI_String* listenAddress,
|
||||
CS_Status* status) {
|
||||
cs::ConvertToC(listenAddress, cs::GetMjpegServerListenAddress(sink, status));
|
||||
wpi::cs::ConvertToC(listenAddress, wpi::cs::GetMjpegServerListenAddress(sink, status));
|
||||
}
|
||||
|
||||
int CS_GetMjpegServerPort(CS_Sink sink, CS_Status* status) {
|
||||
return cs::GetMjpegServerPort(sink, status);
|
||||
return wpi::cs::GetMjpegServerPort(sink, status);
|
||||
}
|
||||
|
||||
} // extern "C"
|
||||
|
||||
@@ -22,16 +22,16 @@
|
||||
#include "wpi/util/raw_istream.hpp"
|
||||
#include "wpi/util/raw_ostream.hpp"
|
||||
|
||||
namespace cs {
|
||||
namespace wpi::cs {
|
||||
|
||||
class SourceImpl;
|
||||
|
||||
class MjpegServerImpl : public SinkImpl {
|
||||
public:
|
||||
MjpegServerImpl(std::string_view name, wpi::Logger& logger,
|
||||
MjpegServerImpl(std::string_view name, wpi::util::Logger& logger,
|
||||
Notifier& notifier, Telemetry& telemetry,
|
||||
std::string_view listenAddress, int port,
|
||||
std::unique_ptr<wpi::NetworkAcceptor> acceptor);
|
||||
std::unique_ptr<wpi::net::NetworkAcceptor> acceptor);
|
||||
~MjpegServerImpl() override;
|
||||
|
||||
void Stop();
|
||||
@@ -49,11 +49,11 @@ class MjpegServerImpl : public SinkImpl {
|
||||
std::string m_listenAddress;
|
||||
int m_port;
|
||||
|
||||
std::unique_ptr<wpi::NetworkAcceptor> m_acceptor;
|
||||
std::unique_ptr<wpi::net::NetworkAcceptor> m_acceptor;
|
||||
std::atomic_bool m_active; // set to false to terminate threads
|
||||
std::thread m_serverThread;
|
||||
|
||||
std::vector<wpi::SafeThreadOwner<ConnThread>> m_connThreads;
|
||||
std::vector<wpi::util::SafeThreadOwner<ConnThread>> m_connThreads;
|
||||
|
||||
// property indices
|
||||
int m_widthProp;
|
||||
@@ -63,6 +63,6 @@ class MjpegServerImpl : public SinkImpl {
|
||||
int m_fpsProp;
|
||||
};
|
||||
|
||||
} // namespace cs
|
||||
} // namespace wpi::cs
|
||||
|
||||
#endif // CSCORE_MJPEGSERVERIMPL_HPP_
|
||||
|
||||
@@ -9,13 +9,13 @@
|
||||
|
||||
#include "wpi/util/Logger.hpp"
|
||||
|
||||
namespace cs {
|
||||
namespace wpi::cs {
|
||||
|
||||
class Notifier;
|
||||
|
||||
class NetworkListener {
|
||||
public:
|
||||
NetworkListener(wpi::Logger& logger, Notifier& notifier);
|
||||
NetworkListener(wpi::util::Logger& logger, Notifier& notifier);
|
||||
~NetworkListener();
|
||||
|
||||
void Start();
|
||||
@@ -26,6 +26,6 @@ class NetworkListener {
|
||||
std::unique_ptr<Impl> m_impl;
|
||||
};
|
||||
|
||||
} // namespace cs
|
||||
} // namespace wpi::cs
|
||||
|
||||
#endif // CSCORE_NETWORKLISTENER_HPP_
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
#include "SinkImpl.hpp"
|
||||
#include "SourceImpl.hpp"
|
||||
|
||||
using namespace cs;
|
||||
using namespace wpi::cs;
|
||||
|
||||
Notifier::Notifier() {}
|
||||
|
||||
|
||||
@@ -12,14 +12,14 @@
|
||||
#include "wpi/cs/cscore_cpp.hpp"
|
||||
#include "wpi/util/CallbackManager.hpp"
|
||||
|
||||
namespace cs {
|
||||
namespace wpi::cs {
|
||||
|
||||
class SinkImpl;
|
||||
class SourceImpl;
|
||||
|
||||
namespace impl {
|
||||
|
||||
struct ListenerData : public wpi::CallbackListenerData<
|
||||
struct ListenerData : public wpi::util::CallbackListenerData<
|
||||
std::function<void(const RawEvent& event)>> {
|
||||
ListenerData() = default;
|
||||
ListenerData(std::function<void(const RawEvent& event)> callback_,
|
||||
@@ -32,7 +32,7 @@ struct ListenerData : public wpi::CallbackListenerData<
|
||||
};
|
||||
|
||||
class NotifierThread
|
||||
: public wpi::CallbackThread<NotifierThread, RawEvent, ListenerData> {
|
||||
: public wpi::util::CallbackThread<NotifierThread, RawEvent, ListenerData> {
|
||||
public:
|
||||
NotifierThread(std::function<void()> on_start, std::function<void()> on_exit)
|
||||
: CallbackThread(std::move(on_start), std::move(on_exit)) {}
|
||||
@@ -53,7 +53,7 @@ class NotifierThread
|
||||
|
||||
} // namespace impl
|
||||
|
||||
class Notifier : public wpi::CallbackManager<Notifier, impl::NotifierThread> {
|
||||
class Notifier : public wpi::util::CallbackManager<Notifier, impl::NotifierThread> {
|
||||
friend class NotifierTest;
|
||||
|
||||
public:
|
||||
@@ -87,6 +87,6 @@ class Notifier : public wpi::CallbackManager<Notifier, impl::NotifierThread> {
|
||||
void NotifyUsbCamerasChanged();
|
||||
};
|
||||
|
||||
} // namespace cs
|
||||
} // namespace wpi::cs
|
||||
|
||||
#endif // CSCORE_NOTIFIER_HPP_
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
#include "wpi/util/SmallVector.hpp"
|
||||
#include "wpi/util/json.hpp"
|
||||
|
||||
using namespace cs;
|
||||
using namespace wpi::cs;
|
||||
|
||||
int PropertyContainer::GetPropertyIndex(std::string_view name) const {
|
||||
// We can't fail, so instead we create a new index if caching fails.
|
||||
@@ -32,7 +32,7 @@ int PropertyContainer::GetPropertyIndex(std::string_view name) const {
|
||||
}
|
||||
|
||||
std::span<int> PropertyContainer::EnumerateProperties(
|
||||
wpi::SmallVectorImpl<int>& vec, CS_Status* status) const {
|
||||
wpi::util::SmallVectorImpl<int>& vec, CS_Status* status) const {
|
||||
if (!m_properties_cached && !CacheProperties(status)) {
|
||||
return {};
|
||||
}
|
||||
@@ -59,7 +59,7 @@ CS_PropertyKind PropertyContainer::GetPropertyKind(int property) const {
|
||||
}
|
||||
|
||||
std::string_view PropertyContainer::GetPropertyName(
|
||||
int property, wpi::SmallVectorImpl<char>& buf, CS_Status* status) const {
|
||||
int property, wpi::util::SmallVectorImpl<char>& buf, CS_Status* status) const {
|
||||
if (!m_properties_cached && !CacheProperties(status)) {
|
||||
return {};
|
||||
}
|
||||
@@ -168,7 +168,7 @@ int PropertyContainer::GetPropertyDefault(int property,
|
||||
}
|
||||
|
||||
std::string_view PropertyContainer::GetStringProperty(
|
||||
int property, wpi::SmallVectorImpl<char>& buf, CS_Status* status) const {
|
||||
int property, wpi::util::SmallVectorImpl<char>& buf, CS_Status* status) const {
|
||||
if (!m_properties_cached && !CacheProperties(status)) {
|
||||
return {};
|
||||
}
|
||||
@@ -238,15 +238,15 @@ bool PropertyContainer::CacheProperties(CS_Status* status) const {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool PropertyContainer::SetPropertiesJson(const wpi::json& config,
|
||||
wpi::Logger& logger,
|
||||
bool PropertyContainer::SetPropertiesJson(const wpi::util::json& config,
|
||||
wpi::util::Logger& logger,
|
||||
std::string_view logName,
|
||||
CS_Status* status) {
|
||||
for (auto&& prop : config) {
|
||||
std::string name;
|
||||
try {
|
||||
name = prop.at("name").get<std::string>();
|
||||
} catch (const wpi::json::exception& e) {
|
||||
} catch (const wpi::util::json::exception& e) {
|
||||
WPI_WARNING(logger, "{}: SetConfigJson: could not read property name: {}",
|
||||
logName, e.what());
|
||||
continue;
|
||||
@@ -270,7 +270,7 @@ bool PropertyContainer::SetPropertiesJson(const wpi::json& config,
|
||||
logName, name, val);
|
||||
SetProperty(n, val, status);
|
||||
}
|
||||
} catch (const wpi::json::exception& e) {
|
||||
} catch (const wpi::util::json::exception& e) {
|
||||
WPI_WARNING(logger,
|
||||
"{}: SetConfigJson: could not read property value: {}",
|
||||
logName, e.what());
|
||||
@@ -281,12 +281,12 @@ bool PropertyContainer::SetPropertiesJson(const wpi::json& config,
|
||||
return true;
|
||||
}
|
||||
|
||||
wpi::json PropertyContainer::GetPropertiesJsonObject(CS_Status* status) {
|
||||
wpi::json j;
|
||||
wpi::SmallVector<int, 32> propVec;
|
||||
wpi::util::json PropertyContainer::GetPropertiesJsonObject(CS_Status* status) {
|
||||
wpi::util::json j;
|
||||
wpi::util::SmallVector<int, 32> propVec;
|
||||
for (int p : EnumerateProperties(propVec, status)) {
|
||||
wpi::json prop;
|
||||
wpi::SmallString<128> strBuf;
|
||||
wpi::util::json prop;
|
||||
wpi::util::SmallString<128> strBuf;
|
||||
prop.emplace("name", GetPropertyName(p, strBuf, status));
|
||||
switch (GetPropertyKind(p)) {
|
||||
case CS_PROP_BOOLEAN:
|
||||
|
||||
@@ -19,24 +19,24 @@
|
||||
#include "wpi/util/json_fwd.hpp"
|
||||
#include "wpi/util/mutex.hpp"
|
||||
|
||||
namespace wpi {
|
||||
namespace wpi::util {
|
||||
class Logger;
|
||||
template <typename T>
|
||||
class SmallVectorImpl;
|
||||
} // namespace wpi
|
||||
|
||||
namespace cs {
|
||||
namespace wpi::cs {
|
||||
|
||||
class PropertyContainer {
|
||||
public:
|
||||
virtual ~PropertyContainer() = default;
|
||||
|
||||
int GetPropertyIndex(std::string_view name) const;
|
||||
std::span<int> EnumerateProperties(wpi::SmallVectorImpl<int>& vec,
|
||||
std::span<int> EnumerateProperties(wpi::util::SmallVectorImpl<int>& vec,
|
||||
CS_Status* status) const;
|
||||
CS_PropertyKind GetPropertyKind(int property) const;
|
||||
std::string_view GetPropertyName(int property,
|
||||
wpi::SmallVectorImpl<char>& buf,
|
||||
wpi::util::SmallVectorImpl<char>& buf,
|
||||
CS_Status* status) const;
|
||||
int GetProperty(int property, CS_Status* status) const;
|
||||
virtual void SetProperty(int property, int value, CS_Status* status);
|
||||
@@ -45,16 +45,16 @@ class PropertyContainer {
|
||||
int GetPropertyStep(int property, CS_Status* status) const;
|
||||
int GetPropertyDefault(int property, CS_Status* status) const;
|
||||
std::string_view GetStringProperty(int property,
|
||||
wpi::SmallVectorImpl<char>& buf,
|
||||
wpi::util::SmallVectorImpl<char>& buf,
|
||||
CS_Status* status) const;
|
||||
virtual void SetStringProperty(int property, std::string_view value,
|
||||
CS_Status* status);
|
||||
std::vector<std::string> GetEnumPropertyChoices(int property,
|
||||
CS_Status* status) const;
|
||||
|
||||
bool SetPropertiesJson(const wpi::json& config, wpi::Logger& logger,
|
||||
bool SetPropertiesJson(const wpi::util::json& config, wpi::util::Logger& logger,
|
||||
std::string_view logName, CS_Status* status);
|
||||
wpi::json GetPropertiesJsonObject(CS_Status* status);
|
||||
wpi::util::json GetPropertiesJsonObject(CS_Status* status);
|
||||
|
||||
protected:
|
||||
// Get a property; must be called with m_mutex held.
|
||||
@@ -116,13 +116,13 @@ class PropertyContainer {
|
||||
// should not be called again)
|
||||
mutable std::atomic_bool m_properties_cached{false};
|
||||
|
||||
mutable wpi::mutex m_mutex;
|
||||
mutable wpi::util::mutex m_mutex;
|
||||
|
||||
// Cached properties (protected with m_mutex)
|
||||
mutable std::vector<std::unique_ptr<PropertyImpl>> m_propertyData;
|
||||
mutable wpi::StringMap<int> m_properties;
|
||||
mutable wpi::util::StringMap<int> m_properties;
|
||||
};
|
||||
|
||||
} // namespace cs
|
||||
} // namespace wpi::cs
|
||||
|
||||
#endif // CSCORE_PROPERTYCONTAINER_HPP_
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
#include "PropertyImpl.hpp"
|
||||
|
||||
using namespace cs;
|
||||
using namespace wpi::cs;
|
||||
|
||||
PropertyImpl::PropertyImpl(std::string_view name_) : name{name_} {}
|
||||
PropertyImpl::PropertyImpl(std::string_view name_, CS_PropertyKind kind_,
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
#include "wpi/cs/cscore_c.h"
|
||||
#include "wpi/util/Signal.h"
|
||||
|
||||
namespace cs {
|
||||
namespace wpi::cs {
|
||||
|
||||
// Property data
|
||||
class PropertyImpl {
|
||||
@@ -45,9 +45,9 @@ class PropertyImpl {
|
||||
bool valueSet{false};
|
||||
|
||||
// emitted when value changes
|
||||
wpi::sig::Signal<> changed;
|
||||
wpi::util::sig::Signal<> changed;
|
||||
};
|
||||
|
||||
} // namespace cs
|
||||
} // namespace wpi::cs
|
||||
|
||||
#endif // CSCORE_PROPERTYIMPL_HPP_
|
||||
|
||||
@@ -10,16 +10,16 @@
|
||||
#include "Instance.hpp"
|
||||
#include "wpi/cs/cscore_raw.h"
|
||||
|
||||
using namespace cs;
|
||||
using namespace wpi::cs;
|
||||
|
||||
RawSinkImpl::RawSinkImpl(std::string_view name, wpi::Logger& logger,
|
||||
RawSinkImpl::RawSinkImpl(std::string_view name, wpi::util::Logger& logger,
|
||||
Notifier& notifier, Telemetry& telemetry)
|
||||
: SinkImpl{name, logger, notifier, telemetry} {
|
||||
m_active = true;
|
||||
// m_thread = std::thread(&RawSinkImpl::ThreadMain, this);
|
||||
}
|
||||
|
||||
RawSinkImpl::RawSinkImpl(std::string_view name, wpi::Logger& logger,
|
||||
RawSinkImpl::RawSinkImpl(std::string_view name, wpi::util::Logger& logger,
|
||||
Notifier& notifier, Telemetry& telemetry,
|
||||
std::function<void(uint64_t time)> processFrame)
|
||||
: SinkImpl{name, logger, notifier, telemetry} {}
|
||||
@@ -151,7 +151,7 @@ void RawSinkImpl::ThreadMain() {
|
||||
Disable();
|
||||
}
|
||||
|
||||
namespace cs {
|
||||
namespace wpi::cs {
|
||||
static constexpr unsigned SinkMask = CS_SINK_CV | CS_SINK_RAW;
|
||||
|
||||
CS_Sink CreateRawSink(std::string_view name, bool isCv, CS_Status* status) {
|
||||
@@ -202,30 +202,30 @@ uint64_t GrabSinkFrameTimeoutLastTime(CS_Sink sink, WPI_RawFrame& image,
|
||||
.GrabFrame(image, timeout, lastFrameTime);
|
||||
}
|
||||
|
||||
} // namespace cs
|
||||
} // namespace wpi::cs
|
||||
|
||||
extern "C" {
|
||||
CS_Sink CS_CreateRawSink(const struct WPI_String* name, CS_Bool isCv,
|
||||
CS_Status* status) {
|
||||
return cs::CreateRawSink(wpi::to_string_view(name), isCv, status);
|
||||
return wpi::cs::CreateRawSink(wpi::util::to_string_view(name), isCv, status);
|
||||
}
|
||||
|
||||
CS_Sink CS_CreateRawSinkCallback(
|
||||
const struct WPI_String* name, CS_Bool isCv, void* data,
|
||||
void (*processFrame)(void* data, uint64_t time), CS_Status* status) {
|
||||
return cs::CreateRawSinkCallback(
|
||||
wpi::to_string_view(name), isCv,
|
||||
return wpi::cs::CreateRawSinkCallback(
|
||||
wpi::util::to_string_view(name), isCv,
|
||||
[=](uint64_t time) { processFrame(data, time); }, status);
|
||||
}
|
||||
|
||||
uint64_t CS_GrabRawSinkFrame(CS_Sink sink, struct WPI_RawFrame* image,
|
||||
CS_Status* status) {
|
||||
return cs::GrabSinkFrame(sink, *image, status);
|
||||
return wpi::cs::GrabSinkFrame(sink, *image, status);
|
||||
}
|
||||
|
||||
uint64_t CS_GrabRawSinkFrameTimeout(CS_Sink sink, struct WPI_RawFrame* image,
|
||||
double timeout, CS_Status* status) {
|
||||
return cs::GrabSinkFrameTimeout(sink, *image, timeout, status);
|
||||
return wpi::cs::GrabSinkFrameTimeout(sink, *image, timeout, status);
|
||||
}
|
||||
|
||||
uint64_t CS_GrabRawSinkFrameTimeoutWithFrameTime(CS_Sink sink,
|
||||
@@ -233,7 +233,7 @@ uint64_t CS_GrabRawSinkFrameTimeoutWithFrameTime(CS_Sink sink,
|
||||
double timeout,
|
||||
uint64_t lastFrameTime,
|
||||
CS_Status* status) {
|
||||
return cs::GrabSinkFrameTimeoutLastTime(sink, *image, timeout, lastFrameTime,
|
||||
return wpi::cs::GrabSinkFrameTimeoutLastTime(sink, *image, timeout, lastFrameTime,
|
||||
status);
|
||||
}
|
||||
|
||||
|
||||
@@ -17,14 +17,14 @@
|
||||
#include "wpi/cs/cscore_raw.h"
|
||||
#include "wpi/util/condition_variable.hpp"
|
||||
|
||||
namespace cs {
|
||||
namespace wpi::cs {
|
||||
class SourceImpl;
|
||||
|
||||
class RawSinkImpl : public SinkImpl {
|
||||
public:
|
||||
RawSinkImpl(std::string_view name, wpi::Logger& logger, Notifier& notifier,
|
||||
RawSinkImpl(std::string_view name, wpi::util::Logger& logger, Notifier& notifier,
|
||||
Telemetry& telemetry);
|
||||
RawSinkImpl(std::string_view name, wpi::Logger& logger, Notifier& notifier,
|
||||
RawSinkImpl(std::string_view name, wpi::util::Logger& logger, Notifier& notifier,
|
||||
Telemetry& telemetry,
|
||||
std::function<void(uint64_t time)> processFrame);
|
||||
~RawSinkImpl() override;
|
||||
@@ -48,6 +48,6 @@ class RawSinkImpl : public SinkImpl {
|
||||
std::thread m_thread;
|
||||
std::function<void(uint64_t time)> m_processFrame;
|
||||
};
|
||||
} // namespace cs
|
||||
} // namespace wpi::cs
|
||||
|
||||
#endif // CSCORE_RAWSINKIMPL_HPP_
|
||||
|
||||
@@ -11,9 +11,9 @@
|
||||
#include "wpi/cs/cscore_raw.h"
|
||||
#include "wpi/util/timestamp.h"
|
||||
|
||||
using namespace cs;
|
||||
using namespace wpi::cs;
|
||||
|
||||
RawSourceImpl::RawSourceImpl(std::string_view name, wpi::Logger& logger,
|
||||
RawSourceImpl::RawSourceImpl(std::string_view name, wpi::util::Logger& logger,
|
||||
Notifier& notifier, Telemetry& telemetry,
|
||||
const VideoMode& mode)
|
||||
: ConfigurableSourceImpl{name, logger, notifier, telemetry, mode} {}
|
||||
@@ -21,13 +21,13 @@ RawSourceImpl::RawSourceImpl(std::string_view name, wpi::Logger& logger,
|
||||
RawSourceImpl::~RawSourceImpl() = default;
|
||||
|
||||
void RawSourceImpl::PutFrame(const WPI_RawFrame& image) {
|
||||
auto currentTime = wpi::Now();
|
||||
auto currentTime = wpi::util::Now();
|
||||
std::string_view data_view{reinterpret_cast<char*>(image.data), image.size};
|
||||
SourceImpl::PutFrame(static_cast<VideoMode::PixelFormat>(image.pixelFormat),
|
||||
image.width, image.height, data_view, currentTime);
|
||||
}
|
||||
|
||||
namespace cs {
|
||||
namespace wpi::cs {
|
||||
static constexpr unsigned SourceMask = CS_SOURCE_CV | CS_SOURCE_RAW;
|
||||
|
||||
CS_Source CreateRawSource(std::string_view name, bool isCv,
|
||||
@@ -49,18 +49,18 @@ void PutSourceFrame(CS_Source source, const WPI_RawFrame& image,
|
||||
static_cast<RawSourceImpl&>(*data->source).PutFrame(image);
|
||||
}
|
||||
|
||||
} // namespace cs
|
||||
} // namespace wpi::cs
|
||||
|
||||
extern "C" {
|
||||
CS_Source CS_CreateRawSource(const struct WPI_String* name, CS_Bool isCv,
|
||||
const CS_VideoMode* mode, CS_Status* status) {
|
||||
return cs::CreateRawSource(wpi::to_string_view(name), isCv,
|
||||
static_cast<const cs::VideoMode&>(*mode), status);
|
||||
return wpi::cs::CreateRawSource(wpi::util::to_string_view(name), isCv,
|
||||
static_cast<const wpi::cs::VideoMode&>(*mode), status);
|
||||
}
|
||||
|
||||
void CS_PutRawSourceFrame(CS_Source source, const struct WPI_RawFrame* image,
|
||||
CS_Status* status) {
|
||||
return cs::PutSourceFrame(source, *image, status);
|
||||
return wpi::cs::PutSourceFrame(source, *image, status);
|
||||
}
|
||||
|
||||
} // extern "C"
|
||||
|
||||
@@ -16,11 +16,11 @@
|
||||
#include "SourceImpl.hpp"
|
||||
#include "wpi/cs/cscore_raw.h"
|
||||
|
||||
namespace cs {
|
||||
namespace wpi::cs {
|
||||
|
||||
class RawSourceImpl : public ConfigurableSourceImpl {
|
||||
public:
|
||||
RawSourceImpl(std::string_view name, wpi::Logger& logger, Notifier& notifier,
|
||||
RawSourceImpl(std::string_view name, wpi::util::Logger& logger, Notifier& notifier,
|
||||
Telemetry& telemetry, const VideoMode& mode);
|
||||
~RawSourceImpl() override;
|
||||
|
||||
@@ -31,6 +31,6 @@ class RawSourceImpl : public ConfigurableSourceImpl {
|
||||
std::atomic_bool m_connected{true};
|
||||
};
|
||||
|
||||
} // namespace cs
|
||||
} // namespace wpi::cs
|
||||
|
||||
#endif // CSCORE_RAWSOURCEIMPL_HPP_
|
||||
|
||||
@@ -13,9 +13,9 @@
|
||||
#include "wpi/util/SmallString.hpp"
|
||||
#include "wpi/util/json.hpp"
|
||||
|
||||
using namespace cs;
|
||||
using namespace wpi::cs;
|
||||
|
||||
SinkImpl::SinkImpl(std::string_view name, wpi::Logger& logger,
|
||||
SinkImpl::SinkImpl(std::string_view name, wpi::util::Logger& logger,
|
||||
Notifier& notifier, Telemetry& telemetry)
|
||||
: m_logger(logger),
|
||||
m_notifier(notifier),
|
||||
@@ -37,7 +37,7 @@ void SinkImpl::SetDescription(std::string_view description) {
|
||||
}
|
||||
|
||||
std::string_view SinkImpl::GetDescription(
|
||||
wpi::SmallVectorImpl<char>& buf) const {
|
||||
wpi::util::SmallVectorImpl<char>& buf) const {
|
||||
std::scoped_lock lock(m_mutex);
|
||||
buf.append(m_description.begin(), m_description.end());
|
||||
return {buf.data(), buf.size()};
|
||||
@@ -113,7 +113,7 @@ std::string SinkImpl::GetError() const {
|
||||
return std::string{m_source->GetCurFrame().GetError()};
|
||||
}
|
||||
|
||||
std::string_view SinkImpl::GetError(wpi::SmallVectorImpl<char>& buf) const {
|
||||
std::string_view SinkImpl::GetError(wpi::util::SmallVectorImpl<char>& buf) const {
|
||||
std::scoped_lock lock(m_mutex);
|
||||
if (!m_source) {
|
||||
return "no source connected";
|
||||
@@ -126,10 +126,10 @@ std::string_view SinkImpl::GetError(wpi::SmallVectorImpl<char>& buf) const {
|
||||
}
|
||||
|
||||
bool SinkImpl::SetConfigJson(std::string_view config, CS_Status* status) {
|
||||
wpi::json j;
|
||||
wpi::util::json j;
|
||||
try {
|
||||
j = wpi::json::parse(config);
|
||||
} catch (const wpi::json::parse_error& e) {
|
||||
j = wpi::util::json::parse(config);
|
||||
} catch (const wpi::util::json::parse_error& e) {
|
||||
SWARNING("SetConfigJson: parse error at byte {}: {}", e.byte, e.what());
|
||||
*status = CS_PROPERTY_WRITE_FAILED;
|
||||
return false;
|
||||
@@ -137,7 +137,7 @@ bool SinkImpl::SetConfigJson(std::string_view config, CS_Status* status) {
|
||||
return SetConfigJson(j, status);
|
||||
}
|
||||
|
||||
bool SinkImpl::SetConfigJson(const wpi::json& config, CS_Status* status) {
|
||||
bool SinkImpl::SetConfigJson(const wpi::util::json& config, CS_Status* status) {
|
||||
if (config.count("properties") != 0) {
|
||||
SetPropertiesJson(config.at("properties"), m_logger, GetName(), status);
|
||||
}
|
||||
@@ -147,16 +147,16 @@ bool SinkImpl::SetConfigJson(const wpi::json& config, CS_Status* status) {
|
||||
|
||||
std::string SinkImpl::GetConfigJson(CS_Status* status) {
|
||||
std::string rv;
|
||||
wpi::raw_string_ostream os(rv);
|
||||
wpi::util::raw_string_ostream os(rv);
|
||||
GetConfigJsonObject(status).dump(os, 4);
|
||||
os.flush();
|
||||
return rv;
|
||||
}
|
||||
|
||||
wpi::json SinkImpl::GetConfigJsonObject(CS_Status* status) {
|
||||
wpi::json j;
|
||||
wpi::util::json SinkImpl::GetConfigJsonObject(CS_Status* status) {
|
||||
wpi::util::json j;
|
||||
|
||||
wpi::json props = GetPropertiesJsonObject(status);
|
||||
wpi::util::json props = GetPropertiesJsonObject(status);
|
||||
if (props.is_array()) {
|
||||
j.emplace("properties", props);
|
||||
}
|
||||
@@ -199,7 +199,7 @@ void SinkImpl::UpdatePropertyValue(int property, bool setString, int value,
|
||||
|
||||
void SinkImpl::SetSourceImpl(std::shared_ptr<SourceImpl> source) {}
|
||||
|
||||
namespace cs {
|
||||
namespace wpi::cs {
|
||||
static constexpr unsigned SinkMask = CS_SINK_CV | CS_SINK_RAW;
|
||||
|
||||
void SetSinkDescription(CS_Sink sink, std::string_view description,
|
||||
@@ -221,7 +221,7 @@ std::string GetSinkError(CS_Sink sink, CS_Status* status) {
|
||||
return data->sink->GetError();
|
||||
}
|
||||
|
||||
std::string_view GetSinkError(CS_Sink sink, wpi::SmallVectorImpl<char>& buf,
|
||||
std::string_view GetSinkError(CS_Sink sink, wpi::util::SmallVectorImpl<char>& buf,
|
||||
CS_Status* status) {
|
||||
auto data = Instance::GetInstance().GetSink(sink);
|
||||
if (!data || (data->kind & SinkMask) == 0) {
|
||||
@@ -240,22 +240,22 @@ void SetSinkEnabled(CS_Sink sink, bool enabled, CS_Status* status) {
|
||||
data->sink->SetEnabled(enabled);
|
||||
}
|
||||
|
||||
} // namespace cs
|
||||
} // namespace wpi::cs
|
||||
|
||||
extern "C" {
|
||||
void CS_SetSinkDescription(CS_Sink sink, const struct WPI_String* description,
|
||||
CS_Status* status) {
|
||||
return cs::SetSinkDescription(sink, wpi::to_string_view(description), status);
|
||||
return wpi::cs::SetSinkDescription(sink, wpi::util::to_string_view(description), status);
|
||||
}
|
||||
|
||||
void CS_GetSinkError(CS_Sink sink, struct WPI_String* error,
|
||||
CS_Status* status) {
|
||||
wpi::SmallString<128> buf;
|
||||
cs::ConvertToC(error, cs::GetSinkError(sink, buf, status));
|
||||
wpi::util::SmallString<128> buf;
|
||||
wpi::cs::ConvertToC(error, wpi::cs::GetSinkError(sink, buf, status));
|
||||
}
|
||||
|
||||
void CS_SetSinkEnabled(CS_Sink sink, CS_Bool enabled, CS_Status* status) {
|
||||
return cs::SetSinkEnabled(sink, enabled, status);
|
||||
return wpi::cs::SetSinkEnabled(sink, enabled, status);
|
||||
}
|
||||
|
||||
} // extern "C"
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
#include "wpi/util/json_fwd.hpp"
|
||||
#include "wpi/util/mutex.hpp"
|
||||
|
||||
namespace cs {
|
||||
namespace wpi::cs {
|
||||
|
||||
class Frame;
|
||||
class Notifier;
|
||||
@@ -22,7 +22,7 @@ class Telemetry;
|
||||
|
||||
class SinkImpl : public PropertyContainer {
|
||||
public:
|
||||
explicit SinkImpl(std::string_view name, wpi::Logger& logger,
|
||||
explicit SinkImpl(std::string_view name, wpi::util::Logger& logger,
|
||||
Notifier& notifier, Telemetry& telemetry);
|
||||
~SinkImpl() override;
|
||||
SinkImpl(const SinkImpl& queue) = delete;
|
||||
@@ -31,7 +31,7 @@ class SinkImpl : public PropertyContainer {
|
||||
std::string_view GetName() const { return m_name; }
|
||||
|
||||
void SetDescription(std::string_view description);
|
||||
std::string_view GetDescription(wpi::SmallVectorImpl<char>& buf) const;
|
||||
std::string_view GetDescription(wpi::util::SmallVectorImpl<char>& buf) const;
|
||||
|
||||
void Enable();
|
||||
void Disable();
|
||||
@@ -45,12 +45,12 @@ class SinkImpl : public PropertyContainer {
|
||||
}
|
||||
|
||||
std::string GetError() const;
|
||||
std::string_view GetError(wpi::SmallVectorImpl<char>& buf) const;
|
||||
std::string_view GetError(wpi::util::SmallVectorImpl<char>& buf) const;
|
||||
|
||||
bool SetConfigJson(std::string_view config, CS_Status* status);
|
||||
virtual bool SetConfigJson(const wpi::json& config, CS_Status* status);
|
||||
virtual bool SetConfigJson(const wpi::util::json& config, CS_Status* status);
|
||||
std::string GetConfigJson(CS_Status* status);
|
||||
virtual wpi::json GetConfigJsonObject(CS_Status* status);
|
||||
virtual wpi::util::json GetConfigJsonObject(CS_Status* status);
|
||||
|
||||
protected:
|
||||
// PropertyContainer implementation
|
||||
@@ -61,7 +61,7 @@ class SinkImpl : public PropertyContainer {
|
||||
virtual void SetSourceImpl(std::shared_ptr<SourceImpl> source);
|
||||
|
||||
protected:
|
||||
wpi::Logger& m_logger;
|
||||
wpi::util::Logger& m_logger;
|
||||
Notifier& m_notifier;
|
||||
Telemetry& m_telemetry;
|
||||
|
||||
@@ -72,6 +72,6 @@ class SinkImpl : public PropertyContainer {
|
||||
int m_enabledCount{0};
|
||||
};
|
||||
|
||||
} // namespace cs
|
||||
} // namespace wpi::cs
|
||||
|
||||
#endif // CSCORE_SINKIMPL_HPP_
|
||||
|
||||
@@ -18,11 +18,11 @@
|
||||
#include "wpi/util/json.hpp"
|
||||
#include "wpi/util/timestamp.h"
|
||||
|
||||
using namespace cs;
|
||||
using namespace wpi::cs;
|
||||
|
||||
static constexpr size_t kMaxImagesAvail = 32;
|
||||
|
||||
SourceImpl::SourceImpl(std::string_view name, wpi::Logger& logger,
|
||||
SourceImpl::SourceImpl(std::string_view name, wpi::util::Logger& logger,
|
||||
Notifier& notifier, Telemetry& telemetry)
|
||||
: m_logger(logger),
|
||||
m_notifier(notifier),
|
||||
@@ -50,7 +50,7 @@ void SourceImpl::SetDescription(std::string_view description) {
|
||||
}
|
||||
|
||||
std::string_view SourceImpl::GetDescription(
|
||||
wpi::SmallVectorImpl<char>& buf) const {
|
||||
wpi::util::SmallVectorImpl<char>& buf) const {
|
||||
std::scoped_lock lock(m_mutex);
|
||||
buf.append(m_description.begin(), m_description.end());
|
||||
return {buf.data(), buf.size()};
|
||||
@@ -94,7 +94,7 @@ Frame SourceImpl::GetNextFrame(double timeout, Frame::Time lastFrameTime) {
|
||||
if (!m_frameCv.wait_for(
|
||||
lock, std::chrono::milliseconds(static_cast<int>(timeout * 1000)),
|
||||
[=, this] { return m_frame.GetTime() != lastFrameTime; })) {
|
||||
m_frame = Frame{*this, "timed out getting frame", wpi::Now(),
|
||||
m_frame = Frame{*this, "timed out getting frame", wpi::util::Now(),
|
||||
WPI_TIMESRC_UNKNOWN};
|
||||
}
|
||||
return m_frame;
|
||||
@@ -179,10 +179,10 @@ bool SourceImpl::SetFPS(int fps, CS_Status* status) {
|
||||
}
|
||||
|
||||
bool SourceImpl::SetConfigJson(std::string_view config, CS_Status* status) {
|
||||
wpi::json j;
|
||||
wpi::util::json j;
|
||||
try {
|
||||
j = wpi::json::parse(config);
|
||||
} catch (const wpi::json::parse_error& e) {
|
||||
j = wpi::util::json::parse(config);
|
||||
} catch (const wpi::util::json::parse_error& e) {
|
||||
SWARNING("SetConfigJson: parse error at byte {}: {}", e.byte, e.what());
|
||||
*status = CS_PROPERTY_WRITE_FAILED;
|
||||
return false;
|
||||
@@ -190,34 +190,34 @@ bool SourceImpl::SetConfigJson(std::string_view config, CS_Status* status) {
|
||||
return SetConfigJson(j, status);
|
||||
}
|
||||
|
||||
bool SourceImpl::SetConfigJson(const wpi::json& config, CS_Status* status) {
|
||||
bool SourceImpl::SetConfigJson(const wpi::util::json& config, CS_Status* status) {
|
||||
VideoMode mode;
|
||||
|
||||
// pixel format
|
||||
if (config.count("pixel format") != 0) {
|
||||
try {
|
||||
auto str = config.at("pixel format").get<std::string>();
|
||||
if (wpi::equals_lower(str, "mjpeg")) {
|
||||
mode.pixelFormat = cs::VideoMode::kMJPEG;
|
||||
} else if (wpi::equals_lower(str, "yuyv")) {
|
||||
mode.pixelFormat = cs::VideoMode::kYUYV;
|
||||
} else if (wpi::equals_lower(str, "rgb565")) {
|
||||
mode.pixelFormat = cs::VideoMode::kRGB565;
|
||||
} else if (wpi::equals_lower(str, "bgr")) {
|
||||
mode.pixelFormat = cs::VideoMode::kBGR;
|
||||
} else if (wpi::equals_lower(str, "bgra")) {
|
||||
mode.pixelFormat = cs::VideoMode::kBGRA;
|
||||
} else if (wpi::equals_lower(str, "gray")) {
|
||||
mode.pixelFormat = cs::VideoMode::kGray;
|
||||
} else if (wpi::equals_lower(str, "y16")) {
|
||||
mode.pixelFormat = cs::VideoMode::kY16;
|
||||
} else if (wpi::equals_lower(str, "uyvy")) {
|
||||
mode.pixelFormat = cs::VideoMode::kUYVY;
|
||||
if (wpi::util::equals_lower(str, "mjpeg")) {
|
||||
mode.pixelFormat = wpi::cs::VideoMode::kMJPEG;
|
||||
} else if (wpi::util::equals_lower(str, "yuyv")) {
|
||||
mode.pixelFormat = wpi::cs::VideoMode::kYUYV;
|
||||
} else if (wpi::util::equals_lower(str, "rgb565")) {
|
||||
mode.pixelFormat = wpi::cs::VideoMode::kRGB565;
|
||||
} else if (wpi::util::equals_lower(str, "bgr")) {
|
||||
mode.pixelFormat = wpi::cs::VideoMode::kBGR;
|
||||
} else if (wpi::util::equals_lower(str, "bgra")) {
|
||||
mode.pixelFormat = wpi::cs::VideoMode::kBGRA;
|
||||
} else if (wpi::util::equals_lower(str, "gray")) {
|
||||
mode.pixelFormat = wpi::cs::VideoMode::kGray;
|
||||
} else if (wpi::util::equals_lower(str, "y16")) {
|
||||
mode.pixelFormat = wpi::cs::VideoMode::kY16;
|
||||
} else if (wpi::util::equals_lower(str, "uyvy")) {
|
||||
mode.pixelFormat = wpi::cs::VideoMode::kUYVY;
|
||||
} else {
|
||||
SWARNING("SetConfigJson: could not understand pixel format value '{}'",
|
||||
str);
|
||||
}
|
||||
} catch (const wpi::json::exception& e) {
|
||||
} catch (const wpi::util::json::exception& e) {
|
||||
SWARNING("SetConfigJson: could not read pixel format: {}", e.what());
|
||||
}
|
||||
}
|
||||
@@ -226,7 +226,7 @@ bool SourceImpl::SetConfigJson(const wpi::json& config, CS_Status* status) {
|
||||
if (config.count("width") != 0) {
|
||||
try {
|
||||
mode.width = config.at("width").get<unsigned int>();
|
||||
} catch (const wpi::json::exception& e) {
|
||||
} catch (const wpi::util::json::exception& e) {
|
||||
SWARNING("SetConfigJson: could not read width: {}", e.what());
|
||||
}
|
||||
}
|
||||
@@ -235,7 +235,7 @@ bool SourceImpl::SetConfigJson(const wpi::json& config, CS_Status* status) {
|
||||
if (config.count("height") != 0) {
|
||||
try {
|
||||
mode.height = config.at("height").get<unsigned int>();
|
||||
} catch (const wpi::json::exception& e) {
|
||||
} catch (const wpi::util::json::exception& e) {
|
||||
SWARNING("SetConfigJson: could not read height: {}", e.what());
|
||||
}
|
||||
}
|
||||
@@ -244,7 +244,7 @@ bool SourceImpl::SetConfigJson(const wpi::json& config, CS_Status* status) {
|
||||
if (config.count("fps") != 0) {
|
||||
try {
|
||||
mode.fps = config.at("fps").get<unsigned int>();
|
||||
} catch (const wpi::json::exception& e) {
|
||||
} catch (const wpi::util::json::exception& e) {
|
||||
SWARNING("SetConfigJson: could not read fps: {}", e.what());
|
||||
}
|
||||
}
|
||||
@@ -258,9 +258,9 @@ bool SourceImpl::SetConfigJson(const wpi::json& config, CS_Status* status) {
|
||||
mode.pixelFormat, mode.width, mode.height, mode.fps);
|
||||
SetVideoMode(mode, status);
|
||||
} else {
|
||||
if (mode.pixelFormat != cs::VideoMode::kUnknown) {
|
||||
if (mode.pixelFormat != wpi::cs::VideoMode::kUnknown) {
|
||||
SINFO("SetConfigJson: setting pixelFormat {}", mode.pixelFormat);
|
||||
SetPixelFormat(static_cast<cs::VideoMode::PixelFormat>(mode.pixelFormat),
|
||||
SetPixelFormat(static_cast<wpi::cs::VideoMode::PixelFormat>(mode.pixelFormat),
|
||||
status);
|
||||
}
|
||||
if (mode.width != 0 && mode.height != 0) {
|
||||
@@ -280,7 +280,7 @@ bool SourceImpl::SetConfigJson(const wpi::json& config, CS_Status* status) {
|
||||
int val = config.at("brightness").get<int>();
|
||||
SINFO("SetConfigJson: setting brightness to {}", val);
|
||||
SetBrightness(val, status);
|
||||
} catch (const wpi::json::exception& e) {
|
||||
} catch (const wpi::util::json::exception& e) {
|
||||
SWARNING("SetConfigJson: could not read brightness: {}", e.what());
|
||||
}
|
||||
}
|
||||
@@ -291,10 +291,10 @@ bool SourceImpl::SetConfigJson(const wpi::json& config, CS_Status* status) {
|
||||
auto& setting = config.at("white balance");
|
||||
if (setting.is_string()) {
|
||||
auto str = setting.get<std::string>();
|
||||
if (wpi::equals_lower(str, "auto")) {
|
||||
if (wpi::util::equals_lower(str, "auto")) {
|
||||
SINFO("SetConfigJson: setting white balance to {}", "auto");
|
||||
SetWhiteBalanceAuto(status);
|
||||
} else if (wpi::equals_lower(str, "hold")) {
|
||||
} else if (wpi::util::equals_lower(str, "hold")) {
|
||||
SINFO("SetConfigJson: setting white balance to {}", "hold current");
|
||||
SetWhiteBalanceHoldCurrent(status);
|
||||
} else {
|
||||
@@ -307,7 +307,7 @@ bool SourceImpl::SetConfigJson(const wpi::json& config, CS_Status* status) {
|
||||
SINFO("SetConfigJson: setting white balance to {}", val);
|
||||
SetWhiteBalanceManual(val, status);
|
||||
}
|
||||
} catch (const wpi::json::exception& e) {
|
||||
} catch (const wpi::util::json::exception& e) {
|
||||
SWARNING("SetConfigJson: could not read white balance: {}", e.what());
|
||||
}
|
||||
}
|
||||
@@ -318,10 +318,10 @@ bool SourceImpl::SetConfigJson(const wpi::json& config, CS_Status* status) {
|
||||
auto& setting = config.at("exposure");
|
||||
if (setting.is_string()) {
|
||||
auto str = setting.get<std::string>();
|
||||
if (wpi::equals_lower(str, "auto")) {
|
||||
if (wpi::util::equals_lower(str, "auto")) {
|
||||
SINFO("SetConfigJson: setting exposure to {}", "auto");
|
||||
SetExposureAuto(status);
|
||||
} else if (wpi::equals_lower(str, "hold")) {
|
||||
} else if (wpi::util::equals_lower(str, "hold")) {
|
||||
SINFO("SetConfigJson: setting exposure to {}", "hold current");
|
||||
SetExposureHoldCurrent(status);
|
||||
} else {
|
||||
@@ -333,7 +333,7 @@ bool SourceImpl::SetConfigJson(const wpi::json& config, CS_Status* status) {
|
||||
SINFO("SetConfigJson: setting exposure to {}", val);
|
||||
SetExposureManual(val, status);
|
||||
}
|
||||
} catch (const wpi::json::exception& e) {
|
||||
} catch (const wpi::util::json::exception& e) {
|
||||
SWARNING("SetConfigJson: could not read exposure: {}", e.what());
|
||||
}
|
||||
}
|
||||
@@ -348,14 +348,14 @@ bool SourceImpl::SetConfigJson(const wpi::json& config, CS_Status* status) {
|
||||
|
||||
std::string SourceImpl::GetConfigJson(CS_Status* status) {
|
||||
std::string rv;
|
||||
wpi::raw_string_ostream os(rv);
|
||||
wpi::util::raw_string_ostream os(rv);
|
||||
GetConfigJsonObject(status).dump(os, 4);
|
||||
os.flush();
|
||||
return rv;
|
||||
}
|
||||
|
||||
wpi::json SourceImpl::GetConfigJsonObject(CS_Status* status) {
|
||||
wpi::json j;
|
||||
wpi::util::json SourceImpl::GetConfigJsonObject(CS_Status* status) {
|
||||
wpi::util::json j;
|
||||
|
||||
// pixel format
|
||||
std::string_view pixelFormat;
|
||||
@@ -409,7 +409,7 @@ wpi::json SourceImpl::GetConfigJsonObject(CS_Status* status) {
|
||||
// TODO: output brightness, white balance, and exposure?
|
||||
|
||||
// properties
|
||||
wpi::json props = GetPropertiesJsonObject(status);
|
||||
wpi::util::json props = GetPropertiesJsonObject(status);
|
||||
if (props.is_array()) {
|
||||
j.emplace("properties", props);
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
#include "wpi/util/json_fwd.hpp"
|
||||
#include "wpi/util/mutex.hpp"
|
||||
|
||||
namespace cs {
|
||||
namespace wpi::cs {
|
||||
|
||||
class Notifier;
|
||||
class Telemetry;
|
||||
@@ -32,7 +32,7 @@ class SourceImpl : public PropertyContainer {
|
||||
friend class Frame;
|
||||
|
||||
public:
|
||||
SourceImpl(std::string_view name, wpi::Logger& logger, Notifier& notifier,
|
||||
SourceImpl(std::string_view name, wpi::util::Logger& logger, Notifier& notifier,
|
||||
Telemetry& telemetry);
|
||||
~SourceImpl() override;
|
||||
SourceImpl(const SourceImpl& oth) = delete;
|
||||
@@ -43,7 +43,7 @@ class SourceImpl : public PropertyContainer {
|
||||
std::string_view GetName() const { return m_name; }
|
||||
|
||||
void SetDescription(std::string_view description);
|
||||
std::string_view GetDescription(wpi::SmallVectorImpl<char>& buf) const;
|
||||
std::string_view GetDescription(wpi::util::SmallVectorImpl<char>& buf) const;
|
||||
|
||||
void SetConnectionStrategy(CS_ConnectionStrategy strategy) {
|
||||
m_strategy = static_cast<int>(strategy);
|
||||
@@ -126,9 +126,9 @@ class SourceImpl : public PropertyContainer {
|
||||
virtual bool SetFPS(int fps, CS_Status* status);
|
||||
|
||||
bool SetConfigJson(std::string_view config, CS_Status* status);
|
||||
virtual bool SetConfigJson(const wpi::json& config, CS_Status* status);
|
||||
virtual bool SetConfigJson(const wpi::util::json& config, CS_Status* status);
|
||||
std::string GetConfigJson(CS_Status* status);
|
||||
virtual wpi::json GetConfigJsonObject(CS_Status* status);
|
||||
virtual wpi::util::json GetConfigJsonObject(CS_Status* status);
|
||||
|
||||
std::vector<VideoMode> EnumerateVideoModes(CS_Status* status) const;
|
||||
|
||||
@@ -159,7 +159,7 @@ class SourceImpl : public PropertyContainer {
|
||||
// Current video mode
|
||||
mutable VideoMode m_mode;
|
||||
|
||||
wpi::Logger& m_logger;
|
||||
wpi::util::Logger& m_logger;
|
||||
Notifier& m_notifier;
|
||||
Telemetry& m_telemetry;
|
||||
|
||||
@@ -174,13 +174,13 @@ class SourceImpl : public PropertyContainer {
|
||||
std::atomic_int m_strategy{CS_CONNECTION_AUTO_MANAGE};
|
||||
std::atomic_int m_numSinksEnabled{0};
|
||||
|
||||
wpi::mutex m_frameMutex;
|
||||
wpi::condition_variable m_frameCv;
|
||||
wpi::util::mutex m_frameMutex;
|
||||
wpi::util::condition_variable m_frameCv;
|
||||
|
||||
bool m_destroyFrames{false};
|
||||
|
||||
// Pool of frames/images to reduce malloc traffic.
|
||||
wpi::mutex m_poolMutex;
|
||||
wpi::util::mutex m_poolMutex;
|
||||
std::vector<std::unique_ptr<Frame::Impl>> m_framesAvail;
|
||||
std::vector<std::unique_ptr<Image>> m_imagesAvail;
|
||||
|
||||
@@ -193,6 +193,6 @@ class SourceImpl : public PropertyContainer {
|
||||
Frame m_frame;
|
||||
};
|
||||
|
||||
} // namespace cs
|
||||
} // namespace wpi::cs
|
||||
|
||||
#endif // CSCORE_SOURCEIMPL_HPP_
|
||||
|
||||
@@ -14,17 +14,17 @@
|
||||
#include "wpi/util/DenseMap.hpp"
|
||||
#include "wpi/util/timestamp.h"
|
||||
|
||||
using namespace cs;
|
||||
using namespace wpi::cs;
|
||||
|
||||
class Telemetry::Thread : public wpi::SafeThread {
|
||||
class Telemetry::Thread : public wpi::util::SafeThread {
|
||||
public:
|
||||
explicit Thread(Notifier& notifier) : m_notifier(notifier) {}
|
||||
|
||||
void Main() override;
|
||||
|
||||
Notifier& m_notifier;
|
||||
wpi::DenseMap<std::pair<CS_Handle, int>, int64_t> m_user;
|
||||
wpi::DenseMap<std::pair<CS_Handle, int>, int64_t> m_current;
|
||||
wpi::util::DenseMap<std::pair<CS_Handle, int>, int64_t> m_user;
|
||||
wpi::util::DenseMap<std::pair<CS_Handle, int>, int64_t> m_current;
|
||||
double m_period = 0.0;
|
||||
double m_elapsed = 0.0;
|
||||
bool m_updated = false;
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
#include "wpi/cs/cscore_cpp.hpp"
|
||||
#include "wpi/util/SafeThread.hpp"
|
||||
|
||||
namespace cs {
|
||||
namespace wpi::cs {
|
||||
|
||||
class Notifier;
|
||||
class SourceImpl;
|
||||
@@ -38,9 +38,9 @@ class Telemetry {
|
||||
Notifier& m_notifier;
|
||||
|
||||
class Thread;
|
||||
wpi::SafeThreadOwner<Thread> m_owner;
|
||||
wpi::util::SafeThreadOwner<Thread> m_owner;
|
||||
};
|
||||
|
||||
} // namespace cs
|
||||
} // namespace wpi::cs
|
||||
|
||||
#endif // CSCORE_TELEMETRY_HPP_
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
#include "wpi/util/SmallVector.hpp"
|
||||
#include "wpi/util/mutex.hpp"
|
||||
|
||||
namespace cs {
|
||||
namespace wpi::cs {
|
||||
|
||||
// The UnlimitedHandleResource class is a way to track handles. This version
|
||||
// allows an unlimited number of handles that are allocated sequentially. When
|
||||
@@ -34,7 +34,7 @@ namespace cs {
|
||||
// @tparam typeValue The type value stored in the handle
|
||||
// @tparam TMutex The mutex type to use
|
||||
template <typename THandle, typename TStruct, int typeValue,
|
||||
typename TMutex = wpi::mutex>
|
||||
typename TMutex = wpi::util::mutex>
|
||||
class UnlimitedHandleResource {
|
||||
public:
|
||||
UnlimitedHandleResource(const UnlimitedHandleResource&) = delete;
|
||||
@@ -50,7 +50,7 @@ class UnlimitedHandleResource {
|
||||
std::shared_ptr<TStruct> Free(THandle handle);
|
||||
|
||||
template <typename T>
|
||||
std::span<T> GetAll(wpi::SmallVectorImpl<T>& vec);
|
||||
std::span<T> GetAll(wpi::util::SmallVectorImpl<T>& vec);
|
||||
|
||||
std::vector<std::shared_ptr<TStruct>> FreeAll();
|
||||
|
||||
@@ -149,7 +149,7 @@ template <typename THandle, typename TStruct, int typeValue, typename TMutex>
|
||||
template <typename T>
|
||||
inline std::span<T>
|
||||
UnlimitedHandleResource<THandle, TStruct, typeValue, TMutex>::GetAll(
|
||||
wpi::SmallVectorImpl<T>& vec) {
|
||||
wpi::util::SmallVectorImpl<T>& vec) {
|
||||
ForEach([&](THandle handle, const TStruct&) { vec.push_back(handle); });
|
||||
return vec;
|
||||
}
|
||||
@@ -189,6 +189,6 @@ UnlimitedHandleResource<THandle, TStruct, typeValue, TMutex>::FindIf(F func) {
|
||||
return std::pair{0, nullptr};
|
||||
}
|
||||
|
||||
} // namespace cs
|
||||
} // namespace wpi::cs
|
||||
|
||||
#endif // CSCORE_UNLIMITEDHANDLERESOURCE_HPP_
|
||||
|
||||
@@ -8,16 +8,16 @@
|
||||
#include "wpi/cs/cscore_cpp.hpp"
|
||||
#include "wpi/util/MemAlloc.hpp"
|
||||
|
||||
using namespace cs;
|
||||
using namespace wpi::cs;
|
||||
|
||||
static void ConvertToC(CS_UsbCameraInfo* out, const UsbCameraInfo& in) {
|
||||
out->dev = in.dev;
|
||||
cs::ConvertToC(&out->path, in.path);
|
||||
cs::ConvertToC(&out->name, in.name);
|
||||
wpi::cs::ConvertToC(&out->path, in.path);
|
||||
wpi::cs::ConvertToC(&out->name, in.name);
|
||||
out->otherPaths = WPI_AllocateStringArray(in.otherPaths.size());
|
||||
out->otherPathsCount = in.otherPaths.size();
|
||||
for (size_t i = 0; i < in.otherPaths.size(); ++i) {
|
||||
cs::ConvertToC(&out->otherPaths[i], in.otherPaths[i]);
|
||||
wpi::cs::ConvertToC(&out->otherPaths[i], in.otherPaths[i]);
|
||||
}
|
||||
out->vendorId = in.vendorId;
|
||||
out->productId = in.productId;
|
||||
@@ -35,36 +35,36 @@ extern "C" {
|
||||
|
||||
CS_Source CS_CreateUsbCameraDev(const struct WPI_String* name, int dev,
|
||||
CS_Status* status) {
|
||||
return cs::CreateUsbCameraDev(wpi::to_string_view(name), dev, status);
|
||||
return wpi::cs::CreateUsbCameraDev(wpi::util::to_string_view(name), dev, status);
|
||||
}
|
||||
|
||||
CS_Source CS_CreateUsbCameraPath(const struct WPI_String* name,
|
||||
const struct WPI_String* path,
|
||||
CS_Status* status) {
|
||||
return cs::CreateUsbCameraPath(wpi::to_string_view(name),
|
||||
wpi::to_string_view(path), status);
|
||||
return wpi::cs::CreateUsbCameraPath(wpi::util::to_string_view(name),
|
||||
wpi::util::to_string_view(path), status);
|
||||
}
|
||||
|
||||
void CS_SetUsbCameraPath(CS_Source source, const struct WPI_String* path,
|
||||
CS_Status* status) {
|
||||
cs::SetUsbCameraPath(source, wpi::to_string_view(path), status);
|
||||
wpi::cs::SetUsbCameraPath(source, wpi::util::to_string_view(path), status);
|
||||
}
|
||||
|
||||
void CS_GetUsbCameraPath(CS_Source source, WPI_String* path,
|
||||
CS_Status* status) {
|
||||
ConvertToC(path, cs::GetUsbCameraPath(source, status));
|
||||
ConvertToC(path, wpi::cs::GetUsbCameraPath(source, status));
|
||||
}
|
||||
|
||||
void CS_GetUsbCameraInfo(CS_Source source, CS_UsbCameraInfo* info,
|
||||
CS_Status* status) {
|
||||
auto info_cpp = cs::GetUsbCameraInfo(source, status);
|
||||
auto info_cpp = wpi::cs::GetUsbCameraInfo(source, status);
|
||||
ConvertToC(info, info_cpp);
|
||||
}
|
||||
|
||||
CS_UsbCameraInfo* CS_EnumerateUsbCameras(int* count, CS_Status* status) {
|
||||
auto cameras = cs::EnumerateUsbCameras(status);
|
||||
auto cameras = wpi::cs::EnumerateUsbCameras(status);
|
||||
CS_UsbCameraInfo* out = static_cast<CS_UsbCameraInfo*>(
|
||||
wpi::safe_malloc(cameras.size() * sizeof(CS_UsbCameraInfo)));
|
||||
wpi::util::safe_malloc(cameras.size() * sizeof(CS_UsbCameraInfo)));
|
||||
*count = cameras.size();
|
||||
for (size_t i = 0; i < cameras.size(); ++i) {
|
||||
ConvertToC(&out[i], cameras[i]);
|
||||
|
||||
@@ -9,13 +9,13 @@
|
||||
|
||||
#include "wpi/util/Logger.hpp"
|
||||
|
||||
namespace cs {
|
||||
namespace wpi::cs {
|
||||
|
||||
class Notifier;
|
||||
|
||||
class UsbCameraListener {
|
||||
public:
|
||||
UsbCameraListener(wpi::Logger& logger, Notifier& notifier);
|
||||
UsbCameraListener(wpi::util::Logger& logger, Notifier& notifier);
|
||||
~UsbCameraListener();
|
||||
|
||||
void Start();
|
||||
@@ -26,6 +26,6 @@ class UsbCameraListener {
|
||||
std::unique_ptr<Impl> m_impl;
|
||||
};
|
||||
|
||||
} // namespace cs
|
||||
} // namespace wpi::cs
|
||||
|
||||
#endif // CSCORE_USBCAMERALISTENER_HPP_
|
||||
|
||||
@@ -10,13 +10,13 @@
|
||||
|
||||
#include "wpi/util/string.h"
|
||||
|
||||
namespace cs {
|
||||
namespace wpi::cs {
|
||||
|
||||
inline void ConvertToC(struct WPI_String* output, std::string_view str) {
|
||||
char* write = WPI_AllocateString(output, str.size());
|
||||
std::memcpy(write, str.data(), str.size());
|
||||
}
|
||||
|
||||
} // namespace cs
|
||||
} // namespace wpi::cs
|
||||
|
||||
#endif // CSCORE_C_UTIL_HPP_
|
||||
|
||||
@@ -15,17 +15,17 @@
|
||||
#include "wpi/util/MemAlloc.hpp"
|
||||
#include "wpi/util/SmallString.hpp"
|
||||
|
||||
static CS_Event ConvertToC(const cs::RawEvent& rawEvent) {
|
||||
static CS_Event ConvertToC(const wpi::cs::RawEvent& rawEvent) {
|
||||
CS_Event event;
|
||||
event.kind = static_cast<CS_EventKind>(static_cast<int>(rawEvent.kind));
|
||||
event.source = rawEvent.sourceHandle;
|
||||
event.sink = rawEvent.sinkHandle;
|
||||
cs::ConvertToC(&event.name, rawEvent.name);
|
||||
wpi::cs::ConvertToC(&event.name, rawEvent.name);
|
||||
event.mode = rawEvent.mode;
|
||||
event.property = rawEvent.propertyHandle;
|
||||
event.propertyKind = rawEvent.propertyKind;
|
||||
event.value = rawEvent.value;
|
||||
cs::ConvertToC(&event.name, rawEvent.valueStr);
|
||||
wpi::cs::ConvertToC(&event.name, rawEvent.valueStr);
|
||||
event.listener = rawEvent.listener;
|
||||
return event;
|
||||
}
|
||||
@@ -34,7 +34,7 @@ template <typename O, typename I>
|
||||
static O* ConvertToC(std::vector<I>&& in, int* count) {
|
||||
using T = std::vector<I>;
|
||||
size_t size = in.size();
|
||||
O* out = static_cast<O*>(wpi::safe_malloc(size * sizeof(O) + sizeof(T)));
|
||||
O* out = static_cast<O*>(wpi::util::safe_malloc(size * sizeof(O) + sizeof(T)));
|
||||
*count = size;
|
||||
for (size_t i = 0; i < size; ++i) {
|
||||
out[i] = ConvertToC(in[i]);
|
||||
@@ -51,106 +51,106 @@ static O* ConvertToC(std::vector<I>&& in, int* count) {
|
||||
extern "C" {
|
||||
|
||||
CS_PropertyKind CS_GetPropertyKind(CS_Property property, CS_Status* status) {
|
||||
return cs::GetPropertyKind(property, status);
|
||||
return wpi::cs::GetPropertyKind(property, status);
|
||||
}
|
||||
|
||||
void CS_GetPropertyName(CS_Property property, WPI_String* name,
|
||||
CS_Status* status) {
|
||||
wpi::SmallString<128> buf;
|
||||
cs::ConvertToC(name, cs::GetPropertyName(property, buf, status));
|
||||
wpi::util::SmallString<128> buf;
|
||||
wpi::cs::ConvertToC(name, wpi::cs::GetPropertyName(property, buf, status));
|
||||
}
|
||||
|
||||
int CS_GetProperty(CS_Property property, CS_Status* status) {
|
||||
return cs::GetProperty(property, status);
|
||||
return wpi::cs::GetProperty(property, status);
|
||||
}
|
||||
|
||||
void CS_SetProperty(CS_Property property, int value, CS_Status* status) {
|
||||
return cs::SetProperty(property, value, status);
|
||||
return wpi::cs::SetProperty(property, value, status);
|
||||
}
|
||||
|
||||
int CS_GetPropertyMin(CS_Property property, CS_Status* status) {
|
||||
return cs::GetPropertyMin(property, status);
|
||||
return wpi::cs::GetPropertyMin(property, status);
|
||||
}
|
||||
|
||||
int CS_GetPropertyMax(CS_Property property, CS_Status* status) {
|
||||
return cs::GetPropertyMax(property, status);
|
||||
return wpi::cs::GetPropertyMax(property, status);
|
||||
}
|
||||
|
||||
int CS_GetPropertyStep(CS_Property property, CS_Status* status) {
|
||||
return cs::GetPropertyStep(property, status);
|
||||
return wpi::cs::GetPropertyStep(property, status);
|
||||
}
|
||||
|
||||
int CS_GetPropertyDefault(CS_Property property, CS_Status* status) {
|
||||
return cs::GetPropertyDefault(property, status);
|
||||
return wpi::cs::GetPropertyDefault(property, status);
|
||||
}
|
||||
|
||||
void CS_GetStringProperty(CS_Property property, WPI_String* value,
|
||||
CS_Status* status) {
|
||||
wpi::SmallString<128> buf;
|
||||
cs::ConvertToC(value, cs::GetStringProperty(property, buf, status));
|
||||
wpi::util::SmallString<128> buf;
|
||||
wpi::cs::ConvertToC(value, wpi::cs::GetStringProperty(property, buf, status));
|
||||
}
|
||||
|
||||
void CS_SetStringProperty(CS_Property property, const struct WPI_String* value,
|
||||
CS_Status* status) {
|
||||
return cs::SetStringProperty(property, wpi::to_string_view(value), status);
|
||||
return wpi::cs::SetStringProperty(property, wpi::util::to_string_view(value), status);
|
||||
}
|
||||
|
||||
WPI_String* CS_GetEnumPropertyChoices(CS_Property property, int* count,
|
||||
CS_Status* status) {
|
||||
auto choices = cs::GetEnumPropertyChoices(property, status);
|
||||
auto choices = wpi::cs::GetEnumPropertyChoices(property, status);
|
||||
WPI_String* out = WPI_AllocateStringArray(choices.size());
|
||||
*count = choices.size();
|
||||
for (size_t i = 0; i < choices.size(); ++i) {
|
||||
cs::ConvertToC(&out[i], choices[i]);
|
||||
wpi::cs::ConvertToC(&out[i], choices[i]);
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
CS_SourceKind CS_GetSourceKind(CS_Source source, CS_Status* status) {
|
||||
return cs::GetSourceKind(source, status);
|
||||
return wpi::cs::GetSourceKind(source, status);
|
||||
}
|
||||
|
||||
void CS_GetSourceName(CS_Source source, WPI_String* name, CS_Status* status) {
|
||||
wpi::SmallString<128> buf;
|
||||
cs::ConvertToC(name, cs::GetSourceName(source, buf, status));
|
||||
wpi::util::SmallString<128> buf;
|
||||
wpi::cs::ConvertToC(name, wpi::cs::GetSourceName(source, buf, status));
|
||||
}
|
||||
|
||||
void CS_GetSourceDescription(CS_Source source, WPI_String* description,
|
||||
CS_Status* status) {
|
||||
wpi::SmallString<128> buf;
|
||||
cs::ConvertToC(description, cs::GetSourceDescription(source, buf, status));
|
||||
wpi::util::SmallString<128> buf;
|
||||
wpi::cs::ConvertToC(description, wpi::cs::GetSourceDescription(source, buf, status));
|
||||
}
|
||||
|
||||
uint64_t CS_GetSourceLastFrameTime(CS_Source source, CS_Status* status) {
|
||||
return cs::GetSourceLastFrameTime(source, status);
|
||||
return wpi::cs::GetSourceLastFrameTime(source, status);
|
||||
}
|
||||
|
||||
void CS_SetSourceConnectionStrategy(CS_Source source,
|
||||
CS_ConnectionStrategy strategy,
|
||||
CS_Status* status) {
|
||||
cs::SetSourceConnectionStrategy(source, strategy, status);
|
||||
wpi::cs::SetSourceConnectionStrategy(source, strategy, status);
|
||||
}
|
||||
|
||||
CS_Bool CS_IsSourceConnected(CS_Source source, CS_Status* status) {
|
||||
return cs::IsSourceConnected(source, status);
|
||||
return wpi::cs::IsSourceConnected(source, status);
|
||||
}
|
||||
|
||||
CS_Bool CS_IsSourceEnabled(CS_Source source, CS_Status* status) {
|
||||
return cs::IsSourceEnabled(source, status);
|
||||
return wpi::cs::IsSourceEnabled(source, status);
|
||||
}
|
||||
|
||||
CS_Property CS_GetSourceProperty(CS_Source source,
|
||||
const struct WPI_String* name,
|
||||
CS_Status* status) {
|
||||
return cs::GetSourceProperty(source, wpi::to_string_view(name), status);
|
||||
return wpi::cs::GetSourceProperty(source, wpi::util::to_string_view(name), status);
|
||||
}
|
||||
|
||||
CS_Property* CS_EnumerateSourceProperties(CS_Source source, int* count,
|
||||
CS_Status* status) {
|
||||
wpi::SmallVector<CS_Property, 32> buf;
|
||||
auto vec = cs::EnumerateSourceProperties(source, buf, status);
|
||||
wpi::util::SmallVector<CS_Property, 32> buf;
|
||||
auto vec = wpi::cs::EnumerateSourceProperties(source, buf, status);
|
||||
CS_Property* out = static_cast<CS_Property*>(
|
||||
wpi::safe_malloc(vec.size() * sizeof(CS_Property)));
|
||||
wpi::util::safe_malloc(vec.size() * sizeof(CS_Property)));
|
||||
*count = vec.size();
|
||||
std::copy(vec.begin(), vec.end(), out);
|
||||
return out;
|
||||
@@ -158,22 +158,22 @@ CS_Property* CS_EnumerateSourceProperties(CS_Source source, int* count,
|
||||
|
||||
void CS_GetSourceVideoMode(CS_Source source, CS_VideoMode* mode,
|
||||
CS_Status* status) {
|
||||
*mode = cs::GetSourceVideoMode(source, status);
|
||||
*mode = wpi::cs::GetSourceVideoMode(source, status);
|
||||
}
|
||||
|
||||
CS_Bool CS_SetSourceVideoMode(CS_Source source, const CS_VideoMode* mode,
|
||||
CS_Status* status) {
|
||||
return cs::SetSourceVideoMode(
|
||||
source, static_cast<const cs::VideoMode&>(*mode), status);
|
||||
return wpi::cs::SetSourceVideoMode(
|
||||
source, static_cast<const wpi::cs::VideoMode&>(*mode), status);
|
||||
}
|
||||
|
||||
CS_Bool CS_SetSourceVideoModeDiscrete(CS_Source source,
|
||||
enum WPI_PixelFormat pixelFormat,
|
||||
int width, int height, int fps,
|
||||
CS_Status* status) {
|
||||
return cs::SetSourceVideoMode(
|
||||
return wpi::cs::SetSourceVideoMode(
|
||||
source,
|
||||
cs::VideoMode{static_cast<cs::VideoMode::PixelFormat>(
|
||||
wpi::cs::VideoMode{static_cast<wpi::cs::VideoMode::PixelFormat>(
|
||||
static_cast<int>(pixelFormat)),
|
||||
width, height, fps},
|
||||
status);
|
||||
@@ -182,37 +182,37 @@ CS_Bool CS_SetSourceVideoModeDiscrete(CS_Source source,
|
||||
CS_Bool CS_SetSourcePixelFormat(CS_Source source,
|
||||
enum WPI_PixelFormat pixelFormat,
|
||||
CS_Status* status) {
|
||||
return cs::SetSourcePixelFormat(
|
||||
return wpi::cs::SetSourcePixelFormat(
|
||||
source,
|
||||
static_cast<cs::VideoMode::PixelFormat>(static_cast<int>(pixelFormat)),
|
||||
static_cast<wpi::cs::VideoMode::PixelFormat>(static_cast<int>(pixelFormat)),
|
||||
status);
|
||||
}
|
||||
|
||||
CS_Bool CS_SetSourceResolution(CS_Source source, int width, int height,
|
||||
CS_Status* status) {
|
||||
return cs::SetSourceResolution(source, width, height, status);
|
||||
return wpi::cs::SetSourceResolution(source, width, height, status);
|
||||
}
|
||||
|
||||
CS_Bool CS_SetSourceFPS(CS_Source source, int fps, CS_Status* status) {
|
||||
return cs::SetSourceFPS(source, fps, status);
|
||||
return wpi::cs::SetSourceFPS(source, fps, status);
|
||||
}
|
||||
|
||||
CS_Bool CS_SetSourceConfigJson(CS_Source source,
|
||||
const struct WPI_String* config,
|
||||
CS_Status* status) {
|
||||
return cs::SetSourceConfigJson(source, wpi::to_string_view(config), status);
|
||||
return wpi::cs::SetSourceConfigJson(source, wpi::util::to_string_view(config), status);
|
||||
}
|
||||
|
||||
void CS_GetSourceConfigJson(CS_Source source, WPI_String* config,
|
||||
CS_Status* status) {
|
||||
cs::ConvertToC(config, cs::GetSourceConfigJson(source, status));
|
||||
wpi::cs::ConvertToC(config, wpi::cs::GetSourceConfigJson(source, status));
|
||||
}
|
||||
|
||||
CS_VideoMode* CS_EnumerateSourceVideoModes(CS_Source source, int* count,
|
||||
CS_Status* status) {
|
||||
auto vec = cs::EnumerateSourceVideoModes(source, status);
|
||||
auto vec = wpi::cs::EnumerateSourceVideoModes(source, status);
|
||||
CS_VideoMode* out = static_cast<CS_VideoMode*>(
|
||||
wpi::safe_malloc(vec.size() * sizeof(CS_VideoMode)));
|
||||
wpi::util::safe_malloc(vec.size() * sizeof(CS_VideoMode)));
|
||||
*count = vec.size();
|
||||
std::copy(vec.begin(), vec.end(), out);
|
||||
return out;
|
||||
@@ -220,84 +220,84 @@ CS_VideoMode* CS_EnumerateSourceVideoModes(CS_Source source, int* count,
|
||||
|
||||
CS_Sink* CS_EnumerateSourceSinks(CS_Source source, int* count,
|
||||
CS_Status* status) {
|
||||
wpi::SmallVector<CS_Sink, 32> buf;
|
||||
auto handles = cs::EnumerateSourceSinks(source, buf, status);
|
||||
wpi::util::SmallVector<CS_Sink, 32> buf;
|
||||
auto handles = wpi::cs::EnumerateSourceSinks(source, buf, status);
|
||||
CS_Sink* sinks =
|
||||
static_cast<CS_Sink*>(wpi::safe_malloc(handles.size() * sizeof(CS_Sink)));
|
||||
static_cast<CS_Sink*>(wpi::util::safe_malloc(handles.size() * sizeof(CS_Sink)));
|
||||
*count = handles.size();
|
||||
std::copy(handles.begin(), handles.end(), sinks);
|
||||
return sinks;
|
||||
}
|
||||
|
||||
CS_Source CS_CopySource(CS_Source source, CS_Status* status) {
|
||||
return cs::CopySource(source, status);
|
||||
return wpi::cs::CopySource(source, status);
|
||||
}
|
||||
|
||||
void CS_ReleaseSource(CS_Source source, CS_Status* status) {
|
||||
return cs::ReleaseSource(source, status);
|
||||
return wpi::cs::ReleaseSource(source, status);
|
||||
}
|
||||
|
||||
void CS_SetCameraBrightness(CS_Source source, int brightness,
|
||||
CS_Status* status) {
|
||||
return cs::SetCameraBrightness(source, brightness, status);
|
||||
return wpi::cs::SetCameraBrightness(source, brightness, status);
|
||||
}
|
||||
|
||||
int CS_GetCameraBrightness(CS_Source source, CS_Status* status) {
|
||||
return cs::GetCameraBrightness(source, status);
|
||||
return wpi::cs::GetCameraBrightness(source, status);
|
||||
}
|
||||
|
||||
void CS_SetCameraWhiteBalanceAuto(CS_Source source, CS_Status* status) {
|
||||
return cs::SetCameraWhiteBalanceAuto(source, status);
|
||||
return wpi::cs::SetCameraWhiteBalanceAuto(source, status);
|
||||
}
|
||||
|
||||
void CS_SetCameraWhiteBalanceHoldCurrent(CS_Source source, CS_Status* status) {
|
||||
return cs::SetCameraWhiteBalanceHoldCurrent(source, status);
|
||||
return wpi::cs::SetCameraWhiteBalanceHoldCurrent(source, status);
|
||||
}
|
||||
|
||||
void CS_SetCameraWhiteBalanceManual(CS_Source source, int value,
|
||||
CS_Status* status) {
|
||||
return cs::SetCameraWhiteBalanceManual(source, value, status);
|
||||
return wpi::cs::SetCameraWhiteBalanceManual(source, value, status);
|
||||
}
|
||||
|
||||
void CS_SetCameraExposureAuto(CS_Source source, CS_Status* status) {
|
||||
return cs::SetCameraExposureAuto(source, status);
|
||||
return wpi::cs::SetCameraExposureAuto(source, status);
|
||||
}
|
||||
|
||||
void CS_SetCameraExposureHoldCurrent(CS_Source source, CS_Status* status) {
|
||||
return cs::SetCameraExposureHoldCurrent(source, status);
|
||||
return wpi::cs::SetCameraExposureHoldCurrent(source, status);
|
||||
}
|
||||
|
||||
void CS_SetCameraExposureManual(CS_Source source, int value,
|
||||
CS_Status* status) {
|
||||
return cs::SetCameraExposureManual(source, value, status);
|
||||
return wpi::cs::SetCameraExposureManual(source, value, status);
|
||||
}
|
||||
|
||||
CS_SinkKind CS_GetSinkKind(CS_Sink sink, CS_Status* status) {
|
||||
return cs::GetSinkKind(sink, status);
|
||||
return wpi::cs::GetSinkKind(sink, status);
|
||||
}
|
||||
|
||||
void CS_GetSinkName(CS_Sink sink, WPI_String* name, CS_Status* status) {
|
||||
wpi::SmallString<128> buf;
|
||||
cs::ConvertToC(name, cs::GetSinkName(sink, buf, status));
|
||||
wpi::util::SmallString<128> buf;
|
||||
wpi::cs::ConvertToC(name, wpi::cs::GetSinkName(sink, buf, status));
|
||||
}
|
||||
|
||||
void CS_GetSinkDescription(CS_Sink sink, WPI_String* description,
|
||||
CS_Status* status) {
|
||||
wpi::SmallString<128> buf;
|
||||
cs::ConvertToC(description, cs::GetSinkDescription(sink, buf, status));
|
||||
wpi::util::SmallString<128> buf;
|
||||
wpi::cs::ConvertToC(description, wpi::cs::GetSinkDescription(sink, buf, status));
|
||||
}
|
||||
|
||||
CS_Property CS_GetSinkProperty(CS_Sink sink, const struct WPI_String* name,
|
||||
CS_Status* status) {
|
||||
return cs::GetSinkProperty(sink, wpi::to_string_view(name), status);
|
||||
return wpi::cs::GetSinkProperty(sink, wpi::util::to_string_view(name), status);
|
||||
}
|
||||
|
||||
CS_Property* CS_EnumerateSinkProperties(CS_Sink sink, int* count,
|
||||
CS_Status* status) {
|
||||
wpi::SmallVector<CS_Property, 32> buf;
|
||||
auto vec = cs::EnumerateSinkProperties(sink, buf, status);
|
||||
wpi::util::SmallVector<CS_Property, 32> buf;
|
||||
auto vec = wpi::cs::EnumerateSinkProperties(sink, buf, status);
|
||||
CS_Property* out = static_cast<CS_Property*>(
|
||||
wpi::safe_malloc(vec.size() * sizeof(CS_Property)));
|
||||
wpi::util::safe_malloc(vec.size() * sizeof(CS_Property)));
|
||||
*count = vec.size();
|
||||
std::copy(vec.begin(), vec.end(), out);
|
||||
return out;
|
||||
@@ -305,49 +305,49 @@ CS_Property* CS_EnumerateSinkProperties(CS_Sink sink, int* count,
|
||||
|
||||
CS_Bool CS_SetSinkConfigJson(CS_Sink sink, const struct WPI_String* config,
|
||||
CS_Status* status) {
|
||||
return cs::SetSinkConfigJson(sink, wpi::to_string_view(config), status);
|
||||
return wpi::cs::SetSinkConfigJson(sink, wpi::util::to_string_view(config), status);
|
||||
}
|
||||
|
||||
void CS_GetSinkConfigJson(CS_Sink sink, WPI_String* config, CS_Status* status) {
|
||||
cs::ConvertToC(config, cs::GetSinkConfigJson(sink, status));
|
||||
wpi::cs::ConvertToC(config, wpi::cs::GetSinkConfigJson(sink, status));
|
||||
}
|
||||
|
||||
void CS_SetSinkSource(CS_Sink sink, CS_Source source, CS_Status* status) {
|
||||
return cs::SetSinkSource(sink, source, status);
|
||||
return wpi::cs::SetSinkSource(sink, source, status);
|
||||
}
|
||||
|
||||
CS_Source CS_GetSinkSource(CS_Sink sink, CS_Status* status) {
|
||||
return cs::GetSinkSource(sink, status);
|
||||
return wpi::cs::GetSinkSource(sink, status);
|
||||
}
|
||||
|
||||
CS_Property CS_GetSinkSourceProperty(CS_Sink sink,
|
||||
const struct WPI_String* name,
|
||||
CS_Status* status) {
|
||||
return cs::GetSinkSourceProperty(sink, wpi::to_string_view(name), status);
|
||||
return wpi::cs::GetSinkSourceProperty(sink, wpi::util::to_string_view(name), status);
|
||||
}
|
||||
|
||||
CS_Sink CS_CopySink(CS_Sink sink, CS_Status* status) {
|
||||
return cs::CopySink(sink, status);
|
||||
return wpi::cs::CopySink(sink, status);
|
||||
}
|
||||
|
||||
void CS_ReleaseSink(CS_Sink sink, CS_Status* status) {
|
||||
return cs::ReleaseSink(sink, status);
|
||||
return wpi::cs::ReleaseSink(sink, status);
|
||||
}
|
||||
|
||||
void CS_SetListenerOnStart(void (*onStart)(void* data), void* data) {
|
||||
cs::SetListenerOnStart([=] { onStart(data); });
|
||||
wpi::cs::SetListenerOnStart([=] { onStart(data); });
|
||||
}
|
||||
|
||||
void CS_SetListenerOnExit(void (*onExit)(void* data), void* data) {
|
||||
cs::SetListenerOnExit([=] { onExit(data); });
|
||||
wpi::cs::SetListenerOnExit([=] { onExit(data); });
|
||||
}
|
||||
|
||||
CS_Listener CS_AddListener(void* data,
|
||||
void (*callback)(void* data, const CS_Event* event),
|
||||
int eventMask, CS_Bool immediateNotify,
|
||||
CS_Status* status) {
|
||||
return cs::AddListener(
|
||||
[=](const cs::RawEvent& rawEvent) {
|
||||
return wpi::cs::AddListener(
|
||||
[=](const wpi::cs::RawEvent& rawEvent) {
|
||||
CS_Event event = ConvertToC(rawEvent);
|
||||
callback(data, &event);
|
||||
},
|
||||
@@ -355,41 +355,41 @@ CS_Listener CS_AddListener(void* data,
|
||||
}
|
||||
|
||||
void CS_RemoveListener(CS_Listener handle, CS_Status* status) {
|
||||
return cs::RemoveListener(handle, status);
|
||||
return wpi::cs::RemoveListener(handle, status);
|
||||
}
|
||||
|
||||
CS_ListenerPoller CS_CreateListenerPoller(void) {
|
||||
return cs::CreateListenerPoller();
|
||||
return wpi::cs::CreateListenerPoller();
|
||||
}
|
||||
|
||||
void CS_DestroyListenerPoller(CS_ListenerPoller poller) {
|
||||
cs::DestroyListenerPoller(poller);
|
||||
wpi::cs::DestroyListenerPoller(poller);
|
||||
}
|
||||
|
||||
CS_Listener CS_AddPolledListener(CS_ListenerPoller poller, int eventMask,
|
||||
CS_Bool immediateNotify, CS_Status* status) {
|
||||
return cs::AddPolledListener(poller, eventMask, immediateNotify, status);
|
||||
return wpi::cs::AddPolledListener(poller, eventMask, immediateNotify, status);
|
||||
}
|
||||
|
||||
struct CS_Event* CS_PollListener(CS_ListenerPoller poller, int* count) {
|
||||
return ConvertToC<CS_Event>(cs::PollListener(poller), count);
|
||||
return ConvertToC<CS_Event>(wpi::cs::PollListener(poller), count);
|
||||
}
|
||||
|
||||
struct CS_Event* CS_PollListenerTimeout(CS_ListenerPoller poller, int* count,
|
||||
double timeout, CS_Bool* timedOut) {
|
||||
bool cppTimedOut = false;
|
||||
auto arrCpp = cs::PollListener(poller, timeout, &cppTimedOut);
|
||||
auto arrCpp = wpi::cs::PollListener(poller, timeout, &cppTimedOut);
|
||||
*timedOut = cppTimedOut;
|
||||
return ConvertToC<CS_Event>(std::move(arrCpp), count);
|
||||
}
|
||||
|
||||
void CS_CancelPollListener(CS_ListenerPoller poller) {
|
||||
cs::CancelPollListener(poller);
|
||||
wpi::cs::CancelPollListener(poller);
|
||||
}
|
||||
|
||||
void CS_FreeEvents(CS_Event* arr, int count) {
|
||||
// destroy vector saved at end of array
|
||||
using T = std::vector<cs::RawEvent>;
|
||||
using T = std::vector<wpi::cs::RawEvent>;
|
||||
alignas(T) unsigned char buf[sizeof(T)];
|
||||
std::memcpy(buf, arr + count, sizeof(T));
|
||||
reinterpret_cast<T*>(buf)->~T();
|
||||
@@ -398,51 +398,51 @@ void CS_FreeEvents(CS_Event* arr, int count) {
|
||||
}
|
||||
|
||||
int CS_NotifierDestroyed(void) {
|
||||
return cs::NotifierDestroyed();
|
||||
return wpi::cs::NotifierDestroyed();
|
||||
}
|
||||
|
||||
void CS_SetTelemetryPeriod(double seconds) {
|
||||
cs::SetTelemetryPeriod(seconds);
|
||||
wpi::cs::SetTelemetryPeriod(seconds);
|
||||
}
|
||||
|
||||
double CS_GetTelemetryElapsedTime(void) {
|
||||
return cs::GetTelemetryElapsedTime();
|
||||
return wpi::cs::GetTelemetryElapsedTime();
|
||||
}
|
||||
|
||||
int64_t CS_GetTelemetryValue(CS_Handle handle, CS_TelemetryKind kind,
|
||||
CS_Status* status) {
|
||||
return cs::GetTelemetryValue(handle, kind, status);
|
||||
return wpi::cs::GetTelemetryValue(handle, kind, status);
|
||||
}
|
||||
|
||||
double CS_GetTelemetryAverageValue(CS_Handle handle, CS_TelemetryKind kind,
|
||||
CS_Status* status) {
|
||||
return cs::GetTelemetryAverageValue(handle, kind, status);
|
||||
return wpi::cs::GetTelemetryAverageValue(handle, kind, status);
|
||||
}
|
||||
|
||||
void CS_SetLogger(CS_LogFunc func, void* data, unsigned int min_level) {
|
||||
cs::SetLogger(
|
||||
wpi::cs::SetLogger(
|
||||
[=](unsigned int level, const char* file, unsigned int line,
|
||||
const char* msg) {
|
||||
auto fileStr = wpi::make_string(file);
|
||||
auto msgStr = wpi::make_string(msg);
|
||||
auto fileStr = wpi::util::make_string(file);
|
||||
auto msgStr = wpi::util::make_string(msg);
|
||||
func(data, level, &fileStr, line, &msgStr);
|
||||
},
|
||||
min_level);
|
||||
}
|
||||
|
||||
void CS_SetDefaultLogger(unsigned int min_level) {
|
||||
cs::SetDefaultLogger(min_level);
|
||||
wpi::cs::SetDefaultLogger(min_level);
|
||||
}
|
||||
|
||||
void CS_Shutdown(void) {
|
||||
cs::Shutdown();
|
||||
wpi::cs::Shutdown();
|
||||
}
|
||||
|
||||
CS_Source* CS_EnumerateSources(int* count, CS_Status* status) {
|
||||
wpi::SmallVector<CS_Source, 32> buf;
|
||||
auto handles = cs::EnumerateSourceHandles(buf, status);
|
||||
wpi::util::SmallVector<CS_Source, 32> buf;
|
||||
auto handles = wpi::cs::EnumerateSourceHandles(buf, status);
|
||||
CS_Source* sources = static_cast<CS_Source*>(
|
||||
wpi::safe_malloc(handles.size() * sizeof(CS_Source)));
|
||||
wpi::util::safe_malloc(handles.size() * sizeof(CS_Source)));
|
||||
*count = handles.size();
|
||||
std::copy(handles.begin(), handles.end(), sources);
|
||||
return sources;
|
||||
@@ -455,17 +455,17 @@ void CS_ReleaseEnumeratedSources(CS_Source* sources, int count) {
|
||||
for (int i = 0; i < count; ++i) {
|
||||
CS_Status status = 0;
|
||||
if (sources[i] != 0) {
|
||||
cs::ReleaseSource(sources[i], &status);
|
||||
wpi::cs::ReleaseSource(sources[i], &status);
|
||||
}
|
||||
}
|
||||
std::free(sources);
|
||||
}
|
||||
|
||||
CS_Sink* CS_EnumerateSinks(int* count, CS_Status* status) {
|
||||
wpi::SmallVector<CS_Sink, 32> buf;
|
||||
auto handles = cs::EnumerateSinkHandles(buf, status);
|
||||
wpi::util::SmallVector<CS_Sink, 32> buf;
|
||||
auto handles = wpi::cs::EnumerateSinkHandles(buf, status);
|
||||
CS_Sink* sinks =
|
||||
static_cast<CS_Sink*>(wpi::safe_malloc(handles.size() * sizeof(CS_Sink)));
|
||||
static_cast<CS_Sink*>(wpi::util::safe_malloc(handles.size() * sizeof(CS_Sink)));
|
||||
*count = handles.size();
|
||||
std::copy(handles.begin(), handles.end(), sinks);
|
||||
return sinks;
|
||||
@@ -478,7 +478,7 @@ void CS_ReleaseEnumeratedSinks(CS_Sink* sinks, int count) {
|
||||
for (int i = 0; i < count; ++i) {
|
||||
CS_Status status = 0;
|
||||
if (sinks[i] != 0) {
|
||||
cs::ReleaseSink(sinks[i], &status);
|
||||
wpi::cs::ReleaseSink(sinks[i], &status);
|
||||
}
|
||||
}
|
||||
std::free(sinks);
|
||||
@@ -493,15 +493,15 @@ void CS_FreeEnumeratedVideoModes(CS_VideoMode* modes, int count) {
|
||||
}
|
||||
|
||||
void CS_GetHostname(struct WPI_String* hostname) {
|
||||
cs::ConvertToC(hostname, cs::GetHostname());
|
||||
wpi::cs::ConvertToC(hostname, wpi::cs::GetHostname());
|
||||
}
|
||||
|
||||
WPI_String* CS_GetNetworkInterfaces(int* count) {
|
||||
auto interfaces = cs::GetNetworkInterfaces();
|
||||
auto interfaces = wpi::cs::GetNetworkInterfaces();
|
||||
WPI_String* out = WPI_AllocateStringArray(interfaces.size());
|
||||
*count = interfaces.size();
|
||||
for (size_t i = 0; i < interfaces.size(); ++i) {
|
||||
cs::ConvertToC(&out[i], interfaces[i]);
|
||||
wpi::cs::ConvertToC(&out[i], interfaces[i]);
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
#include "wpi/util/SmallString.hpp"
|
||||
#include "wpi/util/json.hpp"
|
||||
|
||||
using namespace cs;
|
||||
using namespace wpi::cs;
|
||||
|
||||
static std::shared_ptr<PropertyContainer> GetPropertyContainer(
|
||||
CS_Property propertyHandle, int* propertyIndex, CS_Status* status) {
|
||||
@@ -51,7 +51,7 @@ static std::shared_ptr<PropertyContainer> GetPropertyContainer(
|
||||
return container;
|
||||
}
|
||||
|
||||
namespace cs {
|
||||
namespace wpi::cs {
|
||||
|
||||
//
|
||||
// Property Functions
|
||||
@@ -67,7 +67,7 @@ CS_PropertyKind GetPropertyKind(CS_Property property, CS_Status* status) {
|
||||
}
|
||||
|
||||
std::string GetPropertyName(CS_Property property, CS_Status* status) {
|
||||
wpi::SmallString<128> buf;
|
||||
wpi::util::SmallString<128> buf;
|
||||
int propertyIndex;
|
||||
auto container = GetPropertyContainer(property, &propertyIndex, status);
|
||||
if (!container) {
|
||||
@@ -77,7 +77,7 @@ std::string GetPropertyName(CS_Property property, CS_Status* status) {
|
||||
}
|
||||
|
||||
std::string_view GetPropertyName(CS_Property property,
|
||||
wpi::SmallVectorImpl<char>& buf,
|
||||
wpi::util::SmallVectorImpl<char>& buf,
|
||||
CS_Status* status) {
|
||||
int propertyIndex;
|
||||
auto container = GetPropertyContainer(property, &propertyIndex, status);
|
||||
@@ -142,7 +142,7 @@ int GetPropertyDefault(CS_Property property, CS_Status* status) {
|
||||
}
|
||||
|
||||
std::string GetStringProperty(CS_Property property, CS_Status* status) {
|
||||
wpi::SmallString<128> buf;
|
||||
wpi::util::SmallString<128> buf;
|
||||
int propertyIndex;
|
||||
auto container = GetPropertyContainer(property, &propertyIndex, status);
|
||||
if (!container) {
|
||||
@@ -152,7 +152,7 @@ std::string GetStringProperty(CS_Property property, CS_Status* status) {
|
||||
}
|
||||
|
||||
std::string_view GetStringProperty(CS_Property property,
|
||||
wpi::SmallVectorImpl<char>& buf,
|
||||
wpi::util::SmallVectorImpl<char>& buf,
|
||||
CS_Status* status) {
|
||||
int propertyIndex;
|
||||
auto container = GetPropertyContainer(property, &propertyIndex, status);
|
||||
@@ -205,7 +205,7 @@ std::string GetSourceName(CS_Source source, CS_Status* status) {
|
||||
}
|
||||
|
||||
std::string_view GetSourceName(CS_Source source,
|
||||
wpi::SmallVectorImpl<char>& buf,
|
||||
wpi::util::SmallVectorImpl<char>& buf,
|
||||
CS_Status* status) {
|
||||
auto data = Instance::GetInstance().GetSource(source);
|
||||
if (!data) {
|
||||
@@ -221,12 +221,12 @@ std::string GetSourceDescription(CS_Source source, CS_Status* status) {
|
||||
*status = CS_INVALID_HANDLE;
|
||||
return {};
|
||||
}
|
||||
wpi::SmallString<128> buf;
|
||||
wpi::util::SmallString<128> buf;
|
||||
return std::string{data->source->GetDescription(buf)};
|
||||
}
|
||||
|
||||
std::string_view GetSourceDescription(CS_Source source,
|
||||
wpi::SmallVectorImpl<char>& buf,
|
||||
wpi::util::SmallVectorImpl<char>& buf,
|
||||
CS_Status* status) {
|
||||
auto data = Instance::GetInstance().GetSource(source);
|
||||
if (!data) {
|
||||
@@ -290,14 +290,14 @@ CS_Property GetSourceProperty(CS_Source source, std::string_view name,
|
||||
}
|
||||
|
||||
std::span<CS_Property> EnumerateSourceProperties(
|
||||
CS_Source source, wpi::SmallVectorImpl<CS_Property>& vec,
|
||||
CS_Source source, wpi::util::SmallVectorImpl<CS_Property>& vec,
|
||||
CS_Status* status) {
|
||||
auto data = Instance::GetInstance().GetSource(source);
|
||||
if (!data) {
|
||||
*status = CS_INVALID_HANDLE;
|
||||
return {};
|
||||
}
|
||||
wpi::SmallVector<int, 32> properties_buf;
|
||||
wpi::util::SmallVector<int, 32> properties_buf;
|
||||
for (auto property :
|
||||
data->source->EnumerateProperties(properties_buf, status)) {
|
||||
vec.push_back(Handle{source, property, Handle::kProperty});
|
||||
@@ -363,7 +363,7 @@ bool SetSourceConfigJson(CS_Source source, std::string_view config,
|
||||
return data->source->SetConfigJson(config, status);
|
||||
}
|
||||
|
||||
bool SetSourceConfigJson(CS_Source source, const wpi::json& config,
|
||||
bool SetSourceConfigJson(CS_Source source, const wpi::util::json& config,
|
||||
CS_Status* status) {
|
||||
auto data = Instance::GetInstance().GetSource(source);
|
||||
if (!data) {
|
||||
@@ -382,11 +382,11 @@ std::string GetSourceConfigJson(CS_Source source, CS_Status* status) {
|
||||
return data->source->GetConfigJson(status);
|
||||
}
|
||||
|
||||
wpi::json GetSourceConfigJsonObject(CS_Source source, CS_Status* status) {
|
||||
wpi::util::json GetSourceConfigJsonObject(CS_Source source, CS_Status* status) {
|
||||
auto data = Instance::GetInstance().GetSource(source);
|
||||
if (!data) {
|
||||
*status = CS_INVALID_HANDLE;
|
||||
return wpi::json{};
|
||||
return wpi::util::json{};
|
||||
}
|
||||
return data->source->GetConfigJsonObject(status);
|
||||
}
|
||||
@@ -402,7 +402,7 @@ std::vector<VideoMode> EnumerateSourceVideoModes(CS_Source source,
|
||||
}
|
||||
|
||||
std::span<CS_Sink> EnumerateSourceSinks(CS_Source source,
|
||||
wpi::SmallVectorImpl<CS_Sink>& vec,
|
||||
wpi::util::SmallVectorImpl<CS_Sink>& vec,
|
||||
CS_Status* status) {
|
||||
auto& inst = Instance::GetInstance();
|
||||
auto data = inst.GetSource(source);
|
||||
@@ -540,7 +540,7 @@ std::string GetSinkName(CS_Sink sink, CS_Status* status) {
|
||||
return std::string{data->sink->GetName()};
|
||||
}
|
||||
|
||||
std::string_view GetSinkName(CS_Sink sink, wpi::SmallVectorImpl<char>& buf,
|
||||
std::string_view GetSinkName(CS_Sink sink, wpi::util::SmallVectorImpl<char>& buf,
|
||||
CS_Status* status) {
|
||||
auto data = Instance::GetInstance().GetSink(sink);
|
||||
if (!data) {
|
||||
@@ -556,12 +556,12 @@ std::string GetSinkDescription(CS_Sink sink, CS_Status* status) {
|
||||
*status = CS_INVALID_HANDLE;
|
||||
return {};
|
||||
}
|
||||
wpi::SmallString<128> buf;
|
||||
wpi::util::SmallString<128> buf;
|
||||
return std::string{data->sink->GetDescription(buf)};
|
||||
}
|
||||
|
||||
std::string_view GetSinkDescription(CS_Sink sink,
|
||||
wpi::SmallVectorImpl<char>& buf,
|
||||
wpi::util::SmallVectorImpl<char>& buf,
|
||||
CS_Status* status) {
|
||||
auto data = Instance::GetInstance().GetSink(sink);
|
||||
if (!data) {
|
||||
@@ -587,13 +587,13 @@ CS_Property GetSinkProperty(CS_Sink sink, std::string_view name,
|
||||
}
|
||||
|
||||
std::span<CS_Property> EnumerateSinkProperties(
|
||||
CS_Sink sink, wpi::SmallVectorImpl<CS_Property>& vec, CS_Status* status) {
|
||||
CS_Sink sink, wpi::util::SmallVectorImpl<CS_Property>& vec, CS_Status* status) {
|
||||
auto data = Instance::GetInstance().GetSink(sink);
|
||||
if (!data) {
|
||||
*status = CS_INVALID_HANDLE;
|
||||
return {};
|
||||
}
|
||||
wpi::SmallVector<int, 32> properties_buf;
|
||||
wpi::util::SmallVector<int, 32> properties_buf;
|
||||
for (auto property :
|
||||
data->sink->EnumerateProperties(properties_buf, status)) {
|
||||
vec.push_back(Handle{sink, property, Handle::kSinkProperty});
|
||||
@@ -611,7 +611,7 @@ bool SetSinkConfigJson(CS_Sink sink, std::string_view config,
|
||||
return data->sink->SetConfigJson(config, status);
|
||||
}
|
||||
|
||||
bool SetSinkConfigJson(CS_Sink sink, const wpi::json& config,
|
||||
bool SetSinkConfigJson(CS_Sink sink, const wpi::util::json& config,
|
||||
CS_Status* status) {
|
||||
auto data = Instance::GetInstance().GetSink(sink);
|
||||
if (!data) {
|
||||
@@ -630,11 +630,11 @@ std::string GetSinkConfigJson(CS_Sink sink, CS_Status* status) {
|
||||
return data->sink->GetConfigJson(status);
|
||||
}
|
||||
|
||||
wpi::json GetSinkConfigJsonObject(CS_Sink sink, CS_Status* status) {
|
||||
wpi::util::json GetSinkConfigJsonObject(CS_Sink sink, CS_Status* status) {
|
||||
auto data = Instance::GetInstance().GetSink(sink);
|
||||
if (!data) {
|
||||
*status = CS_INVALID_HANDLE;
|
||||
return wpi::json{};
|
||||
return wpi::util::json{};
|
||||
}
|
||||
return data->sink->GetConfigJsonObject(status);
|
||||
}
|
||||
@@ -869,17 +869,17 @@ void Shutdown() {
|
||||
//
|
||||
|
||||
std::span<CS_Source> EnumerateSourceHandles(
|
||||
wpi::SmallVectorImpl<CS_Source>& vec, CS_Status* status) {
|
||||
wpi::util::SmallVectorImpl<CS_Source>& vec, CS_Status* status) {
|
||||
return Instance::GetInstance().EnumerateSourceHandles(vec);
|
||||
}
|
||||
|
||||
std::span<CS_Sink> EnumerateSinkHandles(wpi::SmallVectorImpl<CS_Sink>& vec,
|
||||
std::span<CS_Sink> EnumerateSinkHandles(wpi::util::SmallVectorImpl<CS_Sink>& vec,
|
||||
CS_Status* status) {
|
||||
return Instance::GetInstance().EnumerateSinkHandles(vec);
|
||||
}
|
||||
|
||||
std::string GetHostname() {
|
||||
return wpi::GetHostname();
|
||||
return wpi::net::GetHostname();
|
||||
}
|
||||
|
||||
} // namespace cs
|
||||
} // namespace wpi::cs
|
||||
|
||||
@@ -11,20 +11,20 @@
|
||||
|
||||
#include "wpi/util/json.hpp"
|
||||
|
||||
using namespace cs;
|
||||
using namespace wpi::cs;
|
||||
|
||||
wpi::json VideoSource::GetConfigJsonObject() const {
|
||||
wpi::util::json VideoSource::GetConfigJsonObject() const {
|
||||
m_status = 0;
|
||||
return GetSourceConfigJsonObject(m_handle, &m_status);
|
||||
}
|
||||
|
||||
wpi::json VideoSink::GetConfigJsonObject() const {
|
||||
wpi::util::json VideoSink::GetConfigJsonObject() const {
|
||||
m_status = 0;
|
||||
return GetSinkConfigJsonObject(m_handle, &m_status);
|
||||
}
|
||||
|
||||
std::vector<VideoProperty> VideoSource::EnumerateProperties() const {
|
||||
wpi::SmallVector<CS_Property, 32> handles_buf;
|
||||
wpi::util::SmallVector<CS_Property, 32> handles_buf;
|
||||
CS_Status status = 0;
|
||||
auto handles = EnumerateSourceProperties(m_handle, handles_buf, &status);
|
||||
|
||||
@@ -37,7 +37,7 @@ std::vector<VideoProperty> VideoSource::EnumerateProperties() const {
|
||||
}
|
||||
|
||||
std::vector<VideoSink> VideoSource::EnumerateSinks() {
|
||||
wpi::SmallVector<CS_Sink, 16> handles_buf;
|
||||
wpi::util::SmallVector<CS_Sink, 16> handles_buf;
|
||||
CS_Status status = 0;
|
||||
auto handles = EnumerateSourceSinks(m_handle, handles_buf, &status);
|
||||
|
||||
@@ -50,9 +50,9 @@ std::vector<VideoSink> VideoSource::EnumerateSinks() {
|
||||
}
|
||||
|
||||
std::vector<VideoSource> VideoSource::EnumerateSources() {
|
||||
wpi::SmallVector<CS_Source, 16> handles_buf;
|
||||
wpi::util::SmallVector<CS_Source, 16> handles_buf;
|
||||
CS_Status status = 0;
|
||||
auto handles = ::cs::EnumerateSourceHandles(handles_buf, &status);
|
||||
auto handles = ::wpi::cs::EnumerateSourceHandles(handles_buf, &status);
|
||||
|
||||
std::vector<VideoSource> sources;
|
||||
sources.reserve(handles.size());
|
||||
@@ -63,7 +63,7 @@ std::vector<VideoSource> VideoSource::EnumerateSources() {
|
||||
}
|
||||
|
||||
std::vector<VideoProperty> VideoSink::EnumerateProperties() const {
|
||||
wpi::SmallVector<CS_Property, 32> handles_buf;
|
||||
wpi::util::SmallVector<CS_Property, 32> handles_buf;
|
||||
CS_Status status = 0;
|
||||
auto handles = EnumerateSinkProperties(m_handle, handles_buf, &status);
|
||||
|
||||
@@ -76,9 +76,9 @@ std::vector<VideoProperty> VideoSink::EnumerateProperties() const {
|
||||
}
|
||||
|
||||
std::vector<VideoSink> VideoSink::EnumerateSinks() {
|
||||
wpi::SmallVector<CS_Sink, 16> handles_buf;
|
||||
wpi::util::SmallVector<CS_Sink, 16> handles_buf;
|
||||
CS_Status status = 0;
|
||||
auto handles = ::cs::EnumerateSinkHandles(handles_buf, &status);
|
||||
auto handles = ::wpi::cs::EnumerateSinkHandles(handles_buf, &status);
|
||||
|
||||
std::vector<VideoSink> sinks;
|
||||
sinks.reserve(handles.size());
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
#include <memory>
|
||||
#include <utility>
|
||||
|
||||
namespace cs {
|
||||
namespace wpi::cs {
|
||||
|
||||
// Allocator adaptor that interposes construct() calls to
|
||||
// convert value initialization into default initialization.
|
||||
@@ -36,6 +36,6 @@ class default_init_allocator : public A {
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace cs
|
||||
} // namespace wpi::cs
|
||||
|
||||
#endif // CSCORE_DEFAULT_INIT_ALLOCATOR_HPP_
|
||||
|
||||
@@ -21,7 +21,7 @@ namespace cv {
|
||||
class Mat;
|
||||
} // namespace cv
|
||||
|
||||
using namespace wpi::java;
|
||||
using namespace wpi::util::java;
|
||||
|
||||
//
|
||||
// Globals and load/unload
|
||||
@@ -107,14 +107,14 @@ JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM* vm, void* reserved) {
|
||||
}
|
||||
|
||||
// Initial configuration of listener start/exit
|
||||
cs::SetListenerOnStart(ListenerOnStart);
|
||||
cs::SetListenerOnExit(ListenerOnExit);
|
||||
wpi::cs::SetListenerOnStart(ListenerOnStart);
|
||||
wpi::cs::SetListenerOnExit(ListenerOnExit);
|
||||
|
||||
return JNI_VERSION_1_6;
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL JNI_OnUnload(JavaVM* vm, void* reserved) {
|
||||
cs::Shutdown();
|
||||
wpi::cs::Shutdown();
|
||||
|
||||
JNIEnv* env;
|
||||
if (vm->GetEnv(reinterpret_cast<void**>(&env), JNI_VERSION_1_6) != JNI_OK) {
|
||||
@@ -141,7 +141,7 @@ class JCSGlobal {
|
||||
JCSGlobal(JNIEnv* env, T obj)
|
||||
: m_obj(static_cast<T>(env->NewGlobalRef(obj))) {}
|
||||
~JCSGlobal() {
|
||||
if (!jvm || cs::NotifierDestroyed()) {
|
||||
if (!jvm || wpi::cs::NotifierDestroyed()) {
|
||||
return;
|
||||
}
|
||||
JNIEnv* env;
|
||||
@@ -223,7 +223,7 @@ static inline bool CheckStatus(JNIEnv* env, CS_Status status) {
|
||||
return status == CS_OK;
|
||||
}
|
||||
|
||||
static jobject MakeJObject(JNIEnv* env, const cs::UsbCameraInfo& info) {
|
||||
static jobject MakeJObject(JNIEnv* env, const wpi::cs::UsbCameraInfo& info) {
|
||||
static jmethodID constructor = env->GetMethodID(
|
||||
usbCameraInfoCls, "<init>",
|
||||
"(ILjava/lang/String;Ljava/lang/String;[Ljava/lang/String;II)V");
|
||||
@@ -236,7 +236,7 @@ static jobject MakeJObject(JNIEnv* env, const cs::UsbCameraInfo& info) {
|
||||
static_cast<jint>(info.productId));
|
||||
}
|
||||
|
||||
static jobject MakeJObject(JNIEnv* env, const cs::VideoMode& videoMode) {
|
||||
static jobject MakeJObject(JNIEnv* env, const wpi::cs::VideoMode& videoMode) {
|
||||
static jmethodID constructor =
|
||||
env->GetMethodID(videoModeCls, "<init>", "(IIII)V");
|
||||
return env->NewObject(
|
||||
@@ -245,7 +245,7 @@ static jobject MakeJObject(JNIEnv* env, const cs::VideoMode& videoMode) {
|
||||
static_cast<jint>(videoMode.fps));
|
||||
}
|
||||
|
||||
static jobject MakeJObject(JNIEnv* env, const cs::RawEvent& event) {
|
||||
static jobject MakeJObject(JNIEnv* env, const wpi::cs::RawEvent& event) {
|
||||
static jmethodID constructor =
|
||||
env->GetMethodID(videoEventCls, "<init>",
|
||||
"(IIILjava/lang/String;IIIIIIILjava/lang/String;I)V");
|
||||
@@ -272,7 +272,7 @@ static jobject MakeJObject(JNIEnv* env, const cs::RawEvent& event) {
|
||||
}
|
||||
|
||||
static jobjectArray MakeJObject(JNIEnv* env,
|
||||
std::span<const cs::RawEvent> arr) {
|
||||
std::span<const wpi::cs::RawEvent> arr) {
|
||||
jobjectArray jarr = env->NewObjectArray(arr.size(), videoEventCls, nullptr);
|
||||
if (!jarr) {
|
||||
return nullptr;
|
||||
@@ -296,7 +296,7 @@ Java_org_wpilib_vision_camera_CameraServerJNI_getPropertyKind
|
||||
(JNIEnv* env, jclass, jint property)
|
||||
{
|
||||
CS_Status status = 0;
|
||||
auto val = cs::GetPropertyKind(property, &status);
|
||||
auto val = wpi::cs::GetPropertyKind(property, &status);
|
||||
CheckStatus(env, status);
|
||||
return val;
|
||||
}
|
||||
@@ -311,8 +311,8 @@ Java_org_wpilib_vision_camera_CameraServerJNI_getPropertyName
|
||||
(JNIEnv* env, jclass, jint property)
|
||||
{
|
||||
CS_Status status = 0;
|
||||
wpi::SmallString<128> buf;
|
||||
auto str = cs::GetPropertyName(property, buf, &status);
|
||||
wpi::util::SmallString<128> buf;
|
||||
auto str = wpi::cs::GetPropertyName(property, buf, &status);
|
||||
if (!CheckStatus(env, status)) {
|
||||
return nullptr;
|
||||
}
|
||||
@@ -329,7 +329,7 @@ Java_org_wpilib_vision_camera_CameraServerJNI_getProperty
|
||||
(JNIEnv* env, jclass, jint property)
|
||||
{
|
||||
CS_Status status = 0;
|
||||
auto val = cs::GetProperty(property, &status);
|
||||
auto val = wpi::cs::GetProperty(property, &status);
|
||||
CheckStatus(env, status);
|
||||
return val;
|
||||
}
|
||||
@@ -344,7 +344,7 @@ Java_org_wpilib_vision_camera_CameraServerJNI_setProperty
|
||||
(JNIEnv* env, jclass, jint property, jint value)
|
||||
{
|
||||
CS_Status status = 0;
|
||||
cs::SetProperty(property, value, &status);
|
||||
wpi::cs::SetProperty(property, value, &status);
|
||||
CheckStatus(env, status);
|
||||
}
|
||||
|
||||
@@ -358,7 +358,7 @@ Java_org_wpilib_vision_camera_CameraServerJNI_getPropertyMin
|
||||
(JNIEnv* env, jclass, jint property)
|
||||
{
|
||||
CS_Status status = 0;
|
||||
auto val = cs::GetPropertyMin(property, &status);
|
||||
auto val = wpi::cs::GetPropertyMin(property, &status);
|
||||
CheckStatus(env, status);
|
||||
return val;
|
||||
}
|
||||
@@ -373,7 +373,7 @@ Java_org_wpilib_vision_camera_CameraServerJNI_getPropertyMax
|
||||
(JNIEnv* env, jclass, jint property)
|
||||
{
|
||||
CS_Status status = 0;
|
||||
auto val = cs::GetPropertyMax(property, &status);
|
||||
auto val = wpi::cs::GetPropertyMax(property, &status);
|
||||
CheckStatus(env, status);
|
||||
return val;
|
||||
}
|
||||
@@ -388,7 +388,7 @@ Java_org_wpilib_vision_camera_CameraServerJNI_getPropertyStep
|
||||
(JNIEnv* env, jclass, jint property)
|
||||
{
|
||||
CS_Status status = 0;
|
||||
auto val = cs::GetPropertyStep(property, &status);
|
||||
auto val = wpi::cs::GetPropertyStep(property, &status);
|
||||
CheckStatus(env, status);
|
||||
return val;
|
||||
}
|
||||
@@ -403,7 +403,7 @@ Java_org_wpilib_vision_camera_CameraServerJNI_getPropertyDefault
|
||||
(JNIEnv* env, jclass, jint property)
|
||||
{
|
||||
CS_Status status = 0;
|
||||
auto val = cs::GetPropertyDefault(property, &status);
|
||||
auto val = wpi::cs::GetPropertyDefault(property, &status);
|
||||
CheckStatus(env, status);
|
||||
return val;
|
||||
}
|
||||
@@ -418,8 +418,8 @@ Java_org_wpilib_vision_camera_CameraServerJNI_getStringProperty
|
||||
(JNIEnv* env, jclass, jint property)
|
||||
{
|
||||
CS_Status status = 0;
|
||||
wpi::SmallString<128> buf;
|
||||
auto str = cs::GetStringProperty(property, buf, &status);
|
||||
wpi::util::SmallString<128> buf;
|
||||
auto str = wpi::cs::GetStringProperty(property, buf, &status);
|
||||
if (!CheckStatus(env, status)) {
|
||||
return nullptr;
|
||||
}
|
||||
@@ -440,7 +440,7 @@ Java_org_wpilib_vision_camera_CameraServerJNI_setStringProperty
|
||||
return;
|
||||
}
|
||||
CS_Status status = 0;
|
||||
cs::SetStringProperty(property, JStringRef{env, value}.str(), &status);
|
||||
wpi::cs::SetStringProperty(property, JStringRef{env, value}.str(), &status);
|
||||
CheckStatus(env, status);
|
||||
}
|
||||
|
||||
@@ -454,7 +454,7 @@ Java_org_wpilib_vision_camera_CameraServerJNI_getEnumPropertyChoices
|
||||
(JNIEnv* env, jclass, jint property)
|
||||
{
|
||||
CS_Status status = 0;
|
||||
auto arr = cs::GetEnumPropertyChoices(property, &status);
|
||||
auto arr = wpi::cs::GetEnumPropertyChoices(property, &status);
|
||||
if (!CheckStatus(env, status)) {
|
||||
return nullptr;
|
||||
}
|
||||
@@ -475,7 +475,7 @@ Java_org_wpilib_vision_camera_CameraServerJNI_createUsbCameraDev
|
||||
return 0;
|
||||
}
|
||||
CS_Status status = 0;
|
||||
auto val = cs::CreateUsbCameraDev(JStringRef{env, name}.str(), dev, &status);
|
||||
auto val = wpi::cs::CreateUsbCameraDev(JStringRef{env, name}.str(), dev, &status);
|
||||
CheckStatus(env, status);
|
||||
return val;
|
||||
}
|
||||
@@ -498,7 +498,7 @@ Java_org_wpilib_vision_camera_CameraServerJNI_createUsbCameraPath
|
||||
return 0;
|
||||
}
|
||||
CS_Status status = 0;
|
||||
auto val = cs::CreateUsbCameraPath(JStringRef{env, name}.str(),
|
||||
auto val = wpi::cs::CreateUsbCameraPath(JStringRef{env, name}.str(),
|
||||
JStringRef{env, path}.str(), &status);
|
||||
CheckStatus(env, status);
|
||||
return val;
|
||||
@@ -522,7 +522,7 @@ Java_org_wpilib_vision_camera_CameraServerJNI_createHttpCamera
|
||||
return 0;
|
||||
}
|
||||
CS_Status status = 0;
|
||||
auto val = cs::CreateHttpCamera(
|
||||
auto val = wpi::cs::CreateHttpCamera(
|
||||
JStringRef{env, name}.str(), JStringRef{env, url}.str(),
|
||||
static_cast<CS_HttpCameraKind>(kind), &status);
|
||||
CheckStatus(env, status);
|
||||
@@ -547,7 +547,7 @@ Java_org_wpilib_vision_camera_CameraServerJNI_createHttpCameraMulti
|
||||
return 0;
|
||||
}
|
||||
size_t len = env->GetArrayLength(urls);
|
||||
wpi::SmallVector<std::string, 8> vec;
|
||||
wpi::util::SmallVector<std::string, 8> vec;
|
||||
vec.reserve(len);
|
||||
for (size_t i = 0; i < len; ++i) {
|
||||
JLocal<jstring> elem{
|
||||
@@ -560,7 +560,7 @@ Java_org_wpilib_vision_camera_CameraServerJNI_createHttpCameraMulti
|
||||
}
|
||||
CS_Status status = 0;
|
||||
auto val =
|
||||
cs::CreateHttpCamera(JStringRef{env, name}.str(), vec,
|
||||
wpi::cs::CreateHttpCamera(JStringRef{env, name}.str(), vec,
|
||||
static_cast<CS_HttpCameraKind>(kind), &status);
|
||||
CheckStatus(env, status);
|
||||
return val;
|
||||
@@ -581,9 +581,9 @@ Java_org_wpilib_vision_camera_CameraServerJNI_createRawSource
|
||||
return 0;
|
||||
}
|
||||
CS_Status status = 0;
|
||||
auto val = cs::CreateRawSource(
|
||||
auto val = wpi::cs::CreateRawSource(
|
||||
JStringRef{env, name}.str(), isCv,
|
||||
cs::VideoMode{static_cast<cs::VideoMode::PixelFormat>(pixelFormat),
|
||||
wpi::cs::VideoMode{static_cast<wpi::cs::VideoMode::PixelFormat>(pixelFormat),
|
||||
static_cast<int>(width), static_cast<int>(height),
|
||||
static_cast<int>(fps)},
|
||||
&status);
|
||||
@@ -601,7 +601,7 @@ Java_org_wpilib_vision_camera_CameraServerJNI_getSourceKind
|
||||
(JNIEnv* env, jclass, jint source)
|
||||
{
|
||||
CS_Status status = 0;
|
||||
auto val = cs::GetSourceKind(source, &status);
|
||||
auto val = wpi::cs::GetSourceKind(source, &status);
|
||||
CheckStatus(env, status);
|
||||
return val;
|
||||
}
|
||||
@@ -616,8 +616,8 @@ Java_org_wpilib_vision_camera_CameraServerJNI_getSourceName
|
||||
(JNIEnv* env, jclass, jint source)
|
||||
{
|
||||
CS_Status status = 0;
|
||||
wpi::SmallString<128> buf;
|
||||
auto str = cs::GetSourceName(source, buf, &status);
|
||||
wpi::util::SmallString<128> buf;
|
||||
auto str = wpi::cs::GetSourceName(source, buf, &status);
|
||||
if (!CheckStatus(env, status)) {
|
||||
return nullptr;
|
||||
}
|
||||
@@ -634,8 +634,8 @@ Java_org_wpilib_vision_camera_CameraServerJNI_getSourceDescription
|
||||
(JNIEnv* env, jclass, jint source)
|
||||
{
|
||||
CS_Status status = 0;
|
||||
wpi::SmallString<128> buf;
|
||||
auto str = cs::GetSourceDescription(source, buf, &status);
|
||||
wpi::util::SmallString<128> buf;
|
||||
auto str = wpi::cs::GetSourceDescription(source, buf, &status);
|
||||
if (!CheckStatus(env, status)) {
|
||||
return nullptr;
|
||||
}
|
||||
@@ -652,7 +652,7 @@ Java_org_wpilib_vision_camera_CameraServerJNI_getSourceLastFrameTime
|
||||
(JNIEnv* env, jclass, jint source)
|
||||
{
|
||||
CS_Status status = 0;
|
||||
auto val = cs::GetSourceLastFrameTime(source, &status);
|
||||
auto val = wpi::cs::GetSourceLastFrameTime(source, &status);
|
||||
CheckStatus(env, status);
|
||||
return val;
|
||||
}
|
||||
@@ -667,7 +667,7 @@ Java_org_wpilib_vision_camera_CameraServerJNI_setSourceConnectionStrategy
|
||||
(JNIEnv* env, jclass, jint source, jint strategy)
|
||||
{
|
||||
CS_Status status = 0;
|
||||
cs::SetSourceConnectionStrategy(
|
||||
wpi::cs::SetSourceConnectionStrategy(
|
||||
source, static_cast<CS_ConnectionStrategy>(strategy), &status);
|
||||
CheckStatus(env, status);
|
||||
}
|
||||
@@ -682,7 +682,7 @@ Java_org_wpilib_vision_camera_CameraServerJNI_isSourceConnected
|
||||
(JNIEnv* env, jclass, jint source)
|
||||
{
|
||||
CS_Status status = 0;
|
||||
auto val = cs::IsSourceConnected(source, &status);
|
||||
auto val = wpi::cs::IsSourceConnected(source, &status);
|
||||
CheckStatus(env, status);
|
||||
return val;
|
||||
}
|
||||
@@ -697,7 +697,7 @@ Java_org_wpilib_vision_camera_CameraServerJNI_isSourceEnabled
|
||||
(JNIEnv* env, jclass, jint source)
|
||||
{
|
||||
CS_Status status = 0;
|
||||
auto val = cs::IsSourceEnabled(source, &status);
|
||||
auto val = wpi::cs::IsSourceEnabled(source, &status);
|
||||
CheckStatus(env, status);
|
||||
return val;
|
||||
}
|
||||
@@ -717,7 +717,7 @@ Java_org_wpilib_vision_camera_CameraServerJNI_getSourceProperty
|
||||
}
|
||||
CS_Status status = 0;
|
||||
auto val =
|
||||
cs::GetSourceProperty(source, JStringRef{env, name}.str(), &status);
|
||||
wpi::cs::GetSourceProperty(source, JStringRef{env, name}.str(), &status);
|
||||
CheckStatus(env, status);
|
||||
return val;
|
||||
}
|
||||
@@ -732,8 +732,8 @@ Java_org_wpilib_vision_camera_CameraServerJNI_enumerateSourceProperties
|
||||
(JNIEnv* env, jclass, jint source)
|
||||
{
|
||||
CS_Status status = 0;
|
||||
wpi::SmallVector<CS_Property, 32> buf;
|
||||
auto arr = cs::EnumerateSourceProperties(source, buf, &status);
|
||||
wpi::util::SmallVector<CS_Property, 32> buf;
|
||||
auto arr = wpi::cs::EnumerateSourceProperties(source, buf, &status);
|
||||
if (!CheckStatus(env, status)) {
|
||||
return nullptr;
|
||||
}
|
||||
@@ -750,7 +750,7 @@ Java_org_wpilib_vision_camera_CameraServerJNI_getSourceVideoMode
|
||||
(JNIEnv* env, jclass, jint source)
|
||||
{
|
||||
CS_Status status = 0;
|
||||
auto val = cs::GetSourceVideoMode(source, &status);
|
||||
auto val = wpi::cs::GetSourceVideoMode(source, &status);
|
||||
if (!CheckStatus(env, status)) {
|
||||
return nullptr;
|
||||
}
|
||||
@@ -768,9 +768,9 @@ Java_org_wpilib_vision_camera_CameraServerJNI_setSourceVideoMode
|
||||
jint fps)
|
||||
{
|
||||
CS_Status status = 0;
|
||||
auto val = cs::SetSourceVideoMode(
|
||||
auto val = wpi::cs::SetSourceVideoMode(
|
||||
source,
|
||||
cs::VideoMode(static_cast<cs::VideoMode::PixelFormat>(pixelFormat), width,
|
||||
wpi::cs::VideoMode(static_cast<wpi::cs::VideoMode::PixelFormat>(pixelFormat), width,
|
||||
height, fps),
|
||||
&status);
|
||||
CheckStatus(env, status);
|
||||
@@ -787,8 +787,8 @@ Java_org_wpilib_vision_camera_CameraServerJNI_setSourcePixelFormat
|
||||
(JNIEnv* env, jclass, jint source, jint pixelFormat)
|
||||
{
|
||||
CS_Status status = 0;
|
||||
auto val = cs::SetSourcePixelFormat(
|
||||
source, static_cast<cs::VideoMode::PixelFormat>(pixelFormat), &status);
|
||||
auto val = wpi::cs::SetSourcePixelFormat(
|
||||
source, static_cast<wpi::cs::VideoMode::PixelFormat>(pixelFormat), &status);
|
||||
CheckStatus(env, status);
|
||||
return val;
|
||||
}
|
||||
@@ -803,7 +803,7 @@ Java_org_wpilib_vision_camera_CameraServerJNI_setSourceResolution
|
||||
(JNIEnv* env, jclass, jint source, jint width, jint height)
|
||||
{
|
||||
CS_Status status = 0;
|
||||
auto val = cs::SetSourceResolution(source, width, height, &status);
|
||||
auto val = wpi::cs::SetSourceResolution(source, width, height, &status);
|
||||
CheckStatus(env, status);
|
||||
return val;
|
||||
}
|
||||
@@ -818,7 +818,7 @@ Java_org_wpilib_vision_camera_CameraServerJNI_setSourceFPS
|
||||
(JNIEnv* env, jclass, jint source, jint fps)
|
||||
{
|
||||
CS_Status status = 0;
|
||||
auto val = cs::SetSourceFPS(source, fps, &status);
|
||||
auto val = wpi::cs::SetSourceFPS(source, fps, &status);
|
||||
CheckStatus(env, status);
|
||||
return val;
|
||||
}
|
||||
@@ -833,7 +833,7 @@ Java_org_wpilib_vision_camera_CameraServerJNI_setSourceConfigJson
|
||||
(JNIEnv* env, jclass, jint source, jstring config)
|
||||
{
|
||||
CS_Status status = 0;
|
||||
auto val = cs::SetSourceConfigJson(source, JStringRef{env, config}, &status);
|
||||
auto val = wpi::cs::SetSourceConfigJson(source, JStringRef{env, config}, &status);
|
||||
CheckStatus(env, status);
|
||||
return val;
|
||||
}
|
||||
@@ -848,7 +848,7 @@ Java_org_wpilib_vision_camera_CameraServerJNI_getSourceConfigJson
|
||||
(JNIEnv* env, jclass, jint source)
|
||||
{
|
||||
CS_Status status = 0;
|
||||
auto val = cs::GetSourceConfigJson(source, &status);
|
||||
auto val = wpi::cs::GetSourceConfigJson(source, &status);
|
||||
CheckStatus(env, status);
|
||||
return MakeJString(env, val);
|
||||
}
|
||||
@@ -863,7 +863,7 @@ Java_org_wpilib_vision_camera_CameraServerJNI_enumerateSourceVideoModes
|
||||
(JNIEnv* env, jclass, jint source)
|
||||
{
|
||||
CS_Status status = 0;
|
||||
auto arr = cs::EnumerateSourceVideoModes(source, &status);
|
||||
auto arr = wpi::cs::EnumerateSourceVideoModes(source, &status);
|
||||
if (!CheckStatus(env, status)) {
|
||||
return nullptr;
|
||||
}
|
||||
@@ -888,8 +888,8 @@ Java_org_wpilib_vision_camera_CameraServerJNI_enumerateSourceSinks
|
||||
(JNIEnv* env, jclass, jint source)
|
||||
{
|
||||
CS_Status status = 0;
|
||||
wpi::SmallVector<CS_Sink, 16> buf;
|
||||
auto arr = cs::EnumerateSourceSinks(source, buf, &status);
|
||||
wpi::util::SmallVector<CS_Sink, 16> buf;
|
||||
auto arr = wpi::cs::EnumerateSourceSinks(source, buf, &status);
|
||||
if (!CheckStatus(env, status)) {
|
||||
return nullptr;
|
||||
}
|
||||
@@ -906,7 +906,7 @@ Java_org_wpilib_vision_camera_CameraServerJNI_copySource
|
||||
(JNIEnv* env, jclass, jint source)
|
||||
{
|
||||
CS_Status status = 0;
|
||||
auto val = cs::CopySource(source, &status);
|
||||
auto val = wpi::cs::CopySource(source, &status);
|
||||
CheckStatus(env, status);
|
||||
return val;
|
||||
}
|
||||
@@ -921,7 +921,7 @@ Java_org_wpilib_vision_camera_CameraServerJNI_releaseSource
|
||||
(JNIEnv* env, jclass, jint source)
|
||||
{
|
||||
CS_Status status = 0;
|
||||
cs::ReleaseSource(source, &status);
|
||||
wpi::cs::ReleaseSource(source, &status);
|
||||
CheckStatus(env, status);
|
||||
}
|
||||
|
||||
@@ -935,7 +935,7 @@ Java_org_wpilib_vision_camera_CameraServerJNI_setCameraBrightness
|
||||
(JNIEnv* env, jclass, jint source, jint brightness)
|
||||
{
|
||||
CS_Status status = 0;
|
||||
cs::SetCameraBrightness(source, brightness, &status);
|
||||
wpi::cs::SetCameraBrightness(source, brightness, &status);
|
||||
CheckStatus(env, status);
|
||||
}
|
||||
|
||||
@@ -949,7 +949,7 @@ Java_org_wpilib_vision_camera_CameraServerJNI_getCameraBrightness
|
||||
(JNIEnv* env, jclass, jint source)
|
||||
{
|
||||
CS_Status status = 0;
|
||||
auto val = cs::GetCameraBrightness(source, &status);
|
||||
auto val = wpi::cs::GetCameraBrightness(source, &status);
|
||||
CheckStatus(env, status);
|
||||
return val;
|
||||
}
|
||||
@@ -964,7 +964,7 @@ Java_org_wpilib_vision_camera_CameraServerJNI_setCameraWhiteBalanceAuto
|
||||
(JNIEnv* env, jclass, jint source)
|
||||
{
|
||||
CS_Status status = 0;
|
||||
cs::SetCameraWhiteBalanceAuto(source, &status);
|
||||
wpi::cs::SetCameraWhiteBalanceAuto(source, &status);
|
||||
CheckStatus(env, status);
|
||||
}
|
||||
|
||||
@@ -978,7 +978,7 @@ Java_org_wpilib_vision_camera_CameraServerJNI_setCameraWhiteBalanceHoldCurrent
|
||||
(JNIEnv* env, jclass, jint source)
|
||||
{
|
||||
CS_Status status = 0;
|
||||
cs::SetCameraWhiteBalanceHoldCurrent(source, &status);
|
||||
wpi::cs::SetCameraWhiteBalanceHoldCurrent(source, &status);
|
||||
CheckStatus(env, status);
|
||||
}
|
||||
|
||||
@@ -992,7 +992,7 @@ Java_org_wpilib_vision_camera_CameraServerJNI_setCameraWhiteBalanceManual
|
||||
(JNIEnv* env, jclass, jint source, jint value)
|
||||
{
|
||||
CS_Status status = 0;
|
||||
cs::SetCameraWhiteBalanceManual(source, value, &status);
|
||||
wpi::cs::SetCameraWhiteBalanceManual(source, value, &status);
|
||||
CheckStatus(env, status);
|
||||
}
|
||||
|
||||
@@ -1006,7 +1006,7 @@ Java_org_wpilib_vision_camera_CameraServerJNI_setCameraExposureAuto
|
||||
(JNIEnv* env, jclass, jint source)
|
||||
{
|
||||
CS_Status status = 0;
|
||||
cs::SetCameraExposureAuto(source, &status);
|
||||
wpi::cs::SetCameraExposureAuto(source, &status);
|
||||
CheckStatus(env, status);
|
||||
}
|
||||
|
||||
@@ -1020,7 +1020,7 @@ Java_org_wpilib_vision_camera_CameraServerJNI_setCameraExposureHoldCurrent
|
||||
(JNIEnv* env, jclass, jint source)
|
||||
{
|
||||
CS_Status status = 0;
|
||||
cs::SetCameraExposureHoldCurrent(source, &status);
|
||||
wpi::cs::SetCameraExposureHoldCurrent(source, &status);
|
||||
CheckStatus(env, status);
|
||||
}
|
||||
|
||||
@@ -1034,7 +1034,7 @@ Java_org_wpilib_vision_camera_CameraServerJNI_setCameraExposureManual
|
||||
(JNIEnv* env, jclass, jint source, jint value)
|
||||
{
|
||||
CS_Status status = 0;
|
||||
cs::SetCameraExposureManual(source, value, &status);
|
||||
wpi::cs::SetCameraExposureManual(source, value, &status);
|
||||
CheckStatus(env, status);
|
||||
}
|
||||
|
||||
@@ -1048,7 +1048,7 @@ Java_org_wpilib_vision_camera_CameraServerJNI_setUsbCameraPath
|
||||
(JNIEnv* env, jclass, jint source, jstring path)
|
||||
{
|
||||
CS_Status status = 0;
|
||||
cs::SetUsbCameraPath(source, JStringRef{env, path}.str(), &status);
|
||||
wpi::cs::SetUsbCameraPath(source, JStringRef{env, path}.str(), &status);
|
||||
CheckStatus(env, status);
|
||||
}
|
||||
|
||||
@@ -1062,7 +1062,7 @@ Java_org_wpilib_vision_camera_CameraServerJNI_getUsbCameraPath
|
||||
(JNIEnv* env, jclass, jint source)
|
||||
{
|
||||
CS_Status status = 0;
|
||||
auto str = cs::GetUsbCameraPath(source, &status);
|
||||
auto str = wpi::cs::GetUsbCameraPath(source, &status);
|
||||
if (!CheckStatus(env, status)) {
|
||||
return nullptr;
|
||||
}
|
||||
@@ -1079,7 +1079,7 @@ Java_org_wpilib_vision_camera_CameraServerJNI_getUsbCameraInfo
|
||||
(JNIEnv* env, jclass, jint source)
|
||||
{
|
||||
CS_Status status = 0;
|
||||
auto info = cs::GetUsbCameraInfo(source, &status);
|
||||
auto info = wpi::cs::GetUsbCameraInfo(source, &status);
|
||||
if (!CheckStatus(env, status)) {
|
||||
return nullptr;
|
||||
}
|
||||
@@ -1096,7 +1096,7 @@ Java_org_wpilib_vision_camera_CameraServerJNI_getHttpCameraKind
|
||||
(JNIEnv* env, jclass, jint source)
|
||||
{
|
||||
CS_Status status = 0;
|
||||
auto kind = cs::GetHttpCameraKind(source, &status);
|
||||
auto kind = wpi::cs::GetHttpCameraKind(source, &status);
|
||||
if (!CheckStatus(env, status)) {
|
||||
return 0;
|
||||
}
|
||||
@@ -1117,7 +1117,7 @@ Java_org_wpilib_vision_camera_CameraServerJNI_setHttpCameraUrls
|
||||
return;
|
||||
}
|
||||
size_t len = env->GetArrayLength(urls);
|
||||
wpi::SmallVector<std::string, 8> vec;
|
||||
wpi::util::SmallVector<std::string, 8> vec;
|
||||
vec.reserve(len);
|
||||
for (size_t i = 0; i < len; ++i) {
|
||||
JLocal<jstring> elem{
|
||||
@@ -1129,7 +1129,7 @@ Java_org_wpilib_vision_camera_CameraServerJNI_setHttpCameraUrls
|
||||
vec.emplace_back(JStringRef{env, elem}.str());
|
||||
}
|
||||
CS_Status status = 0;
|
||||
cs::SetHttpCameraUrls(source, vec, &status);
|
||||
wpi::cs::SetHttpCameraUrls(source, vec, &status);
|
||||
CheckStatus(env, status);
|
||||
}
|
||||
|
||||
@@ -1143,7 +1143,7 @@ Java_org_wpilib_vision_camera_CameraServerJNI_getHttpCameraUrls
|
||||
(JNIEnv* env, jclass, jint source)
|
||||
{
|
||||
CS_Status status = 0;
|
||||
auto arr = cs::GetHttpCameraUrls(source, &status);
|
||||
auto arr = wpi::cs::GetHttpCameraUrls(source, &status);
|
||||
if (!CheckStatus(env, status)) {
|
||||
return nullptr;
|
||||
}
|
||||
@@ -1159,13 +1159,13 @@ JNIEXPORT void JNICALL
|
||||
Java_org_wpilib_vision_camera_CameraServerJNI_putRawSourceFrame
|
||||
(JNIEnv* env, jclass, jint source, jlong framePtr)
|
||||
{
|
||||
auto* frame = reinterpret_cast<wpi::RawFrame*>(framePtr);
|
||||
auto* frame = reinterpret_cast<wpi::util::RawFrame*>(framePtr);
|
||||
if (!frame) {
|
||||
nullPointerEx.Throw(env, "frame is null");
|
||||
return;
|
||||
}
|
||||
CS_Status status = 0;
|
||||
cs::PutSourceFrame(source, *frame, &status);
|
||||
wpi::cs::PutSourceFrame(source, *frame, &status);
|
||||
CheckStatus(env, status);
|
||||
}
|
||||
|
||||
@@ -1193,7 +1193,7 @@ Java_org_wpilib_vision_camera_CameraServerJNI_putRawSourceFrameBB
|
||||
frame.stride = stride;
|
||||
frame.pixelFormat = pixelFormat;
|
||||
CS_Status status = 0;
|
||||
cs::PutSourceFrame(source, frame, &status);
|
||||
wpi::cs::PutSourceFrame(source, frame, &status);
|
||||
CheckStatus(env, status);
|
||||
}
|
||||
|
||||
@@ -1221,7 +1221,7 @@ Java_org_wpilib_vision_camera_CameraServerJNI_putRawSourceFrameData
|
||||
frame.stride = stride;
|
||||
frame.pixelFormat = pixelFormat;
|
||||
CS_Status status = 0;
|
||||
cs::PutSourceFrame(source, frame, &status);
|
||||
wpi::cs::PutSourceFrame(source, frame, &status);
|
||||
CheckStatus(env, status);
|
||||
}
|
||||
|
||||
@@ -1239,7 +1239,7 @@ Java_org_wpilib_vision_camera_CameraServerJNI_notifySourceError
|
||||
return;
|
||||
}
|
||||
CS_Status status = 0;
|
||||
cs::NotifySourceError(source, JStringRef{env, msg}.str(), &status);
|
||||
wpi::cs::NotifySourceError(source, JStringRef{env, msg}.str(), &status);
|
||||
CheckStatus(env, status);
|
||||
}
|
||||
|
||||
@@ -1253,7 +1253,7 @@ Java_org_wpilib_vision_camera_CameraServerJNI_setSourceConnected
|
||||
(JNIEnv* env, jclass, jint source, jboolean connected)
|
||||
{
|
||||
CS_Status status = 0;
|
||||
cs::SetSourceConnected(source, connected, &status);
|
||||
wpi::cs::SetSourceConnected(source, connected, &status);
|
||||
CheckStatus(env, status);
|
||||
}
|
||||
|
||||
@@ -1271,7 +1271,7 @@ Java_org_wpilib_vision_camera_CameraServerJNI_setSourceDescription
|
||||
return;
|
||||
}
|
||||
CS_Status status = 0;
|
||||
cs::SetSourceDescription(source, JStringRef{env, description}.str(), &status);
|
||||
wpi::cs::SetSourceDescription(source, JStringRef{env, description}.str(), &status);
|
||||
CheckStatus(env, status);
|
||||
}
|
||||
|
||||
@@ -1286,7 +1286,7 @@ Java_org_wpilib_vision_camera_CameraServerJNI_createSourceProperty
|
||||
jint maximum, jint step, jint defaultValue, jint value)
|
||||
{
|
||||
CS_Status status = 0;
|
||||
auto val = cs::CreateSourceProperty(
|
||||
auto val = wpi::cs::CreateSourceProperty(
|
||||
source, JStringRef{env, name}.str(), static_cast<CS_PropertyKind>(kind),
|
||||
minimum, maximum, step, defaultValue, value, &status);
|
||||
CheckStatus(env, status);
|
||||
@@ -1307,7 +1307,7 @@ Java_org_wpilib_vision_camera_CameraServerJNI_setSourceEnumPropertyChoices
|
||||
return;
|
||||
}
|
||||
size_t len = env->GetArrayLength(choices);
|
||||
wpi::SmallVector<std::string, 8> vec;
|
||||
wpi::util::SmallVector<std::string, 8> vec;
|
||||
vec.reserve(len);
|
||||
for (size_t i = 0; i < len; ++i) {
|
||||
JLocal<jstring> elem{
|
||||
@@ -1319,7 +1319,7 @@ Java_org_wpilib_vision_camera_CameraServerJNI_setSourceEnumPropertyChoices
|
||||
vec.emplace_back(JStringRef{env, elem}.str());
|
||||
}
|
||||
CS_Status status = 0;
|
||||
cs::SetSourceEnumPropertyChoices(source, property, vec, &status);
|
||||
wpi::cs::SetSourceEnumPropertyChoices(source, property, vec, &status);
|
||||
CheckStatus(env, status);
|
||||
}
|
||||
|
||||
@@ -1341,7 +1341,7 @@ Java_org_wpilib_vision_camera_CameraServerJNI_createMjpegServer
|
||||
return 0;
|
||||
}
|
||||
CS_Status status = 0;
|
||||
auto val = cs::CreateMjpegServer(JStringRef{env, name}.str(),
|
||||
auto val = wpi::cs::CreateMjpegServer(JStringRef{env, name}.str(),
|
||||
JStringRef{env, listenAddress}.str(), port,
|
||||
&status);
|
||||
CheckStatus(env, status);
|
||||
@@ -1362,7 +1362,7 @@ Java_org_wpilib_vision_camera_CameraServerJNI_createRawSink
|
||||
return 0;
|
||||
}
|
||||
CS_Status status = 0;
|
||||
auto val = cs::CreateRawSink(JStringRef{env, name}.str(), isCv, &status);
|
||||
auto val = wpi::cs::CreateRawSink(JStringRef{env, name}.str(), isCv, &status);
|
||||
CheckStatus(env, status);
|
||||
return val;
|
||||
}
|
||||
@@ -1377,7 +1377,7 @@ Java_org_wpilib_vision_camera_CameraServerJNI_getSinkKind
|
||||
(JNIEnv* env, jclass, jint sink)
|
||||
{
|
||||
CS_Status status = 0;
|
||||
auto val = cs::GetSinkKind(sink, &status);
|
||||
auto val = wpi::cs::GetSinkKind(sink, &status);
|
||||
CheckStatus(env, status);
|
||||
return val;
|
||||
}
|
||||
@@ -1392,8 +1392,8 @@ Java_org_wpilib_vision_camera_CameraServerJNI_getSinkName
|
||||
(JNIEnv* env, jclass, jint sink)
|
||||
{
|
||||
CS_Status status = 0;
|
||||
wpi::SmallString<128> buf;
|
||||
auto str = cs::GetSinkName(sink, buf, &status);
|
||||
wpi::util::SmallString<128> buf;
|
||||
auto str = wpi::cs::GetSinkName(sink, buf, &status);
|
||||
if (!CheckStatus(env, status)) {
|
||||
return nullptr;
|
||||
}
|
||||
@@ -1410,8 +1410,8 @@ Java_org_wpilib_vision_camera_CameraServerJNI_getSinkDescription
|
||||
(JNIEnv* env, jclass, jint sink)
|
||||
{
|
||||
CS_Status status = 0;
|
||||
wpi::SmallString<128> buf;
|
||||
auto str = cs::GetSinkDescription(sink, buf, &status);
|
||||
wpi::util::SmallString<128> buf;
|
||||
auto str = wpi::cs::GetSinkDescription(sink, buf, &status);
|
||||
if (!CheckStatus(env, status)) {
|
||||
return nullptr;
|
||||
}
|
||||
@@ -1432,7 +1432,7 @@ Java_org_wpilib_vision_camera_CameraServerJNI_getSinkProperty
|
||||
return 0;
|
||||
}
|
||||
CS_Status status = 0;
|
||||
auto val = cs::GetSinkProperty(sink, JStringRef{env, name}.str(), &status);
|
||||
auto val = wpi::cs::GetSinkProperty(sink, JStringRef{env, name}.str(), &status);
|
||||
CheckStatus(env, status);
|
||||
return val;
|
||||
}
|
||||
@@ -1447,8 +1447,8 @@ Java_org_wpilib_vision_camera_CameraServerJNI_enumerateSinkProperties
|
||||
(JNIEnv* env, jclass, jint source)
|
||||
{
|
||||
CS_Status status = 0;
|
||||
wpi::SmallVector<CS_Property, 32> buf;
|
||||
auto arr = cs::EnumerateSinkProperties(source, buf, &status);
|
||||
wpi::util::SmallVector<CS_Property, 32> buf;
|
||||
auto arr = wpi::cs::EnumerateSinkProperties(source, buf, &status);
|
||||
if (!CheckStatus(env, status)) {
|
||||
return nullptr;
|
||||
}
|
||||
@@ -1465,7 +1465,7 @@ Java_org_wpilib_vision_camera_CameraServerJNI_setSinkConfigJson
|
||||
(JNIEnv* env, jclass, jint source, jstring config)
|
||||
{
|
||||
CS_Status status = 0;
|
||||
auto val = cs::SetSinkConfigJson(source, JStringRef{env, config}, &status);
|
||||
auto val = wpi::cs::SetSinkConfigJson(source, JStringRef{env, config}, &status);
|
||||
CheckStatus(env, status);
|
||||
return val;
|
||||
}
|
||||
@@ -1480,7 +1480,7 @@ Java_org_wpilib_vision_camera_CameraServerJNI_getSinkConfigJson
|
||||
(JNIEnv* env, jclass, jint source)
|
||||
{
|
||||
CS_Status status = 0;
|
||||
auto val = cs::GetSinkConfigJson(source, &status);
|
||||
auto val = wpi::cs::GetSinkConfigJson(source, &status);
|
||||
CheckStatus(env, status);
|
||||
return MakeJString(env, val);
|
||||
}
|
||||
@@ -1495,7 +1495,7 @@ Java_org_wpilib_vision_camera_CameraServerJNI_setSinkSource
|
||||
(JNIEnv* env, jclass, jint sink, jint source)
|
||||
{
|
||||
CS_Status status = 0;
|
||||
cs::SetSinkSource(sink, source, &status);
|
||||
wpi::cs::SetSinkSource(sink, source, &status);
|
||||
CheckStatus(env, status);
|
||||
}
|
||||
|
||||
@@ -1514,7 +1514,7 @@ Java_org_wpilib_vision_camera_CameraServerJNI_getSinkSourceProperty
|
||||
}
|
||||
CS_Status status = 0;
|
||||
auto val =
|
||||
cs::GetSinkSourceProperty(sink, JStringRef{env, name}.str(), &status);
|
||||
wpi::cs::GetSinkSourceProperty(sink, JStringRef{env, name}.str(), &status);
|
||||
CheckStatus(env, status);
|
||||
return val;
|
||||
}
|
||||
@@ -1529,7 +1529,7 @@ Java_org_wpilib_vision_camera_CameraServerJNI_getSinkSource
|
||||
(JNIEnv* env, jclass, jint sink)
|
||||
{
|
||||
CS_Status status = 0;
|
||||
auto val = cs::GetSinkSource(sink, &status);
|
||||
auto val = wpi::cs::GetSinkSource(sink, &status);
|
||||
CheckStatus(env, status);
|
||||
return val;
|
||||
}
|
||||
@@ -1544,7 +1544,7 @@ Java_org_wpilib_vision_camera_CameraServerJNI_copySink
|
||||
(JNIEnv* env, jclass, jint sink)
|
||||
{
|
||||
CS_Status status = 0;
|
||||
auto val = cs::CopySink(sink, &status);
|
||||
auto val = wpi::cs::CopySink(sink, &status);
|
||||
CheckStatus(env, status);
|
||||
return val;
|
||||
}
|
||||
@@ -1559,7 +1559,7 @@ Java_org_wpilib_vision_camera_CameraServerJNI_releaseSink
|
||||
(JNIEnv* env, jclass, jint sink)
|
||||
{
|
||||
CS_Status status = 0;
|
||||
cs::ReleaseSink(sink, &status);
|
||||
wpi::cs::ReleaseSink(sink, &status);
|
||||
CheckStatus(env, status);
|
||||
}
|
||||
|
||||
@@ -1573,7 +1573,7 @@ Java_org_wpilib_vision_camera_CameraServerJNI_getMjpegServerListenAddress
|
||||
(JNIEnv* env, jclass, jint sink)
|
||||
{
|
||||
CS_Status status = 0;
|
||||
auto str = cs::GetMjpegServerListenAddress(sink, &status);
|
||||
auto str = wpi::cs::GetMjpegServerListenAddress(sink, &status);
|
||||
if (!CheckStatus(env, status)) {
|
||||
return nullptr;
|
||||
}
|
||||
@@ -1590,7 +1590,7 @@ Java_org_wpilib_vision_camera_CameraServerJNI_getMjpegServerPort
|
||||
(JNIEnv* env, jclass, jint sink)
|
||||
{
|
||||
CS_Status status = 0;
|
||||
auto val = cs::GetMjpegServerPort(sink, &status);
|
||||
auto val = wpi::cs::GetMjpegServerPort(sink, &status);
|
||||
CheckStatus(env, status);
|
||||
return val;
|
||||
}
|
||||
@@ -1609,7 +1609,7 @@ Java_org_wpilib_vision_camera_CameraServerJNI_setSinkDescription
|
||||
return;
|
||||
}
|
||||
CS_Status status = 0;
|
||||
cs::SetSinkDescription(sink, JStringRef{env, description}.str(), &status);
|
||||
wpi::cs::SetSinkDescription(sink, JStringRef{env, description}.str(), &status);
|
||||
CheckStatus(env, status);
|
||||
}
|
||||
|
||||
@@ -1622,14 +1622,14 @@ JNIEXPORT jlong JNICALL
|
||||
Java_org_wpilib_vision_camera_CameraServerJNI_grabRawSinkFrame
|
||||
(JNIEnv* env, jclass, jint sink, jobject frameObj, jlong framePtr)
|
||||
{
|
||||
auto* frame = reinterpret_cast<wpi::RawFrame*>(framePtr);
|
||||
auto* frame = reinterpret_cast<wpi::util::RawFrame*>(framePtr);
|
||||
auto origData = frame->data;
|
||||
CS_Status status = 0;
|
||||
auto rv = cs::GrabSinkFrame(static_cast<CS_Sink>(sink), *frame, &status);
|
||||
auto rv = wpi::cs::GrabSinkFrame(static_cast<CS_Sink>(sink), *frame, &status);
|
||||
if (!CheckStatus(env, status)) {
|
||||
return 0;
|
||||
}
|
||||
wpi::SetFrameData(env, rawFrameCls, frameObj, *frame,
|
||||
wpi::util::SetFrameData(env, rawFrameCls, frameObj, *frame,
|
||||
origData != frame->data);
|
||||
return rv;
|
||||
}
|
||||
@@ -1644,15 +1644,15 @@ Java_org_wpilib_vision_camera_CameraServerJNI_grabRawSinkFrameTimeout
|
||||
(JNIEnv* env, jclass, jint sink, jobject frameObj, jlong framePtr,
|
||||
jdouble timeout)
|
||||
{
|
||||
auto* frame = reinterpret_cast<wpi::RawFrame*>(framePtr);
|
||||
auto* frame = reinterpret_cast<wpi::util::RawFrame*>(framePtr);
|
||||
auto origData = frame->data;
|
||||
CS_Status status = 0;
|
||||
auto rv = cs::GrabSinkFrameTimeout(static_cast<CS_Sink>(sink), *frame,
|
||||
auto rv = wpi::cs::GrabSinkFrameTimeout(static_cast<CS_Sink>(sink), *frame,
|
||||
timeout, &status);
|
||||
if (!CheckStatus(env, status)) {
|
||||
return 0;
|
||||
}
|
||||
wpi::SetFrameData(env, rawFrameCls, frameObj, *frame,
|
||||
wpi::util::SetFrameData(env, rawFrameCls, frameObj, *frame,
|
||||
origData != frame->data);
|
||||
return rv;
|
||||
}
|
||||
@@ -1667,8 +1667,8 @@ Java_org_wpilib_vision_camera_CameraServerJNI_getSinkError
|
||||
(JNIEnv* env, jclass, jint sink)
|
||||
{
|
||||
CS_Status status = 0;
|
||||
wpi::SmallString<128> buf;
|
||||
auto str = cs::GetSinkError(sink, buf, &status);
|
||||
wpi::util::SmallString<128> buf;
|
||||
auto str = wpi::cs::GetSinkError(sink, buf, &status);
|
||||
if (!CheckStatus(env, status)) {
|
||||
return nullptr;
|
||||
}
|
||||
@@ -1685,7 +1685,7 @@ Java_org_wpilib_vision_camera_CameraServerJNI_setSinkEnabled
|
||||
(JNIEnv* env, jclass, jint sink, jboolean enabled)
|
||||
{
|
||||
CS_Status status = 0;
|
||||
cs::SetSinkEnabled(sink, enabled, &status);
|
||||
wpi::cs::SetSinkEnabled(sink, enabled, &status);
|
||||
CheckStatus(env, status);
|
||||
}
|
||||
|
||||
@@ -1721,8 +1721,8 @@ Java_org_wpilib_vision_camera_CameraServerJNI_addListener
|
||||
}
|
||||
|
||||
CS_Status status = 0;
|
||||
CS_Listener handle = cs::AddListener(
|
||||
[=](const cs::RawEvent& event) {
|
||||
CS_Listener handle = wpi::cs::AddListener(
|
||||
[=](const wpi::cs::RawEvent& event) {
|
||||
JNIEnv* env = listenerEnv;
|
||||
if (!env || !env->functions) {
|
||||
return;
|
||||
@@ -1763,7 +1763,7 @@ Java_org_wpilib_vision_camera_CameraServerJNI_removeListener
|
||||
(JNIEnv* env, jclass, jint handle)
|
||||
{
|
||||
CS_Status status = 0;
|
||||
cs::RemoveListener(handle, &status);
|
||||
wpi::cs::RemoveListener(handle, &status);
|
||||
CheckStatus(env, status);
|
||||
}
|
||||
|
||||
@@ -1776,7 +1776,7 @@ JNIEXPORT jint JNICALL
|
||||
Java_org_wpilib_vision_camera_CameraServerJNI_createListenerPoller
|
||||
(JNIEnv*, jclass)
|
||||
{
|
||||
return cs::CreateListenerPoller();
|
||||
return wpi::cs::CreateListenerPoller();
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -1788,7 +1788,7 @@ JNIEXPORT void JNICALL
|
||||
Java_org_wpilib_vision_camera_CameraServerJNI_destroyListenerPoller
|
||||
(JNIEnv*, jclass, jint poller)
|
||||
{
|
||||
cs::DestroyListenerPoller(poller);
|
||||
wpi::cs::DestroyListenerPoller(poller);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -1801,7 +1801,7 @@ Java_org_wpilib_vision_camera_CameraServerJNI_addPolledListener
|
||||
(JNIEnv* env, jclass, jint poller, jint eventMask, jboolean immediateNotify)
|
||||
{
|
||||
CS_Status status = 0;
|
||||
auto rv = cs::AddPolledListener(poller, eventMask, immediateNotify, &status);
|
||||
auto rv = wpi::cs::AddPolledListener(poller, eventMask, immediateNotify, &status);
|
||||
CheckStatus(env, status);
|
||||
return rv;
|
||||
}
|
||||
@@ -1815,7 +1815,7 @@ JNIEXPORT jobjectArray JNICALL
|
||||
Java_org_wpilib_vision_camera_CameraServerJNI_pollListener
|
||||
(JNIEnv* env, jclass, jint poller)
|
||||
{
|
||||
auto events = cs::PollListener(poller);
|
||||
auto events = wpi::cs::PollListener(poller);
|
||||
if (events.empty()) {
|
||||
interruptedEx.Throw(env, "PollListener interrupted");
|
||||
return nullptr;
|
||||
@@ -1833,7 +1833,7 @@ Java_org_wpilib_vision_camera_CameraServerJNI_pollListenerTimeout
|
||||
(JNIEnv* env, jclass, jint poller, jdouble timeout)
|
||||
{
|
||||
bool timed_out = false;
|
||||
auto events = cs::PollListener(poller, timeout, &timed_out);
|
||||
auto events = wpi::cs::PollListener(poller, timeout, &timed_out);
|
||||
if (events.empty() && !timed_out) {
|
||||
interruptedEx.Throw(env, "PollListener interrupted");
|
||||
return nullptr;
|
||||
@@ -1850,7 +1850,7 @@ JNIEXPORT void JNICALL
|
||||
Java_org_wpilib_vision_camera_CameraServerJNI_cancelPollListener
|
||||
(JNIEnv*, jclass, jint poller)
|
||||
{
|
||||
cs::CancelPollListener(poller);
|
||||
wpi::cs::CancelPollListener(poller);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -1862,7 +1862,7 @@ JNIEXPORT void JNICALL
|
||||
Java_org_wpilib_vision_camera_CameraServerJNI_setTelemetryPeriod
|
||||
(JNIEnv* env, jclass, jdouble seconds)
|
||||
{
|
||||
cs::SetTelemetryPeriod(seconds);
|
||||
wpi::cs::SetTelemetryPeriod(seconds);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -1874,7 +1874,7 @@ JNIEXPORT jdouble JNICALL
|
||||
Java_org_wpilib_vision_camera_CameraServerJNI_getTelemetryElapsedTime
|
||||
(JNIEnv* env, jclass)
|
||||
{
|
||||
return cs::GetTelemetryElapsedTime();
|
||||
return wpi::cs::GetTelemetryElapsedTime();
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -1887,7 +1887,7 @@ Java_org_wpilib_vision_camera_CameraServerJNI_getTelemetryValue
|
||||
(JNIEnv* env, jclass, jint handle, jint kind)
|
||||
{
|
||||
CS_Status status = 0;
|
||||
auto val = cs::GetTelemetryValue(handle, static_cast<CS_TelemetryKind>(kind),
|
||||
auto val = wpi::cs::GetTelemetryValue(handle, static_cast<CS_TelemetryKind>(kind),
|
||||
&status);
|
||||
CheckStatus(env, status);
|
||||
return val;
|
||||
@@ -1903,7 +1903,7 @@ Java_org_wpilib_vision_camera_CameraServerJNI_getTelemetryAverageValue
|
||||
(JNIEnv* env, jclass, jint handle, jint kind)
|
||||
{
|
||||
CS_Status status = 0;
|
||||
auto val = cs::GetTelemetryAverageValue(
|
||||
auto val = wpi::cs::GetTelemetryAverageValue(
|
||||
handle, static_cast<CS_TelemetryKind>(kind), &status);
|
||||
CheckStatus(env, status);
|
||||
return val;
|
||||
@@ -1919,7 +1919,7 @@ Java_org_wpilib_vision_camera_CameraServerJNI_enumerateUsbCameras
|
||||
(JNIEnv* env, jclass)
|
||||
{
|
||||
CS_Status status = 0;
|
||||
auto arr = cs::EnumerateUsbCameras(&status);
|
||||
auto arr = wpi::cs::EnumerateUsbCameras(&status);
|
||||
if (!CheckStatus(env, status)) {
|
||||
return nullptr;
|
||||
}
|
||||
@@ -1945,8 +1945,8 @@ Java_org_wpilib_vision_camera_CameraServerJNI_enumerateSources
|
||||
(JNIEnv* env, jclass)
|
||||
{
|
||||
CS_Status status = 0;
|
||||
wpi::SmallVector<CS_Source, 16> buf;
|
||||
auto arr = cs::EnumerateSourceHandles(buf, &status);
|
||||
wpi::util::SmallVector<CS_Source, 16> buf;
|
||||
auto arr = wpi::cs::EnumerateSourceHandles(buf, &status);
|
||||
if (!CheckStatus(env, status)) {
|
||||
return nullptr;
|
||||
}
|
||||
@@ -1963,8 +1963,8 @@ Java_org_wpilib_vision_camera_CameraServerJNI_enumerateSinks
|
||||
(JNIEnv* env, jclass)
|
||||
{
|
||||
CS_Status status = 0;
|
||||
wpi::SmallVector<CS_Sink, 16> buf;
|
||||
auto arr = cs::EnumerateSinkHandles(buf, &status);
|
||||
wpi::util::SmallVector<CS_Sink, 16> buf;
|
||||
auto arr = wpi::cs::EnumerateSinkHandles(buf, &status);
|
||||
if (!CheckStatus(env, status)) {
|
||||
return nullptr;
|
||||
}
|
||||
@@ -1980,7 +1980,7 @@ JNIEXPORT jstring JNICALL
|
||||
Java_org_wpilib_vision_camera_CameraServerJNI_getHostname
|
||||
(JNIEnv* env, jclass)
|
||||
{
|
||||
return MakeJString(env, cs::GetHostname());
|
||||
return MakeJString(env, wpi::cs::GetHostname());
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -1992,7 +1992,7 @@ JNIEXPORT jobjectArray JNICALL
|
||||
Java_org_wpilib_vision_camera_CameraServerJNI_getNetworkInterfaces
|
||||
(JNIEnv* env, jclass)
|
||||
{
|
||||
return MakeJStringArray(env, cs::GetNetworkInterfaces());
|
||||
return MakeJStringArray(env, wpi::cs::GetNetworkInterfaces());
|
||||
}
|
||||
|
||||
} // extern "C"
|
||||
@@ -2058,7 +2058,7 @@ Java_org_wpilib_vision_camera_CameraServerJNI_setLogger
|
||||
logger.Start();
|
||||
logger.SetFunc(env, func, mid);
|
||||
|
||||
cs::SetLogger(
|
||||
wpi::cs::SetLogger(
|
||||
[](unsigned int level, const char* file, unsigned int line,
|
||||
const char* msg) {
|
||||
LoggerJNI::GetInstance().Send(level, file, line, msg);
|
||||
@@ -2075,7 +2075,7 @@ JNIEXPORT void JNICALL
|
||||
Java_org_wpilib_vision_camera_CameraServerJNI_runMainRunLoop
|
||||
(JNIEnv*, jclass)
|
||||
{
|
||||
cs::RunMainRunLoop();
|
||||
wpi::cs::RunMainRunLoop();
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -2087,7 +2087,7 @@ JNIEXPORT jint JNICALL
|
||||
Java_org_wpilib_vision_camera_CameraServerJNI_runMainRunLoopTimeout
|
||||
(JNIEnv*, jclass, jdouble timeout)
|
||||
{
|
||||
return cs::RunMainRunLoopTimeout(timeout);
|
||||
return wpi::cs::RunMainRunLoopTimeout(timeout);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -2099,7 +2099,7 @@ JNIEXPORT void JNICALL
|
||||
Java_org_wpilib_vision_camera_CameraServerJNI_stopMainRunLoop
|
||||
(JNIEnv*, jclass)
|
||||
{
|
||||
return cs::StopMainRunLoop();
|
||||
return wpi::cs::StopMainRunLoop();
|
||||
}
|
||||
|
||||
} // extern "C"
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
#endif
|
||||
|
||||
/** CameraServer (cscore) namespace */
|
||||
namespace cs {
|
||||
namespace wpi::cs {
|
||||
|
||||
/**
|
||||
* @defgroup cscore_cpp_api cscore C++ function API
|
||||
@@ -178,7 +178,7 @@ struct RawEvent {
|
||||
CS_PropertyKind GetPropertyKind(CS_Property property, CS_Status* status);
|
||||
std::string GetPropertyName(CS_Property property, CS_Status* status);
|
||||
std::string_view GetPropertyName(CS_Property property,
|
||||
wpi::SmallVectorImpl<char>& buf,
|
||||
wpi::util::SmallVectorImpl<char>& buf,
|
||||
CS_Status* status);
|
||||
int GetProperty(CS_Property property, CS_Status* status);
|
||||
void SetProperty(CS_Property property, int value, CS_Status* status);
|
||||
@@ -188,7 +188,7 @@ int GetPropertyStep(CS_Property property, CS_Status* status);
|
||||
int GetPropertyDefault(CS_Property property, CS_Status* status);
|
||||
std::string GetStringProperty(CS_Property property, CS_Status* status);
|
||||
std::string_view GetStringProperty(CS_Property property,
|
||||
wpi::SmallVectorImpl<char>& buf,
|
||||
wpi::util::SmallVectorImpl<char>& buf,
|
||||
CS_Status* status);
|
||||
void SetStringProperty(CS_Property property, std::string_view value,
|
||||
CS_Status* status);
|
||||
@@ -219,11 +219,11 @@ CS_Source CreateCvSource(std::string_view name, const VideoMode& mode,
|
||||
CS_SourceKind GetSourceKind(CS_Source source, CS_Status* status);
|
||||
std::string GetSourceName(CS_Source source, CS_Status* status);
|
||||
std::string_view GetSourceName(CS_Source source,
|
||||
wpi::SmallVectorImpl<char>& buf,
|
||||
wpi::util::SmallVectorImpl<char>& buf,
|
||||
CS_Status* status);
|
||||
std::string GetSourceDescription(CS_Source source, CS_Status* status);
|
||||
std::string_view GetSourceDescription(CS_Source source,
|
||||
wpi::SmallVectorImpl<char>& buf,
|
||||
wpi::util::SmallVectorImpl<char>& buf,
|
||||
CS_Status* status);
|
||||
uint64_t GetSourceLastFrameTime(CS_Source source, CS_Status* status);
|
||||
void SetSourceConnectionStrategy(CS_Source source,
|
||||
@@ -234,7 +234,7 @@ bool IsSourceEnabled(CS_Source source, CS_Status* status);
|
||||
CS_Property GetSourceProperty(CS_Source source, std::string_view name,
|
||||
CS_Status* status);
|
||||
std::span<CS_Property> EnumerateSourceProperties(
|
||||
CS_Source source, wpi::SmallVectorImpl<CS_Property>& vec,
|
||||
CS_Source source, wpi::util::SmallVectorImpl<CS_Property>& vec,
|
||||
CS_Status* status);
|
||||
VideoMode GetSourceVideoMode(CS_Source source, CS_Status* status);
|
||||
bool SetSourceVideoMode(CS_Source source, const VideoMode& mode,
|
||||
@@ -246,14 +246,14 @@ bool SetSourceResolution(CS_Source source, int width, int height,
|
||||
bool SetSourceFPS(CS_Source source, int fps, CS_Status* status);
|
||||
bool SetSourceConfigJson(CS_Source source, std::string_view config,
|
||||
CS_Status* status);
|
||||
bool SetSourceConfigJson(CS_Source source, const wpi::json& config,
|
||||
bool SetSourceConfigJson(CS_Source source, const wpi::util::json& config,
|
||||
CS_Status* status);
|
||||
std::string GetSourceConfigJson(CS_Source source, CS_Status* status);
|
||||
wpi::json GetSourceConfigJsonObject(CS_Source source, CS_Status* status);
|
||||
wpi::util::json GetSourceConfigJsonObject(CS_Source source, CS_Status* status);
|
||||
std::vector<VideoMode> EnumerateSourceVideoModes(CS_Source source,
|
||||
CS_Status* status);
|
||||
std::span<CS_Sink> EnumerateSourceSinks(CS_Source source,
|
||||
wpi::SmallVectorImpl<CS_Sink>& vec,
|
||||
wpi::util::SmallVectorImpl<CS_Sink>& vec,
|
||||
CS_Status* status);
|
||||
CS_Source CopySource(CS_Source source, CS_Status* status);
|
||||
void ReleaseSource(CS_Source source, CS_Status* status);
|
||||
@@ -332,25 +332,25 @@ CS_Sink CreateCvSinkCallback(std::string_view name,
|
||||
*/
|
||||
CS_SinkKind GetSinkKind(CS_Sink sink, CS_Status* status);
|
||||
std::string GetSinkName(CS_Sink sink, CS_Status* status);
|
||||
std::string_view GetSinkName(CS_Sink sink, wpi::SmallVectorImpl<char>& buf,
|
||||
std::string_view GetSinkName(CS_Sink sink, wpi::util::SmallVectorImpl<char>& buf,
|
||||
CS_Status* status);
|
||||
std::string GetSinkDescription(CS_Sink sink, CS_Status* status);
|
||||
std::string_view GetSinkDescription(CS_Sink sink,
|
||||
wpi::SmallVectorImpl<char>& buf,
|
||||
wpi::util::SmallVectorImpl<char>& buf,
|
||||
CS_Status* status);
|
||||
CS_Property GetSinkProperty(CS_Sink sink, std::string_view name,
|
||||
CS_Status* status);
|
||||
std::span<CS_Property> EnumerateSinkProperties(
|
||||
CS_Sink sink, wpi::SmallVectorImpl<CS_Property>& vec, CS_Status* status);
|
||||
CS_Sink sink, wpi::util::SmallVectorImpl<CS_Property>& vec, CS_Status* status);
|
||||
void SetSinkSource(CS_Sink sink, CS_Source source, CS_Status* status);
|
||||
CS_Property GetSinkSourceProperty(CS_Sink sink, std::string_view name,
|
||||
CS_Status* status);
|
||||
bool SetSinkConfigJson(CS_Sink sink, std::string_view config,
|
||||
CS_Status* status);
|
||||
bool SetSinkConfigJson(CS_Sink sink, const wpi::json& config,
|
||||
bool SetSinkConfigJson(CS_Sink sink, const wpi::util::json& config,
|
||||
CS_Status* status);
|
||||
std::string GetSinkConfigJson(CS_Sink sink, CS_Status* status);
|
||||
wpi::json GetSinkConfigJsonObject(CS_Sink sink, CS_Status* status);
|
||||
wpi::util::json GetSinkConfigJsonObject(CS_Sink sink, CS_Status* status);
|
||||
CS_Source GetSinkSource(CS_Sink sink, CS_Status* status);
|
||||
CS_Sink CopySink(CS_Sink sink, CS_Status* status);
|
||||
void ReleaseSink(CS_Sink sink, CS_Status* status);
|
||||
@@ -371,7 +371,7 @@ int GetMjpegServerPort(CS_Sink sink, CS_Status* status);
|
||||
void SetSinkDescription(CS_Sink sink, std::string_view description,
|
||||
CS_Status* status);
|
||||
std::string GetSinkError(CS_Sink sink, CS_Status* status);
|
||||
std::string_view GetSinkError(CS_Sink sink, wpi::SmallVectorImpl<char>& buf,
|
||||
std::string_view GetSinkError(CS_Sink sink, wpi::util::SmallVectorImpl<char>& buf,
|
||||
CS_Status* status);
|
||||
void SetSinkEnabled(CS_Sink sink, bool enabled, CS_Status* status);
|
||||
/** @} */
|
||||
@@ -436,8 +436,8 @@ void Shutdown();
|
||||
std::vector<UsbCameraInfo> EnumerateUsbCameras(CS_Status* status);
|
||||
|
||||
std::span<CS_Source> EnumerateSourceHandles(
|
||||
wpi::SmallVectorImpl<CS_Source>& vec, CS_Status* status);
|
||||
std::span<CS_Sink> EnumerateSinkHandles(wpi::SmallVectorImpl<CS_Sink>& vec,
|
||||
wpi::util::SmallVectorImpl<CS_Source>& vec, CS_Status* status);
|
||||
std::span<CS_Sink> EnumerateSinkHandles(wpi::util::SmallVectorImpl<CS_Sink>& vec,
|
||||
CS_Status* status);
|
||||
|
||||
std::string GetHostname();
|
||||
@@ -447,7 +447,7 @@ std::vector<std::string> GetNetworkInterfaces();
|
||||
|
||||
/** @} */
|
||||
|
||||
} // namespace cs
|
||||
} // namespace wpi::cs
|
||||
|
||||
#ifdef _WIN32
|
||||
// Disable uninitialized variable warnings
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
#include "wpi/cs/cscore_raw.h"
|
||||
#include "wpi/util/RawFrame.h"
|
||||
|
||||
namespace cs {
|
||||
namespace wpi::cs {
|
||||
/**
|
||||
* A source for user code to provide OpenCV images as video frames.
|
||||
*
|
||||
@@ -107,7 +107,7 @@ class CvSink : public ImageSink {
|
||||
* with.
|
||||
*
|
||||
* @return Frame time, or 0 on error (call GetError() to obtain the error
|
||||
* message); the frame time is in the same time base as wpi::Now(),
|
||||
* message); the frame time is in the same time base as wpi::util::Now(),
|
||||
* and is in 1 us increments.
|
||||
*/
|
||||
[[nodiscard]]
|
||||
@@ -119,7 +119,7 @@ class CvSink : public ImageSink {
|
||||
* with.
|
||||
*
|
||||
* @return Frame time, or 0 on error (call GetError() to obtain the error
|
||||
* message); the frame time is in the same time base as wpi::Now(),
|
||||
* message); the frame time is in the same time base as wpi::util::Now(),
|
||||
* and is in 1 us increments.
|
||||
*/
|
||||
[[nodiscard]]
|
||||
@@ -133,7 +133,7 @@ class CvSink : public ImageSink {
|
||||
* any grabFrame*() call on the sink.
|
||||
*
|
||||
* @return Frame time, or 0 on error (call GetError() to obtain the error
|
||||
* message); the frame time is in the same time base as wpi::Now(),
|
||||
* message); the frame time is in the same time base as wpi::util::Now(),
|
||||
* and is in 1 us increments.
|
||||
*/
|
||||
[[nodiscard]]
|
||||
@@ -146,7 +146,7 @@ class CvSink : public ImageSink {
|
||||
* any grabFrame*() call on the sink.
|
||||
*
|
||||
* @return Frame time, or 0 on error (call GetError() to obtain the error
|
||||
* message); the frame time is in the same time base as wpi::Now(),
|
||||
* message); the frame time is in the same time base as wpi::util::Now(),
|
||||
* and is in 1 us increments.
|
||||
*/
|
||||
[[nodiscard]]
|
||||
@@ -166,7 +166,7 @@ class CvSink : public ImageSink {
|
||||
* a new frame.
|
||||
*
|
||||
* @return Frame time, or 0 on error (call GetError() to obtain the error
|
||||
* message); the frame time is in the same time base as wpi::Now(),
|
||||
* message); the frame time is in the same time base as wpi::util::Now(),
|
||||
* and is in 1 us increments.
|
||||
*/
|
||||
[[nodiscard]]
|
||||
@@ -175,7 +175,7 @@ class CvSink : public ImageSink {
|
||||
|
||||
/**
|
||||
* Get the last time a frame was grabbed. This uses the same time base as
|
||||
* wpi::Now().
|
||||
* wpi::util::Now().
|
||||
*
|
||||
* @return Time in 1 us increments.
|
||||
*/
|
||||
@@ -193,7 +193,7 @@ class CvSink : public ImageSink {
|
||||
private:
|
||||
constexpr int GetCvFormat(WPI_PixelFormat pixelFormat);
|
||||
|
||||
wpi::RawFrame rawFrame;
|
||||
wpi::util::RawFrame rawFrame;
|
||||
VideoMode::PixelFormat pixelFormat;
|
||||
};
|
||||
|
||||
@@ -431,6 +431,6 @@ inline WPI_TimestampSource CvSink::LastFrameTimeSource() {
|
||||
return static_cast<WPI_TimestampSource>(rawFrame.timestampSrc);
|
||||
}
|
||||
|
||||
} // namespace cs
|
||||
} // namespace wpi::cs
|
||||
|
||||
#endif // CSCORE_WPI_CS_CSCORE_CV_HPP_
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
#include "wpi/cs/cscore_cpp.hpp"
|
||||
#include "wpi/util/deprecated.hpp"
|
||||
|
||||
namespace cs {
|
||||
namespace wpi::cs {
|
||||
|
||||
/**
|
||||
* @defgroup cscore_oo cscore C++ object-oriented API
|
||||
@@ -191,7 +191,7 @@ class VideoProperty {
|
||||
* @param buf The backing storage to which to write the property value.
|
||||
* @return The string property value as a reference to the given buffer.
|
||||
*/
|
||||
std::string_view GetString(wpi::SmallVectorImpl<char>& buf) const {
|
||||
std::string_view GetString(wpi::util::SmallVectorImpl<char>& buf) const {
|
||||
m_status = 0;
|
||||
return GetStringProperty(m_handle, buf, &m_status);
|
||||
}
|
||||
@@ -349,7 +349,7 @@ class VideoSource {
|
||||
|
||||
/**
|
||||
* Get the last time a frame was captured.
|
||||
* This uses the same time base as wpi::Now().
|
||||
* This uses the same time base as wpi::util::Now().
|
||||
*
|
||||
* @return Time in 1 us increments.
|
||||
*/
|
||||
@@ -515,7 +515,7 @@ class VideoSource {
|
||||
* @param config configuration
|
||||
* @return True if set successfully
|
||||
*/
|
||||
bool SetConfigJson(const wpi::json& config) {
|
||||
bool SetConfigJson(const wpi::util::json& config) {
|
||||
m_status = 0;
|
||||
return SetSourceConfigJson(m_handle, config, &m_status);
|
||||
}
|
||||
@@ -535,7 +535,7 @@ class VideoSource {
|
||||
*
|
||||
* @return JSON configuration object
|
||||
*/
|
||||
wpi::json GetConfigJsonObject() const;
|
||||
wpi::util::json GetConfigJsonObject() const;
|
||||
|
||||
/**
|
||||
* Get the actual FPS.
|
||||
@@ -546,7 +546,7 @@ class VideoSource {
|
||||
*/
|
||||
double GetActualFPS() const {
|
||||
m_status = 0;
|
||||
return cs::GetTelemetryAverageValue(m_handle, CS_SOURCE_FRAMES_RECEIVED,
|
||||
return wpi::cs::GetTelemetryAverageValue(m_handle, CS_SOURCE_FRAMES_RECEIVED,
|
||||
&m_status);
|
||||
}
|
||||
|
||||
@@ -559,7 +559,7 @@ class VideoSource {
|
||||
*/
|
||||
double GetActualDataRate() const {
|
||||
m_status = 0;
|
||||
return cs::GetTelemetryAverageValue(m_handle, CS_SOURCE_BYTES_RECEIVED,
|
||||
return wpi::cs::GetTelemetryAverageValue(m_handle, CS_SOURCE_BYTES_RECEIVED,
|
||||
&m_status);
|
||||
}
|
||||
|
||||
@@ -727,7 +727,7 @@ class UsbCamera : public VideoCamera {
|
||||
*/
|
||||
static std::vector<UsbCameraInfo> EnumerateUsbCameras() {
|
||||
CS_Status status = 0;
|
||||
return ::cs::EnumerateUsbCameras(&status);
|
||||
return ::wpi::cs::EnumerateUsbCameras(&status);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -735,7 +735,7 @@ class UsbCamera : public VideoCamera {
|
||||
*/
|
||||
void SetPath(std::string_view path) {
|
||||
m_status = 0;
|
||||
return ::cs::SetUsbCameraPath(m_handle, path, &m_status);
|
||||
return ::wpi::cs::SetUsbCameraPath(m_handle, path, &m_status);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -743,7 +743,7 @@ class UsbCamera : public VideoCamera {
|
||||
*/
|
||||
std::string GetPath() const {
|
||||
m_status = 0;
|
||||
return ::cs::GetUsbCameraPath(m_handle, &m_status);
|
||||
return ::wpi::cs::GetUsbCameraPath(m_handle, &m_status);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -751,7 +751,7 @@ class UsbCamera : public VideoCamera {
|
||||
*/
|
||||
UsbCameraInfo GetInfo() const {
|
||||
m_status = 0;
|
||||
return ::cs::GetUsbCameraInfo(m_handle, &m_status);
|
||||
return ::wpi::cs::GetUsbCameraInfo(m_handle, &m_status);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -867,7 +867,7 @@ class HttpCamera : public VideoCamera {
|
||||
HttpCameraKind GetHttpCameraKind() const {
|
||||
m_status = 0;
|
||||
return static_cast<HttpCameraKind>(
|
||||
static_cast<int>(::cs::GetHttpCameraKind(m_handle, &m_status)));
|
||||
static_cast<int>(::wpi::cs::GetHttpCameraKind(m_handle, &m_status)));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -875,7 +875,7 @@ class HttpCamera : public VideoCamera {
|
||||
*/
|
||||
void SetUrls(std::span<const std::string> urls) {
|
||||
m_status = 0;
|
||||
::cs::SetHttpCameraUrls(m_handle, urls, &m_status);
|
||||
::wpi::cs::SetHttpCameraUrls(m_handle, urls, &m_status);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -889,7 +889,7 @@ class HttpCamera : public VideoCamera {
|
||||
vec.emplace_back(url);
|
||||
}
|
||||
m_status = 0;
|
||||
::cs::SetHttpCameraUrls(m_handle, vec, &m_status);
|
||||
::wpi::cs::SetHttpCameraUrls(m_handle, vec, &m_status);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -897,7 +897,7 @@ class HttpCamera : public VideoCamera {
|
||||
*/
|
||||
std::vector<std::string> GetUrls() const {
|
||||
m_status = 0;
|
||||
return ::cs::GetHttpCameraUrls(m_handle, &m_status);
|
||||
return ::wpi::cs::GetHttpCameraUrls(m_handle, &m_status);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1256,7 +1256,7 @@ class VideoSink {
|
||||
* @param config configuration
|
||||
* @return True if set successfully
|
||||
*/
|
||||
bool SetConfigJson(const wpi::json& config) {
|
||||
bool SetConfigJson(const wpi::util::json& config) {
|
||||
m_status = 0;
|
||||
return SetSinkConfigJson(m_handle, config, &m_status);
|
||||
}
|
||||
@@ -1276,7 +1276,7 @@ class VideoSink {
|
||||
*
|
||||
* @return JSON configuration object
|
||||
*/
|
||||
wpi::json GetConfigJsonObject() const;
|
||||
wpi::util::json GetConfigJsonObject() const;
|
||||
|
||||
/**
|
||||
* Configure which source should provide frames to this sink. Each sink
|
||||
@@ -1370,7 +1370,7 @@ class MjpegServer : public VideoSink {
|
||||
*/
|
||||
std::string GetListenAddress() const {
|
||||
m_status = 0;
|
||||
return cs::GetMjpegServerListenAddress(m_handle, &m_status);
|
||||
return wpi::cs::GetMjpegServerListenAddress(m_handle, &m_status);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1378,7 +1378,7 @@ class MjpegServer : public VideoSink {
|
||||
*/
|
||||
int GetPort() const {
|
||||
m_status = 0;
|
||||
return cs::GetMjpegServerPort(m_handle, &m_status);
|
||||
return wpi::cs::GetMjpegServerPort(m_handle, &m_status);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1577,6 +1577,6 @@ class VideoListener {
|
||||
|
||||
/** @} */
|
||||
|
||||
} // namespace cs
|
||||
} // namespace wpi::cs
|
||||
|
||||
#endif // CSCORE_WPI_CS_CSCORE_OO_HPP_
|
||||
|
||||
@@ -52,7 +52,7 @@ CS_Source CS_CreateRawSource(const struct WPI_String* name, CS_Bool isCv,
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
namespace cs {
|
||||
namespace wpi::cs {
|
||||
|
||||
/**
|
||||
* @defgroup cscore_raw_func Raw Image Functions
|
||||
@@ -111,7 +111,7 @@ class RawSource : public ImageSource {
|
||||
*
|
||||
* @param image raw frame image
|
||||
*/
|
||||
void PutFrame(wpi::RawFrame& image);
|
||||
void PutFrame(wpi::util::RawFrame& image);
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -155,22 +155,22 @@ class RawSink : public ImageSink {
|
||||
* The provided image will have three 8-bit channels stored in BGR order.
|
||||
*
|
||||
* @return Frame time, or 0 on error (call GetError() to obtain the error
|
||||
* message); the frame time is in the same time base as wpi::Now(),
|
||||
* message); the frame time is in the same time base as wpi::util::Now(),
|
||||
* and is in 1 us increments.
|
||||
*/
|
||||
[[nodiscard]]
|
||||
uint64_t GrabFrame(wpi::RawFrame& image, double timeout = 0.225) const;
|
||||
uint64_t GrabFrame(wpi::util::RawFrame& image, double timeout = 0.225) const;
|
||||
|
||||
/**
|
||||
* Wait for the next frame and get the image. May block forever.
|
||||
* The provided image will have three 8-bit channels stored in BGR order.
|
||||
*
|
||||
* @return Frame time, or 0 on error (call GetError() to obtain the error
|
||||
* message); the frame time is in the same time base as wpi::Now(),
|
||||
* message); the frame time is in the same time base as wpi::util::Now(),
|
||||
* and is in 1 us increments.
|
||||
*/
|
||||
[[nodiscard]]
|
||||
uint64_t GrabFrameNoTimeout(wpi::RawFrame& image) const;
|
||||
uint64_t GrabFrameNoTimeout(wpi::util::RawFrame& image) const;
|
||||
|
||||
/**
|
||||
* Wait for the next frame and get the image. May block forever.
|
||||
@@ -183,11 +183,11 @@ class RawSink : public ImageSink {
|
||||
* a new frame.
|
||||
*
|
||||
* @return Frame time, or 0 on error (call GetError() to obtain the error
|
||||
* message); the frame time is in the same time base as wpi::Now(),
|
||||
* message); the frame time is in the same time base as wpi::util::Now(),
|
||||
* and is in 1 us increments.
|
||||
*/
|
||||
[[nodiscard]]
|
||||
uint64_t GrabFrameLastTime(wpi::RawFrame& image, uint64_t lastFrameTime,
|
||||
uint64_t GrabFrameLastTime(wpi::util::RawFrame& image, uint64_t lastFrameTime,
|
||||
double timeout = 0.225) const;
|
||||
};
|
||||
|
||||
@@ -202,7 +202,7 @@ inline RawSource::RawSource(std::string_view name,
|
||||
&m_status);
|
||||
}
|
||||
|
||||
inline void RawSource::PutFrame(wpi::RawFrame& image) {
|
||||
inline void RawSource::PutFrame(wpi::util::RawFrame& image) {
|
||||
m_status = 0;
|
||||
PutSourceFrame(m_handle, image, &m_status);
|
||||
}
|
||||
@@ -216,17 +216,17 @@ inline RawSink::RawSink(std::string_view name,
|
||||
m_handle = CreateRawSinkCallback(name, false, processFrame, &m_status);
|
||||
}
|
||||
|
||||
inline uint64_t RawSink::GrabFrame(wpi::RawFrame& image, double timeout) const {
|
||||
inline uint64_t RawSink::GrabFrame(wpi::util::RawFrame& image, double timeout) const {
|
||||
m_status = 0;
|
||||
return GrabSinkFrameTimeout(m_handle, image, timeout, &m_status);
|
||||
}
|
||||
|
||||
inline uint64_t RawSink::GrabFrameNoTimeout(wpi::RawFrame& image) const {
|
||||
inline uint64_t RawSink::GrabFrameNoTimeout(wpi::util::RawFrame& image) const {
|
||||
m_status = 0;
|
||||
return GrabSinkFrame(m_handle, image, &m_status);
|
||||
}
|
||||
|
||||
inline uint64_t RawSink::GrabFrameLastTime(wpi::RawFrame& image,
|
||||
inline uint64_t RawSink::GrabFrameLastTime(wpi::util::RawFrame& image,
|
||||
uint64_t lastFrameTime,
|
||||
double timeout) const {
|
||||
m_status = 0;
|
||||
@@ -235,7 +235,7 @@ inline uint64_t RawSink::GrabFrameLastTime(wpi::RawFrame& image,
|
||||
}
|
||||
/** @} */
|
||||
|
||||
} // namespace cs
|
||||
} // namespace wpi::cs
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
namespace cs {
|
||||
namespace wpi::cs {
|
||||
|
||||
void RunMainRunLoop();
|
||||
|
||||
@@ -17,4 +17,4 @@ int RunMainRunLoopTimeout(double timeout);
|
||||
|
||||
void StopMainRunLoop();
|
||||
|
||||
} // namespace cs
|
||||
} // namespace wpi::cs
|
||||
|
||||
@@ -20,31 +20,31 @@
|
||||
#include "Notifier.hpp"
|
||||
#include "wpi/util/SafeThread.hpp"
|
||||
|
||||
using namespace cs;
|
||||
using namespace wpi::cs;
|
||||
|
||||
class NetworkListener::Impl {
|
||||
public:
|
||||
Impl(wpi::Logger& logger, Notifier& notifier)
|
||||
Impl(wpi::util::Logger& logger, Notifier& notifier)
|
||||
: m_logger(logger), m_notifier(notifier) {}
|
||||
|
||||
wpi::Logger& m_logger;
|
||||
wpi::util::Logger& m_logger;
|
||||
Notifier& m_notifier;
|
||||
|
||||
class Thread : public wpi::SafeThread {
|
||||
class Thread : public wpi::util::SafeThread {
|
||||
public:
|
||||
Thread(wpi::Logger& logger, Notifier& notifier)
|
||||
Thread(wpi::util::Logger& logger, Notifier& notifier)
|
||||
: m_logger(logger), m_notifier(notifier) {}
|
||||
void Main() override;
|
||||
|
||||
wpi::Logger& m_logger;
|
||||
wpi::util::Logger& m_logger;
|
||||
Notifier& m_notifier;
|
||||
int m_command_fd = -1;
|
||||
};
|
||||
|
||||
wpi::SafeThreadOwner<Thread> m_owner;
|
||||
wpi::util::SafeThreadOwner<Thread> m_owner;
|
||||
};
|
||||
|
||||
NetworkListener::NetworkListener(wpi::Logger& logger, Notifier& notifier)
|
||||
NetworkListener::NetworkListener(wpi::util::Logger& logger, Notifier& notifier)
|
||||
: m_impl(std::make_unique<Impl>(logger, notifier)) {}
|
||||
|
||||
NetworkListener::~NetworkListener() {
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace cs {
|
||||
namespace wpi::cs {
|
||||
|
||||
std::vector<std::string> GetNetworkInterfaces() {
|
||||
struct ifaddrs* ifa;
|
||||
@@ -42,4 +42,4 @@ std::vector<std::string> GetNetworkInterfaces() {
|
||||
return rv;
|
||||
}
|
||||
|
||||
} // namespace cs
|
||||
} // namespace wpi::cs
|
||||
|
||||
@@ -5,22 +5,22 @@
|
||||
#include "wpi/cs/cscore_runloop.hpp"
|
||||
#include "wpi/util/Synchronization.h"
|
||||
|
||||
static wpi::Event& GetInstance() {
|
||||
static wpi::Event event;
|
||||
static wpi::util::Event& GetInstance() {
|
||||
static wpi::util::Event event;
|
||||
return event;
|
||||
}
|
||||
|
||||
namespace cs {
|
||||
namespace wpi::cs {
|
||||
|
||||
void RunMainRunLoop() {
|
||||
wpi::Event& event = GetInstance();
|
||||
wpi::WaitForObject(event.GetHandle());
|
||||
wpi::util::Event& event = GetInstance();
|
||||
wpi::util::WaitForObject(event.GetHandle());
|
||||
}
|
||||
|
||||
int RunMainRunLoopTimeout(double timeout) {
|
||||
wpi::Event& event = GetInstance();
|
||||
wpi::util::Event& event = GetInstance();
|
||||
bool timedOut = false;
|
||||
bool signaled = wpi::WaitForObject(event.GetHandle(), timeout, &timedOut);
|
||||
bool signaled = wpi::util::WaitForObject(event.GetHandle(), timeout, &timedOut);
|
||||
if (timedOut) {
|
||||
return 3;
|
||||
}
|
||||
@@ -31,8 +31,8 @@ int RunMainRunLoopTimeout(double timeout) {
|
||||
}
|
||||
|
||||
void StopMainRunLoop() {
|
||||
wpi::Event& event = GetInstance();
|
||||
wpi::util::Event& event = GetInstance();
|
||||
event.Set();
|
||||
}
|
||||
|
||||
} // namespace cs
|
||||
} // namespace wpi::cs
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
|
||||
#include <utility>
|
||||
|
||||
namespace cs {
|
||||
namespace wpi::cs {
|
||||
|
||||
class UsbCameraBuffer {
|
||||
public:
|
||||
@@ -50,6 +50,6 @@ class UsbCameraBuffer {
|
||||
size_t m_length{0};
|
||||
};
|
||||
|
||||
} // namespace cs
|
||||
} // namespace wpi::cs
|
||||
|
||||
#endif // CSCORE_USBCAMERABUFFER_HPP_
|
||||
|
||||
@@ -41,7 +41,7 @@
|
||||
#include "wpi/util/raw_ostream.hpp"
|
||||
#include "wpi/util/timestamp.h"
|
||||
|
||||
using namespace cs;
|
||||
using namespace wpi::cs;
|
||||
|
||||
namespace {
|
||||
// Find the length of an array.
|
||||
@@ -120,8 +120,8 @@ static __u32 FromPixelFormat(VideoMode::PixelFormat pixelFormat) {
|
||||
}
|
||||
|
||||
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" ||
|
||||
@@ -206,14 +206,14 @@ static bool GetVendorProduct(int dev, int* vendor, int* product) {
|
||||
return false;
|
||||
}
|
||||
std::string_view readStr{readBuf};
|
||||
if (auto v = wpi::parse_integer<int>(
|
||||
wpi::substr(wpi::substr(readStr, readStr.find('v')), 1, 4), 16)) {
|
||||
if (auto v = wpi::util::parse_integer<int>(
|
||||
wpi::util::substr(wpi::util::substr(readStr, readStr.find('v')), 1, 4), 16)) {
|
||||
*vendor = v.value();
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
if (auto v = wpi::parse_integer<int>(
|
||||
wpi::substr(wpi::substr(readStr, readStr.find('p')), 1, 4), 16)) {
|
||||
if (auto v = wpi::util::parse_integer<int>(
|
||||
wpi::util::substr(wpi::util::substr(readStr, readStr.find('p')), 1, 4), 16)) {
|
||||
*product = v.value();
|
||||
} else {
|
||||
return false;
|
||||
@@ -239,7 +239,7 @@ static bool GetDescriptionSysV4L(int dev, std::string* desc) {
|
||||
return false;
|
||||
}
|
||||
|
||||
*desc = wpi::rtrim(std::string_view(readBuf, n));
|
||||
*desc = wpi::util::rtrim(std::string_view(readBuf, n));
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -261,9 +261,9 @@ static bool GetDescriptionIoctl(const char* cpath, std::string* desc) {
|
||||
// try to convert "UVC Camera (0000:0000)" into a better name
|
||||
std::optional<int> vendor;
|
||||
std::optional<int> product;
|
||||
if (wpi::starts_with(card, "UVC Camera (") &&
|
||||
(vendor = wpi::parse_integer<int>(wpi::substr(card, 12, 4), 16)) &&
|
||||
(product = wpi::parse_integer<int>(wpi::substr(card, 17, 4), 16))) {
|
||||
if (wpi::util::starts_with(card, "UVC Camera (") &&
|
||||
(vendor = wpi::util::parse_integer<int>(wpi::util::substr(card, 12, 4), 16)) &&
|
||||
(product = wpi::util::parse_integer<int>(wpi::util::substr(card, 17, 4), 16))) {
|
||||
std::string card2 = GetUsbNameFromId(vendor.value(), product.value());
|
||||
if (!card2.empty()) {
|
||||
*desc = std::move(card2);
|
||||
@@ -306,10 +306,10 @@ static int GetDeviceNum(const char* cpath) {
|
||||
}
|
||||
|
||||
std::string fn = path.filename();
|
||||
if (!wpi::starts_with(fn, "video")) {
|
||||
if (!wpi::util::starts_with(fn, "video")) {
|
||||
return -1;
|
||||
}
|
||||
if (auto dev = wpi::parse_integer<int>(wpi::substr(fn, 5), 10)) {
|
||||
if (auto dev = wpi::util::parse_integer<int>(wpi::util::substr(fn, 5), 10)) {
|
||||
return dev.value();
|
||||
}
|
||||
return -1;
|
||||
@@ -334,7 +334,7 @@ static std::string GetDescriptionImpl(const char* cpath) {
|
||||
return std::string{};
|
||||
}
|
||||
|
||||
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},
|
||||
@@ -391,27 +391,27 @@ void UsbCameraImpl::Start() {
|
||||
void UsbCameraImpl::CameraThreadMain() {
|
||||
// We want to be notified on file creation and deletion events in the device
|
||||
// path. This is used to detect disconnects and reconnects.
|
||||
std::unique_ptr<wpi::raw_fd_istream> notify_is;
|
||||
std::unique_ptr<wpi::util::raw_fd_istream> notify_is;
|
||||
int notify_fd = inotify_init();
|
||||
if (notify_fd >= 0) {
|
||||
// need to make a copy as dirname can modify it
|
||||
wpi::SmallString<64> pathCopy{m_path};
|
||||
wpi::util::SmallString<64> pathCopy{m_path};
|
||||
pathCopy.push_back('\0');
|
||||
if (inotify_add_watch(notify_fd, dirname(pathCopy.data()),
|
||||
IN_CREATE | IN_DELETE) < 0) {
|
||||
close(notify_fd);
|
||||
notify_fd = -1;
|
||||
} else {
|
||||
notify_is = std::make_unique<wpi::raw_fd_istream>(
|
||||
notify_is = std::make_unique<wpi::util::raw_fd_istream>(
|
||||
notify_fd, true, sizeof(struct inotify_event) + NAME_MAX + 1);
|
||||
}
|
||||
}
|
||||
bool notified = (notify_fd < 0); // treat as always notified if cannot notify
|
||||
|
||||
// Get the basename for later notify use
|
||||
wpi::SmallString<64> pathCopy{m_path};
|
||||
wpi::util::SmallString<64> pathCopy{m_path};
|
||||
pathCopy.push_back('\0');
|
||||
wpi::SmallString<64> base{basename(pathCopy.data())};
|
||||
wpi::util::SmallString<64> base{basename(pathCopy.data())};
|
||||
|
||||
// Used to restart streaming on reconnect
|
||||
bool wasStreaming = false;
|
||||
@@ -486,7 +486,7 @@ void UsbCameraImpl::CameraThreadMain() {
|
||||
// Read the event structure
|
||||
notify_is->read(&event, sizeof(event));
|
||||
// Read the event name
|
||||
wpi::SmallString<64> raw_name;
|
||||
wpi::util::SmallString<64> raw_name;
|
||||
raw_name.resize(event.len);
|
||||
notify_is->read(raw_name.data(), event.len);
|
||||
// If the name is what we expect...
|
||||
@@ -555,18 +555,18 @@ void UsbCameraImpl::CameraThreadMain() {
|
||||
good = false;
|
||||
}
|
||||
if (good) {
|
||||
Frame::Time frameTime{wpi::Now()};
|
||||
Frame::Time frameTime{wpi::util::Now()};
|
||||
WPI_TimestampSource timeSource{WPI_TIMESRC_FRAME_DEQUEUE};
|
||||
|
||||
// check the timestamp time
|
||||
auto tsFlags = buf.flags & V4L2_BUF_FLAG_TIMESTAMP_MASK;
|
||||
SDEBUG4("Flags {}", tsFlags);
|
||||
if (tsFlags == V4L2_BUF_FLAG_TIMESTAMP_UNKNOWN) {
|
||||
SDEBUG4("Got unknown time for frame - default to wpi::Now");
|
||||
SDEBUG4("Got unknown time for frame - default to wpi::util::Now");
|
||||
} else if (tsFlags == V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC) {
|
||||
SDEBUG4("Got valid monotonic time for frame");
|
||||
// we can't go directly to frametime, since the rest of cscore
|
||||
// expects us to use wpi::Now, which is in an arbitrary timebase
|
||||
// expects us to use wpi::util::Now, which is in an arbitrary timebase
|
||||
// (see timestamp.cpp). Best I can do is (approximately) translate
|
||||
// between timebases
|
||||
|
||||
@@ -595,7 +595,7 @@ void UsbCameraImpl::CameraThreadMain() {
|
||||
// Can't do anything if we can't access the clock, leave default
|
||||
}
|
||||
} else if (tsFlags == V4L2_BUF_FLAG_TIMESTAMP_COPY) {
|
||||
SDEBUG4("Got valid copy time for frame - default to wpi::Now");
|
||||
SDEBUG4("Got valid copy time for frame - default to wpi::util::Now");
|
||||
}
|
||||
|
||||
PutFrame(static_cast<VideoMode::PixelFormat>(m_mode.pixelFormat),
|
||||
@@ -813,7 +813,7 @@ bool UsbCameraImpl::DeviceStreamOff() {
|
||||
}
|
||||
|
||||
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];
|
||||
@@ -877,7 +877,7 @@ CS_StatusValue UsbCameraImpl::DeviceCmdSetMode(
|
||||
}
|
||||
|
||||
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];
|
||||
@@ -940,7 +940,7 @@ CS_StatusValue UsbCameraImpl::DeviceCmdSetProperty(
|
||||
}
|
||||
|
||||
CS_StatusValue UsbCameraImpl::DeviceCmdSetPath(
|
||||
std::unique_lock<wpi::mutex>& lock, const Message& msg) {
|
||||
std::unique_lock<wpi::util::mutex>& lock, const Message& msg) {
|
||||
m_path = msg.dataStr;
|
||||
lock.unlock();
|
||||
// disconnect and reconnect
|
||||
@@ -960,7 +960,7 @@ CS_StatusValue UsbCameraImpl::DeviceCmdSetPath(
|
||||
}
|
||||
|
||||
CS_StatusValue UsbCameraImpl::DeviceProcessCommand(
|
||||
std::unique_lock<wpi::mutex>& lock, const Message& msg) {
|
||||
std::unique_lock<wpi::util::mutex>& lock, const Message& msg) {
|
||||
if (msg.kind == Message::kCmdSetMode ||
|
||||
msg.kind == Message::kCmdSetPixelFormat ||
|
||||
msg.kind == Message::kCmdSetResolution ||
|
||||
@@ -1453,12 +1453,12 @@ bool UsbCameraImpl::CacheProperties(CS_Status* status) const {
|
||||
}
|
||||
|
||||
void UsbCameraImpl::SetQuirks() {
|
||||
wpi::SmallString<128> descbuf;
|
||||
wpi::util::SmallString<128> descbuf;
|
||||
std::string_view desc = GetDescription(descbuf);
|
||||
m_lifecam_exposure = wpi::ends_with(desc, "LifeCam HD-3000") ||
|
||||
wpi::ends_with(desc, "LifeCam Cinema (TM)");
|
||||
m_ov9281_exposure = wpi::contains(desc, "OV9281");
|
||||
m_picamera = wpi::ends_with(desc, "mmal service");
|
||||
m_lifecam_exposure = wpi::util::ends_with(desc, "LifeCam HD-3000") ||
|
||||
wpi::util::ends_with(desc, "LifeCam Cinema (TM)");
|
||||
m_ov9281_exposure = wpi::util::contains(desc, "OV9281");
|
||||
m_picamera = wpi::util::ends_with(desc, "mmal service");
|
||||
|
||||
int deviceNum = GetDeviceNum(m_path.c_str());
|
||||
if (deviceNum >= 0) {
|
||||
@@ -1611,7 +1611,7 @@ std::string UsbCameraImpl::GetPath() const {
|
||||
return m_path;
|
||||
}
|
||||
|
||||
namespace cs {
|
||||
namespace wpi::cs {
|
||||
|
||||
CS_Source CreateUsbCameraDev(std::string_view name, int dev,
|
||||
CS_Status* status) {
|
||||
@@ -1668,7 +1668,7 @@ UsbCameraInfo GetUsbCameraInfo(CS_Source source, CS_Status* status) {
|
||||
|
||||
// look through /dev/v4l/by-id and /dev/v4l/by-path for symlinks to the
|
||||
// keypath
|
||||
wpi::SmallString<128> path;
|
||||
wpi::util::SmallString<128> path;
|
||||
for (auto symlinkDir : symlinkDirs) {
|
||||
if (DIR* dp = ::opendir(symlinkDir)) {
|
||||
while (struct dirent* ep = ::readdir(dp)) {
|
||||
@@ -1703,13 +1703,13 @@ std::vector<UsbCameraInfo> EnumerateUsbCameras(CS_Status* status) {
|
||||
if (DIR* dp = ::opendir("/dev")) {
|
||||
while (struct dirent* ep = ::readdir(dp)) {
|
||||
std::string_view fname{ep->d_name};
|
||||
if (!wpi::starts_with(fname, "video")) {
|
||||
if (!wpi::util::starts_with(fname, "video")) {
|
||||
continue;
|
||||
}
|
||||
|
||||
unsigned int dev = 0;
|
||||
if (auto v =
|
||||
wpi::parse_integer<unsigned int>(wpi::substr(fname, 5), 10)) {
|
||||
wpi::util::parse_integer<unsigned int>(wpi::util::substr(fname, 5), 10)) {
|
||||
dev = v.value();
|
||||
} else {
|
||||
continue;
|
||||
@@ -1718,7 +1718,7 @@ std::vector<UsbCameraInfo> EnumerateUsbCameras(CS_Status* status) {
|
||||
UsbCameraInfo info;
|
||||
info.dev = dev;
|
||||
|
||||
wpi::SmallString<32> path{"/dev/"};
|
||||
wpi::util::SmallString<32> path{"/dev/"};
|
||||
path += fname;
|
||||
info.path = path.str();
|
||||
|
||||
@@ -1747,7 +1747,7 @@ std::vector<UsbCameraInfo> EnumerateUsbCameras(CS_Status* status) {
|
||||
|
||||
// look through /dev/v4l/by-id and /dev/v4l/by-path for symlinks to
|
||||
// /dev/videoN
|
||||
wpi::SmallString<128> path;
|
||||
wpi::util::SmallString<128> path;
|
||||
for (auto symlinkDir : symlinkDirs) {
|
||||
if (DIR* dp = ::opendir(symlinkDir)) {
|
||||
while (struct dirent* ep = ::readdir(dp)) {
|
||||
@@ -1759,8 +1759,8 @@ std::vector<UsbCameraInfo> EnumerateUsbCameras(CS_Status* status) {
|
||||
if (target) {
|
||||
std::string fname = fs::path{target}.filename();
|
||||
std::optional<unsigned int> dev;
|
||||
if (wpi::starts_with(fname, "video") &&
|
||||
(dev = wpi::parse_integer<unsigned int>(wpi::substr(fname, 5),
|
||||
if (wpi::util::starts_with(fname, "video") &&
|
||||
(dev = wpi::util::parse_integer<unsigned int>(wpi::util::substr(fname, 5),
|
||||
10)) &&
|
||||
dev.value() < retval.size()) {
|
||||
retval[dev.value()].otherPaths.emplace_back(path.str());
|
||||
@@ -1782,4 +1782,4 @@ std::vector<UsbCameraInfo> EnumerateUsbCameras(CS_Status* status) {
|
||||
return retval;
|
||||
}
|
||||
|
||||
} // namespace cs
|
||||
} // namespace wpi::cs
|
||||
|
||||
@@ -24,14 +24,14 @@
|
||||
#include "wpi/util/raw_istream.hpp"
|
||||
#include "wpi/util/raw_ostream.hpp"
|
||||
|
||||
namespace cs {
|
||||
namespace wpi::cs {
|
||||
|
||||
class Notifier;
|
||||
class Telemetry;
|
||||
|
||||
class UsbCameraImpl : public SourceImpl {
|
||||
public:
|
||||
UsbCameraImpl(std::string_view name, wpi::Logger& logger, Notifier& notifier,
|
||||
UsbCameraImpl(std::string_view name, wpi::util::Logger& logger, Notifier& notifier,
|
||||
Telemetry& telemetry, std::string_view path);
|
||||
~UsbCameraImpl() override;
|
||||
|
||||
@@ -123,13 +123,13 @@ class UsbCameraImpl : public SourceImpl {
|
||||
void DeviceCacheVideoModes();
|
||||
|
||||
// Command helper functions
|
||||
CS_StatusValue DeviceProcessCommand(std::unique_lock<wpi::mutex>& lock,
|
||||
CS_StatusValue DeviceProcessCommand(std::unique_lock<wpi::util::mutex>& lock,
|
||||
const Message& msg);
|
||||
CS_StatusValue DeviceCmdSetMode(std::unique_lock<wpi::mutex>& lock,
|
||||
CS_StatusValue DeviceCmdSetMode(std::unique_lock<wpi::util::mutex>& lock,
|
||||
const Message& msg);
|
||||
CS_StatusValue DeviceCmdSetProperty(std::unique_lock<wpi::mutex>& lock,
|
||||
CS_StatusValue DeviceCmdSetProperty(std::unique_lock<wpi::util::mutex>& lock,
|
||||
const Message& msg);
|
||||
CS_StatusValue DeviceCmdSetPath(std::unique_lock<wpi::mutex>& lock,
|
||||
CS_StatusValue DeviceCmdSetPath(std::unique_lock<wpi::util::mutex>& lock,
|
||||
const Message& msg);
|
||||
|
||||
// Property helper functions
|
||||
@@ -170,12 +170,12 @@ class UsbCameraImpl : public SourceImpl {
|
||||
// Message queues
|
||||
mutable std::vector<Message> m_commands;
|
||||
mutable std::vector<std::pair<std::thread::id, CS_StatusValue>> m_responses;
|
||||
mutable wpi::condition_variable m_responseCv;
|
||||
mutable wpi::util::condition_variable m_responseCv;
|
||||
|
||||
// Path
|
||||
std::string m_path;
|
||||
};
|
||||
|
||||
} // namespace cs
|
||||
} // namespace wpi::cs
|
||||
|
||||
#endif // CSCORE_USBCAMERAIMPL_HPP_
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
#include "Notifier.hpp"
|
||||
#include "wpi/util/StringExtras.hpp"
|
||||
|
||||
using namespace cs;
|
||||
using namespace wpi::cs;
|
||||
|
||||
class UsbCameraListener::Impl {
|
||||
public:
|
||||
@@ -21,28 +21,28 @@ class UsbCameraListener::Impl {
|
||||
|
||||
Notifier& m_notifier;
|
||||
|
||||
std::unique_ptr<wpi::EventLoopRunner> m_runner;
|
||||
std::unique_ptr<wpi::net::EventLoopRunner> m_runner;
|
||||
};
|
||||
|
||||
UsbCameraListener::UsbCameraListener(wpi::Logger& logger, Notifier& notifier)
|
||||
UsbCameraListener::UsbCameraListener(wpi::util::Logger& logger, Notifier& notifier)
|
||||
: m_impl(std::make_unique<Impl>(notifier)) {}
|
||||
|
||||
UsbCameraListener::~UsbCameraListener() = default;
|
||||
|
||||
void UsbCameraListener::Start() {
|
||||
if (!m_impl->m_runner) {
|
||||
m_impl->m_runner = std::make_unique<wpi::EventLoopRunner>();
|
||||
m_impl->m_runner->ExecAsync([impl = m_impl.get()](wpi::uv::Loop& loop) {
|
||||
auto refreshTimer = wpi::uv::Timer::Create(loop);
|
||||
m_impl->m_runner = std::make_unique<wpi::net::EventLoopRunner>();
|
||||
m_impl->m_runner->ExecAsync([impl = m_impl.get()](wpi::net::uv::Loop& loop) {
|
||||
auto refreshTimer = wpi::net::uv::Timer::Create(loop);
|
||||
refreshTimer->timeout.connect([notifier = &impl->m_notifier] {
|
||||
notifier->NotifyUsbCamerasChanged();
|
||||
});
|
||||
refreshTimer->Unreference();
|
||||
|
||||
auto devEvents = wpi::uv::FsEvent::Create(loop);
|
||||
auto devEvents = wpi::net::uv::FsEvent::Create(loop);
|
||||
devEvents->fsEvent.connect([refreshTimer](const char* fn, int flags) {
|
||||
if (wpi::starts_with(fn, "video")) {
|
||||
refreshTimer->Start(wpi::uv::Timer::Time(200));
|
||||
if (wpi::util::starts_with(fn, "video")) {
|
||||
refreshTimer->Start(wpi::net::uv::Timer::Time(200));
|
||||
}
|
||||
});
|
||||
devEvents->Start("/dev");
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
#include "wpi/util/SmallString.hpp"
|
||||
#include "wpi/util/StringExtras.hpp"
|
||||
|
||||
using namespace cs;
|
||||
using namespace wpi::cs;
|
||||
|
||||
static int GetIntCtrlIoctl(int fd, unsigned id, int type, int64_t* value) {
|
||||
unsigned ctrl_class = V4L2_CTRL_ID2CLASS(id);
|
||||
@@ -98,7 +98,7 @@ static int GetStringCtrlIoctl(int fd, int id, int maximum, std::string* value) {
|
||||
|
||||
static int SetStringCtrlIoctl(int fd, int id, int maximum,
|
||||
std::string_view value) {
|
||||
wpi::SmallString<64> str{wpi::substr(value, 0, maximum)};
|
||||
wpi::util::SmallString<64> str{wpi::util::substr(value, 0, maximum)};
|
||||
|
||||
struct v4l2_ext_control ctrl;
|
||||
struct v4l2_ext_controls ctrls;
|
||||
@@ -116,7 +116,7 @@ static int SetStringCtrlIoctl(int fd, int id, int maximum,
|
||||
// Removes non-alphanumeric characters and replaces spaces with underscores.
|
||||
// e.g. "Zoom, Absolute" -> "zoom_absolute", "Pan (Absolute)" -> "pan_absolute"
|
||||
static std::string_view NormalizeName(std::string_view name,
|
||||
wpi::SmallVectorImpl<char>& buf) {
|
||||
wpi::util::SmallVectorImpl<char>& buf) {
|
||||
bool newWord = false;
|
||||
for (auto ch : name) {
|
||||
if (std::isalnum(ch)) {
|
||||
@@ -170,7 +170,7 @@ UsbCameraProperty::UsbCameraProperty(const struct v4l2_query_ext_ctrl& ctrl)
|
||||
while (len < sizeof(ctrl.name) && ctrl.name[len] != '\0') {
|
||||
++len;
|
||||
}
|
||||
wpi::SmallString<64> name_buf;
|
||||
wpi::util::SmallString<64> name_buf;
|
||||
name = NormalizeName({ctrl.name, len}, name_buf);
|
||||
}
|
||||
#endif
|
||||
@@ -209,7 +209,7 @@ UsbCameraProperty::UsbCameraProperty(const struct v4l2_queryctrl& ctrl)
|
||||
while (len < sizeof(ctrl.name) && ctrl.name[len] != '\0') {
|
||||
++len;
|
||||
}
|
||||
wpi::SmallString<64> name_buf;
|
||||
wpi::util::SmallString<64> name_buf;
|
||||
name =
|
||||
NormalizeName({reinterpret_cast<const char*>(ctrl.name), len}, name_buf);
|
||||
}
|
||||
@@ -267,7 +267,7 @@ std::unique_ptr<UsbCameraProperty> UsbCameraProperty::DeviceQuery(int fd,
|
||||
return prop;
|
||||
}
|
||||
|
||||
bool UsbCameraProperty::DeviceGet(std::unique_lock<wpi::mutex>& lock, int fd) {
|
||||
bool UsbCameraProperty::DeviceGet(std::unique_lock<wpi::util::mutex>& lock, int fd) {
|
||||
if (fd < 0) {
|
||||
return true;
|
||||
}
|
||||
@@ -306,14 +306,14 @@ bool UsbCameraProperty::DeviceGet(std::unique_lock<wpi::mutex>& lock, int fd) {
|
||||
return rv >= 0;
|
||||
}
|
||||
|
||||
bool UsbCameraProperty::DeviceSet(std::unique_lock<wpi::mutex>& lock,
|
||||
bool UsbCameraProperty::DeviceSet(std::unique_lock<wpi::util::mutex>& lock,
|
||||
int fd) const {
|
||||
// Make a copy of the string as we're about to release the lock
|
||||
wpi::SmallString<128> valueStrCopy{valueStr};
|
||||
wpi::util::SmallString<128> valueStrCopy{valueStr};
|
||||
return DeviceSet(lock, fd, value, valueStrCopy.str());
|
||||
}
|
||||
|
||||
bool UsbCameraProperty::DeviceSet(std::unique_lock<wpi::mutex>& lock, int fd,
|
||||
bool UsbCameraProperty::DeviceSet(std::unique_lock<wpi::util::mutex>& lock, int fd,
|
||||
int newValue,
|
||||
std::string_view newValueStr) const {
|
||||
if (!device || fd < 0) {
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
#include "PropertyImpl.hpp"
|
||||
#include "wpi/util/mutex.hpp"
|
||||
|
||||
namespace cs {
|
||||
namespace wpi::cs {
|
||||
|
||||
// Property data
|
||||
class UsbCameraProperty : public PropertyImpl {
|
||||
@@ -52,9 +52,9 @@ class UsbCameraProperty : public PropertyImpl {
|
||||
|
||||
static std::unique_ptr<UsbCameraProperty> DeviceQuery(int fd, __u32* id);
|
||||
|
||||
bool DeviceGet(std::unique_lock<wpi::mutex>& lock, int fd);
|
||||
bool DeviceSet(std::unique_lock<wpi::mutex>& lock, int fd) const;
|
||||
bool DeviceSet(std::unique_lock<wpi::mutex>& lock, int fd, int newValue,
|
||||
bool DeviceGet(std::unique_lock<wpi::util::mutex>& lock, int fd);
|
||||
bool DeviceSet(std::unique_lock<wpi::util::mutex>& lock, int fd) const;
|
||||
bool DeviceSet(std::unique_lock<wpi::util::mutex>& lock, int fd, int newValue,
|
||||
std::string_view newValueStr) const;
|
||||
|
||||
// If this is a device (rather than software) property
|
||||
@@ -73,6 +73,6 @@ class UsbCameraProperty : public PropertyImpl {
|
||||
bool intMenu{false};
|
||||
};
|
||||
|
||||
} // namespace cs
|
||||
} // namespace wpi::cs
|
||||
|
||||
#endif // CSCORE_USBCAMERAPROPERTY_HPP_
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
#include "wpi/util/raw_istream.hpp"
|
||||
#include "wpi/util/raw_ostream.hpp"
|
||||
|
||||
namespace cs {
|
||||
namespace wpi::cs {
|
||||
|
||||
static std::string GetUsbNameFromFile(int vendor, int product) {
|
||||
int fd = open("/var/lib/usbutils/usb.ids", O_RDONLY);
|
||||
@@ -27,15 +27,15 @@ static std::string GetUsbNameFromFile(int vendor, int product) {
|
||||
return {};
|
||||
}
|
||||
|
||||
wpi::SmallString<128> buf;
|
||||
wpi::raw_fd_istream is{fd, true};
|
||||
wpi::util::SmallString<128> buf;
|
||||
wpi::util::raw_fd_istream is{fd, true};
|
||||
|
||||
// build vendor and product 4-char hex strings
|
||||
auto vendorStr = fmt::format("{:04x}", vendor);
|
||||
auto productStr = fmt::format("{:04x}", product);
|
||||
|
||||
// scan file
|
||||
wpi::SmallString<128> lineBuf;
|
||||
wpi::util::SmallString<128> lineBuf;
|
||||
bool foundVendor = false;
|
||||
for (;;) {
|
||||
auto line = is.getline(lineBuf, 4096);
|
||||
@@ -48,9 +48,9 @@ static std::string GetUsbNameFromFile(int vendor, int product) {
|
||||
}
|
||||
|
||||
// look for vendor at start of line
|
||||
if (wpi::starts_with(line, vendorStr)) {
|
||||
if (wpi::util::starts_with(line, vendorStr)) {
|
||||
foundVendor = true;
|
||||
buf += wpi::trim(wpi::substr(line, 5));
|
||||
buf += wpi::util::trim(wpi::util::substr(line, 5));
|
||||
buf += ' ';
|
||||
continue;
|
||||
}
|
||||
@@ -63,8 +63,8 @@ static std::string GetUsbNameFromFile(int vendor, int product) {
|
||||
}
|
||||
|
||||
// look for product
|
||||
if (wpi::starts_with(wpi::substr(line, 1), productStr)) {
|
||||
buf += wpi::trim(wpi::substr(line, 6));
|
||||
if (wpi::util::starts_with(wpi::util::substr(line, 1), productStr)) {
|
||||
buf += wpi::util::trim(wpi::util::substr(line, 6));
|
||||
return std::string{buf};
|
||||
}
|
||||
}
|
||||
@@ -161,4 +161,4 @@ int CheckedIoctl(int fd, unsigned long req, void* data, // NOLINT(runtime/int)
|
||||
return retval;
|
||||
}
|
||||
|
||||
} // namespace cs
|
||||
} // namespace wpi::cs
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace cs {
|
||||
namespace wpi::cs {
|
||||
|
||||
std::string GetUsbNameFromId(int vendor, int product);
|
||||
|
||||
@@ -19,6 +19,6 @@ int CheckedIoctl(int fd, unsigned long req, void* data, // NOLINT(runtime/int)
|
||||
#define TryIoctl(fd, req, data) \
|
||||
CheckedIoctl(fd, req, data, #req, __FILE__, __LINE__, true)
|
||||
|
||||
} // namespace cs
|
||||
} // namespace wpi::cs
|
||||
|
||||
#endif // CSCORE_USBUTIL_HPP_
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
#include <CoreFoundation/CFRunLoop.h>
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
namespace cs {
|
||||
namespace wpi::cs {
|
||||
|
||||
void RunMainRunLoop() {
|
||||
if (CFRunLoopGetMain() != CFRunLoopGetCurrent()) {
|
||||
|
||||
@@ -7,14 +7,14 @@
|
||||
#import <AVFoundation/AVFoundation.h>
|
||||
#include <memory>
|
||||
|
||||
namespace cs {
|
||||
namespace wpi::cs {
|
||||
class UsbCameraImpl;
|
||||
}
|
||||
|
||||
@interface UsbCameraDelegate
|
||||
: NSObject <AVCaptureVideoDataOutputSampleBufferDelegate>
|
||||
|
||||
@property(nonatomic) std::weak_ptr<cs::UsbCameraImpl> cppImpl;
|
||||
@property(nonatomic) std::weak_ptr<wpi::cs::UsbCameraImpl> cppImpl;
|
||||
|
||||
- (void)captureOutput:(AVCaptureOutput*)captureOutput
|
||||
didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
(void)sampleBuffer;
|
||||
(void)connection;
|
||||
|
||||
auto currentTime = wpi::Now();
|
||||
auto currentTime = wpi::util::Now();
|
||||
|
||||
auto sharedThis = self.cppImpl.lock();
|
||||
if (!sharedThis) {
|
||||
@@ -51,7 +51,7 @@
|
||||
return;
|
||||
}
|
||||
|
||||
std::unique_ptr<cs::Image> image = cs::CreateImageFromBGRA(
|
||||
std::unique_ptr<wpi::cs::Image> image = wpi::cs::CreateImageFromBGRA(
|
||||
sharedThis.get(), width, height, rowBytes, reinterpret_cast<uint8_t*>(baseaddress));
|
||||
|
||||
CVPixelBufferUnlockBaseAddress(imageBuffer, 0);
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
#include "SourceImpl.hpp"
|
||||
|
||||
namespace cs {
|
||||
namespace wpi::cs {
|
||||
struct CameraFPSRange {
|
||||
int min;
|
||||
int max;
|
||||
@@ -32,9 +32,9 @@ struct CameraModeStore {
|
||||
|
||||
class UsbCameraImpl : public SourceImpl {
|
||||
public:
|
||||
UsbCameraImpl(std::string_view name, wpi::Logger& logger, Notifier& notifier,
|
||||
UsbCameraImpl(std::string_view name, wpi::util::Logger& logger, Notifier& notifier,
|
||||
Telemetry& telemetry, std::string_view path);
|
||||
UsbCameraImpl(std::string_view name, wpi::Logger& logger, Notifier& notifier,
|
||||
UsbCameraImpl(std::string_view name, wpi::util::Logger& logger, Notifier& notifier,
|
||||
Telemetry& telemetry, int deviceId);
|
||||
~UsbCameraImpl() override;
|
||||
|
||||
@@ -64,7 +64,7 @@ class UsbCameraImpl : public SourceImpl {
|
||||
void NumSinksChanged() override;
|
||||
void NumSinksEnabledChanged() override;
|
||||
|
||||
cs::Notifier& objcGetNotifier() { return m_notifier; }
|
||||
wpi::cs::Notifier& objcGetNotifier() { return m_notifier; }
|
||||
|
||||
void objcSwapVideoModes(std::vector<VideoMode>& modes) {
|
||||
std::scoped_lock lock(m_mutex);
|
||||
@@ -86,7 +86,7 @@ class UsbCameraImpl : public SourceImpl {
|
||||
return m_platformModes;
|
||||
}
|
||||
|
||||
wpi::Logger& objcGetLogger() { return m_logger; }
|
||||
wpi::util::Logger& objcGetLogger() { return m_logger; }
|
||||
|
||||
UsbCameraImplObjc* cppGetObjc() { return m_objc; }
|
||||
|
||||
@@ -106,18 +106,18 @@ class UsbCameraImpl : public SourceImpl {
|
||||
UpdatePropertyValue(property, setString, value, valueStr);
|
||||
}
|
||||
|
||||
wpi::mutex& GetMutex() { return m_mutex; }
|
||||
wpi::util::mutex& GetMutex() { return m_mutex; }
|
||||
|
||||
// Property cache accessors
|
||||
wpi::StringMap<uint32_t>& GetPropertyCache() { return m_propertyCache; }
|
||||
wpi::StringMap<uint32_t>& GetPropertyAutoCache() { return m_propertyAutoCache; }
|
||||
wpi::util::StringMap<uint32_t>& GetPropertyCache() { return m_propertyCache; }
|
||||
wpi::util::StringMap<uint32_t>& GetPropertyAutoCache() { return m_propertyAutoCache; }
|
||||
|
||||
private:
|
||||
UsbCameraImplObjc* m_objc;
|
||||
std::vector<CameraModeStore> m_platformModes;
|
||||
|
||||
// Property caches
|
||||
wpi::StringMap<uint32_t> m_propertyCache;
|
||||
wpi::StringMap<uint32_t> m_propertyAutoCache;
|
||||
wpi::util::StringMap<uint32_t> m_propertyCache;
|
||||
wpi::util::StringMap<uint32_t> m_propertyAutoCache;
|
||||
};
|
||||
} // namespace cs
|
||||
} // namespace wpi::cs
|
||||
|
||||
@@ -20,9 +20,9 @@
|
||||
#include "wpi/cs/cscore_cpp.hpp"
|
||||
#include "UsbCameraImpl.hpp"
|
||||
|
||||
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} {
|
||||
@@ -32,7 +32,7 @@ UsbCameraImpl::UsbCameraImpl(std::string_view name, wpi::Logger& logger,
|
||||
encoding:NSUTF8StringEncoding];
|
||||
m_objc = objc;
|
||||
}
|
||||
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} {
|
||||
@@ -108,7 +108,7 @@ void UsbCameraImpl::NumSinksEnabledChanged() {
|
||||
|
||||
CS_Source CreateUsbCameraDev(std::string_view name, int dev,
|
||||
CS_Status* status) {
|
||||
std::vector<UsbCameraInfo> devices = cs::EnumerateUsbCameras(status);
|
||||
std::vector<UsbCameraInfo> devices = wpi::cs::EnumerateUsbCameras(status);
|
||||
if (static_cast<int>(devices.size()) > dev) {
|
||||
return CreateUsbCameraPath(name, devices[dev].path, status);
|
||||
}
|
||||
@@ -203,4 +203,4 @@ UsbCameraInfo GetUsbCameraInfo(CS_Source source, CS_Status* status) {
|
||||
return info;
|
||||
}
|
||||
|
||||
} // namespace cs
|
||||
} // namespace wpi::cs
|
||||
|
||||
@@ -38,7 +38,7 @@
|
||||
#define kPropertyAutoWhiteBalance "white_balance_automatic"
|
||||
#define kPropertyAutoFocus "focus_auto"
|
||||
|
||||
namespace cs {
|
||||
namespace wpi::cs {
|
||||
class UsbCameraImpl;
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ class UsbCameraImpl;
|
||||
|
||||
@property(nonatomic) AVCaptureDeviceFormat* currentFormat;
|
||||
@property(nonatomic) int currentFPS;
|
||||
@property(nonatomic) std::weak_ptr<cs::UsbCameraImpl> cppImpl;
|
||||
@property(nonatomic) std::weak_ptr<wpi::cs::UsbCameraImpl> cppImpl;
|
||||
@property(nonatomic) dispatch_queue_t sessionQueue;
|
||||
@property(nonatomic) NSString* path;
|
||||
@property(nonatomic) int deviceId;
|
||||
@@ -82,8 +82,8 @@ class UsbCameraImpl;
|
||||
- (void)setExposureHoldCurrent:(CS_Status*)status;
|
||||
- (void)setExposureManual:(int)value status:(CS_Status*)status;
|
||||
|
||||
- (bool)setVideoMode:(const cs::VideoMode&)mode status:(CS_Status*)status;
|
||||
- (bool)setPixelFormat:(cs::VideoMode::PixelFormat)pixelFormat
|
||||
- (bool)setVideoMode:(const wpi::cs::VideoMode&)mode status:(CS_Status*)status;
|
||||
- (bool)setPixelFormat:(wpi::cs::VideoMode::PixelFormat)pixelFormat
|
||||
status:(CS_Status*)status;
|
||||
- (bool)setResolutionWidth:(int)width
|
||||
withHeight:(int)height
|
||||
|
||||
@@ -20,11 +20,11 @@ inline void NamedLog(UsbCameraImplObjc* objc, unsigned int level,
|
||||
return;
|
||||
}
|
||||
|
||||
wpi::Logger& logger = sharedThis->objcGetLogger();
|
||||
wpi::util::Logger& logger = sharedThis->objcGetLogger();
|
||||
std::string_view name = sharedThis->GetName();
|
||||
|
||||
if (logger.HasLogger() && level >= logger.min_level()) {
|
||||
cs::NamedLogV(logger, level, file, line, name, format,
|
||||
wpi::cs::NamedLogV(logger, level, file, line, name, format,
|
||||
fmt::make_format_args(args...));
|
||||
}
|
||||
}
|
||||
@@ -34,11 +34,11 @@ inline void NamedLog(UsbCameraImplObjc* objc, unsigned int level,
|
||||
format __VA_OPT__(, ) __VA_ARGS__)
|
||||
|
||||
#define OBJCERROR(format, ...) \
|
||||
OBJCLOG(::wpi::WPI_LOG_ERROR, format __VA_OPT__(, ) __VA_ARGS__)
|
||||
OBJCLOG(::wpi::util::WPI_LOG_ERROR, format __VA_OPT__(, ) __VA_ARGS__)
|
||||
#define OBJCWARNING(format, ...) \
|
||||
OBJCLOG(::wpi::WPI_LOG_WARNING, format __VA_OPT__(, ) __VA_ARGS__)
|
||||
OBJCLOG(::wpi::util::WPI_LOG_WARNING, format __VA_OPT__(, ) __VA_ARGS__)
|
||||
#define OBJCINFO(format, ...) \
|
||||
OBJCLOG(::wpi::WPI_LOG_INFO, format __VA_OPT__(, ) __VA_ARGS__)
|
||||
OBJCLOG(::wpi::util::WPI_LOG_INFO, format __VA_OPT__(, ) __VA_ARGS__)
|
||||
|
||||
#ifdef NDEBUG
|
||||
#define OBJCDEBUG(format, ...) \
|
||||
@@ -58,18 +58,18 @@ inline void NamedLog(UsbCameraImplObjc* objc, unsigned int level,
|
||||
} while (0)
|
||||
#else
|
||||
#define OBJCDEBUG(format, ...) \
|
||||
OBJCLOG(::wpi::WPI_LOG_DEBUG, format __VA_OPT__(, ) __VA_ARGS__)
|
||||
OBJCLOG(::wpi::util::WPI_LOG_DEBUG, format __VA_OPT__(, ) __VA_ARGS__)
|
||||
#define OBJCDEBUG1(format, ...) \
|
||||
OBJCLOG(::wpi::WPI_LOG_DEBUG1, format __VA_OPT__(, ) __VA_ARGS__)
|
||||
OBJCLOG(::wpi::util::WPI_LOG_DEBUG1, format __VA_OPT__(, ) __VA_ARGS__)
|
||||
#define OBJCDEBUG2(format, ...) \
|
||||
OBJCLOG(::wpi::WPI_LOG_DEBUG2, format __VA_OPT__(, ) __VA_ARGS__)
|
||||
OBJCLOG(::wpi::util::WPI_LOG_DEBUG2, format __VA_OPT__(, ) __VA_ARGS__)
|
||||
#define OBJCDEBUG3(format, ...) \
|
||||
OBJCLOG(::wpi::WPI_LOG_DEBUG3, format __VA_OPT__(, ) __VA_ARGS__)
|
||||
OBJCLOG(::wpi::util::WPI_LOG_DEBUG3, format __VA_OPT__(, ) __VA_ARGS__)
|
||||
#define OBJCDEBUG4(format, ...) \
|
||||
OBJCLOG(::wpi::WPI_LOG_DEBUG4, format __VA_OPT__(, ) __VA_ARGS__)
|
||||
OBJCLOG(::wpi::util::WPI_LOG_DEBUG4, format __VA_OPT__(, ) __VA_ARGS__)
|
||||
#endif
|
||||
|
||||
using namespace cs;
|
||||
using namespace wpi::cs;
|
||||
|
||||
@implementation UsbCameraImplObjc
|
||||
|
||||
@@ -169,7 +169,7 @@ using namespace cs;
|
||||
}
|
||||
|
||||
// Get the property name from the property index
|
||||
wpi::SmallString<128> nameBuf;
|
||||
wpi::util::SmallString<128> nameBuf;
|
||||
std::string_view propName = sharedThis->GetPropertyName(property, nameBuf, status);
|
||||
if (*status != 0) {
|
||||
OBJCERROR("Failed to get property name for index {}", property);
|
||||
@@ -402,7 +402,7 @@ using namespace cs;
|
||||
sharedThis->SetProperty(prop, value, status);
|
||||
}
|
||||
|
||||
- (bool)setVideoMode:(const cs::VideoMode&)mode status:(CS_Status*)status {
|
||||
- (bool)setVideoMode:(const wpi::cs::VideoMode&)mode status:(CS_Status*)status {
|
||||
dispatch_async_and_wait(self.sessionQueue, ^{
|
||||
auto sharedThis = self.cppImpl.lock();
|
||||
if (!sharedThis) {
|
||||
@@ -414,7 +414,7 @@ using namespace cs;
|
||||
});
|
||||
return true;
|
||||
}
|
||||
- (bool)setPixelFormat:(cs::VideoMode::PixelFormat)pixelFormat
|
||||
- (bool)setPixelFormat:(wpi::cs::VideoMode::PixelFormat)pixelFormat
|
||||
status:(CS_Status*)status {
|
||||
dispatch_async_and_wait(self.sessionQueue, ^{
|
||||
auto sharedThis = self.cppImpl.lock();
|
||||
@@ -449,7 +449,7 @@ using namespace cs;
|
||||
return true;
|
||||
}
|
||||
|
||||
- (void)internalSetMode:(const cs::VideoMode&)newMode
|
||||
- (void)internalSetMode:(const wpi::cs::VideoMode&)newMode
|
||||
status:(CS_Status*)status {
|
||||
auto sharedThis = self.cppImpl.lock();
|
||||
if (!sharedThis) {
|
||||
@@ -693,13 +693,13 @@ using namespace cs;
|
||||
propertyAutoCache[nameStr] = propID;
|
||||
}
|
||||
|
||||
static cs::VideoMode::PixelFormat FourCCToPixelFormat(FourCharCode fourcc) {
|
||||
static wpi::cs::VideoMode::PixelFormat FourCCToPixelFormat(FourCharCode fourcc) {
|
||||
switch (fourcc) {
|
||||
case kCVPixelFormatType_422YpCbCr8_yuvs:
|
||||
case kCVPixelFormatType_422YpCbCr8FullRange:
|
||||
return cs::VideoMode::PixelFormat::kYUYV;
|
||||
return wpi::cs::VideoMode::PixelFormat::kYUYV;
|
||||
default:
|
||||
return cs::VideoMode::PixelFormat::kBGR;
|
||||
return wpi::cs::VideoMode::PixelFormat::kBGR;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -761,7 +761,7 @@ static cs::VideoMode::PixelFormat FourCCToPixelFormat(FourCharCode fourcc) {
|
||||
CS_SOURCE_VIDEOMODES_UPDATED);
|
||||
}
|
||||
|
||||
- (AVCaptureDeviceFormat*)deviceCheckModeValid:(const cs::VideoMode*)toCheck
|
||||
- (AVCaptureDeviceFormat*)deviceCheckModeValid:(const wpi::cs::VideoMode*)toCheck
|
||||
withFps:(int*)fps {
|
||||
auto sharedThis = self.cppImpl.lock();
|
||||
if (!sharedThis) {
|
||||
@@ -995,7 +995,7 @@ static cs::VideoMode::PixelFormat FourCCToPixelFormat(FourCharCode fourcc) {
|
||||
OBJCINFO("Starting for device id {}", self.deviceId);
|
||||
// Enumerate Devices
|
||||
CS_Status status = 0;
|
||||
auto cameras = cs::EnumerateUsbCameras(&status);
|
||||
auto cameras = wpi::cs::EnumerateUsbCameras(&status);
|
||||
if (static_cast<int>(cameras.size()) <= self.deviceId) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
#pragma GCC diagnostic ignored "-Wunused-parameter"
|
||||
#include "Notifier.hpp"
|
||||
|
||||
using namespace cs;
|
||||
using namespace wpi::cs;
|
||||
|
||||
@interface UsbCameraListenerImpl : NSObject
|
||||
@property(nonatomic) Notifier* notifier;
|
||||
@@ -99,7 +99,7 @@ class UsbCameraListener::Impl {
|
||||
}
|
||||
};
|
||||
|
||||
UsbCameraListener::UsbCameraListener(wpi::Logger&, Notifier& notifier)
|
||||
UsbCameraListener::UsbCameraListener(wpi::util::Logger&, Notifier& notifier)
|
||||
: m_impl{std::make_unique<Impl>(notifier)} {}
|
||||
|
||||
UsbCameraListener::~UsbCameraListener() {
|
||||
|
||||
@@ -82,7 +82,7 @@
|
||||
#define CAPPROPID_POWERLINEFREQ 13
|
||||
#define CAPPROPID_LAST 14
|
||||
|
||||
namespace cs {
|
||||
namespace wpi::cs {
|
||||
class UsbCameraImpl;
|
||||
}
|
||||
|
||||
@@ -90,7 +90,7 @@ class UsbCameraImpl;
|
||||
|
||||
@property(nonatomic) IOUSBInterfaceInterface190** controlInterface;
|
||||
@property(nonatomic) uint32_t processingUnitID;
|
||||
@property(nonatomic) std::weak_ptr<cs::UsbCameraImpl> cppImpl;
|
||||
@property(nonatomic) std::weak_ptr<wpi::cs::UsbCameraImpl> cppImpl;
|
||||
|
||||
// Create from AVCaptureDevice
|
||||
+ (instancetype)createFromAVCaptureDevice:(AVCaptureDevice*)device status:(CS_Status*)status;
|
||||
|
||||
@@ -40,11 +40,11 @@ inline void NamedLog(UvcControlImpl* objc, unsigned int level,
|
||||
return;
|
||||
}
|
||||
|
||||
wpi::Logger& logger = sharedThis->objcGetLogger();
|
||||
wpi::util::Logger& logger = sharedThis->objcGetLogger();
|
||||
std::string_view name = sharedThis->GetName();
|
||||
|
||||
if (logger.HasLogger() && level >= logger.min_level()) {
|
||||
cs::NamedLogV(logger, level, file, line, name, format,
|
||||
wpi::cs::NamedLogV(logger, level, file, line, name, format,
|
||||
fmt::make_format_args(args...));
|
||||
}
|
||||
}
|
||||
@@ -54,11 +54,11 @@ inline void NamedLog(UvcControlImpl* objc, unsigned int level,
|
||||
format __VA_OPT__(, ) __VA_ARGS__)
|
||||
|
||||
#define UVCERROR(format, ...) \
|
||||
UVCLOG(::wpi::WPI_LOG_ERROR, format __VA_OPT__(, ) __VA_ARGS__)
|
||||
UVCLOG(::wpi::util::WPI_LOG_ERROR, format __VA_OPT__(, ) __VA_ARGS__)
|
||||
#define UVCWARNING(format, ...) \
|
||||
UVCLOG(::wpi::WPI_LOG_WARNING, format __VA_OPT__(, ) __VA_ARGS__)
|
||||
UVCLOG(::wpi::util::WPI_LOG_WARNING, format __VA_OPT__(, ) __VA_ARGS__)
|
||||
#define UVCINFO(format, ...) \
|
||||
UVCLOG(::wpi::WPI_LOG_INFO, format __VA_OPT__(, ) __VA_ARGS__)
|
||||
UVCLOG(::wpi::util::WPI_LOG_INFO, format __VA_OPT__(, ) __VA_ARGS__)
|
||||
|
||||
#ifdef NDEBUG
|
||||
#define UVCDEBUG(format, ...) \
|
||||
@@ -78,15 +78,15 @@ inline void NamedLog(UvcControlImpl* objc, unsigned int level,
|
||||
} while (0)
|
||||
#else
|
||||
#define UVCDEBUG(format, ...) \
|
||||
UVCLOG(::wpi::WPI_LOG_DEBUG, format __VA_OPT__(, ) __VA_ARGS__)
|
||||
UVCLOG(::wpi::util::WPI_LOG_DEBUG, format __VA_OPT__(, ) __VA_ARGS__)
|
||||
#define UVCDEBUG1(format, ...) \
|
||||
UVCLOG(::wpi::WPI_LOG_DEBUG1, format __VA_OPT__(, ) __VA_ARGS__)
|
||||
UVCLOG(::wpi::util::WPI_LOG_DEBUG1, format __VA_OPT__(, ) __VA_ARGS__)
|
||||
#define UVCDEBUG2(format, ...) \
|
||||
UVCLOG(::wpi::WPI_LOG_DEBUG2, format __VA_OPT__(, ) __VA_ARGS__)
|
||||
UVCLOG(::wpi::util::WPI_LOG_DEBUG2, format __VA_OPT__(, ) __VA_ARGS__)
|
||||
#define UVCDEBUG3(format, ...) \
|
||||
UVCLOG(::wpi::WPI_LOG_DEBUG3, format __VA_OPT__(, ) __VA_ARGS__)
|
||||
UVCLOG(::wpi::util::WPI_LOG_DEBUG3, format __VA_OPT__(, ) __VA_ARGS__)
|
||||
#define UVCDEBUG4(format, ...) \
|
||||
UVCLOG(::wpi::WPI_LOG_DEBUG4, format __VA_OPT__(, ) __VA_ARGS__)
|
||||
UVCLOG(::wpi::util::WPI_LOG_DEBUG4, format __VA_OPT__(, ) __VA_ARGS__)
|
||||
#endif
|
||||
|
||||
// USB descriptor for UVC processing unit
|
||||
|
||||
@@ -4,11 +4,11 @@
|
||||
|
||||
#include "NetworkListener.hpp"
|
||||
|
||||
using namespace cs;
|
||||
using namespace wpi::cs;
|
||||
|
||||
class NetworkListener::Impl {};
|
||||
|
||||
NetworkListener::NetworkListener(wpi::Logger& logger, Notifier& notifier) {}
|
||||
NetworkListener::NetworkListener(wpi::util::Logger& logger, Notifier& notifier) {}
|
||||
|
||||
NetworkListener::~NetworkListener() = default;
|
||||
|
||||
|
||||
@@ -7,10 +7,10 @@
|
||||
|
||||
#include "wpi/cs/cscore_cpp.hpp"
|
||||
|
||||
namespace cs {
|
||||
namespace wpi::cs {
|
||||
|
||||
std::vector<std::string> GetNetworkInterfaces() {
|
||||
return std::vector<std::string>{}; // TODO
|
||||
}
|
||||
|
||||
} // namespace cs
|
||||
} // namespace wpi::cs
|
||||
|
||||
@@ -31,10 +31,10 @@
|
||||
#pragma comment(lib, "Mfreadwrite.lib")
|
||||
#pragma comment(lib, "Shlwapi.lib")
|
||||
|
||||
namespace cs {
|
||||
namespace wpi::cs {
|
||||
|
||||
SourceReaderCB::SourceReaderCB(std::weak_ptr<cs::UsbCameraImpl> source,
|
||||
const cs::VideoMode& mode)
|
||||
SourceReaderCB::SourceReaderCB(std::weak_ptr<wpi::cs::UsbCameraImpl> source,
|
||||
const wpi::cs::VideoMode& mode)
|
||||
: m_nRefCount(1), m_source(source), m_mode{mode} {}
|
||||
|
||||
// IUnknown methods
|
||||
@@ -94,7 +94,7 @@ STDMETHODIMP SourceReaderCB::OnReadSample(HRESULT hrStatus, DWORD dwStreamIndex,
|
||||
|
||||
// Create a Source Reader COM Smart Object
|
||||
ComPtr<SourceReaderCB> CreateSourceReaderCB(
|
||||
std::weak_ptr<cs::UsbCameraImpl> source, const cs::VideoMode& mode) {
|
||||
std::weak_ptr<wpi::cs::UsbCameraImpl> source, const wpi::cs::VideoMode& mode) {
|
||||
SourceReaderCB* ptr = new SourceReaderCB(source, mode);
|
||||
ComPtr<SourceReaderCB> sourceReaderCB;
|
||||
sourceReaderCB.Attach(ptr);
|
||||
@@ -157,4 +157,4 @@ ComPtr<IMFSourceReader> CreateSourceReader(IMFMediaSource* mediaSource,
|
||||
return sourceReader;
|
||||
}
|
||||
|
||||
} // namespace cs
|
||||
} // namespace wpi::cs
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
#include "ComPtr.hpp"
|
||||
#include "wpi/cs/cscore_cpp.hpp"
|
||||
|
||||
namespace cs {
|
||||
namespace wpi::cs {
|
||||
|
||||
class UsbCameraImpl;
|
||||
|
||||
@@ -20,8 +20,8 @@ class UsbCameraImpl;
|
||||
// COM object, so it needs a to ref count itself.
|
||||
class SourceReaderCB : public IMFSourceReaderCallback {
|
||||
public:
|
||||
explicit SourceReaderCB(std::weak_ptr<cs::UsbCameraImpl> source,
|
||||
const cs::VideoMode& mode);
|
||||
explicit SourceReaderCB(std::weak_ptr<wpi::cs::UsbCameraImpl> source,
|
||||
const wpi::cs::VideoMode& mode);
|
||||
void SetVideoMode(const VideoMode& mode) { m_mode = mode; }
|
||||
|
||||
STDMETHODIMP QueryInterface(REFIID iid, void** ppv);
|
||||
@@ -35,7 +35,7 @@ class SourceReaderCB : public IMFSourceReaderCallback {
|
||||
IMFSample* pSample // Can be NULL
|
||||
);
|
||||
|
||||
void InvalidateCapture() { m_source = std::weak_ptr<cs::UsbCameraImpl>(); }
|
||||
void InvalidateCapture() { m_source = std::weak_ptr<wpi::cs::UsbCameraImpl>(); }
|
||||
|
||||
private:
|
||||
// Destructor is private. Caller should call Release.
|
||||
@@ -43,13 +43,13 @@ class SourceReaderCB : public IMFSourceReaderCallback {
|
||||
void NotifyError(HRESULT hr);
|
||||
|
||||
ULONG m_nRefCount;
|
||||
std::weak_ptr<cs::UsbCameraImpl> m_source;
|
||||
cs::VideoMode m_mode;
|
||||
std::weak_ptr<wpi::cs::UsbCameraImpl> m_source;
|
||||
wpi::cs::VideoMode m_mode;
|
||||
};
|
||||
|
||||
ComPtr<SourceReaderCB> CreateSourceReaderCB(
|
||||
std::weak_ptr<cs::UsbCameraImpl> source, const cs::VideoMode& mode);
|
||||
std::weak_ptr<wpi::cs::UsbCameraImpl> source, const wpi::cs::VideoMode& mode);
|
||||
ComPtr<IMFSourceReader> CreateSourceReader(IMFMediaSource* mediaSource,
|
||||
IMFSourceReaderCallback* callback);
|
||||
ComPtr<IMFMediaSource> CreateVideoCaptureDevice(LPCWSTR pszSymbolicLink);
|
||||
} // namespace cs
|
||||
} // namespace wpi::cs
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
|
||||
#include <cassert>
|
||||
|
||||
namespace cs {
|
||||
namespace wpi::cs {
|
||||
|
||||
template <typename Interface>
|
||||
class RemoveAddRefRelease : public Interface {
|
||||
@@ -146,4 +146,4 @@ void swap(
|
||||
left.Swap(right);
|
||||
}
|
||||
|
||||
} // namespace cs
|
||||
} // namespace wpi::cs
|
||||
|
||||
@@ -22,13 +22,13 @@
|
||||
|
||||
#pragma comment(lib, "Iphlpapi.lib")
|
||||
|
||||
using namespace cs;
|
||||
using namespace wpi::cs;
|
||||
|
||||
class NetworkListener::Impl {
|
||||
public:
|
||||
Impl(wpi::Logger& logger, Notifier& notifier)
|
||||
Impl(wpi::util::Logger& logger, Notifier& notifier)
|
||||
: m_logger(logger), m_notifier(notifier) {}
|
||||
wpi::Logger& m_logger;
|
||||
wpi::util::Logger& m_logger;
|
||||
Notifier& m_notifier;
|
||||
HANDLE eventHandle = 0;
|
||||
};
|
||||
@@ -41,7 +41,7 @@ static void WINAPI OnInterfaceChange(PVOID callerContext,
|
||||
notifier->NotifyNetworkInterfacesChanged();
|
||||
}
|
||||
|
||||
NetworkListener::NetworkListener(wpi::Logger& logger, Notifier& notifier)
|
||||
NetworkListener::NetworkListener(wpi::util::Logger& logger, Notifier& notifier)
|
||||
: m_impl(std::make_unique<Impl>(logger, notifier)) {}
|
||||
|
||||
NetworkListener::~NetworkListener() {
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
|
||||
#pragma comment(lib, "Ws2_32.lib")
|
||||
|
||||
namespace cs {
|
||||
namespace wpi::cs {
|
||||
|
||||
std::vector<std::string> GetNetworkInterfaces() {
|
||||
uv_interface_address_t* adrs;
|
||||
@@ -42,4 +42,4 @@ std::vector<std::string> GetNetworkInterfaces() {
|
||||
return addresses;
|
||||
}
|
||||
|
||||
} // namespace cs
|
||||
} // namespace wpi::cs
|
||||
|
||||
@@ -5,22 +5,22 @@
|
||||
#include "wpi/cs/cscore_runloop.hpp"
|
||||
#include "wpi/util/Synchronization.h"
|
||||
|
||||
static wpi::Event& GetInstance() {
|
||||
static wpi::Event event;
|
||||
static wpi::util::Event& GetInstance() {
|
||||
static wpi::util::Event event;
|
||||
return event;
|
||||
}
|
||||
|
||||
namespace cs {
|
||||
namespace wpi::cs {
|
||||
|
||||
void RunMainRunLoop() {
|
||||
wpi::Event& event = GetInstance();
|
||||
wpi::WaitForObject(event.GetHandle());
|
||||
wpi::util::Event& event = GetInstance();
|
||||
wpi::util::WaitForObject(event.GetHandle());
|
||||
}
|
||||
|
||||
int RunMainRunLoopTimeout(double timeout) {
|
||||
wpi::Event& event = GetInstance();
|
||||
wpi::util::Event& event = GetInstance();
|
||||
bool timedOut = false;
|
||||
bool signaled = wpi::WaitForObject(event.GetHandle(), timeout, &timedOut);
|
||||
bool signaled = wpi::util::WaitForObject(event.GetHandle(), timeout, &timedOut);
|
||||
if (timedOut) {
|
||||
return 3;
|
||||
}
|
||||
@@ -31,8 +31,8 @@ int RunMainRunLoopTimeout(double timeout) {
|
||||
}
|
||||
|
||||
void StopMainRunLoop() {
|
||||
wpi::Event& event = GetInstance();
|
||||
wpi::util::Event& event = GetInstance();
|
||||
event.Set();
|
||||
}
|
||||
|
||||
} // namespace cs
|
||||
} // namespace wpi::cs
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -34,14 +34,14 @@
|
||||
#include "wpi/util/raw_istream.hpp"
|
||||
#include "wpi/util/raw_ostream.hpp"
|
||||
|
||||
namespace cs {
|
||||
namespace wpi::cs {
|
||||
|
||||
class UsbCameraImpl : public SourceImpl,
|
||||
public std::enable_shared_from_this<UsbCameraImpl> {
|
||||
public:
|
||||
UsbCameraImpl(std::string_view name, wpi::Logger& logger, Notifier& notifier,
|
||||
UsbCameraImpl(std::string_view name, wpi::util::Logger& logger, Notifier& notifier,
|
||||
Telemetry& telemetry, std::string_view path);
|
||||
UsbCameraImpl(std::string_view name, wpi::Logger& logger, Notifier& notifier,
|
||||
UsbCameraImpl(std::string_view name, wpi::util::Logger& logger, Notifier& notifier,
|
||||
Telemetry& telemetry, int deviceId);
|
||||
~UsbCameraImpl() override;
|
||||
|
||||
@@ -137,12 +137,12 @@ class UsbCameraImpl : public SourceImpl,
|
||||
ComPtr<IMFMediaType> DeviceCheckModeValid(const VideoMode& toCheck);
|
||||
|
||||
// Command helper functions
|
||||
CS_StatusValue DeviceProcessCommand(std::unique_lock<wpi::mutex>& lock,
|
||||
CS_StatusValue DeviceProcessCommand(std::unique_lock<wpi::util::mutex>& lock,
|
||||
Message::Kind msgKind,
|
||||
const Message* msg);
|
||||
CS_StatusValue DeviceCmdSetMode(std::unique_lock<wpi::mutex>& lock,
|
||||
CS_StatusValue DeviceCmdSetMode(std::unique_lock<wpi::util::mutex>& lock,
|
||||
const Message& msg);
|
||||
CS_StatusValue DeviceCmdSetProperty(std::unique_lock<wpi::mutex>& lock,
|
||||
CS_StatusValue DeviceCmdSetProperty(std::unique_lock<wpi::util::mutex>& lock,
|
||||
const Message& msg);
|
||||
|
||||
// Property helper functions
|
||||
@@ -163,7 +163,7 @@ class UsbCameraImpl : public SourceImpl,
|
||||
ComPtr<IMFMediaSource> m_mediaSource;
|
||||
ComPtr<IMFSourceReader> m_sourceReader;
|
||||
ComPtr<SourceReaderCB> m_imageCallback;
|
||||
std::unique_ptr<cs::WindowsMessagePump> m_messagePump;
|
||||
std::unique_ptr<wpi::cs::WindowsMessagePump> m_messagePump;
|
||||
ComPtr<IMFMediaType> m_currentMode;
|
||||
|
||||
std::string m_path;
|
||||
@@ -174,6 +174,6 @@ class UsbCameraImpl : public SourceImpl,
|
||||
std::vector<std::pair<VideoMode, ComPtr<IMFMediaType>>> m_windowsVideoModes;
|
||||
};
|
||||
|
||||
} // namespace cs
|
||||
} // namespace wpi::cs
|
||||
|
||||
#endif // CSCORE_USBCAMERAIMPL_HPP_
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
|
||||
#define IDT_TIMER1 1001
|
||||
|
||||
using namespace cs;
|
||||
using namespace wpi::cs;
|
||||
|
||||
class UsbCameraListener::Impl {
|
||||
public:
|
||||
@@ -55,10 +55,10 @@ class UsbCameraListener::Impl {
|
||||
}
|
||||
|
||||
Notifier& m_notifier;
|
||||
std::unique_ptr<cs::WindowsMessagePump> m_messagePump;
|
||||
std::unique_ptr<wpi::cs::WindowsMessagePump> m_messagePump;
|
||||
};
|
||||
|
||||
UsbCameraListener::UsbCameraListener(wpi::Logger& logger, Notifier& notifier)
|
||||
UsbCameraListener::UsbCameraListener(wpi::util::Logger& logger, Notifier& notifier)
|
||||
: m_impl{std::make_unique<Impl>(notifier)} {}
|
||||
|
||||
UsbCameraListener::~UsbCameraListener() {
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
#include "ComPtr.hpp"
|
||||
|
||||
using namespace cs;
|
||||
using namespace wpi::cs;
|
||||
|
||||
UsbCameraProperty::UsbCameraProperty(std::string_view name_,
|
||||
tagVideoProcAmpProperty tag, bool autoProp,
|
||||
@@ -38,7 +38,7 @@ UsbCameraProperty::UsbCameraProperty(std::string_view name_,
|
||||
}
|
||||
}
|
||||
|
||||
bool UsbCameraProperty::DeviceGet(std::unique_lock<wpi::mutex>& lock,
|
||||
bool UsbCameraProperty::DeviceGet(std::unique_lock<wpi::util::mutex>& lock,
|
||||
IAMVideoProcAmp* pProcAmp) {
|
||||
if (!pProcAmp) {
|
||||
return true;
|
||||
@@ -54,11 +54,11 @@ bool UsbCameraProperty::DeviceGet(std::unique_lock<wpi::mutex>& lock,
|
||||
|
||||
return false;
|
||||
}
|
||||
bool UsbCameraProperty::DeviceSet(std::unique_lock<wpi::mutex>& lock,
|
||||
bool UsbCameraProperty::DeviceSet(std::unique_lock<wpi::util::mutex>& lock,
|
||||
IAMVideoProcAmp* pProcAmp) const {
|
||||
return DeviceSet(lock, pProcAmp, value);
|
||||
}
|
||||
bool UsbCameraProperty::DeviceSet(std::unique_lock<wpi::mutex>& lock,
|
||||
bool UsbCameraProperty::DeviceSet(std::unique_lock<wpi::util::mutex>& lock,
|
||||
IAMVideoProcAmp* pProcAmp,
|
||||
int newValue) const {
|
||||
if (!pProcAmp) {
|
||||
@@ -104,7 +104,7 @@ UsbCameraProperty::UsbCameraProperty(std::string_view name_,
|
||||
}
|
||||
}
|
||||
|
||||
bool UsbCameraProperty::DeviceGet(std::unique_lock<wpi::mutex>& lock,
|
||||
bool UsbCameraProperty::DeviceGet(std::unique_lock<wpi::util::mutex>& lock,
|
||||
IAMCameraControl* pProcAmp) {
|
||||
if (!pProcAmp) {
|
||||
return true;
|
||||
@@ -120,11 +120,11 @@ bool UsbCameraProperty::DeviceGet(std::unique_lock<wpi::mutex>& lock,
|
||||
|
||||
return false;
|
||||
}
|
||||
bool UsbCameraProperty::DeviceSet(std::unique_lock<wpi::mutex>& lock,
|
||||
bool UsbCameraProperty::DeviceSet(std::unique_lock<wpi::util::mutex>& lock,
|
||||
IAMCameraControl* pProcAmp) const {
|
||||
return DeviceSet(lock, pProcAmp, value);
|
||||
}
|
||||
bool UsbCameraProperty::DeviceSet(std::unique_lock<wpi::mutex>& lock,
|
||||
bool UsbCameraProperty::DeviceSet(std::unique_lock<wpi::util::mutex>& lock,
|
||||
IAMCameraControl* pProcAmp,
|
||||
int newValue) const {
|
||||
if (!pProcAmp) {
|
||||
@@ -141,7 +141,7 @@ bool UsbCameraProperty::DeviceSet(std::unique_lock<wpi::mutex>& lock,
|
||||
return false;
|
||||
}
|
||||
|
||||
bool UsbCameraProperty::DeviceGet(std::unique_lock<wpi::mutex>& lock,
|
||||
bool UsbCameraProperty::DeviceGet(std::unique_lock<wpi::util::mutex>& lock,
|
||||
IMFSourceReader* sourceReader) {
|
||||
if (!sourceReader) {
|
||||
return true;
|
||||
@@ -167,11 +167,11 @@ bool UsbCameraProperty::DeviceGet(std::unique_lock<wpi::mutex>& lock,
|
||||
}
|
||||
}
|
||||
}
|
||||
bool UsbCameraProperty::DeviceSet(std::unique_lock<wpi::mutex>& lock,
|
||||
bool UsbCameraProperty::DeviceSet(std::unique_lock<wpi::util::mutex>& lock,
|
||||
IMFSourceReader* sourceReader) const {
|
||||
return DeviceSet(lock, sourceReader, value);
|
||||
}
|
||||
bool UsbCameraProperty::DeviceSet(std::unique_lock<wpi::mutex>& lock,
|
||||
bool UsbCameraProperty::DeviceSet(std::unique_lock<wpi::util::mutex>& lock,
|
||||
IMFSourceReader* sourceReader,
|
||||
int newValue) const {
|
||||
if (!sourceReader) {
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
#include "PropertyImpl.hpp"
|
||||
#include "wpi/util/mutex.hpp"
|
||||
|
||||
namespace cs {
|
||||
namespace wpi::cs {
|
||||
|
||||
// Property data
|
||||
class UsbCameraProperty : public PropertyImpl {
|
||||
@@ -54,11 +54,11 @@ class UsbCameraProperty : public PropertyImpl {
|
||||
UsbCameraProperty(std::string_view name_, tagCameraControlProperty tag,
|
||||
bool autoProp, IAMCameraControl* pProcAmp, bool* isValid);
|
||||
|
||||
bool DeviceGet(std::unique_lock<wpi::mutex>& lock,
|
||||
bool DeviceGet(std::unique_lock<wpi::util::mutex>& lock,
|
||||
IMFSourceReader* sourceReader);
|
||||
bool DeviceSet(std::unique_lock<wpi::mutex>& lock,
|
||||
bool DeviceSet(std::unique_lock<wpi::util::mutex>& lock,
|
||||
IMFSourceReader* sourceReader) const;
|
||||
bool DeviceSet(std::unique_lock<wpi::mutex>& lock,
|
||||
bool DeviceSet(std::unique_lock<wpi::util::mutex>& lock,
|
||||
IMFSourceReader* sourceReader, int newValue) const;
|
||||
|
||||
// If this is a device (rather than software) property
|
||||
@@ -81,17 +81,17 @@ class UsbCameraProperty : public PropertyImpl {
|
||||
int type{0}; // implementation type, not CS_PropertyKind!
|
||||
|
||||
private:
|
||||
bool DeviceGet(std::unique_lock<wpi::mutex>& lock,
|
||||
bool DeviceGet(std::unique_lock<wpi::util::mutex>& lock,
|
||||
IAMCameraControl* pProcAmp);
|
||||
bool DeviceSet(std::unique_lock<wpi::mutex>& lock,
|
||||
bool DeviceSet(std::unique_lock<wpi::util::mutex>& lock,
|
||||
IAMCameraControl* pProcAmp) const;
|
||||
bool DeviceSet(std::unique_lock<wpi::mutex>& lock, IAMCameraControl* pProcAmp,
|
||||
bool DeviceSet(std::unique_lock<wpi::util::mutex>& lock, IAMCameraControl* pProcAmp,
|
||||
int newValue) const;
|
||||
|
||||
bool DeviceGet(std::unique_lock<wpi::mutex>& lock, IAMVideoProcAmp* pProcAmp);
|
||||
bool DeviceSet(std::unique_lock<wpi::mutex>& lock,
|
||||
bool DeviceGet(std::unique_lock<wpi::util::mutex>& lock, IAMVideoProcAmp* pProcAmp);
|
||||
bool DeviceSet(std::unique_lock<wpi::util::mutex>& lock,
|
||||
IAMVideoProcAmp* pProcAmp) const;
|
||||
bool DeviceSet(std::unique_lock<wpi::mutex>& lock, IAMVideoProcAmp* pProcAmp,
|
||||
bool DeviceSet(std::unique_lock<wpi::util::mutex>& lock, IAMVideoProcAmp* pProcAmp,
|
||||
int newValue) const;
|
||||
};
|
||||
} // namespace cs
|
||||
} // namespace wpi::cs
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
#pragma comment(lib, "Ole32.lib")
|
||||
#pragma comment(lib, "User32.lib")
|
||||
|
||||
namespace cs {
|
||||
namespace wpi::cs {
|
||||
|
||||
static LRESULT CALLBACK pWndProc(HWND hwnd, UINT uiMsg, WPARAM wParam,
|
||||
LPARAM lParam) {
|
||||
@@ -148,4 +148,4 @@ void WindowsMessagePump::ThreadMain(HANDLE eventHandle) {
|
||||
CoUninitialize();
|
||||
}
|
||||
|
||||
} // namespace cs
|
||||
} // namespace wpi::cs
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#include <functional>
|
||||
#include <thread>
|
||||
|
||||
namespace cs {
|
||||
namespace wpi::cs {
|
||||
class WindowsMessagePump {
|
||||
public:
|
||||
explicit WindowsMessagePump(
|
||||
@@ -60,4 +60,4 @@ class WindowsMessagePump {
|
||||
|
||||
std::thread m_mainThread;
|
||||
};
|
||||
} // namespace cs
|
||||
} // namespace wpi::cs
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
#include "wpi/cs/cscore.h"
|
||||
|
||||
namespace cs {
|
||||
namespace wpi::cs {
|
||||
|
||||
class CameraSourceTest : public ::testing::Test {
|
||||
protected:
|
||||
@@ -15,7 +15,7 @@ class CameraSourceTest : public ::testing::Test {
|
||||
|
||||
TEST_F(CameraSourceTest, HTTPCamera) {
|
||||
auto source = HttpCamera("axis", "http://localhost:8000");
|
||||
cs::Shutdown();
|
||||
wpi::cs::Shutdown();
|
||||
}
|
||||
|
||||
} // namespace cs
|
||||
} // namespace wpi::cs
|
||||
|
||||
Reference in New Issue
Block a user