mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-21 01:01:43 +00:00
SCRIPT namespace replacements
This commit is contained in:
committed by
Peter Johnson
parent
ae6c043632
commit
9aca8e0fd6
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user