mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-20 00:51:42 +00:00
Move entirety of llvm namespace to wpi namespace.
During shared library loading, a different libLLVM can be pulled in, causing llvm symbols from dependent libraries to resolve to that library instead of this one. This has been seen in the wild with the Mesa OpenGL implementation in JavaFX applications (see wpilibsuite/shuffleboard#361). This is clearly a very breaking change. For some level of backwards compatibility, a namespace alias from llvm to wpi is performed in the "llvm" headers. Unfortunately, forward declarations of llvm classes will still break, but compilers seem to generate clear error messages in those cases ("namespace alias 'llvm' not allowed here, assuming 'wpi'"). This change also moves all the wpiutil headers to a single "wpi" subdirectory from the previously split "llvm", "support", "tcpsockets", and "udpsockets". Shim headers will be added for backwards compatibility in a later commit.
This commit is contained in:
@@ -7,10 +7,10 @@
|
||||
|
||||
#include "CvSinkImpl.h"
|
||||
|
||||
#include <llvm/SmallString.h>
|
||||
#include <opencv2/core/core.hpp>
|
||||
#include <opencv2/highgui/highgui.hpp>
|
||||
#include <opencv2/imgproc/imgproc.hpp>
|
||||
#include <wpi/SmallString.h>
|
||||
|
||||
#include "Handle.h"
|
||||
#include "Log.h"
|
||||
@@ -20,12 +20,12 @@
|
||||
|
||||
using namespace cs;
|
||||
|
||||
CvSinkImpl::CvSinkImpl(llvm::StringRef name) : SinkImpl{name} {
|
||||
CvSinkImpl::CvSinkImpl(wpi::StringRef name) : SinkImpl{name} {
|
||||
m_active = true;
|
||||
// m_thread = std::thread(&CvSinkImpl::ThreadMain, this);
|
||||
}
|
||||
|
||||
CvSinkImpl::CvSinkImpl(llvm::StringRef name,
|
||||
CvSinkImpl::CvSinkImpl(wpi::StringRef name,
|
||||
std::function<void(uint64_t time)> processFrame)
|
||||
: SinkImpl{name} {}
|
||||
|
||||
@@ -118,14 +118,14 @@ void CvSinkImpl::ThreadMain() {
|
||||
|
||||
namespace cs {
|
||||
|
||||
CS_Sink CreateCvSink(llvm::StringRef name, CS_Status* status) {
|
||||
CS_Sink CreateCvSink(wpi::StringRef name, CS_Status* status) {
|
||||
auto sink = std::make_shared<CvSinkImpl>(name);
|
||||
auto handle = Sinks::GetInstance().Allocate(CS_SINK_CV, sink);
|
||||
Notifier::GetInstance().NotifySink(name, handle, CS_SINK_CREATED);
|
||||
return handle;
|
||||
}
|
||||
|
||||
CS_Sink CreateCvSinkCallback(llvm::StringRef name,
|
||||
CS_Sink CreateCvSinkCallback(wpi::StringRef name,
|
||||
std::function<void(uint64_t time)> processFrame,
|
||||
CS_Status* status) {
|
||||
auto sink = std::make_shared<CvSinkImpl>(name, processFrame);
|
||||
@@ -134,7 +134,7 @@ CS_Sink CreateCvSinkCallback(llvm::StringRef name,
|
||||
return handle;
|
||||
}
|
||||
|
||||
void SetSinkDescription(CS_Sink sink, llvm::StringRef description,
|
||||
void SetSinkDescription(CS_Sink sink, wpi::StringRef description,
|
||||
CS_Status* status) {
|
||||
auto data = Sinks::GetInstance().Get(sink);
|
||||
if (!data || data->kind != CS_SINK_CV) {
|
||||
@@ -172,12 +172,12 @@ std::string GetSinkError(CS_Sink sink, CS_Status* status) {
|
||||
return static_cast<CvSinkImpl&>(*data->sink).GetError();
|
||||
}
|
||||
|
||||
llvm::StringRef GetSinkError(CS_Sink sink, llvm::SmallVectorImpl<char>& buf,
|
||||
wpi::StringRef GetSinkError(CS_Sink sink, wpi::SmallVectorImpl<char>& buf,
|
||||
CS_Status* status) {
|
||||
auto data = Sinks::GetInstance().Get(sink);
|
||||
if (!data || data->kind != CS_SINK_CV) {
|
||||
*status = CS_INVALID_HANDLE;
|
||||
return llvm::StringRef{};
|
||||
return wpi::StringRef{};
|
||||
}
|
||||
return static_cast<CvSinkImpl&>(*data->sink).GetError(buf);
|
||||
}
|
||||
@@ -233,7 +233,7 @@ uint64_t CS_GrabSinkFrameTimeoutCpp(CS_Sink sink, cv::Mat* image,
|
||||
}
|
||||
|
||||
char* CS_GetSinkError(CS_Sink sink, CS_Status* status) {
|
||||
llvm::SmallString<128> buf;
|
||||
wpi::SmallString<128> buf;
|
||||
auto str = cs::GetSinkError(sink, buf, status);
|
||||
if (*status != 0) return nullptr;
|
||||
return cs::ConvertToC(str);
|
||||
|
||||
@@ -13,13 +13,13 @@
|
||||
#include <thread>
|
||||
#include <vector>
|
||||
|
||||
#include <llvm/SmallVector.h>
|
||||
#include <llvm/StringRef.h>
|
||||
#include <llvm/raw_ostream.h>
|
||||
#include <support/raw_istream.h>
|
||||
#include <support/raw_socket_ostream.h>
|
||||
#include <tcpsockets/NetworkAcceptor.h>
|
||||
#include <tcpsockets/NetworkStream.h>
|
||||
#include <wpi/NetworkAcceptor.h>
|
||||
#include <wpi/NetworkStream.h>
|
||||
#include <wpi/SmallVector.h>
|
||||
#include <wpi/StringRef.h>
|
||||
#include <wpi/raw_istream.h>
|
||||
#include <wpi/raw_ostream.h>
|
||||
#include <wpi/raw_socket_ostream.h>
|
||||
|
||||
#include "SinkImpl.h"
|
||||
|
||||
@@ -29,8 +29,8 @@ class SourceImpl;
|
||||
|
||||
class CvSinkImpl : public SinkImpl {
|
||||
public:
|
||||
explicit CvSinkImpl(llvm::StringRef name);
|
||||
CvSinkImpl(llvm::StringRef name,
|
||||
explicit CvSinkImpl(wpi::StringRef name);
|
||||
CvSinkImpl(wpi::StringRef name,
|
||||
std::function<void(uint64_t time)> processFrame);
|
||||
~CvSinkImpl() override;
|
||||
|
||||
|
||||
@@ -7,11 +7,11 @@
|
||||
|
||||
#include "CvSourceImpl.h"
|
||||
|
||||
#include <llvm/STLExtras.h>
|
||||
#include <opencv2/core/core.hpp>
|
||||
#include <opencv2/highgui/highgui.hpp>
|
||||
#include <opencv2/imgproc/imgproc.hpp>
|
||||
#include <support/timestamp.h>
|
||||
#include <wpi/STLExtras.h>
|
||||
#include <wpi/timestamp.h>
|
||||
|
||||
#include "Handle.h"
|
||||
#include "Log.h"
|
||||
@@ -21,7 +21,7 @@
|
||||
|
||||
using namespace cs;
|
||||
|
||||
CvSourceImpl::CvSourceImpl(llvm::StringRef name, const VideoMode& mode)
|
||||
CvSourceImpl::CvSourceImpl(wpi::StringRef name, const VideoMode& mode)
|
||||
: SourceImpl{name} {
|
||||
m_mode = mode;
|
||||
m_videoModes.push_back(m_mode);
|
||||
@@ -32,8 +32,8 @@ CvSourceImpl::~CvSourceImpl() {}
|
||||
void CvSourceImpl::Start() {}
|
||||
|
||||
std::unique_ptr<PropertyImpl> CvSourceImpl::CreateEmptyProperty(
|
||||
llvm::StringRef name) const {
|
||||
return llvm::make_unique<PropertyData>(name);
|
||||
wpi::StringRef name) const {
|
||||
return wpi::make_unique<PropertyData>(name);
|
||||
}
|
||||
|
||||
bool CvSourceImpl::CacheProperties(CS_Status* status) const {
|
||||
@@ -59,10 +59,10 @@ void CvSourceImpl::SetProperty(int property, int value, CS_Status* status) {
|
||||
return;
|
||||
}
|
||||
|
||||
UpdatePropertyValue(property, false, value, llvm::StringRef{});
|
||||
UpdatePropertyValue(property, false, value, wpi::StringRef{});
|
||||
}
|
||||
|
||||
void CvSourceImpl::SetStringProperty(int property, llvm::StringRef value,
|
||||
void CvSourceImpl::SetStringProperty(int property, wpi::StringRef value,
|
||||
CS_Status* status) {
|
||||
std::lock_guard<wpi::mutex> lock(m_mutex);
|
||||
auto prop = static_cast<PropertyData*>(GetProperty(property));
|
||||
@@ -168,11 +168,11 @@ void CvSourceImpl::PutFrame(cv::Mat& image) {
|
||||
SourceImpl::PutFrame(std::move(dest), wpi::Now());
|
||||
}
|
||||
|
||||
void CvSourceImpl::NotifyError(llvm::StringRef msg) {
|
||||
void CvSourceImpl::NotifyError(wpi::StringRef msg) {
|
||||
PutError(msg, wpi::Now());
|
||||
}
|
||||
|
||||
int CvSourceImpl::CreateProperty(llvm::StringRef name, CS_PropertyKind kind,
|
||||
int CvSourceImpl::CreateProperty(wpi::StringRef name, CS_PropertyKind kind,
|
||||
int minimum, int maximum, int step,
|
||||
int defaultValue, int value) {
|
||||
std::lock_guard<wpi::mutex> lock(m_mutex);
|
||||
@@ -180,7 +180,7 @@ int CvSourceImpl::CreateProperty(llvm::StringRef name, CS_PropertyKind kind,
|
||||
if (ndx == 0) {
|
||||
// create a new index
|
||||
ndx = m_propertyData.size() + 1;
|
||||
m_propertyData.emplace_back(llvm::make_unique<PropertyData>(
|
||||
m_propertyData.emplace_back(wpi::make_unique<PropertyData>(
|
||||
name, kind, minimum, maximum, step, defaultValue, value));
|
||||
} else {
|
||||
// update all but value
|
||||
@@ -194,12 +194,12 @@ int CvSourceImpl::CreateProperty(llvm::StringRef name, CS_PropertyKind kind,
|
||||
}
|
||||
Notifier::GetInstance().NotifySourceProperty(
|
||||
*this, CS_SOURCE_PROPERTY_CREATED, name, ndx, kind, value,
|
||||
llvm::StringRef{});
|
||||
wpi::StringRef{});
|
||||
return ndx;
|
||||
}
|
||||
|
||||
int CvSourceImpl::CreateProperty(
|
||||
llvm::StringRef name, CS_PropertyKind kind, int minimum, int maximum,
|
||||
wpi::StringRef name, CS_PropertyKind kind, int minimum, int maximum,
|
||||
int step, int defaultValue, int value,
|
||||
std::function<void(CS_Property property)> onChange) {
|
||||
// TODO
|
||||
@@ -207,7 +207,7 @@ int CvSourceImpl::CreateProperty(
|
||||
}
|
||||
|
||||
void CvSourceImpl::SetEnumPropertyChoices(int property,
|
||||
llvm::ArrayRef<std::string> choices,
|
||||
wpi::ArrayRef<std::string> choices,
|
||||
CS_Status* status) {
|
||||
std::lock_guard<wpi::mutex> lock(m_mutex);
|
||||
auto prop = GetProperty(property);
|
||||
@@ -222,12 +222,12 @@ void CvSourceImpl::SetEnumPropertyChoices(int property,
|
||||
prop->enumChoices = choices;
|
||||
Notifier::GetInstance().NotifySourceProperty(
|
||||
*this, CS_SOURCE_PROPERTY_CHOICES_UPDATED, prop->name, property,
|
||||
CS_PROP_ENUM, prop->value, llvm::StringRef{});
|
||||
CS_PROP_ENUM, prop->value, wpi::StringRef{});
|
||||
}
|
||||
|
||||
namespace cs {
|
||||
|
||||
CS_Source CreateCvSource(llvm::StringRef name, const VideoMode& mode,
|
||||
CS_Source CreateCvSource(wpi::StringRef name, const VideoMode& mode,
|
||||
CS_Status* status) {
|
||||
auto source = std::make_shared<CvSourceImpl>(name, mode);
|
||||
auto handle = Sources::GetInstance().Allocate(CS_SOURCE_CV, source);
|
||||
@@ -250,7 +250,7 @@ void PutSourceFrame(CS_Source source, cv::Mat& image, CS_Status* status) {
|
||||
static_cast<CvSourceImpl&>(*data->source).PutFrame(image);
|
||||
}
|
||||
|
||||
void NotifySourceError(CS_Source source, llvm::StringRef msg,
|
||||
void NotifySourceError(CS_Source source, wpi::StringRef msg,
|
||||
CS_Status* status) {
|
||||
auto data = Sources::GetInstance().Get(source);
|
||||
if (!data || data->kind != CS_SOURCE_CV) {
|
||||
@@ -269,7 +269,7 @@ void SetSourceConnected(CS_Source source, bool connected, CS_Status* status) {
|
||||
static_cast<CvSourceImpl&>(*data->source).SetConnected(connected);
|
||||
}
|
||||
|
||||
void SetSourceDescription(CS_Source source, llvm::StringRef description,
|
||||
void SetSourceDescription(CS_Source source, wpi::StringRef description,
|
||||
CS_Status* status) {
|
||||
auto data = Sources::GetInstance().Get(source);
|
||||
if (!data || data->kind != CS_SOURCE_CV) {
|
||||
@@ -279,7 +279,7 @@ void SetSourceDescription(CS_Source source, llvm::StringRef description,
|
||||
static_cast<CvSourceImpl&>(*data->source).SetDescription(description);
|
||||
}
|
||||
|
||||
CS_Property CreateSourceProperty(CS_Source source, llvm::StringRef name,
|
||||
CS_Property CreateSourceProperty(CS_Source source, wpi::StringRef name,
|
||||
CS_PropertyKind kind, int minimum, int maximum,
|
||||
int step, int defaultValue, int value,
|
||||
CS_Status* status) {
|
||||
@@ -295,7 +295,7 @@ CS_Property CreateSourceProperty(CS_Source source, llvm::StringRef name,
|
||||
}
|
||||
|
||||
CS_Property CreateSourcePropertyCallback(
|
||||
CS_Source source, llvm::StringRef name, CS_PropertyKind kind, int minimum,
|
||||
CS_Source source, wpi::StringRef name, CS_PropertyKind kind, int minimum,
|
||||
int maximum, int step, int defaultValue, int value,
|
||||
std::function<void(CS_Property property)> onChange, CS_Status* status) {
|
||||
auto data = Sources::GetInstance().Get(source);
|
||||
@@ -310,7 +310,7 @@ CS_Property CreateSourcePropertyCallback(
|
||||
}
|
||||
|
||||
void SetSourceEnumPropertyChoices(CS_Source source, CS_Property property,
|
||||
llvm::ArrayRef<std::string> choices,
|
||||
wpi::ArrayRef<std::string> choices,
|
||||
CS_Status* status) {
|
||||
auto data = Sources::GetInstance().Get(source);
|
||||
if (!data || data->kind != CS_SOURCE_CV) {
|
||||
@@ -390,7 +390,7 @@ CS_Property CS_CreateSourcePropertyCallback(
|
||||
void CS_SetSourceEnumPropertyChoices(CS_Source source, CS_Property property,
|
||||
const char** choices, int count,
|
||||
CS_Status* status) {
|
||||
llvm::SmallVector<std::string, 8> vec;
|
||||
wpi::SmallVector<std::string, 8> vec;
|
||||
vec.reserve(count);
|
||||
for (int i = 0; i < count; ++i) vec.push_back(choices[i]);
|
||||
return cs::SetSourceEnumPropertyChoices(source, property, vec, status);
|
||||
|
||||
@@ -20,14 +20,14 @@ namespace cs {
|
||||
|
||||
class CvSourceImpl : public SourceImpl {
|
||||
public:
|
||||
CvSourceImpl(llvm::StringRef name, const VideoMode& mode);
|
||||
CvSourceImpl(wpi::StringRef name, const VideoMode& mode);
|
||||
~CvSourceImpl() override;
|
||||
|
||||
void Start();
|
||||
|
||||
// Property functions
|
||||
void SetProperty(int property, int value, CS_Status* status) override;
|
||||
void SetStringProperty(int property, llvm::StringRef value,
|
||||
void SetStringProperty(int property, wpi::StringRef value,
|
||||
CS_Status* status) override;
|
||||
|
||||
// Standard common camera properties
|
||||
@@ -47,21 +47,21 @@ class CvSourceImpl : public SourceImpl {
|
||||
|
||||
// OpenCV-specific functions
|
||||
void PutFrame(cv::Mat& image);
|
||||
void NotifyError(llvm::StringRef msg);
|
||||
int CreateProperty(llvm::StringRef name, CS_PropertyKind kind, int minimum,
|
||||
void NotifyError(wpi::StringRef msg);
|
||||
int CreateProperty(wpi::StringRef name, CS_PropertyKind kind, int minimum,
|
||||
int maximum, int step, int defaultValue, int value);
|
||||
int CreateProperty(llvm::StringRef name, CS_PropertyKind kind, int minimum,
|
||||
int CreateProperty(wpi::StringRef name, CS_PropertyKind kind, int minimum,
|
||||
int maximum, int step, int defaultValue, int value,
|
||||
std::function<void(CS_Property property)> onChange);
|
||||
void SetEnumPropertyChoices(int property, llvm::ArrayRef<std::string> choices,
|
||||
void SetEnumPropertyChoices(int property, wpi::ArrayRef<std::string> choices,
|
||||
CS_Status* status);
|
||||
|
||||
// Property data
|
||||
class PropertyData : public PropertyImpl {
|
||||
public:
|
||||
PropertyData() = default;
|
||||
explicit PropertyData(llvm::StringRef name_) : PropertyImpl{name_} {}
|
||||
PropertyData(llvm::StringRef name_, CS_PropertyKind kind_, int minimum_,
|
||||
explicit PropertyData(wpi::StringRef name_) : PropertyImpl{name_} {}
|
||||
PropertyData(wpi::StringRef name_, CS_PropertyKind kind_, int minimum_,
|
||||
int maximum_, int step_, int defaultValue_, int value_)
|
||||
: PropertyImpl{name_, kind_, step_, defaultValue_, value_} {
|
||||
hasMinimum = true;
|
||||
@@ -76,7 +76,7 @@ class CvSourceImpl : public SourceImpl {
|
||||
|
||||
protected:
|
||||
std::unique_ptr<PropertyImpl> CreateEmptyProperty(
|
||||
llvm::StringRef name) const override;
|
||||
wpi::StringRef name) const override;
|
||||
|
||||
bool CacheProperties(CS_Status* status) const override;
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
using namespace cs;
|
||||
|
||||
Frame::Frame(SourceImpl& source, llvm::StringRef error, Time time)
|
||||
Frame::Frame(SourceImpl& source, wpi::StringRef error, Time time)
|
||||
: m_impl{source.AllocFrameImpl().release()} {
|
||||
m_impl->refcount = 1;
|
||||
m_impl->error = error;
|
||||
|
||||
@@ -14,8 +14,8 @@
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include <llvm/SmallVector.h>
|
||||
#include <support/mutex.h>
|
||||
#include <wpi/SmallVector.h>
|
||||
#include <wpi/mutex.h>
|
||||
|
||||
#include "Image.h"
|
||||
#include "cscore_cpp.h"
|
||||
@@ -39,14 +39,14 @@ class Frame {
|
||||
Time time{0};
|
||||
SourceImpl& source;
|
||||
std::string error;
|
||||
llvm::SmallVector<Image*, 4> images;
|
||||
wpi::SmallVector<Image*, 4> images;
|
||||
std::vector<int> compressionParams;
|
||||
};
|
||||
|
||||
public:
|
||||
Frame() noexcept : m_impl{nullptr} {}
|
||||
|
||||
Frame(SourceImpl& source, llvm::StringRef error, Time time);
|
||||
Frame(SourceImpl& source, wpi::StringRef error, Time time);
|
||||
|
||||
Frame(SourceImpl& source, std::unique_ptr<Image> image, Time time);
|
||||
|
||||
@@ -72,8 +72,8 @@ class Frame {
|
||||
|
||||
Time GetTime() const { return m_impl ? m_impl->time : 0; }
|
||||
|
||||
llvm::StringRef GetError() const {
|
||||
if (!m_impl) return llvm::StringRef{};
|
||||
wpi::StringRef GetError() const {
|
||||
if (!m_impl) return wpi::StringRef{};
|
||||
return m_impl->error;
|
||||
}
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
#include <memory>
|
||||
#include <utility>
|
||||
|
||||
#include <llvm/StringRef.h>
|
||||
#include <wpi/StringRef.h>
|
||||
|
||||
#include "UnlimitedHandleResource.h"
|
||||
#include "cscore_c.h"
|
||||
|
||||
@@ -7,9 +7,9 @@
|
||||
|
||||
#include "HttpCameraImpl.h"
|
||||
|
||||
#include <llvm/STLExtras.h>
|
||||
#include <support/timestamp.h>
|
||||
#include <tcpsockets/TCPConnector.h>
|
||||
#include <wpi/STLExtras.h>
|
||||
#include <wpi/TCPConnector.h>
|
||||
#include <wpi/timestamp.h>
|
||||
|
||||
#include "Handle.h"
|
||||
#include "JpegUtil.h"
|
||||
@@ -20,7 +20,7 @@
|
||||
|
||||
using namespace cs;
|
||||
|
||||
HttpCameraImpl::HttpCameraImpl(llvm::StringRef name, CS_HttpCameraKind kind)
|
||||
HttpCameraImpl::HttpCameraImpl(wpi::StringRef name, CS_HttpCameraKind kind)
|
||||
: SourceImpl{name}, m_kind{kind} {}
|
||||
|
||||
HttpCameraImpl::~HttpCameraImpl() {
|
||||
@@ -79,7 +79,7 @@ void HttpCameraImpl::StreamThreadMain() {
|
||||
}
|
||||
|
||||
// connect
|
||||
llvm::SmallString<64> boundary;
|
||||
wpi::SmallString<64> boundary;
|
||||
wpi::HttpConnection* conn = DeviceStreamConnect(boundary);
|
||||
|
||||
if (!m_active) break;
|
||||
@@ -99,7 +99,7 @@ void HttpCameraImpl::StreamThreadMain() {
|
||||
}
|
||||
|
||||
wpi::HttpConnection* HttpCameraImpl::DeviceStreamConnect(
|
||||
llvm::SmallVectorImpl<char>& boundary) {
|
||||
wpi::SmallVectorImpl<char>& boundary) {
|
||||
// Build the request
|
||||
wpi::HttpRequest req;
|
||||
{
|
||||
@@ -120,7 +120,7 @@ wpi::HttpConnection* HttpCameraImpl::DeviceStreamConnect(
|
||||
|
||||
if (!m_active || !stream) return nullptr;
|
||||
|
||||
auto connPtr = llvm::make_unique<wpi::HttpConnection>(std::move(stream), 1);
|
||||
auto connPtr = wpi::make_unique<wpi::HttpConnection>(std::move(stream), 1);
|
||||
wpi::HttpConnection* conn = connPtr.get();
|
||||
|
||||
// update m_streamConn
|
||||
@@ -138,7 +138,7 @@ wpi::HttpConnection* HttpCameraImpl::DeviceStreamConnect(
|
||||
}
|
||||
|
||||
// Parse Content-Type header to get the boundary
|
||||
llvm::StringRef mediaType, contentType;
|
||||
wpi::StringRef mediaType, contentType;
|
||||
std::tie(mediaType, contentType) = conn->contentType.str().split(';');
|
||||
mediaType = mediaType.trim();
|
||||
if (mediaType != "multipart/x-mixed-replace") {
|
||||
@@ -152,10 +152,10 @@ wpi::HttpConnection* HttpCameraImpl::DeviceStreamConnect(
|
||||
// media parameters
|
||||
boundary.clear();
|
||||
while (!contentType.empty()) {
|
||||
llvm::StringRef keyvalue;
|
||||
wpi::StringRef keyvalue;
|
||||
std::tie(keyvalue, contentType) = contentType.split(';');
|
||||
contentType = contentType.ltrim();
|
||||
llvm::StringRef key, value;
|
||||
wpi::StringRef key, value;
|
||||
std::tie(key, value) = keyvalue.split('=');
|
||||
if (key.trim() == "boundary") {
|
||||
value = value.trim().trim('"'); // value may be quoted
|
||||
@@ -175,7 +175,7 @@ wpi::HttpConnection* HttpCameraImpl::DeviceStreamConnect(
|
||||
}
|
||||
|
||||
void HttpCameraImpl::DeviceStream(wpi::raw_istream& is,
|
||||
llvm::StringRef boundary) {
|
||||
wpi::StringRef boundary) {
|
||||
// Stored here so we reuse it from frame to frame
|
||||
std::string imageBuf;
|
||||
|
||||
@@ -205,8 +205,8 @@ void HttpCameraImpl::DeviceStream(wpi::raw_istream& is,
|
||||
bool HttpCameraImpl::DeviceStreamFrame(wpi::raw_istream& is,
|
||||
std::string& imageBuf) {
|
||||
// Read the headers
|
||||
llvm::SmallString<64> contentTypeBuf;
|
||||
llvm::SmallString<64> contentLengthBuf;
|
||||
wpi::SmallString<64> contentTypeBuf;
|
||||
wpi::SmallString<64> contentLengthBuf;
|
||||
if (!ParseHttpHeaders(is, &contentTypeBuf, &contentLengthBuf)) {
|
||||
SWARNING("disconnected during headers");
|
||||
PutError("disconnected during headers", wpi::Now());
|
||||
@@ -216,8 +216,8 @@ bool HttpCameraImpl::DeviceStreamFrame(wpi::raw_istream& is,
|
||||
// Check the content type (if present)
|
||||
if (!contentTypeBuf.str().empty() &&
|
||||
!contentTypeBuf.str().startswith("image/jpeg")) {
|
||||
llvm::SmallString<64> errBuf;
|
||||
llvm::raw_svector_ostream errMsg{errBuf};
|
||||
wpi::SmallString<64> errBuf;
|
||||
wpi::raw_svector_ostream errMsg{errBuf};
|
||||
errMsg << "received unknown Content-Type \"" << contentTypeBuf << "\"";
|
||||
SWARNING(errMsg.str());
|
||||
PutError(errMsg.str(), wpi::Now());
|
||||
@@ -282,7 +282,7 @@ void HttpCameraImpl::DeviceSendSettings(wpi::HttpRequest& req) {
|
||||
|
||||
if (!m_active || !stream) return;
|
||||
|
||||
auto connPtr = llvm::make_unique<wpi::HttpConnection>(std::move(stream), 1);
|
||||
auto connPtr = wpi::make_unique<wpi::HttpConnection>(std::move(stream), 1);
|
||||
wpi::HttpConnection* conn = connPtr.get();
|
||||
|
||||
// update m_settingsConn
|
||||
@@ -303,7 +303,7 @@ CS_HttpCameraKind HttpCameraImpl::GetKind() const {
|
||||
return m_kind;
|
||||
}
|
||||
|
||||
bool HttpCameraImpl::SetUrls(llvm::ArrayRef<std::string> urls,
|
||||
bool HttpCameraImpl::SetUrls(wpi::ArrayRef<std::string> urls,
|
||||
CS_Status* status) {
|
||||
std::vector<wpi::HttpLocation> locations;
|
||||
for (const auto& url : urls) {
|
||||
@@ -331,27 +331,27 @@ std::vector<std::string> HttpCameraImpl::GetUrls() const {
|
||||
return urls;
|
||||
}
|
||||
|
||||
void HttpCameraImpl::CreateProperty(llvm::StringRef name,
|
||||
llvm::StringRef httpParam, bool viaSettings,
|
||||
void HttpCameraImpl::CreateProperty(wpi::StringRef name,
|
||||
wpi::StringRef httpParam, bool viaSettings,
|
||||
CS_PropertyKind kind, int minimum,
|
||||
int maximum, int step, int defaultValue,
|
||||
int value) const {
|
||||
std::lock_guard<wpi::mutex> lock(m_mutex);
|
||||
m_propertyData.emplace_back(llvm::make_unique<PropertyData>(
|
||||
m_propertyData.emplace_back(wpi::make_unique<PropertyData>(
|
||||
name, httpParam, viaSettings, kind, minimum, maximum, step, defaultValue,
|
||||
value));
|
||||
|
||||
Notifier::GetInstance().NotifySourceProperty(
|
||||
*this, CS_SOURCE_PROPERTY_CREATED, name, m_propertyData.size() + 1, kind,
|
||||
value, llvm::StringRef{});
|
||||
value, wpi::StringRef{});
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void HttpCameraImpl::CreateEnumProperty(
|
||||
llvm::StringRef name, llvm::StringRef httpParam, bool viaSettings,
|
||||
wpi::StringRef name, wpi::StringRef httpParam, bool viaSettings,
|
||||
int defaultValue, int value, std::initializer_list<T> choices) const {
|
||||
std::lock_guard<wpi::mutex> lock(m_mutex);
|
||||
m_propertyData.emplace_back(llvm::make_unique<PropertyData>(
|
||||
m_propertyData.emplace_back(wpi::make_unique<PropertyData>(
|
||||
name, httpParam, viaSettings, CS_PROP_ENUM, 0, choices.size() - 1, 1,
|
||||
defaultValue, value));
|
||||
|
||||
@@ -361,15 +361,15 @@ void HttpCameraImpl::CreateEnumProperty(
|
||||
|
||||
Notifier::GetInstance().NotifySourceProperty(
|
||||
*this, CS_SOURCE_PROPERTY_CREATED, name, m_propertyData.size() + 1,
|
||||
CS_PROP_ENUM, value, llvm::StringRef{});
|
||||
CS_PROP_ENUM, value, wpi::StringRef{});
|
||||
Notifier::GetInstance().NotifySourceProperty(
|
||||
*this, CS_SOURCE_PROPERTY_CHOICES_UPDATED, name,
|
||||
m_propertyData.size() + 1, CS_PROP_ENUM, value, llvm::StringRef{});
|
||||
m_propertyData.size() + 1, CS_PROP_ENUM, value, wpi::StringRef{});
|
||||
}
|
||||
|
||||
std::unique_ptr<PropertyImpl> HttpCameraImpl::CreateEmptyProperty(
|
||||
llvm::StringRef name) const {
|
||||
return llvm::make_unique<PropertyData>(name);
|
||||
wpi::StringRef name) const {
|
||||
return wpi::make_unique<PropertyData>(name);
|
||||
}
|
||||
|
||||
bool HttpCameraImpl::CacheProperties(CS_Status* status) const {
|
||||
@@ -389,7 +389,7 @@ void HttpCameraImpl::SetProperty(int property, int value, CS_Status* status) {
|
||||
// TODO
|
||||
}
|
||||
|
||||
void HttpCameraImpl::SetStringProperty(int property, llvm::StringRef value,
|
||||
void HttpCameraImpl::SetStringProperty(int property, wpi::StringRef value,
|
||||
CS_Status* status) {
|
||||
// TODO
|
||||
}
|
||||
@@ -473,7 +473,7 @@ bool AxisCameraImpl::CacheProperties(CS_Status* status) const {
|
||||
|
||||
namespace cs {
|
||||
|
||||
CS_Source CreateHttpCamera(llvm::StringRef name, llvm::StringRef url,
|
||||
CS_Source CreateHttpCamera(wpi::StringRef name, wpi::StringRef url,
|
||||
CS_HttpCameraKind kind, CS_Status* status) {
|
||||
std::shared_ptr<HttpCameraImpl> source;
|
||||
switch (kind) {
|
||||
@@ -493,8 +493,8 @@ CS_Source CreateHttpCamera(llvm::StringRef name, llvm::StringRef url,
|
||||
return handle;
|
||||
}
|
||||
|
||||
CS_Source CreateHttpCamera(llvm::StringRef name,
|
||||
llvm::ArrayRef<std::string> urls,
|
||||
CS_Source CreateHttpCamera(wpi::StringRef name,
|
||||
wpi::ArrayRef<std::string> urls,
|
||||
CS_HttpCameraKind kind, CS_Status* status) {
|
||||
if (urls.empty()) {
|
||||
*status = CS_EMPTY_VALUE;
|
||||
@@ -518,7 +518,7 @@ CS_HttpCameraKind GetHttpCameraKind(CS_Source source, CS_Status* status) {
|
||||
return static_cast<HttpCameraImpl&>(*data->source).GetKind();
|
||||
}
|
||||
|
||||
void SetHttpCameraUrls(CS_Source source, llvm::ArrayRef<std::string> urls,
|
||||
void SetHttpCameraUrls(CS_Source source, wpi::ArrayRef<std::string> urls,
|
||||
CS_Status* status) {
|
||||
if (urls.empty()) {
|
||||
*status = CS_EMPTY_VALUE;
|
||||
@@ -554,7 +554,7 @@ CS_Source CS_CreateHttpCamera(const char* name, const char* url,
|
||||
CS_Source CS_CreateHttpCameraMulti(const char* name, const char** urls,
|
||||
int count, CS_HttpCameraKind kind,
|
||||
CS_Status* status) {
|
||||
llvm::SmallVector<std::string, 4> vec;
|
||||
wpi::SmallVector<std::string, 4> vec;
|
||||
vec.reserve(count);
|
||||
for (int i = 0; i < count; ++i) vec.push_back(urls[i]);
|
||||
return cs::CreateHttpCamera(name, vec, kind, status);
|
||||
@@ -566,7 +566,7 @@ CS_HttpCameraKind CS_GetHttpCameraKind(CS_Source source, CS_Status* status) {
|
||||
|
||||
void CS_SetHttpCameraUrls(CS_Source source, const char** urls, int count,
|
||||
CS_Status* status) {
|
||||
llvm::SmallVector<std::string, 4> vec;
|
||||
wpi::SmallVector<std::string, 4> vec;
|
||||
vec.reserve(count);
|
||||
for (int i = 0; i < count; ++i) vec.push_back(urls[i]);
|
||||
cs::SetHttpCameraUrls(source, vec, status);
|
||||
|
||||
@@ -16,11 +16,11 @@
|
||||
#include <thread>
|
||||
#include <vector>
|
||||
|
||||
#include <llvm/SmallString.h>
|
||||
#include <llvm/StringMap.h>
|
||||
#include <support/HttpUtil.h>
|
||||
#include <support/condition_variable.h>
|
||||
#include <support/raw_istream.h>
|
||||
#include <wpi/HttpUtil.h>
|
||||
#include <wpi/SmallString.h>
|
||||
#include <wpi/StringMap.h>
|
||||
#include <wpi/condition_variable.h>
|
||||
#include <wpi/raw_istream.h>
|
||||
|
||||
#include "SourceImpl.h"
|
||||
#include "cscore_cpp.h"
|
||||
@@ -29,14 +29,14 @@ namespace cs {
|
||||
|
||||
class HttpCameraImpl : public SourceImpl {
|
||||
public:
|
||||
HttpCameraImpl(llvm::StringRef name, CS_HttpCameraKind kind);
|
||||
HttpCameraImpl(wpi::StringRef name, CS_HttpCameraKind kind);
|
||||
~HttpCameraImpl() override;
|
||||
|
||||
void Start();
|
||||
|
||||
// Property functions
|
||||
void SetProperty(int property, int value, CS_Status* status) override;
|
||||
void SetStringProperty(int property, llvm::StringRef value,
|
||||
void SetStringProperty(int property, wpi::StringRef value,
|
||||
CS_Status* status) override;
|
||||
|
||||
// Standard common camera properties
|
||||
@@ -55,15 +55,15 @@ class HttpCameraImpl : public SourceImpl {
|
||||
void NumSinksEnabledChanged() override;
|
||||
|
||||
CS_HttpCameraKind GetKind() const;
|
||||
bool SetUrls(llvm::ArrayRef<std::string> urls, CS_Status* status);
|
||||
bool SetUrls(wpi::ArrayRef<std::string> urls, CS_Status* status);
|
||||
std::vector<std::string> GetUrls() const;
|
||||
|
||||
// Property data
|
||||
class PropertyData : public PropertyImpl {
|
||||
public:
|
||||
PropertyData() = default;
|
||||
explicit PropertyData(llvm::StringRef name_) : PropertyImpl{name_} {}
|
||||
PropertyData(llvm::StringRef name_, llvm::StringRef httpParam_,
|
||||
explicit PropertyData(wpi::StringRef name_) : PropertyImpl{name_} {}
|
||||
PropertyData(wpi::StringRef name_, wpi::StringRef httpParam_,
|
||||
bool viaSettings_, CS_PropertyKind kind_, int minimum_,
|
||||
int maximum_, int step_, int defaultValue_, int value_)
|
||||
: PropertyImpl(name_, kind_, step_, defaultValue_, value_),
|
||||
@@ -82,16 +82,16 @@ class HttpCameraImpl : public SourceImpl {
|
||||
|
||||
protected:
|
||||
std::unique_ptr<PropertyImpl> CreateEmptyProperty(
|
||||
llvm::StringRef name) const override;
|
||||
wpi::StringRef name) const override;
|
||||
|
||||
bool CacheProperties(CS_Status* status) const override;
|
||||
|
||||
void CreateProperty(llvm::StringRef name, llvm::StringRef httpParam,
|
||||
void CreateProperty(wpi::StringRef name, wpi::StringRef httpParam,
|
||||
bool viaSettings, CS_PropertyKind kind, int minimum,
|
||||
int maximum, int step, int defaultValue, int value) const;
|
||||
|
||||
template <typename T>
|
||||
void CreateEnumProperty(llvm::StringRef name, llvm::StringRef httpParam,
|
||||
void CreateEnumProperty(wpi::StringRef name, wpi::StringRef httpParam,
|
||||
bool viaSettings, int defaultValue, int value,
|
||||
std::initializer_list<T> choices) const;
|
||||
|
||||
@@ -101,8 +101,8 @@ class HttpCameraImpl : public SourceImpl {
|
||||
|
||||
// Functions used by StreamThreadMain()
|
||||
wpi::HttpConnection* DeviceStreamConnect(
|
||||
llvm::SmallVectorImpl<char>& boundary);
|
||||
void DeviceStream(wpi::raw_istream& is, llvm::StringRef boundary);
|
||||
wpi::SmallVectorImpl<char>& boundary);
|
||||
void DeviceStream(wpi::raw_istream& is, wpi::StringRef boundary);
|
||||
bool DeviceStreamFrame(wpi::raw_istream& is, std::string& imageBuf);
|
||||
|
||||
// The camera settings thread
|
||||
@@ -130,20 +130,20 @@ class HttpCameraImpl : public SourceImpl {
|
||||
|
||||
wpi::condition_variable m_sinkEnabledCond;
|
||||
|
||||
llvm::StringMap<llvm::SmallString<16>> m_settings;
|
||||
wpi::StringMap<wpi::SmallString<16>> m_settings;
|
||||
wpi::condition_variable m_settingsCond;
|
||||
|
||||
llvm::StringMap<llvm::SmallString<16>> m_streamSettings;
|
||||
wpi::StringMap<wpi::SmallString<16>> m_streamSettings;
|
||||
std::atomic_bool m_streamSettingsUpdated{false};
|
||||
};
|
||||
|
||||
class AxisCameraImpl : public HttpCameraImpl {
|
||||
public:
|
||||
explicit AxisCameraImpl(llvm::StringRef name)
|
||||
explicit AxisCameraImpl(wpi::StringRef name)
|
||||
: HttpCameraImpl{name, CS_HTTP_AXIS} {}
|
||||
#if 0
|
||||
void SetProperty(int property, int value, CS_Status* status) override;
|
||||
void SetStringProperty(int property, llvm::StringRef value,
|
||||
void SetStringProperty(int property, wpi::StringRef value,
|
||||
CS_Status* status) override;
|
||||
#endif
|
||||
protected:
|
||||
|
||||
@@ -10,8 +10,8 @@
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include <llvm/StringRef.h>
|
||||
#include <opencv2/core/core.hpp>
|
||||
#include <wpi/StringRef.h>
|
||||
|
||||
#include "cscore_cpp.h"
|
||||
#include "default_init_allocator.h"
|
||||
@@ -37,8 +37,8 @@ class Image {
|
||||
Image& operator=(const Image&) = delete;
|
||||
|
||||
// Getters
|
||||
operator llvm::StringRef() const { return str(); }
|
||||
llvm::StringRef str() const { return llvm::StringRef(data(), size()); }
|
||||
operator wpi::StringRef() const { return str(); }
|
||||
wpi::StringRef str() const { return wpi::StringRef(data(), size()); }
|
||||
size_t capacity() const { return m_data.capacity(); }
|
||||
const char* data() const {
|
||||
return reinterpret_cast<const char*>(m_data.data());
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
#include "JpegUtil.h"
|
||||
|
||||
#include <support/raw_istream.h>
|
||||
#include <wpi/raw_istream.h>
|
||||
|
||||
namespace cs {
|
||||
|
||||
@@ -49,7 +49,7 @@ static const unsigned char dhtData[] = {
|
||||
0xd5, 0xd6, 0xd7, 0xd8, 0xd9, 0xda, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7,
|
||||
0xe8, 0xe9, 0xea, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, 0xf9, 0xfa};
|
||||
|
||||
bool IsJpeg(llvm::StringRef data) {
|
||||
bool IsJpeg(wpi::StringRef data) {
|
||||
if (data.size() < 11) return false;
|
||||
|
||||
// Check for valid SOI
|
||||
@@ -58,7 +58,7 @@ bool IsJpeg(llvm::StringRef data) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool GetJpegSize(llvm::StringRef data, int* width, int* height) {
|
||||
bool GetJpegSize(wpi::StringRef data, int* width, int* height) {
|
||||
if (!IsJpeg(data)) return false;
|
||||
|
||||
data = data.substr(2); // Get to the first block
|
||||
@@ -82,7 +82,7 @@ bool GetJpegSize(llvm::StringRef data, int* width, int* height) {
|
||||
}
|
||||
|
||||
bool JpegNeedsDHT(const char* data, size_t* size, size_t* locSOF) {
|
||||
llvm::StringRef sdata(data, *size);
|
||||
wpi::StringRef sdata(data, *size);
|
||||
if (!IsJpeg(sdata)) return false;
|
||||
|
||||
*locSOF = *size;
|
||||
@@ -109,8 +109,8 @@ bool JpegNeedsDHT(const char* data, size_t* size, size_t* locSOF) {
|
||||
return false;
|
||||
}
|
||||
|
||||
llvm::StringRef JpegGetDHT() {
|
||||
return llvm::StringRef(reinterpret_cast<const char*>(dhtData),
|
||||
wpi::StringRef JpegGetDHT() {
|
||||
return wpi::StringRef(reinterpret_cast<const char*>(dhtData),
|
||||
sizeof(dhtData));
|
||||
}
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
|
||||
#include <string>
|
||||
|
||||
#include <llvm/StringRef.h>
|
||||
#include <wpi/StringRef.h>
|
||||
|
||||
namespace wpi {
|
||||
class raw_istream;
|
||||
@@ -18,13 +18,13 @@ class raw_istream;
|
||||
|
||||
namespace cs {
|
||||
|
||||
bool IsJpeg(llvm::StringRef data);
|
||||
bool IsJpeg(wpi::StringRef data);
|
||||
|
||||
bool GetJpegSize(llvm::StringRef data, int* width, int* height);
|
||||
bool GetJpegSize(wpi::StringRef data, int* width, int* height);
|
||||
|
||||
bool JpegNeedsDHT(const char* data, size_t* size, size_t* locSOF);
|
||||
|
||||
llvm::StringRef JpegGetDHT();
|
||||
wpi::StringRef JpegGetDHT();
|
||||
|
||||
bool ReadJpeg(wpi::raw_istream& is, std::string& buf, int* width, int* height);
|
||||
|
||||
|
||||
@@ -7,24 +7,24 @@
|
||||
|
||||
#include "Log.h"
|
||||
|
||||
#include <llvm/Path.h>
|
||||
#include <llvm/SmallString.h>
|
||||
#include <llvm/StringRef.h>
|
||||
#include <llvm/raw_ostream.h>
|
||||
#include <wpi/Path.h>
|
||||
#include <wpi/SmallString.h>
|
||||
#include <wpi/StringRef.h>
|
||||
#include <wpi/raw_ostream.h>
|
||||
|
||||
using namespace cs;
|
||||
|
||||
static void def_log_func(unsigned int level, const char* file,
|
||||
unsigned int line, const char* msg) {
|
||||
llvm::SmallString<128> buf;
|
||||
llvm::raw_svector_ostream oss(buf);
|
||||
wpi::SmallString<128> buf;
|
||||
wpi::raw_svector_ostream oss(buf);
|
||||
if (level == 20) {
|
||||
oss << "CS: " << msg << '\n';
|
||||
llvm::errs() << oss.str();
|
||||
wpi::errs() << oss.str();
|
||||
return;
|
||||
}
|
||||
|
||||
llvm::StringRef levelmsg;
|
||||
wpi::StringRef levelmsg;
|
||||
if (level >= 50)
|
||||
levelmsg = "CRITICAL: ";
|
||||
else if (level >= 40)
|
||||
@@ -33,9 +33,9 @@ static void def_log_func(unsigned int level, const char* file,
|
||||
levelmsg = "WARNING: ";
|
||||
else
|
||||
return;
|
||||
oss << "CS: " << levelmsg << msg << " (" << llvm::sys::path::filename(file)
|
||||
oss << "CS: " << levelmsg << msg << " (" << wpi::sys::path::filename(file)
|
||||
<< ':' << line << ")\n";
|
||||
llvm::errs() << oss.str();
|
||||
wpi::errs() << oss.str();
|
||||
}
|
||||
|
||||
Logger::Logger() { SetDefaultLogger(); }
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
#ifndef CSCORE_LOG_H_
|
||||
#define CSCORE_LOG_H_
|
||||
|
||||
#include <support/Logger.h>
|
||||
#include <wpi/Logger.h>
|
||||
|
||||
namespace cs {
|
||||
|
||||
|
||||
@@ -9,11 +9,11 @@
|
||||
|
||||
#include <chrono>
|
||||
|
||||
#include <llvm/SmallString.h>
|
||||
#include <support/HttpUtil.h>
|
||||
#include <support/raw_socket_istream.h>
|
||||
#include <support/raw_socket_ostream.h>
|
||||
#include <tcpsockets/TCPAcceptor.h>
|
||||
#include <wpi/HttpUtil.h>
|
||||
#include <wpi/SmallString.h>
|
||||
#include <wpi/TCPAcceptor.h>
|
||||
#include <wpi/raw_socket_istream.h>
|
||||
#include <wpi/raw_socket_ostream.h>
|
||||
|
||||
#include "Handle.h"
|
||||
#include "JpegUtil.h"
|
||||
@@ -73,15 +73,15 @@ static const char* endRootPage = "</div></body></html>";
|
||||
|
||||
class MjpegServerImpl::ConnThread : public wpi::SafeThread {
|
||||
public:
|
||||
explicit ConnThread(llvm::StringRef name) : m_name(name) {}
|
||||
explicit ConnThread(wpi::StringRef name) : m_name(name) {}
|
||||
|
||||
void Main();
|
||||
|
||||
bool ProcessCommand(llvm::raw_ostream& os, SourceImpl& source,
|
||||
llvm::StringRef parameters, bool respond);
|
||||
void SendJSON(llvm::raw_ostream& os, SourceImpl& source, bool header);
|
||||
void SendHTMLHeadTitle(llvm::raw_ostream& os) const;
|
||||
void SendHTML(llvm::raw_ostream& os, SourceImpl& source, bool header);
|
||||
bool ProcessCommand(wpi::raw_ostream& os, SourceImpl& source,
|
||||
wpi::StringRef 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 ProcessRequest();
|
||||
|
||||
@@ -93,7 +93,7 @@ class MjpegServerImpl::ConnThread : public wpi::SafeThread {
|
||||
private:
|
||||
std::string m_name;
|
||||
|
||||
llvm::StringRef GetName() { return m_name; }
|
||||
wpi::StringRef GetName() { return m_name; }
|
||||
|
||||
std::shared_ptr<SourceImpl> GetSource() {
|
||||
std::lock_guard<wpi::mutex> lock(m_mutex);
|
||||
@@ -124,9 +124,9 @@ 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(llvm::raw_ostream& os, int code,
|
||||
llvm::StringRef codeText, llvm::StringRef contentType,
|
||||
llvm::StringRef extra = llvm::StringRef{}) {
|
||||
static void SendHeader(wpi::raw_ostream& os, int code,
|
||||
wpi::StringRef codeText, wpi::StringRef contentType,
|
||||
wpi::StringRef extra = wpi::StringRef{}) {
|
||||
os << "HTTP/1.0 " << code << ' ' << codeText << "\r\n";
|
||||
os << "Connection: close\r\n"
|
||||
"Server: CameraServer/1.0\r\n"
|
||||
@@ -143,9 +143,9 @@ static void SendHeader(llvm::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(llvm::raw_ostream& os, int code,
|
||||
llvm::StringRef message) {
|
||||
llvm::StringRef codeText, extra, baseMessage;
|
||||
static void SendError(wpi::raw_ostream& os, int code,
|
||||
wpi::StringRef message) {
|
||||
wpi::StringRef codeText, extra, baseMessage;
|
||||
switch (code) {
|
||||
case 401:
|
||||
codeText = "Unauthorized";
|
||||
@@ -183,16 +183,16 @@ static void SendError(llvm::raw_ostream& os, int code,
|
||||
}
|
||||
|
||||
// Perform a command specified by HTTP GET parameters.
|
||||
bool MjpegServerImpl::ConnThread::ProcessCommand(llvm::raw_ostream& os,
|
||||
bool MjpegServerImpl::ConnThread::ProcessCommand(wpi::raw_ostream& os,
|
||||
SourceImpl& source,
|
||||
llvm::StringRef parameters,
|
||||
wpi::StringRef parameters,
|
||||
bool respond) {
|
||||
llvm::SmallString<256> responseBuf;
|
||||
llvm::raw_svector_ostream response{responseBuf};
|
||||
wpi::SmallString<256> responseBuf;
|
||||
wpi::raw_svector_ostream response{responseBuf};
|
||||
// command format: param1=value1¶m2=value2...
|
||||
while (!parameters.empty()) {
|
||||
// split out next param and value
|
||||
llvm::StringRef rawParam, rawValue;
|
||||
wpi::StringRef rawParam, rawValue;
|
||||
std::tie(rawParam, parameters) = parameters.split('&');
|
||||
if (rawParam.empty()) continue; // ignore "&&"
|
||||
std::tie(rawParam, rawValue) = rawParam.split('=');
|
||||
@@ -202,11 +202,11 @@ bool MjpegServerImpl::ConnThread::ProcessCommand(llvm::raw_ostream& os,
|
||||
|
||||
// unescape param
|
||||
bool error = false;
|
||||
llvm::SmallString<64> paramBuf;
|
||||
llvm::StringRef param = wpi::UnescapeURI(rawParam, paramBuf, &error);
|
||||
wpi::SmallString<64> paramBuf;
|
||||
wpi::StringRef param = wpi::UnescapeURI(rawParam, paramBuf, &error);
|
||||
if (error) {
|
||||
llvm::SmallString<128> error;
|
||||
llvm::raw_svector_ostream oss{error};
|
||||
wpi::SmallString<128> error;
|
||||
wpi::raw_svector_ostream oss{error};
|
||||
oss << "could not unescape parameter \"" << rawParam << "\"";
|
||||
SendError(os, 500, error.str());
|
||||
SDEBUG(error.str());
|
||||
@@ -214,11 +214,11 @@ bool MjpegServerImpl::ConnThread::ProcessCommand(llvm::raw_ostream& os,
|
||||
}
|
||||
|
||||
// unescape value
|
||||
llvm::SmallString<64> valueBuf;
|
||||
llvm::StringRef value = wpi::UnescapeURI(rawValue, valueBuf, &error);
|
||||
wpi::SmallString<64> valueBuf;
|
||||
wpi::StringRef value = wpi::UnescapeURI(rawValue, valueBuf, &error);
|
||||
if (error) {
|
||||
llvm::SmallString<128> error;
|
||||
llvm::raw_svector_ostream oss{error};
|
||||
wpi::SmallString<128> error;
|
||||
wpi::raw_svector_ostream oss{error};
|
||||
oss << "could not unescape value \"" << rawValue << "\"";
|
||||
SendError(os, 500, error.str());
|
||||
SDEBUG(error.str());
|
||||
@@ -228,7 +228,7 @@ bool MjpegServerImpl::ConnThread::ProcessCommand(llvm::raw_ostream& os,
|
||||
// Handle resolution, compression, and FPS. These are handled locally
|
||||
// rather than passed to the source.
|
||||
if (param == "resolution") {
|
||||
llvm::StringRef widthStr, heightStr;
|
||||
wpi::StringRef widthStr, heightStr;
|
||||
std::tie(widthStr, heightStr) = value.split('x');
|
||||
int width, height;
|
||||
if (widthStr.getAsInteger(10, width)) {
|
||||
@@ -327,21 +327,21 @@ bool MjpegServerImpl::ConnThread::ProcessCommand(llvm::raw_ostream& os,
|
||||
}
|
||||
|
||||
void MjpegServerImpl::ConnThread::SendHTMLHeadTitle(
|
||||
llvm::raw_ostream& os) const {
|
||||
wpi::raw_ostream& os) const {
|
||||
os << "<html><head><title>" << m_name << " CameraServer</title>";
|
||||
}
|
||||
|
||||
// Send the root html file with controls for all the settable properties.
|
||||
void MjpegServerImpl::ConnThread::SendHTML(llvm::raw_ostream& os,
|
||||
void MjpegServerImpl::ConnThread::SendHTML(wpi::raw_ostream& os,
|
||||
SourceImpl& source, bool header) {
|
||||
if (header) SendHeader(os, 200, "OK", "application/x-javascript");
|
||||
|
||||
SendHTMLHeadTitle(os);
|
||||
os << startRootPage;
|
||||
llvm::SmallVector<int, 32> properties_vec;
|
||||
wpi::SmallVector<int, 32> properties_vec;
|
||||
CS_Status status = 0;
|
||||
for (auto prop : source.EnumerateProperties(properties_vec, &status)) {
|
||||
llvm::SmallString<128> name_buf;
|
||||
wpi::SmallString<128> name_buf;
|
||||
auto name = source.GetPropertyName(prop, name_buf, &status);
|
||||
if (name.startswith("raw_")) continue;
|
||||
auto kind = source.GetPropertyKind(prop);
|
||||
@@ -378,7 +378,7 @@ void MjpegServerImpl::ConnThread::SendHTML(llvm::raw_ostream& os,
|
||||
++j, ++choice) {
|
||||
if (choice->empty()) continue; // skip empty choices
|
||||
// replace any non-printable characters in name with spaces
|
||||
llvm::SmallString<128> ch_name;
|
||||
wpi::SmallString<128> ch_name;
|
||||
for (char ch : *choice)
|
||||
ch_name.push_back(std::isprint(ch) ? ch : ' ');
|
||||
os << "<input id=\"" << name << j << "\" type=\"radio\" name=\""
|
||||
@@ -393,7 +393,7 @@ void MjpegServerImpl::ConnThread::SendHTML(llvm::raw_ostream& os,
|
||||
break;
|
||||
}
|
||||
case CS_PROP_STRING: {
|
||||
llvm::SmallString<128> strval_buf;
|
||||
wpi::SmallString<128> strval_buf;
|
||||
os << "<input type=\"text\" id=\"" << name << "box\" name=\"" << name
|
||||
<< "\" value=\""
|
||||
<< source.GetStringProperty(prop, strval_buf, &status) << "\" />\n";
|
||||
@@ -445,12 +445,12 @@ void MjpegServerImpl::ConnThread::SendHTML(llvm::raw_ostream& os,
|
||||
}
|
||||
|
||||
// Send a JSON file which is contains information about the source parameters.
|
||||
void MjpegServerImpl::ConnThread::SendJSON(llvm::raw_ostream& os,
|
||||
void MjpegServerImpl::ConnThread::SendJSON(wpi::raw_ostream& os,
|
||||
SourceImpl& source, bool header) {
|
||||
if (header) SendHeader(os, 200, "OK", "application/x-javascript");
|
||||
|
||||
os << "{\n\"controls\": [\n";
|
||||
llvm::SmallVector<int, 32> properties_vec;
|
||||
wpi::SmallVector<int, 32> properties_vec;
|
||||
bool first = true;
|
||||
CS_Status status = 0;
|
||||
for (auto prop : source.EnumerateProperties(properties_vec, &status)) {
|
||||
@@ -459,7 +459,7 @@ void MjpegServerImpl::ConnThread::SendJSON(llvm::raw_ostream& os,
|
||||
else
|
||||
os << ",\n";
|
||||
os << '{';
|
||||
llvm::SmallString<128> name_buf;
|
||||
wpi::SmallString<128> name_buf;
|
||||
auto name = source.GetPropertyName(prop, name_buf, &status);
|
||||
auto kind = source.GetPropertyKind(prop);
|
||||
os << "\n\"name\": \"" << name << '"';
|
||||
@@ -478,7 +478,7 @@ void MjpegServerImpl::ConnThread::SendJSON(llvm::raw_ostream& os,
|
||||
os << source.GetProperty(prop, &status);
|
||||
break;
|
||||
case CS_PROP_STRING: {
|
||||
llvm::SmallString<128> strval_buf;
|
||||
wpi::SmallString<128> strval_buf;
|
||||
os << source.GetStringProperty(prop, strval_buf, &status);
|
||||
break;
|
||||
}
|
||||
@@ -499,7 +499,7 @@ void MjpegServerImpl::ConnThread::SendJSON(llvm::raw_ostream& os,
|
||||
++j, ++choice) {
|
||||
if (j != 0) os << ", ";
|
||||
// replace any non-printable characters in name with spaces
|
||||
llvm::SmallString<128> ch_name;
|
||||
wpi::SmallString<128> ch_name;
|
||||
for (char ch : *choice) ch_name.push_back(std::isprint(ch) ? ch : ' ');
|
||||
os << '"' << j << "\": \"" << ch_name << '"';
|
||||
}
|
||||
@@ -545,8 +545,8 @@ void MjpegServerImpl::ConnThread::SendJSON(llvm::raw_ostream& os,
|
||||
os.flush();
|
||||
}
|
||||
|
||||
MjpegServerImpl::MjpegServerImpl(llvm::StringRef name,
|
||||
llvm::StringRef listenAddress, int port,
|
||||
MjpegServerImpl::MjpegServerImpl(wpi::StringRef name,
|
||||
wpi::StringRef listenAddress, int port,
|
||||
std::unique_ptr<wpi::NetworkAcceptor> acceptor)
|
||||
: SinkImpl{name},
|
||||
m_listenAddress(listenAddress),
|
||||
@@ -554,8 +554,8 @@ MjpegServerImpl::MjpegServerImpl(llvm::StringRef name,
|
||||
m_acceptor{std::move(acceptor)} {
|
||||
m_active = true;
|
||||
|
||||
llvm::SmallString<128> descBuf;
|
||||
llvm::raw_svector_ostream desc{descBuf};
|
||||
wpi::SmallString<128> descBuf;
|
||||
wpi::raw_svector_ostream desc{descBuf};
|
||||
desc << "HTTP Server on port " << port;
|
||||
SetDescription(desc.str());
|
||||
|
||||
@@ -595,8 +595,8 @@ void MjpegServerImpl::ConnThread::SendStream(wpi::raw_socket_ostream& os) {
|
||||
|
||||
os.SetUnbuffered();
|
||||
|
||||
llvm::SmallString<256> header;
|
||||
llvm::raw_svector_ostream oss{header};
|
||||
wpi::SmallString<256> header;
|
||||
wpi::raw_svector_ostream oss{header};
|
||||
|
||||
SendHeader(oss, 200, "OK", "multipart/x-mixed-replace;boundary=" BOUNDARY);
|
||||
os << oss.str();
|
||||
@@ -678,11 +678,11 @@ void MjpegServerImpl::ConnThread::SendStream(wpi::raw_socket_ostream& os) {
|
||||
os << oss.str();
|
||||
if (addDHT) {
|
||||
// Insert DHT data immediately before SOF
|
||||
os << llvm::StringRef(data, locSOF);
|
||||
os << wpi::StringRef(data, locSOF);
|
||||
os << JpegGetDHT();
|
||||
os << llvm::StringRef(data + locSOF, image->size() - locSOF);
|
||||
os << wpi::StringRef(data + locSOF, image->size() - locSOF);
|
||||
} else {
|
||||
os << llvm::StringRef(data, size);
|
||||
os << wpi::StringRef(data, size);
|
||||
}
|
||||
// os.flush();
|
||||
}
|
||||
@@ -700,44 +700,44 @@ void MjpegServerImpl::ConnThread::ProcessRequest() {
|
||||
m_fps = 0;
|
||||
|
||||
// Read the request string from the stream
|
||||
llvm::SmallString<128> reqBuf;
|
||||
llvm::StringRef req = is.getline(reqBuf, 4096);
|
||||
wpi::SmallString<128> reqBuf;
|
||||
wpi::StringRef req = is.getline(reqBuf, 4096);
|
||||
if (is.has_error()) {
|
||||
SDEBUG("error getting request string");
|
||||
return;
|
||||
}
|
||||
|
||||
enum { kCommand, kStream, kGetSettings, kRootPage } kind;
|
||||
llvm::StringRef parameters;
|
||||
wpi::StringRef parameters;
|
||||
size_t pos;
|
||||
|
||||
SDEBUG("HTTP request: '" << req << "'\n");
|
||||
|
||||
// Determine request kind. Most of these are for mjpgstreamer
|
||||
// compatibility, others are for Axis camera compatibility.
|
||||
if ((pos = req.find("POST /stream")) != llvm::StringRef::npos) {
|
||||
if ((pos = req.find("POST /stream")) != wpi::StringRef::npos) {
|
||||
kind = kStream;
|
||||
parameters = req.substr(req.find('?', pos + 12)).substr(1);
|
||||
} else if ((pos = req.find("GET /?action=stream")) != llvm::StringRef::npos) {
|
||||
} else if ((pos = req.find("GET /?action=stream")) != wpi::StringRef::npos) {
|
||||
kind = kStream;
|
||||
parameters = req.substr(req.find('&', pos + 19)).substr(1);
|
||||
} else if ((pos = req.find("GET /stream.mjpg")) != llvm::StringRef::npos) {
|
||||
} else if ((pos = req.find("GET /stream.mjpg")) != wpi::StringRef::npos) {
|
||||
kind = kStream;
|
||||
parameters = req.substr(req.find('?', pos + 16)).substr(1);
|
||||
} else if (req.find("GET /settings") != llvm::StringRef::npos &&
|
||||
req.find(".json") != llvm::StringRef::npos) {
|
||||
} else if (req.find("GET /settings") != wpi::StringRef::npos &&
|
||||
req.find(".json") != wpi::StringRef::npos) {
|
||||
kind = kGetSettings;
|
||||
} else if (req.find("GET /input") != llvm::StringRef::npos &&
|
||||
req.find(".json") != llvm::StringRef::npos) {
|
||||
} else if (req.find("GET /input") != wpi::StringRef::npos &&
|
||||
req.find(".json") != wpi::StringRef::npos) {
|
||||
kind = kGetSettings;
|
||||
} else if (req.find("GET /output") != llvm::StringRef::npos &&
|
||||
req.find(".json") != llvm::StringRef::npos) {
|
||||
} else if (req.find("GET /output") != wpi::StringRef::npos &&
|
||||
req.find(".json") != wpi::StringRef::npos) {
|
||||
kind = kGetSettings;
|
||||
} else if ((pos = req.find("GET /?action=command")) !=
|
||||
llvm::StringRef::npos) {
|
||||
wpi::StringRef::npos) {
|
||||
kind = kCommand;
|
||||
parameters = req.substr(req.find('&', pos + 20)).substr(1);
|
||||
} else if (req.find("GET / ") != llvm::StringRef::npos || req == "GET /\n") {
|
||||
} else if (req.find("GET / ") != wpi::StringRef::npos || req == "GET /\n") {
|
||||
kind = kRootPage;
|
||||
} else {
|
||||
SDEBUG("HTTP request resource not found");
|
||||
@@ -754,7 +754,7 @@ void MjpegServerImpl::ConnThread::ProcessRequest() {
|
||||
|
||||
// Read the rest of the HTTP request.
|
||||
// The end of the request is marked by a single, empty line
|
||||
llvm::SmallString<128> lineBuf;
|
||||
wpi::SmallString<128> lineBuf;
|
||||
for (;;) {
|
||||
if (is.getline(lineBuf, 4096).startswith("\n")) break;
|
||||
if (is.has_error()) return;
|
||||
@@ -888,9 +888,9 @@ void MjpegServerImpl::SetSourceImpl(std::shared_ptr<SourceImpl> source) {
|
||||
|
||||
namespace cs {
|
||||
|
||||
CS_Sink CreateMjpegServer(llvm::StringRef name, llvm::StringRef listenAddress,
|
||||
CS_Sink CreateMjpegServer(wpi::StringRef name, wpi::StringRef listenAddress,
|
||||
int port, CS_Status* status) {
|
||||
llvm::SmallString<128> str{listenAddress};
|
||||
wpi::SmallString<128> str{listenAddress};
|
||||
auto sink = std::make_shared<MjpegServerImpl>(
|
||||
name, listenAddress, port,
|
||||
std::unique_ptr<wpi::NetworkAcceptor>(
|
||||
|
||||
@@ -14,14 +14,14 @@
|
||||
#include <thread>
|
||||
#include <vector>
|
||||
|
||||
#include <llvm/SmallVector.h>
|
||||
#include <llvm/StringRef.h>
|
||||
#include <llvm/raw_ostream.h>
|
||||
#include <support/SafeThread.h>
|
||||
#include <support/raw_istream.h>
|
||||
#include <support/raw_socket_ostream.h>
|
||||
#include <tcpsockets/NetworkAcceptor.h>
|
||||
#include <tcpsockets/NetworkStream.h>
|
||||
#include <wpi/NetworkAcceptor.h>
|
||||
#include <wpi/NetworkStream.h>
|
||||
#include <wpi/SafeThread.h>
|
||||
#include <wpi/SmallVector.h>
|
||||
#include <wpi/StringRef.h>
|
||||
#include <wpi/raw_istream.h>
|
||||
#include <wpi/raw_ostream.h>
|
||||
#include <wpi/raw_socket_ostream.h>
|
||||
|
||||
#include "SinkImpl.h"
|
||||
|
||||
@@ -31,7 +31,7 @@ class SourceImpl;
|
||||
|
||||
class MjpegServerImpl : public SinkImpl {
|
||||
public:
|
||||
MjpegServerImpl(llvm::StringRef name, llvm::StringRef listenAddress, int port,
|
||||
MjpegServerImpl(wpi::StringRef name, wpi::StringRef listenAddress, int port,
|
||||
std::unique_ptr<wpi::NetworkAcceptor> acceptor);
|
||||
~MjpegServerImpl() override;
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
#ifndef CSCORE_NETWORKLISTENER_H_
|
||||
#define CSCORE_NETWORKLISTENER_H_
|
||||
|
||||
#include <support/SafeThread.h>
|
||||
#include <wpi/SafeThread.h>
|
||||
|
||||
namespace cs {
|
||||
|
||||
|
||||
@@ -151,7 +151,7 @@ void Notifier::RemoveListener(int uid) {
|
||||
thr->m_listeners.erase(uid);
|
||||
}
|
||||
|
||||
void Notifier::NotifySource(llvm::StringRef name, CS_Source source,
|
||||
void Notifier::NotifySource(wpi::StringRef name, CS_Source source,
|
||||
CS_EventKind kind) {
|
||||
auto thr = m_owner.GetThread();
|
||||
if (!thr) return;
|
||||
@@ -176,9 +176,9 @@ void Notifier::NotifySourceVideoMode(const SourceImpl& source,
|
||||
}
|
||||
|
||||
void Notifier::NotifySourceProperty(const SourceImpl& source, CS_EventKind kind,
|
||||
llvm::StringRef propertyName, int property,
|
||||
wpi::StringRef propertyName, int property,
|
||||
CS_PropertyKind propertyKind, int value,
|
||||
llvm::StringRef valueStr) {
|
||||
wpi::StringRef valueStr) {
|
||||
auto thr = m_owner.GetThread();
|
||||
if (!thr) return;
|
||||
|
||||
@@ -191,7 +191,7 @@ void Notifier::NotifySourceProperty(const SourceImpl& source, CS_EventKind kind,
|
||||
thr->m_cond.notify_one();
|
||||
}
|
||||
|
||||
void Notifier::NotifySink(llvm::StringRef name, CS_Sink sink,
|
||||
void Notifier::NotifySink(wpi::StringRef name, CS_Sink sink,
|
||||
CS_EventKind kind) {
|
||||
auto thr = m_owner.GetThread();
|
||||
if (!thr) return;
|
||||
@@ -205,7 +205,7 @@ void Notifier::NotifySink(const SinkImpl& sink, CS_EventKind kind) {
|
||||
NotifySink(sink.GetName(), handleData.first, kind);
|
||||
}
|
||||
|
||||
void Notifier::NotifySinkSourceChanged(llvm::StringRef name, CS_Sink sink,
|
||||
void Notifier::NotifySinkSourceChanged(wpi::StringRef name, CS_Sink sink,
|
||||
CS_Source source) {
|
||||
auto thr = m_owner.GetThread();
|
||||
if (!thr) return;
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
|
||||
#include <functional>
|
||||
|
||||
#include <support/SafeThread.h>
|
||||
#include <wpi/SafeThread.h>
|
||||
|
||||
#include "cscore_cpp.h"
|
||||
|
||||
@@ -42,16 +42,16 @@ class Notifier {
|
||||
void RemoveListener(int uid);
|
||||
|
||||
// Notification events
|
||||
void NotifySource(llvm::StringRef name, CS_Source source, CS_EventKind kind);
|
||||
void NotifySource(wpi::StringRef name, CS_Source source, CS_EventKind kind);
|
||||
void NotifySource(const SourceImpl& source, CS_EventKind kind);
|
||||
void NotifySourceVideoMode(const SourceImpl& source, const VideoMode& mode);
|
||||
void NotifySourceProperty(const SourceImpl& source, CS_EventKind kind,
|
||||
llvm::StringRef propertyName, int property,
|
||||
wpi::StringRef propertyName, int property,
|
||||
CS_PropertyKind propertyKind, int value,
|
||||
llvm::StringRef valueStr);
|
||||
void NotifySink(llvm::StringRef name, CS_Sink sink, CS_EventKind kind);
|
||||
wpi::StringRef valueStr);
|
||||
void NotifySink(wpi::StringRef name, CS_Sink sink, CS_EventKind kind);
|
||||
void NotifySink(const SinkImpl& sink, CS_EventKind kind);
|
||||
void NotifySinkSourceChanged(llvm::StringRef name, CS_Sink sink,
|
||||
void NotifySinkSourceChanged(wpi::StringRef name, CS_Sink sink,
|
||||
CS_Source source);
|
||||
void NotifyNetworkInterfacesChanged();
|
||||
void NotifyTelemetryUpdated();
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include <llvm/StringRef.h>
|
||||
#include <wpi/StringRef.h>
|
||||
|
||||
#include "cscore_c.h"
|
||||
|
||||
@@ -21,8 +21,8 @@ namespace cs {
|
||||
class PropertyImpl {
|
||||
public:
|
||||
PropertyImpl() = default;
|
||||
explicit PropertyImpl(llvm::StringRef name_) : name{name_} {}
|
||||
PropertyImpl(llvm::StringRef name_, CS_PropertyKind kind_, int step_,
|
||||
explicit PropertyImpl(wpi::StringRef name_) : name{name_} {}
|
||||
PropertyImpl(wpi::StringRef name_, CS_PropertyKind kind_, int step_,
|
||||
int defaultValue_, int value_)
|
||||
: name{name_},
|
||||
propKind{kind_},
|
||||
@@ -43,7 +43,7 @@ class PropertyImpl {
|
||||
valueSet = true;
|
||||
}
|
||||
|
||||
void SetValue(llvm::StringRef v) {
|
||||
void SetValue(wpi::StringRef v) {
|
||||
valueStr = v;
|
||||
valueSet = true;
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
|
||||
using namespace cs;
|
||||
|
||||
SinkImpl::SinkImpl(llvm::StringRef name) : m_name{name} {}
|
||||
SinkImpl::SinkImpl(wpi::StringRef name) : m_name{name} {}
|
||||
|
||||
SinkImpl::~SinkImpl() {
|
||||
if (m_source) {
|
||||
@@ -21,16 +21,16 @@ SinkImpl::~SinkImpl() {
|
||||
}
|
||||
}
|
||||
|
||||
void SinkImpl::SetDescription(llvm::StringRef description) {
|
||||
void SinkImpl::SetDescription(wpi::StringRef description) {
|
||||
std::lock_guard<wpi::mutex> lock(m_mutex);
|
||||
m_description = description;
|
||||
}
|
||||
|
||||
llvm::StringRef SinkImpl::GetDescription(
|
||||
llvm::SmallVectorImpl<char>& buf) const {
|
||||
wpi::StringRef SinkImpl::GetDescription(
|
||||
wpi::SmallVectorImpl<char>& buf) const {
|
||||
std::lock_guard<wpi::mutex> lock(m_mutex);
|
||||
buf.append(m_description.begin(), m_description.end());
|
||||
return llvm::StringRef{buf.data(), buf.size()};
|
||||
return wpi::StringRef{buf.data(), buf.size()};
|
||||
}
|
||||
|
||||
void SinkImpl::Enable() {
|
||||
@@ -87,14 +87,14 @@ std::string SinkImpl::GetError() const {
|
||||
return m_source->GetCurFrame().GetError();
|
||||
}
|
||||
|
||||
llvm::StringRef SinkImpl::GetError(llvm::SmallVectorImpl<char>& buf) const {
|
||||
wpi::StringRef SinkImpl::GetError(wpi::SmallVectorImpl<char>& buf) const {
|
||||
std::lock_guard<wpi::mutex> lock(m_mutex);
|
||||
if (!m_source) return "no source connected";
|
||||
// Make a copy as it's shared data
|
||||
llvm::StringRef error = m_source->GetCurFrame().GetError();
|
||||
wpi::StringRef error = m_source->GetCurFrame().GetError();
|
||||
buf.clear();
|
||||
buf.append(error.data(), error.data() + error.size());
|
||||
return llvm::StringRef{buf.data(), buf.size()};
|
||||
return wpi::StringRef{buf.data(), buf.size()};
|
||||
}
|
||||
|
||||
void SinkImpl::SetSourceImpl(std::shared_ptr<SourceImpl> source) {}
|
||||
|
||||
@@ -11,8 +11,8 @@
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
#include <llvm/StringRef.h>
|
||||
#include <support/mutex.h>
|
||||
#include <wpi/StringRef.h>
|
||||
#include <wpi/mutex.h>
|
||||
|
||||
#include "SourceImpl.h"
|
||||
|
||||
@@ -22,15 +22,15 @@ class Frame;
|
||||
|
||||
class SinkImpl {
|
||||
public:
|
||||
explicit SinkImpl(llvm::StringRef name);
|
||||
explicit SinkImpl(wpi::StringRef name);
|
||||
virtual ~SinkImpl();
|
||||
SinkImpl(const SinkImpl& queue) = delete;
|
||||
SinkImpl& operator=(const SinkImpl& queue) = delete;
|
||||
|
||||
llvm::StringRef GetName() const { return m_name; }
|
||||
wpi::StringRef GetName() const { return m_name; }
|
||||
|
||||
void SetDescription(llvm::StringRef description);
|
||||
llvm::StringRef GetDescription(llvm::SmallVectorImpl<char>& buf) const;
|
||||
void SetDescription(wpi::StringRef description);
|
||||
wpi::StringRef GetDescription(wpi::SmallVectorImpl<char>& buf) const;
|
||||
|
||||
void Enable();
|
||||
void Disable();
|
||||
@@ -44,7 +44,7 @@ class SinkImpl {
|
||||
}
|
||||
|
||||
std::string GetError() const;
|
||||
llvm::StringRef GetError(llvm::SmallVectorImpl<char>& buf) const;
|
||||
wpi::StringRef GetError(wpi::SmallVectorImpl<char>& buf) const;
|
||||
|
||||
protected:
|
||||
virtual void SetSourceImpl(std::shared_ptr<SourceImpl> source);
|
||||
|
||||
@@ -10,8 +10,8 @@
|
||||
#include <algorithm>
|
||||
#include <cstring>
|
||||
|
||||
#include <llvm/STLExtras.h>
|
||||
#include <support/timestamp.h>
|
||||
#include <wpi/STLExtras.h>
|
||||
#include <wpi/timestamp.h>
|
||||
|
||||
#include "Log.h"
|
||||
#include "Notifier.h"
|
||||
@@ -21,8 +21,8 @@ using namespace cs;
|
||||
|
||||
static constexpr size_t kMaxImagesAvail = 32;
|
||||
|
||||
SourceImpl::SourceImpl(llvm::StringRef name) : m_name{name} {
|
||||
m_frame = Frame{*this, llvm::StringRef{}, 0};
|
||||
SourceImpl::SourceImpl(wpi::StringRef name) : m_name{name} {
|
||||
m_frame = Frame{*this, wpi::StringRef{}, 0};
|
||||
}
|
||||
|
||||
SourceImpl::~SourceImpl() {
|
||||
@@ -38,16 +38,16 @@ SourceImpl::~SourceImpl() {
|
||||
// Everything else can clean up itself.
|
||||
}
|
||||
|
||||
void SourceImpl::SetDescription(llvm::StringRef description) {
|
||||
void SourceImpl::SetDescription(wpi::StringRef description) {
|
||||
std::lock_guard<wpi::mutex> lock(m_mutex);
|
||||
m_description = description;
|
||||
}
|
||||
|
||||
llvm::StringRef SourceImpl::GetDescription(
|
||||
llvm::SmallVectorImpl<char>& buf) const {
|
||||
wpi::StringRef SourceImpl::GetDescription(
|
||||
wpi::SmallVectorImpl<char>& buf) const {
|
||||
std::lock_guard<wpi::mutex> lock(m_mutex);
|
||||
buf.append(m_description.begin(), m_description.end());
|
||||
return llvm::StringRef{buf.data(), buf.size()};
|
||||
return wpi::StringRef{buf.data(), buf.size()};
|
||||
}
|
||||
|
||||
void SourceImpl::SetConnected(bool connected) {
|
||||
@@ -89,12 +89,12 @@ Frame SourceImpl::GetNextFrame(double timeout) {
|
||||
void SourceImpl::Wakeup() {
|
||||
{
|
||||
std::lock_guard<wpi::mutex> lock{m_frameMutex};
|
||||
m_frame = Frame{*this, llvm::StringRef{}, 0};
|
||||
m_frame = Frame{*this, wpi::StringRef{}, 0};
|
||||
}
|
||||
m_frameCv.notify_all();
|
||||
}
|
||||
|
||||
int SourceImpl::GetPropertyIndex(llvm::StringRef name) const {
|
||||
int SourceImpl::GetPropertyIndex(wpi::StringRef name) const {
|
||||
// We can't fail, so instead we create a new index if caching fails.
|
||||
CS_Status status = 0;
|
||||
if (!m_properties_cached) CacheProperties(&status);
|
||||
@@ -108,10 +108,10 @@ int SourceImpl::GetPropertyIndex(llvm::StringRef name) const {
|
||||
return ndx;
|
||||
}
|
||||
|
||||
llvm::ArrayRef<int> SourceImpl::EnumerateProperties(
|
||||
llvm::SmallVectorImpl<int>& vec, CS_Status* status) const {
|
||||
wpi::ArrayRef<int> SourceImpl::EnumerateProperties(
|
||||
wpi::SmallVectorImpl<int>& vec, CS_Status* status) const {
|
||||
if (!m_properties_cached && !CacheProperties(status))
|
||||
return llvm::ArrayRef<int>{};
|
||||
return wpi::ArrayRef<int>{};
|
||||
std::lock_guard<wpi::mutex> lock(m_mutex);
|
||||
for (int i = 0; i < static_cast<int>(m_propertyData.size()); ++i) {
|
||||
if (m_propertyData[i]) vec.push_back(i + 1);
|
||||
@@ -128,16 +128,16 @@ CS_PropertyKind SourceImpl::GetPropertyKind(int property) const {
|
||||
return prop->propKind;
|
||||
}
|
||||
|
||||
llvm::StringRef SourceImpl::GetPropertyName(int property,
|
||||
llvm::SmallVectorImpl<char>& buf,
|
||||
CS_Status* status) const {
|
||||
wpi::StringRef SourceImpl::GetPropertyName(int property,
|
||||
wpi::SmallVectorImpl<char>& buf,
|
||||
CS_Status* status) const {
|
||||
if (!m_properties_cached && !CacheProperties(status))
|
||||
return llvm::StringRef{};
|
||||
return wpi::StringRef{};
|
||||
std::lock_guard<wpi::mutex> lock(m_mutex);
|
||||
auto prop = GetProperty(property);
|
||||
if (!prop) {
|
||||
*status = CS_INVALID_PROPERTY;
|
||||
return llvm::StringRef{};
|
||||
return wpi::StringRef{};
|
||||
}
|
||||
// safe to not copy because we never modify it after caching
|
||||
return prop->name;
|
||||
@@ -203,24 +203,24 @@ int SourceImpl::GetPropertyDefault(int property, CS_Status* status) const {
|
||||
return prop->defaultValue;
|
||||
}
|
||||
|
||||
llvm::StringRef SourceImpl::GetStringProperty(int property,
|
||||
llvm::SmallVectorImpl<char>& buf,
|
||||
CS_Status* status) const {
|
||||
wpi::StringRef SourceImpl::GetStringProperty(int property,
|
||||
wpi::SmallVectorImpl<char>& buf,
|
||||
CS_Status* status) const {
|
||||
if (!m_properties_cached && !CacheProperties(status))
|
||||
return llvm::StringRef{};
|
||||
return wpi::StringRef{};
|
||||
std::lock_guard<wpi::mutex> lock(m_mutex);
|
||||
auto prop = GetProperty(property);
|
||||
if (!prop) {
|
||||
*status = CS_INVALID_PROPERTY;
|
||||
return llvm::StringRef{};
|
||||
return wpi::StringRef{};
|
||||
}
|
||||
if (prop->propKind != CS_PROP_STRING) {
|
||||
*status = CS_WRONG_PROPERTY_TYPE;
|
||||
return llvm::StringRef{};
|
||||
return wpi::StringRef{};
|
||||
}
|
||||
buf.clear();
|
||||
buf.append(prop->valueStr.begin(), prop->valueStr.end());
|
||||
return llvm::StringRef(buf.data(), buf.size());
|
||||
return wpi::StringRef(buf.data(), buf.size());
|
||||
}
|
||||
|
||||
std::vector<std::string> SourceImpl::GetEnumPropertyChoices(
|
||||
@@ -313,7 +313,7 @@ std::unique_ptr<Image> SourceImpl::AllocImage(
|
||||
}
|
||||
|
||||
void SourceImpl::PutFrame(VideoMode::PixelFormat pixelFormat, int width,
|
||||
int height, llvm::StringRef data, Frame::Time time) {
|
||||
int height, wpi::StringRef data, Frame::Time time) {
|
||||
auto image = AllocImage(pixelFormat, width, height, data.size());
|
||||
|
||||
// Copy in image data
|
||||
@@ -342,7 +342,7 @@ void SourceImpl::PutFrame(std::unique_ptr<Image> image, Frame::Time time) {
|
||||
m_frameCv.notify_all();
|
||||
}
|
||||
|
||||
void SourceImpl::PutError(llvm::StringRef msg, Frame::Time time) {
|
||||
void SourceImpl::PutError(wpi::StringRef msg, Frame::Time time) {
|
||||
// Update frame
|
||||
{
|
||||
std::lock_guard<wpi::mutex> lock{m_frameMutex};
|
||||
@@ -362,11 +362,11 @@ void SourceImpl::NotifyPropertyCreated(int propIndex, PropertyImpl& prop) {
|
||||
if (prop.propKind == CS_PROP_ENUM)
|
||||
notifier.NotifySourceProperty(*this, CS_SOURCE_PROPERTY_CHOICES_UPDATED,
|
||||
prop.name, propIndex, prop.propKind,
|
||||
prop.value, llvm::StringRef{});
|
||||
prop.value, wpi::StringRef{});
|
||||
}
|
||||
|
||||
void SourceImpl::UpdatePropertyValue(int property, bool setString, int value,
|
||||
llvm::StringRef valueStr) {
|
||||
wpi::StringRef valueStr) {
|
||||
auto prop = GetProperty(property);
|
||||
if (!prop) return;
|
||||
|
||||
@@ -407,7 +407,7 @@ void SourceImpl::ReleaseImage(std::unique_ptr<Image> image) {
|
||||
std::unique_ptr<Frame::Impl> SourceImpl::AllocFrameImpl() {
|
||||
std::lock_guard<wpi::mutex> lock{m_poolMutex};
|
||||
|
||||
if (m_framesAvail.empty()) return llvm::make_unique<Frame::Impl>(*this);
|
||||
if (m_framesAvail.empty()) return wpi::make_unique<Frame::Impl>(*this);
|
||||
|
||||
auto impl = std::move(m_framesAvail.back());
|
||||
m_framesAvail.pop_back();
|
||||
|
||||
@@ -14,11 +14,11 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include <llvm/ArrayRef.h>
|
||||
#include <llvm/StringMap.h>
|
||||
#include <llvm/StringRef.h>
|
||||
#include <support/condition_variable.h>
|
||||
#include <support/mutex.h>
|
||||
#include <wpi/ArrayRef.h>
|
||||
#include <wpi/StringMap.h>
|
||||
#include <wpi/StringRef.h>
|
||||
#include <wpi/condition_variable.h>
|
||||
#include <wpi/mutex.h>
|
||||
|
||||
#include "Frame.h"
|
||||
#include "Image.h"
|
||||
@@ -31,15 +31,15 @@ class SourceImpl {
|
||||
friend class Frame;
|
||||
|
||||
public:
|
||||
explicit SourceImpl(llvm::StringRef name);
|
||||
explicit SourceImpl(wpi::StringRef name);
|
||||
virtual ~SourceImpl();
|
||||
SourceImpl(const SourceImpl& oth) = delete;
|
||||
SourceImpl& operator=(const SourceImpl& oth) = delete;
|
||||
|
||||
llvm::StringRef GetName() const { return m_name; }
|
||||
wpi::StringRef GetName() const { return m_name; }
|
||||
|
||||
void SetDescription(llvm::StringRef description);
|
||||
llvm::StringRef GetDescription(llvm::SmallVectorImpl<char>& buf) const;
|
||||
void SetDescription(wpi::StringRef description);
|
||||
wpi::StringRef GetDescription(wpi::SmallVectorImpl<char>& buf) const;
|
||||
|
||||
void SetConnected(bool connected);
|
||||
bool IsConnected() const { return m_connected; }
|
||||
@@ -90,23 +90,23 @@ class SourceImpl {
|
||||
void Wakeup();
|
||||
|
||||
// Property functions
|
||||
int GetPropertyIndex(llvm::StringRef name) const;
|
||||
llvm::ArrayRef<int> EnumerateProperties(llvm::SmallVectorImpl<int>& vec,
|
||||
CS_Status* status) const;
|
||||
int GetPropertyIndex(wpi::StringRef name) const;
|
||||
wpi::ArrayRef<int> EnumerateProperties(wpi::SmallVectorImpl<int>& vec,
|
||||
CS_Status* status) const;
|
||||
CS_PropertyKind GetPropertyKind(int property) const;
|
||||
llvm::StringRef GetPropertyName(int property,
|
||||
llvm::SmallVectorImpl<char>& buf,
|
||||
CS_Status* status) const;
|
||||
wpi::StringRef GetPropertyName(int property,
|
||||
wpi::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) = 0;
|
||||
int GetPropertyMin(int property, CS_Status* status) const;
|
||||
int GetPropertyMax(int property, CS_Status* status) const;
|
||||
int GetPropertyStep(int property, CS_Status* status) const;
|
||||
int GetPropertyDefault(int property, CS_Status* status) const;
|
||||
llvm::StringRef GetStringProperty(int property,
|
||||
llvm::SmallVectorImpl<char>& buf,
|
||||
CS_Status* status) const;
|
||||
virtual void SetStringProperty(int property, llvm::StringRef value,
|
||||
wpi::StringRef GetStringProperty(int property,
|
||||
wpi::SmallVectorImpl<char>& buf,
|
||||
CS_Status* status) const;
|
||||
virtual void SetStringProperty(int property, wpi::StringRef value,
|
||||
CS_Status* status) = 0;
|
||||
std::vector<std::string> GetEnumPropertyChoices(int property,
|
||||
CS_Status* status) const;
|
||||
@@ -139,9 +139,9 @@ class SourceImpl {
|
||||
|
||||
protected:
|
||||
void PutFrame(VideoMode::PixelFormat pixelFormat, int width, int height,
|
||||
llvm::StringRef data, Frame::Time time);
|
||||
wpi::StringRef data, Frame::Time time);
|
||||
void PutFrame(std::unique_ptr<Image> image, Frame::Time time);
|
||||
void PutError(llvm::StringRef msg, Frame::Time time);
|
||||
void PutError(wpi::StringRef msg, Frame::Time time);
|
||||
|
||||
// Notification functions for corresponding atomics
|
||||
virtual void NumSinksChanged() = 0;
|
||||
@@ -167,7 +167,7 @@ class SourceImpl {
|
||||
// properties that don't exist (as GetPropertyIndex can't fail).
|
||||
// Note: called with m_mutex held.
|
||||
virtual std::unique_ptr<PropertyImpl> CreateEmptyProperty(
|
||||
llvm::StringRef name) const = 0;
|
||||
wpi::StringRef name) const = 0;
|
||||
|
||||
// Cache properties. Implementations must return false and set status to
|
||||
// CS_SOURCE_IS_DISCONNECTED if not possible to cache.
|
||||
@@ -177,11 +177,11 @@ class SourceImpl {
|
||||
|
||||
// Update property value; must be called with m_mutex held.
|
||||
void UpdatePropertyValue(int property, bool setString, int value,
|
||||
llvm::StringRef valueStr);
|
||||
wpi::StringRef valueStr);
|
||||
|
||||
// Cached properties and video modes (protected with m_mutex)
|
||||
mutable std::vector<std::unique_ptr<PropertyImpl>> m_propertyData;
|
||||
mutable llvm::StringMap<int> m_properties;
|
||||
mutable wpi::StringMap<int> m_properties;
|
||||
mutable std::vector<VideoMode> m_videoModes;
|
||||
// Current video mode
|
||||
mutable VideoMode m_mode;
|
||||
|
||||
@@ -10,8 +10,8 @@
|
||||
#include <chrono>
|
||||
#include <limits>
|
||||
|
||||
#include <llvm/DenseMap.h>
|
||||
#include <support/timestamp.h>
|
||||
#include <wpi/DenseMap.h>
|
||||
#include <wpi/timestamp.h>
|
||||
|
||||
#include "Handle.h"
|
||||
#include "Notifier.h"
|
||||
@@ -23,8 +23,8 @@ class Telemetry::Thread : public wpi::SafeThread {
|
||||
public:
|
||||
void Main();
|
||||
|
||||
llvm::DenseMap<std::pair<CS_Handle, int>, int64_t> m_user;
|
||||
llvm::DenseMap<std::pair<CS_Handle, int>, int64_t> m_current;
|
||||
wpi::DenseMap<std::pair<CS_Handle, int>, int64_t> m_user;
|
||||
wpi::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 @@
|
||||
#ifndef CSCORE_TELEMETRY_H_
|
||||
#define CSCORE_TELEMETRY_H_
|
||||
|
||||
#include <support/SafeThread.h>
|
||||
#include <wpi/SafeThread.h>
|
||||
|
||||
#include "cscore_cpp.h"
|
||||
|
||||
|
||||
@@ -12,9 +12,9 @@
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include <llvm/ArrayRef.h>
|
||||
#include <llvm/SmallVector.h>
|
||||
#include <support/mutex.h>
|
||||
#include <wpi/ArrayRef.h>
|
||||
#include <wpi/SmallVector.h>
|
||||
#include <wpi/mutex.h>
|
||||
|
||||
namespace cs {
|
||||
|
||||
@@ -53,7 +53,7 @@ class UnlimitedHandleResource {
|
||||
void Free(THandle handle);
|
||||
|
||||
template <typename T>
|
||||
llvm::ArrayRef<T> GetAll(llvm::SmallVectorImpl<T>& vec);
|
||||
wpi::ArrayRef<T> GetAll(wpi::SmallVectorImpl<T>& vec);
|
||||
|
||||
// @param func functor with (THandle, const TStruct&) parameters
|
||||
template <typename F>
|
||||
@@ -133,9 +133,9 @@ inline void UnlimitedHandleResource<THandle, TStruct, typeValue, TMutex>::Free(
|
||||
|
||||
template <typename THandle, typename TStruct, int typeValue, typename TMutex>
|
||||
template <typename T>
|
||||
inline llvm::ArrayRef<T>
|
||||
inline wpi::ArrayRef<T>
|
||||
UnlimitedHandleResource<THandle, TStruct, typeValue, TMutex>::GetAll(
|
||||
llvm::SmallVectorImpl<T>& vec) {
|
||||
wpi::SmallVectorImpl<T>& vec) {
|
||||
ForEach([&](THandle handle, const TStruct& data) { vec.push_back(handle); });
|
||||
return vec;
|
||||
}
|
||||
|
||||
@@ -27,9 +27,9 @@
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#include <llvm/SmallString.h>
|
||||
#include <llvm/raw_ostream.h>
|
||||
#include <support/timestamp.h>
|
||||
#include <wpi/SmallString.h>
|
||||
#include <wpi/raw_ostream.h>
|
||||
#include <wpi/timestamp.h>
|
||||
|
||||
#include "Handle.h"
|
||||
#include "Log.h"
|
||||
@@ -97,7 +97,7 @@ static __u32 FromPixelFormat(VideoMode::PixelFormat pixelFormat) {
|
||||
}
|
||||
}
|
||||
|
||||
static bool IsPercentageProperty(llvm::StringRef name) {
|
||||
static bool IsPercentageProperty(wpi::StringRef name) {
|
||||
if (name.startswith("raw_")) name = name.substr(4);
|
||||
return name == "brightness" || name == "contrast" || name == "saturation" ||
|
||||
name == "hue" || name == "sharpness" || name == "gain" ||
|
||||
@@ -112,7 +112,7 @@ int UsbCameraImpl::RawToPercentage(const UsbCameraProperty& rawProp,
|
||||
// LifeCam exposure setting quirk
|
||||
if (m_lifecam_exposure && rawProp.name == "raw_exposure_absolute" &&
|
||||
rawProp.minimum == 5 && rawProp.maximum == 20000) {
|
||||
int nelems = llvm::array_lengthof(quirkLifeCamHd3000);
|
||||
int nelems = wpi::array_lengthof(quirkLifeCamHd3000);
|
||||
for (int i = 0; i < nelems; ++i) {
|
||||
if (rawValue < quirkLifeCamHd3000[i]) return 100.0 * i / nelems;
|
||||
}
|
||||
@@ -127,7 +127,7 @@ int UsbCameraImpl::PercentageToRaw(const UsbCameraProperty& rawProp,
|
||||
// LifeCam exposure setting quirk
|
||||
if (m_lifecam_exposure && rawProp.name == "raw_exposure_absolute" &&
|
||||
rawProp.minimum == 5 && rawProp.maximum == 20000) {
|
||||
int nelems = llvm::array_lengthof(quirkLifeCamHd3000);
|
||||
int nelems = wpi::array_lengthof(quirkLifeCamHd3000);
|
||||
int ndx = nelems * percentValue / 100.0;
|
||||
if (ndx < 0) ndx = 0;
|
||||
if (ndx >= nelems) ndx = nelems - 1;
|
||||
@@ -137,8 +137,8 @@ int UsbCameraImpl::PercentageToRaw(const UsbCameraProperty& rawProp,
|
||||
(rawProp.maximum - rawProp.minimum) * (percentValue / 100.0);
|
||||
}
|
||||
|
||||
static bool GetDescriptionSysV4L(llvm::StringRef path, std::string* desc) {
|
||||
llvm::SmallString<64> ifpath{"/sys/class/video4linux/"};
|
||||
static bool GetDescriptionSysV4L(wpi::StringRef path, std::string* desc) {
|
||||
wpi::SmallString<64> ifpath{"/sys/class/video4linux/"};
|
||||
ifpath += path.substr(5);
|
||||
ifpath += "/device/interface";
|
||||
|
||||
@@ -151,7 +151,7 @@ static bool GetDescriptionSysV4L(llvm::StringRef path, std::string* desc) {
|
||||
|
||||
if (n <= 0) return false;
|
||||
|
||||
*desc = llvm::StringRef(readBuf, n).rtrim();
|
||||
*desc = wpi::StringRef(readBuf, n).rtrim();
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -167,15 +167,15 @@ static bool GetDescriptionIoctl(const char* cpath, std::string* desc) {
|
||||
}
|
||||
close(fd);
|
||||
|
||||
llvm::StringRef card{reinterpret_cast<const char*>(vcap.card)};
|
||||
wpi::StringRef card{reinterpret_cast<const char*>(vcap.card)};
|
||||
// try to convert "UVC Camera (0000:0000)" into a better name
|
||||
int vendor = 0;
|
||||
int product = 0;
|
||||
if (card.startswith("UVC Camera (") &&
|
||||
!card.substr(12, 4).getAsInteger(16, vendor) &&
|
||||
!card.substr(17, 4).getAsInteger(16, product)) {
|
||||
llvm::SmallString<64> card2Buf;
|
||||
llvm::StringRef card2 = GetUsbNameFromId(vendor, product, card2Buf);
|
||||
wpi::SmallString<64> card2Buf;
|
||||
wpi::StringRef card2 = GetUsbNameFromId(vendor, product, card2Buf);
|
||||
if (!card2.empty()) {
|
||||
*desc = card2;
|
||||
return true;
|
||||
@@ -187,17 +187,17 @@ static bool GetDescriptionIoctl(const char* cpath, std::string* desc) {
|
||||
}
|
||||
|
||||
static std::string GetDescriptionImpl(const char* cpath) {
|
||||
llvm::StringRef path{cpath};
|
||||
wpi::StringRef path{cpath};
|
||||
char pathBuf[128];
|
||||
std::string rv;
|
||||
|
||||
// If trying to get by id or path, follow symlink
|
||||
if (path.startswith("/dev/v4l/by-id/")) {
|
||||
ssize_t n = readlink(cpath, pathBuf, sizeof(pathBuf));
|
||||
if (n > 0) path = llvm::StringRef(pathBuf, n);
|
||||
if (n > 0) path = wpi::StringRef(pathBuf, n);
|
||||
} else if (path.startswith("/dev/v4l/by-path/")) {
|
||||
ssize_t n = readlink(cpath, pathBuf, sizeof(pathBuf));
|
||||
if (n > 0) path = llvm::StringRef(pathBuf, n);
|
||||
if (n > 0) path = wpi::StringRef(pathBuf, n);
|
||||
}
|
||||
|
||||
if (path.startswith("/dev/video")) {
|
||||
@@ -211,7 +211,7 @@ static std::string GetDescriptionImpl(const char* cpath) {
|
||||
return std::string{};
|
||||
}
|
||||
|
||||
UsbCameraImpl::UsbCameraImpl(llvm::StringRef name, llvm::StringRef path)
|
||||
UsbCameraImpl::UsbCameraImpl(wpi::StringRef name, wpi::StringRef path)
|
||||
: SourceImpl{name},
|
||||
m_path{path},
|
||||
m_fd{-1},
|
||||
@@ -258,7 +258,7 @@ void UsbCameraImpl::CameraThreadMain() {
|
||||
int notify_fd = inotify_init();
|
||||
if (notify_fd >= 0) {
|
||||
// need to make a copy as dirname can modify it
|
||||
llvm::SmallString<64> pathCopy{m_path};
|
||||
wpi::SmallString<64> pathCopy{m_path};
|
||||
pathCopy.push_back('\0');
|
||||
if (inotify_add_watch(notify_fd, dirname(pathCopy.data()),
|
||||
IN_CREATE | IN_DELETE) < 0) {
|
||||
@@ -272,9 +272,9 @@ void UsbCameraImpl::CameraThreadMain() {
|
||||
bool notified = (notify_fd < 0); // treat as always notified if cannot notify
|
||||
|
||||
// Get the basename for later notify use
|
||||
llvm::SmallString<64> pathCopy{m_path};
|
||||
wpi::SmallString<64> pathCopy{m_path};
|
||||
pathCopy.push_back('\0');
|
||||
llvm::SmallString<64> base{basename(pathCopy.data())};
|
||||
wpi::SmallString<64> base{basename(pathCopy.data())};
|
||||
|
||||
// Used to restart streaming on reconnect
|
||||
bool wasStreaming = false;
|
||||
@@ -341,11 +341,11 @@ void UsbCameraImpl::CameraThreadMain() {
|
||||
// Read the event structure
|
||||
notify_is->read(&event, sizeof(event));
|
||||
// Read the event name
|
||||
llvm::SmallString<64> raw_name;
|
||||
wpi::SmallString<64> raw_name;
|
||||
raw_name.resize(event.len);
|
||||
notify_is->read(raw_name.data(), event.len);
|
||||
// If the name is what we expect...
|
||||
llvm::StringRef name{raw_name.c_str()};
|
||||
wpi::StringRef name{raw_name.c_str()};
|
||||
SDEBUG4("got event on '" << name << "' (" << name.size()
|
||||
<< ") compare to '" << base << "' ("
|
||||
<< base.size() << ") mask " << event.mask);
|
||||
@@ -401,7 +401,7 @@ void UsbCameraImpl::CameraThreadMain() {
|
||||
|
||||
PutFrame(static_cast<VideoMode::PixelFormat>(m_mode.pixelFormat),
|
||||
m_mode.width, m_mode.height,
|
||||
llvm::StringRef(
|
||||
wpi::StringRef(
|
||||
static_cast<const char*>(m_buffers[buf.index].m_data),
|
||||
static_cast<size_t>(buf.bytesused)),
|
||||
wpi::Now()); // TODO: time
|
||||
@@ -649,7 +649,7 @@ CS_StatusValue UsbCameraImpl::DeviceCmdSetProperty(
|
||||
bool setString = (msg.kind == Message::kCmdSetPropertyStr);
|
||||
int property = msg.data[0];
|
||||
int value = msg.data[1];
|
||||
llvm::StringRef valueStr = msg.dataStr;
|
||||
wpi::StringRef valueStr = msg.dataStr;
|
||||
|
||||
// Look up
|
||||
auto prop = static_cast<UsbCameraProperty*>(GetProperty(property));
|
||||
@@ -885,7 +885,7 @@ void UsbCameraImpl::DeviceCacheProperty(
|
||||
std::unique_ptr<UsbCameraProperty> perProp;
|
||||
if (IsPercentageProperty(rawProp->name)) {
|
||||
perProp =
|
||||
llvm::make_unique<UsbCameraProperty>(rawProp->name, 0, *rawProp, 0, 0);
|
||||
wpi::make_unique<UsbCameraProperty>(rawProp->name, 0, *rawProp, 0, 0);
|
||||
rawProp->name = "raw_" + perProp->name;
|
||||
}
|
||||
|
||||
@@ -1107,8 +1107,8 @@ void UsbCameraImpl::Send(Message&& msg) const {
|
||||
}
|
||||
|
||||
std::unique_ptr<PropertyImpl> UsbCameraImpl::CreateEmptyProperty(
|
||||
llvm::StringRef name) const {
|
||||
return llvm::make_unique<UsbCameraProperty>(name);
|
||||
wpi::StringRef name) const {
|
||||
return wpi::make_unique<UsbCameraProperty>(name);
|
||||
}
|
||||
|
||||
bool UsbCameraImpl::CacheProperties(CS_Status* status) const {
|
||||
@@ -1123,8 +1123,8 @@ bool UsbCameraImpl::CacheProperties(CS_Status* status) const {
|
||||
}
|
||||
|
||||
void UsbCameraImpl::SetQuirks() {
|
||||
llvm::SmallString<128> descbuf;
|
||||
llvm::StringRef desc = GetDescription(descbuf);
|
||||
wpi::SmallString<128> descbuf;
|
||||
wpi::StringRef desc = GetDescription(descbuf);
|
||||
m_lifecam_exposure =
|
||||
desc.endswith("LifeCam HD-3000") || desc.endswith("LifeCam Cinema (TM)");
|
||||
}
|
||||
@@ -1136,7 +1136,7 @@ void UsbCameraImpl::SetProperty(int property, int value, CS_Status* status) {
|
||||
*status = SendAndWait(std::move(msg));
|
||||
}
|
||||
|
||||
void UsbCameraImpl::SetStringProperty(int property, llvm::StringRef value,
|
||||
void UsbCameraImpl::SetStringProperty(int property, wpi::StringRef value,
|
||||
CS_Status* status) {
|
||||
Message msg{Message::kCmdSetPropertyStr};
|
||||
msg.data[0] = property;
|
||||
@@ -1232,14 +1232,14 @@ void UsbCameraImpl::NumSinksEnabledChanged() {
|
||||
|
||||
namespace cs {
|
||||
|
||||
CS_Source CreateUsbCameraDev(llvm::StringRef name, int dev, CS_Status* status) {
|
||||
llvm::SmallString<32> path;
|
||||
llvm::raw_svector_ostream oss{path};
|
||||
CS_Source CreateUsbCameraDev(wpi::StringRef name, int dev, CS_Status* status) {
|
||||
wpi::SmallString<32> path;
|
||||
wpi::raw_svector_ostream oss{path};
|
||||
oss << "/dev/video" << dev;
|
||||
return CreateUsbCameraPath(name, oss.str(), status);
|
||||
}
|
||||
|
||||
CS_Source CreateUsbCameraPath(llvm::StringRef name, llvm::StringRef path,
|
||||
CS_Source CreateUsbCameraPath(wpi::StringRef name, wpi::StringRef path,
|
||||
CS_Status* status) {
|
||||
auto source = std::make_shared<UsbCameraImpl>(name, path);
|
||||
auto handle = Sources::GetInstance().Allocate(CS_SOURCE_USB, source);
|
||||
@@ -1264,13 +1264,13 @@ std::vector<UsbCameraInfo> EnumerateUsbCameras(CS_Status* status) {
|
||||
|
||||
if (DIR* dp = opendir("/dev")) {
|
||||
while (struct dirent* ep = readdir(dp)) {
|
||||
llvm::StringRef fname{ep->d_name};
|
||||
wpi::StringRef fname{ep->d_name};
|
||||
if (!fname.startswith("video")) continue;
|
||||
|
||||
UsbCameraInfo info;
|
||||
info.dev = -1;
|
||||
fname.substr(5).getAsInteger(10, info.dev);
|
||||
llvm::SmallString<32> path{"/dev/"};
|
||||
wpi::SmallString<32> path{"/dev/"};
|
||||
path += fname;
|
||||
info.path = path.str();
|
||||
|
||||
|
||||
@@ -19,12 +19,12 @@
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include <llvm/STLExtras.h>
|
||||
#include <llvm/SmallVector.h>
|
||||
#include <llvm/raw_ostream.h>
|
||||
#include <support/condition_variable.h>
|
||||
#include <support/mutex.h>
|
||||
#include <support/raw_istream.h>
|
||||
#include <wpi/STLExtras.h>
|
||||
#include <wpi/SmallVector.h>
|
||||
#include <wpi/condition_variable.h>
|
||||
#include <wpi/mutex.h>
|
||||
#include <wpi/raw_istream.h>
|
||||
#include <wpi/raw_ostream.h>
|
||||
|
||||
#include "SourceImpl.h"
|
||||
#include "UsbCameraBuffer.h"
|
||||
@@ -34,14 +34,14 @@ namespace cs {
|
||||
|
||||
class UsbCameraImpl : public SourceImpl {
|
||||
public:
|
||||
UsbCameraImpl(llvm::StringRef name, llvm::StringRef path);
|
||||
UsbCameraImpl(wpi::StringRef name, wpi::StringRef path);
|
||||
~UsbCameraImpl() override;
|
||||
|
||||
void Start();
|
||||
|
||||
// Property functions
|
||||
void SetProperty(int property, int value, CS_Status* status) override;
|
||||
void SetStringProperty(int property, llvm::StringRef value,
|
||||
void SetStringProperty(int property, wpi::StringRef value,
|
||||
CS_Status* status) override;
|
||||
|
||||
// Standard common camera properties
|
||||
@@ -93,7 +93,7 @@ class UsbCameraImpl : public SourceImpl {
|
||||
|
||||
protected:
|
||||
std::unique_ptr<PropertyImpl> CreateEmptyProperty(
|
||||
llvm::StringRef name) const override;
|
||||
wpi::StringRef name) const override;
|
||||
|
||||
// Cache properties. Immediately successful if properties are already cached.
|
||||
// If they are not, tries to connect to the camera to do so; returns false and
|
||||
|
||||
@@ -7,8 +7,8 @@
|
||||
|
||||
#include "UsbCameraProperty.h"
|
||||
|
||||
#include <llvm/STLExtras.h>
|
||||
#include <llvm/SmallString.h>
|
||||
#include <wpi/STLExtras.h>
|
||||
#include <wpi/SmallString.h>
|
||||
|
||||
#include "UsbUtil.h"
|
||||
|
||||
@@ -92,8 +92,8 @@ static int GetStringCtrlIoctl(int fd, int id, int maximum, std::string* value) {
|
||||
}
|
||||
|
||||
static int SetStringCtrlIoctl(int fd, int id, int maximum,
|
||||
llvm::StringRef value) {
|
||||
llvm::SmallString<64> str{
|
||||
wpi::StringRef value) {
|
||||
wpi::SmallString<64> str{
|
||||
value.substr(0, std::min(value.size(), static_cast<size_t>(maximum)))};
|
||||
|
||||
struct v4l2_ext_control ctrl;
|
||||
@@ -111,8 +111,8 @@ static int SetStringCtrlIoctl(int fd, int id, int maximum,
|
||||
|
||||
// Removes non-alphanumeric characters and replaces spaces with underscores.
|
||||
// e.g. "Zoom, Absolute" -> "zoom_absolute", "Pan (Absolute)" -> "pan_absolute"
|
||||
static llvm::StringRef NormalizeName(llvm::StringRef name,
|
||||
llvm::SmallVectorImpl<char>& buf) {
|
||||
static wpi::StringRef NormalizeName(wpi::StringRef name,
|
||||
wpi::SmallVectorImpl<char>& buf) {
|
||||
bool newWord = false;
|
||||
for (auto ch : name) {
|
||||
if (std::isalnum(ch)) {
|
||||
@@ -123,12 +123,12 @@ static llvm::StringRef NormalizeName(llvm::StringRef name,
|
||||
newWord = true;
|
||||
}
|
||||
}
|
||||
return llvm::StringRef(buf.data(), buf.size());
|
||||
return wpi::StringRef(buf.data(), buf.size());
|
||||
}
|
||||
|
||||
#ifdef VIDIOC_QUERY_EXT_CTRL
|
||||
UsbCameraProperty::UsbCameraProperty(const struct v4l2_query_ext_ctrl& ctrl)
|
||||
: PropertyImpl(llvm::StringRef{}, CS_PROP_NONE, ctrl.step,
|
||||
: PropertyImpl(wpi::StringRef{}, CS_PROP_NONE, ctrl.step,
|
||||
ctrl.default_value, 0),
|
||||
id(ctrl.id & V4L2_CTRL_ID_MASK),
|
||||
type(ctrl.type) {
|
||||
@@ -160,13 +160,13 @@ UsbCameraProperty::UsbCameraProperty(const struct v4l2_query_ext_ctrl& ctrl)
|
||||
// name
|
||||
size_t len = 0;
|
||||
while (len < sizeof(ctrl.name) && ctrl.name[len] != '\0') ++len;
|
||||
llvm::SmallString<64> name_buf;
|
||||
name = NormalizeName(llvm::StringRef(ctrl.name, len), name_buf);
|
||||
wpi::SmallString<64> name_buf;
|
||||
name = NormalizeName(wpi::StringRef(ctrl.name, len), name_buf);
|
||||
}
|
||||
#endif
|
||||
|
||||
UsbCameraProperty::UsbCameraProperty(const struct v4l2_queryctrl& ctrl)
|
||||
: PropertyImpl(llvm::StringRef{}, CS_PROP_NONE, ctrl.step,
|
||||
: PropertyImpl(wpi::StringRef{}, CS_PROP_NONE, ctrl.step,
|
||||
ctrl.default_value, 0),
|
||||
id(ctrl.id & V4L2_CTRL_ID_MASK),
|
||||
type(ctrl.type) {
|
||||
@@ -198,9 +198,9 @@ UsbCameraProperty::UsbCameraProperty(const struct v4l2_queryctrl& ctrl)
|
||||
// name
|
||||
size_t len = 0;
|
||||
while (len < sizeof(ctrl.name) && ctrl.name[len] != '\0') ++len;
|
||||
llvm::SmallString<64> name_buf;
|
||||
wpi::SmallString<64> name_buf;
|
||||
name = NormalizeName(
|
||||
llvm::StringRef(reinterpret_cast<const char*>(ctrl.name), len), name_buf);
|
||||
wpi::StringRef(reinterpret_cast<const char*>(ctrl.name), len), name_buf);
|
||||
}
|
||||
|
||||
std::unique_ptr<UsbCameraProperty> UsbCameraProperty::DeviceQuery(int fd,
|
||||
@@ -216,7 +216,7 @@ std::unique_ptr<UsbCameraProperty> UsbCameraProperty::DeviceQuery(int fd,
|
||||
*id = qc_ext.id; // copy back
|
||||
// We don't support array types
|
||||
if (qc_ext.elems > 1 || qc_ext.nr_of_dims > 0) return nullptr;
|
||||
prop = llvm::make_unique<UsbCameraProperty>(qc_ext);
|
||||
prop = wpi::make_unique<UsbCameraProperty>(qc_ext);
|
||||
}
|
||||
#endif
|
||||
if (!prop) {
|
||||
@@ -227,7 +227,7 @@ std::unique_ptr<UsbCameraProperty> UsbCameraProperty::DeviceQuery(int fd,
|
||||
rc = TryIoctl(fd, VIDIOC_QUERYCTRL, &qc);
|
||||
*id = qc.id; // copy back
|
||||
if (rc != 0) return nullptr;
|
||||
prop = llvm::make_unique<UsbCameraProperty>(qc);
|
||||
prop = wpi::make_unique<UsbCameraProperty>(qc);
|
||||
}
|
||||
|
||||
// Cache enum property choices
|
||||
@@ -282,13 +282,13 @@ bool UsbCameraProperty::DeviceGet(std::unique_lock<wpi::mutex>& lock, int fd) {
|
||||
bool UsbCameraProperty::DeviceSet(std::unique_lock<wpi::mutex>& lock,
|
||||
int fd) const {
|
||||
// Make a copy of the string as we're about to release the lock
|
||||
llvm::SmallString<128> valueStrCopy{valueStr};
|
||||
wpi::SmallString<128> valueStrCopy{valueStr};
|
||||
return DeviceSet(lock, fd, value, valueStrCopy);
|
||||
}
|
||||
|
||||
bool UsbCameraProperty::DeviceSet(std::unique_lock<wpi::mutex>& lock, int fd,
|
||||
int newValue,
|
||||
llvm::StringRef newValueStr) const {
|
||||
wpi::StringRef newValueStr) const {
|
||||
if (fd < 0) return true;
|
||||
unsigned idCopy = id;
|
||||
int rv = 0;
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include <support/mutex.h>
|
||||
#include <wpi/mutex.h>
|
||||
|
||||
#include "PropertyImpl.h"
|
||||
|
||||
@@ -24,10 +24,10 @@ namespace cs {
|
||||
class UsbCameraProperty : public PropertyImpl {
|
||||
public:
|
||||
UsbCameraProperty() = default;
|
||||
explicit UsbCameraProperty(llvm::StringRef name_) : PropertyImpl{name_} {}
|
||||
explicit UsbCameraProperty(wpi::StringRef name_) : PropertyImpl{name_} {}
|
||||
|
||||
// Normalized property constructor
|
||||
UsbCameraProperty(llvm::StringRef name_, int rawIndex_,
|
||||
UsbCameraProperty(wpi::StringRef name_, int rawIndex_,
|
||||
const UsbCameraProperty& rawProp, int defaultValue_,
|
||||
int value_)
|
||||
: PropertyImpl(name_, rawProp.propKind, 1, defaultValue_, value_),
|
||||
@@ -52,7 +52,7 @@ class UsbCameraProperty : public PropertyImpl {
|
||||
bool DeviceGet(std::unique_lock<wpi::mutex>& lock, int fd);
|
||||
bool DeviceSet(std::unique_lock<wpi::mutex>& lock, int fd) const;
|
||||
bool DeviceSet(std::unique_lock<wpi::mutex>& lock, int fd, int newValue,
|
||||
llvm::StringRef newValueStr) const;
|
||||
wpi::StringRef newValueStr) const;
|
||||
#endif
|
||||
|
||||
// If this is a percentage (rather than raw) property
|
||||
|
||||
@@ -14,10 +14,10 @@
|
||||
#include <sys/ioctl.h>
|
||||
#endif
|
||||
|
||||
#include <llvm/Format.h>
|
||||
#include <llvm/SmallString.h>
|
||||
#include <llvm/raw_ostream.h>
|
||||
#include <support/raw_istream.h>
|
||||
#include <wpi/Format.h>
|
||||
#include <wpi/SmallString.h>
|
||||
#include <wpi/raw_istream.h>
|
||||
#include <wpi/raw_ostream.h>
|
||||
|
||||
#include "Log.h"
|
||||
|
||||
@@ -25,22 +25,22 @@ namespace cs {
|
||||
|
||||
#ifdef __linux__
|
||||
|
||||
static llvm::StringRef GetUsbNameFromFile(int vendor, int product,
|
||||
llvm::SmallVectorImpl<char>& buf) {
|
||||
static wpi::StringRef GetUsbNameFromFile(int vendor, int product,
|
||||
wpi::SmallVectorImpl<char>& buf) {
|
||||
int fd = open("/var/lib/usbutils/usb.ids", O_RDONLY);
|
||||
if (fd < 0) return llvm::StringRef{};
|
||||
if (fd < 0) return wpi::StringRef{};
|
||||
|
||||
llvm::raw_svector_ostream os{buf};
|
||||
wpi::raw_svector_ostream os{buf};
|
||||
wpi::raw_fd_istream is{fd, true};
|
||||
|
||||
// build vendor and product 4-char hex strings
|
||||
llvm::SmallString<16> vendorStr, productStr;
|
||||
llvm::raw_svector_ostream vendorOs{vendorStr}, productOs{productStr};
|
||||
vendorOs << llvm::format_hex_no_prefix(vendor, 4);
|
||||
productOs << llvm::format_hex_no_prefix(product, 4);
|
||||
wpi::SmallString<16> vendorStr, productStr;
|
||||
wpi::raw_svector_ostream vendorOs{vendorStr}, productOs{productStr};
|
||||
vendorOs << wpi::format_hex_no_prefix(vendor, 4);
|
||||
productOs << wpi::format_hex_no_prefix(product, 4);
|
||||
|
||||
// scan file
|
||||
llvm::SmallString<128> lineBuf;
|
||||
wpi::SmallString<128> lineBuf;
|
||||
bool foundVendor = false;
|
||||
for (;;) {
|
||||
auto line = is.getline(lineBuf, 4096);
|
||||
@@ -70,17 +70,17 @@ static llvm::StringRef GetUsbNameFromFile(int vendor, int product,
|
||||
}
|
||||
}
|
||||
|
||||
return llvm::StringRef{};
|
||||
return wpi::StringRef{};
|
||||
}
|
||||
|
||||
llvm::StringRef GetUsbNameFromId(int vendor, int product,
|
||||
llvm::SmallVectorImpl<char>& buf) {
|
||||
wpi::StringRef GetUsbNameFromId(int vendor, int product,
|
||||
wpi::SmallVectorImpl<char>& buf) {
|
||||
// try reading usb.ids
|
||||
llvm::StringRef rv = GetUsbNameFromFile(vendor, product, buf);
|
||||
wpi::StringRef rv = GetUsbNameFromFile(vendor, product, buf);
|
||||
if (!rv.empty()) return rv;
|
||||
|
||||
// Fall back to internal database
|
||||
llvm::raw_svector_ostream os{buf};
|
||||
wpi::raw_svector_ostream os{buf};
|
||||
switch (vendor) {
|
||||
case 0x046d:
|
||||
os << "Logitech, Inc. ";
|
||||
@@ -153,7 +153,7 @@ int CheckedIoctl(int fd, unsigned long req, void* data, // NOLINT(runtime/int)
|
||||
const char* name, const char* file, int line, bool quiet) {
|
||||
int retval = ioctl(fd, req, data);
|
||||
if (!quiet && retval < 0) {
|
||||
llvm::SmallString<64> localfile{file};
|
||||
wpi::SmallString<64> localfile{file};
|
||||
localfile.push_back('\0');
|
||||
ERROR("ioctl " << name << " failed at " << basename(localfile.data()) << ":"
|
||||
<< line << ": " << std::strerror(errno));
|
||||
|
||||
@@ -10,15 +10,15 @@
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include <llvm/SmallVector.h>
|
||||
#include <llvm/StringRef.h>
|
||||
#include <wpi/SmallVector.h>
|
||||
#include <wpi/StringRef.h>
|
||||
|
||||
namespace cs {
|
||||
|
||||
#ifdef __linux__
|
||||
|
||||
llvm::StringRef GetUsbNameFromId(int vendor, int product,
|
||||
llvm::SmallVectorImpl<char>& buf);
|
||||
wpi::StringRef GetUsbNameFromId(int vendor, int product,
|
||||
wpi::SmallVectorImpl<char>& buf);
|
||||
|
||||
int CheckedIoctl(int fd, unsigned long req, void* data, // NOLINT(runtime/int)
|
||||
const char* name, const char* file, int line, bool quiet);
|
||||
|
||||
@@ -11,11 +11,11 @@
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
|
||||
#include <llvm/StringRef.h>
|
||||
#include <wpi/StringRef.h>
|
||||
|
||||
namespace cs {
|
||||
|
||||
inline char* ConvertToC(llvm::StringRef in) {
|
||||
inline char* ConvertToC(wpi::StringRef in) {
|
||||
char* out = static_cast<char*>(std::malloc(in.size() + 1));
|
||||
std::memmove(out, in.data(), in.size());
|
||||
out[in.size()] = '\0';
|
||||
|
||||
@@ -10,8 +10,8 @@
|
||||
#include <cstddef>
|
||||
#include <cstdlib>
|
||||
|
||||
#include <llvm/SmallString.h>
|
||||
#include <opencv2/core/core.hpp>
|
||||
#include <wpi/SmallString.h>
|
||||
|
||||
#include "c_util.h"
|
||||
#include "cscore_cpp.h"
|
||||
@@ -23,7 +23,7 @@ CS_PropertyKind CS_GetPropertyKind(CS_Property property, CS_Status* status) {
|
||||
}
|
||||
|
||||
char* CS_GetPropertyName(CS_Property property, CS_Status* status) {
|
||||
llvm::SmallString<128> buf;
|
||||
wpi::SmallString<128> buf;
|
||||
auto str = cs::GetPropertyName(property, buf, status);
|
||||
if (*status != 0) return nullptr;
|
||||
return cs::ConvertToC(str);
|
||||
@@ -54,7 +54,7 @@ int CS_GetPropertyDefault(CS_Property property, CS_Status* status) {
|
||||
}
|
||||
|
||||
char* CS_GetStringProperty(CS_Property property, CS_Status* status) {
|
||||
llvm::SmallString<128> buf;
|
||||
wpi::SmallString<128> buf;
|
||||
auto str = cs::GetStringProperty(property, buf, status);
|
||||
if (*status != 0) return nullptr;
|
||||
return cs::ConvertToC(str);
|
||||
@@ -80,14 +80,14 @@ CS_SourceKind CS_GetSourceKind(CS_Source source, CS_Status* status) {
|
||||
}
|
||||
|
||||
char* CS_GetSourceName(CS_Source source, CS_Status* status) {
|
||||
llvm::SmallString<128> buf;
|
||||
wpi::SmallString<128> buf;
|
||||
auto str = cs::GetSourceName(source, buf, status);
|
||||
if (*status != 0) return nullptr;
|
||||
return cs::ConvertToC(str);
|
||||
}
|
||||
|
||||
char* CS_GetSourceDescription(CS_Source source, CS_Status* status) {
|
||||
llvm::SmallString<128> buf;
|
||||
wpi::SmallString<128> buf;
|
||||
auto str = cs::GetSourceDescription(source, buf, status);
|
||||
if (*status != 0) return nullptr;
|
||||
return cs::ConvertToC(str);
|
||||
@@ -108,7 +108,7 @@ CS_Property CS_GetSourceProperty(CS_Source source, const char* name,
|
||||
|
||||
CS_Property* CS_EnumerateSourceProperties(CS_Source source, int* count,
|
||||
CS_Status* status) {
|
||||
llvm::SmallVector<CS_Property, 32> buf;
|
||||
wpi::SmallVector<CS_Property, 32> buf;
|
||||
auto vec = cs::EnumerateSourceProperties(source, buf, status);
|
||||
CS_Property* out =
|
||||
static_cast<CS_Property*>(std::malloc(vec.size() * sizeof(CS_Property)));
|
||||
@@ -170,7 +170,7 @@ CS_VideoMode* CS_EnumerateSourceVideoModes(CS_Source source, int* count,
|
||||
|
||||
CS_Sink* CS_EnumerateSourceSinks(CS_Source source, int* count,
|
||||
CS_Status* status) {
|
||||
llvm::SmallVector<CS_Sink, 32> buf;
|
||||
wpi::SmallVector<CS_Sink, 32> buf;
|
||||
auto handles = cs::EnumerateSourceSinks(source, buf, status);
|
||||
CS_Sink* sinks =
|
||||
static_cast<CS_Sink*>(std::malloc(handles.size() * sizeof(CS_Sink)));
|
||||
@@ -227,14 +227,14 @@ CS_SinkKind CS_GetSinkKind(CS_Sink sink, CS_Status* status) {
|
||||
}
|
||||
|
||||
char* CS_GetSinkName(CS_Sink sink, CS_Status* status) {
|
||||
llvm::SmallString<128> buf;
|
||||
wpi::SmallString<128> buf;
|
||||
auto str = cs::GetSinkName(sink, buf, status);
|
||||
if (*status != 0) return nullptr;
|
||||
return cs::ConvertToC(str);
|
||||
}
|
||||
|
||||
char* CS_GetSinkDescription(CS_Sink sink, CS_Status* status) {
|
||||
llvm::SmallString<128> buf;
|
||||
wpi::SmallString<128> buf;
|
||||
auto str = cs::GetSinkDescription(sink, buf, status);
|
||||
if (*status != 0) return nullptr;
|
||||
return cs::ConvertToC(str);
|
||||
@@ -321,7 +321,7 @@ void CS_SetDefaultLogger(unsigned int min_level) {
|
||||
}
|
||||
|
||||
CS_Source* CS_EnumerateSources(int* count, CS_Status* status) {
|
||||
llvm::SmallVector<CS_Source, 32> buf;
|
||||
wpi::SmallVector<CS_Source, 32> buf;
|
||||
auto handles = cs::EnumerateSourceHandles(buf, status);
|
||||
CS_Source* sources =
|
||||
static_cast<CS_Source*>(std::malloc(handles.size() * sizeof(CS_Source)));
|
||||
@@ -340,7 +340,7 @@ void CS_ReleaseEnumeratedSources(CS_Source* sources, int count) {
|
||||
}
|
||||
|
||||
CS_Sink* CS_EnumerateSinks(int* count, CS_Status* status) {
|
||||
llvm::SmallVector<CS_Sink, 32> buf;
|
||||
wpi::SmallVector<CS_Sink, 32> buf;
|
||||
auto handles = cs::EnumerateSinkHandles(buf, status);
|
||||
CS_Sink* sinks =
|
||||
static_cast<CS_Sink*>(std::malloc(handles.size() * sizeof(CS_Sink)));
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#include <llvm/SmallString.h>
|
||||
#include <wpi/SmallString.h>
|
||||
|
||||
#include "Handle.h"
|
||||
#include "Log.h"
|
||||
@@ -58,19 +58,19 @@ CS_PropertyKind GetPropertyKind(CS_Property property, CS_Status* status) {
|
||||
}
|
||||
|
||||
std::string GetPropertyName(CS_Property property, CS_Status* status) {
|
||||
llvm::SmallString<128> buf;
|
||||
wpi::SmallString<128> buf;
|
||||
int propertyIndex;
|
||||
auto source = GetPropertySource(property, &propertyIndex, status);
|
||||
if (!source) return std::string{};
|
||||
return source->GetPropertyName(propertyIndex, buf, status);
|
||||
}
|
||||
|
||||
llvm::StringRef GetPropertyName(CS_Property property,
|
||||
llvm::SmallVectorImpl<char>& buf,
|
||||
CS_Status* status) {
|
||||
wpi::StringRef GetPropertyName(CS_Property property,
|
||||
wpi::SmallVectorImpl<char>& buf,
|
||||
CS_Status* status) {
|
||||
int propertyIndex;
|
||||
auto source = GetPropertySource(property, &propertyIndex, status);
|
||||
if (!source) return llvm::StringRef{};
|
||||
if (!source) return wpi::StringRef{};
|
||||
return source->GetPropertyName(propertyIndex, buf, status);
|
||||
}
|
||||
|
||||
@@ -117,23 +117,23 @@ int GetPropertyDefault(CS_Property property, CS_Status* status) {
|
||||
}
|
||||
|
||||
std::string GetStringProperty(CS_Property property, CS_Status* status) {
|
||||
llvm::SmallString<128> buf;
|
||||
wpi::SmallString<128> buf;
|
||||
int propertyIndex;
|
||||
auto source = GetPropertySource(property, &propertyIndex, status);
|
||||
if (!source) return std::string{};
|
||||
return source->GetStringProperty(propertyIndex, buf, status);
|
||||
}
|
||||
|
||||
llvm::StringRef GetStringProperty(CS_Property property,
|
||||
llvm::SmallVectorImpl<char>& buf,
|
||||
CS_Status* status) {
|
||||
wpi::StringRef GetStringProperty(CS_Property property,
|
||||
wpi::SmallVectorImpl<char>& buf,
|
||||
CS_Status* status) {
|
||||
int propertyIndex;
|
||||
auto source = GetPropertySource(property, &propertyIndex, status);
|
||||
if (!source) return llvm::StringRef{};
|
||||
if (!source) return wpi::StringRef{};
|
||||
return source->GetStringProperty(propertyIndex, buf, status);
|
||||
}
|
||||
|
||||
void SetStringProperty(CS_Property property, llvm::StringRef value,
|
||||
void SetStringProperty(CS_Property property, wpi::StringRef value,
|
||||
CS_Status* status) {
|
||||
int propertyIndex;
|
||||
auto source = GetPropertySource(property, &propertyIndex, status);
|
||||
@@ -171,13 +171,13 @@ std::string GetSourceName(CS_Source source, CS_Status* status) {
|
||||
return data->source->GetName();
|
||||
}
|
||||
|
||||
llvm::StringRef GetSourceName(CS_Source source,
|
||||
llvm::SmallVectorImpl<char>& buf,
|
||||
CS_Status* status) {
|
||||
wpi::StringRef GetSourceName(CS_Source source,
|
||||
wpi::SmallVectorImpl<char>& buf,
|
||||
CS_Status* status) {
|
||||
auto data = Sources::GetInstance().Get(source);
|
||||
if (!data) {
|
||||
*status = CS_INVALID_HANDLE;
|
||||
return llvm::StringRef{};
|
||||
return wpi::StringRef{};
|
||||
}
|
||||
return data->source->GetName();
|
||||
}
|
||||
@@ -188,17 +188,17 @@ std::string GetSourceDescription(CS_Source source, CS_Status* status) {
|
||||
*status = CS_INVALID_HANDLE;
|
||||
return std::string{};
|
||||
}
|
||||
llvm::SmallString<128> buf;
|
||||
wpi::SmallString<128> buf;
|
||||
return data->source->GetDescription(buf);
|
||||
}
|
||||
|
||||
llvm::StringRef GetSourceDescription(CS_Source source,
|
||||
llvm::SmallVectorImpl<char>& buf,
|
||||
CS_Status* status) {
|
||||
wpi::StringRef GetSourceDescription(CS_Source source,
|
||||
wpi::SmallVectorImpl<char>& buf,
|
||||
CS_Status* status) {
|
||||
auto data = Sources::GetInstance().Get(source);
|
||||
if (!data) {
|
||||
*status = CS_INVALID_HANDLE;
|
||||
return llvm::StringRef{};
|
||||
return wpi::StringRef{};
|
||||
}
|
||||
return data->source->GetDescription(buf);
|
||||
}
|
||||
@@ -221,7 +221,7 @@ bool IsSourceConnected(CS_Source source, CS_Status* status) {
|
||||
return data->source->IsConnected();
|
||||
}
|
||||
|
||||
CS_Property GetSourceProperty(CS_Source source, llvm::StringRef name,
|
||||
CS_Property GetSourceProperty(CS_Source source, wpi::StringRef name,
|
||||
CS_Status* status) {
|
||||
auto data = Sources::GetInstance().Get(source);
|
||||
if (!data) {
|
||||
@@ -236,15 +236,15 @@ CS_Property GetSourceProperty(CS_Source source, llvm::StringRef name,
|
||||
return Handle{source, property, Handle::kProperty};
|
||||
}
|
||||
|
||||
llvm::ArrayRef<CS_Property> EnumerateSourceProperties(
|
||||
CS_Source source, llvm::SmallVectorImpl<CS_Property>& vec,
|
||||
wpi::ArrayRef<CS_Property> EnumerateSourceProperties(
|
||||
CS_Source source, wpi::SmallVectorImpl<CS_Property>& vec,
|
||||
CS_Status* status) {
|
||||
auto data = Sources::GetInstance().Get(source);
|
||||
if (!data) {
|
||||
*status = CS_INVALID_HANDLE;
|
||||
return 0;
|
||||
}
|
||||
llvm::SmallVector<int, 32> properties_buf;
|
||||
wpi::SmallVector<int, 32> properties_buf;
|
||||
for (auto property :
|
||||
data->source->EnumerateProperties(properties_buf, status))
|
||||
vec.push_back(Handle{source, property, Handle::kProperty});
|
||||
@@ -309,12 +309,12 @@ std::vector<VideoMode> EnumerateSourceVideoModes(CS_Source source,
|
||||
return data->source->EnumerateVideoModes(status);
|
||||
}
|
||||
|
||||
llvm::ArrayRef<CS_Sink> EnumerateSourceSinks(
|
||||
CS_Source source, llvm::SmallVectorImpl<CS_Sink>& vec, CS_Status* status) {
|
||||
wpi::ArrayRef<CS_Sink> EnumerateSourceSinks(
|
||||
CS_Source source, wpi::SmallVectorImpl<CS_Sink>& vec, CS_Status* status) {
|
||||
auto data = Sources::GetInstance().Get(source);
|
||||
if (!data) {
|
||||
*status = CS_INVALID_HANDLE;
|
||||
return llvm::ArrayRef<CS_Sink>{};
|
||||
return wpi::ArrayRef<CS_Sink>{};
|
||||
}
|
||||
vec.clear();
|
||||
Sinks::GetInstance().ForEach([&](CS_Sink sinkHandle, const SinkData& data) {
|
||||
@@ -448,12 +448,12 @@ std::string GetSinkName(CS_Sink sink, CS_Status* status) {
|
||||
return data->sink->GetName();
|
||||
}
|
||||
|
||||
llvm::StringRef GetSinkName(CS_Sink sink, llvm::SmallVectorImpl<char>& buf,
|
||||
CS_Status* status) {
|
||||
wpi::StringRef GetSinkName(CS_Sink sink, wpi::SmallVectorImpl<char>& buf,
|
||||
CS_Status* status) {
|
||||
auto data = Sinks::GetInstance().Get(sink);
|
||||
if (!data) {
|
||||
*status = CS_INVALID_HANDLE;
|
||||
return llvm::StringRef{};
|
||||
return wpi::StringRef{};
|
||||
}
|
||||
return data->sink->GetName();
|
||||
}
|
||||
@@ -464,17 +464,17 @@ std::string GetSinkDescription(CS_Sink sink, CS_Status* status) {
|
||||
*status = CS_INVALID_HANDLE;
|
||||
return std::string{};
|
||||
}
|
||||
llvm::SmallString<128> buf;
|
||||
wpi::SmallString<128> buf;
|
||||
return data->sink->GetDescription(buf);
|
||||
}
|
||||
|
||||
llvm::StringRef GetSinkDescription(CS_Sink sink,
|
||||
llvm::SmallVectorImpl<char>& buf,
|
||||
CS_Status* status) {
|
||||
wpi::StringRef GetSinkDescription(CS_Sink sink,
|
||||
wpi::SmallVectorImpl<char>& buf,
|
||||
CS_Status* status) {
|
||||
auto data = Sinks::GetInstance().Get(sink);
|
||||
if (!data) {
|
||||
*status = CS_INVALID_HANDLE;
|
||||
return llvm::StringRef{};
|
||||
return wpi::StringRef{};
|
||||
}
|
||||
return data->sink->GetDescription(buf);
|
||||
}
|
||||
@@ -509,7 +509,7 @@ CS_Source GetSinkSource(CS_Sink sink, CS_Status* status) {
|
||||
return data->sourceHandle.load();
|
||||
}
|
||||
|
||||
CS_Property GetSinkSourceProperty(CS_Sink sink, llvm::StringRef name,
|
||||
CS_Property GetSinkSourceProperty(CS_Sink sink, wpi::StringRef name,
|
||||
CS_Status* status) {
|
||||
auto data = Sinks::GetInstance().Get(sink);
|
||||
if (!data) {
|
||||
@@ -625,13 +625,13 @@ void SetDefaultLogger(unsigned int min_level) {
|
||||
// Utility Functions
|
||||
//
|
||||
|
||||
llvm::ArrayRef<CS_Source> EnumerateSourceHandles(
|
||||
llvm::SmallVectorImpl<CS_Source>& vec, CS_Status* status) {
|
||||
wpi::ArrayRef<CS_Source> EnumerateSourceHandles(
|
||||
wpi::SmallVectorImpl<CS_Source>& vec, CS_Status* status) {
|
||||
return Sources::GetInstance().GetAll(vec);
|
||||
}
|
||||
|
||||
llvm::ArrayRef<CS_Sink> EnumerateSinkHandles(
|
||||
llvm::SmallVectorImpl<CS_Sink>& vec, CS_Status* status) {
|
||||
wpi::ArrayRef<CS_Sink> EnumerateSinkHandles(
|
||||
wpi::SmallVectorImpl<CS_Sink>& vec, CS_Status* status) {
|
||||
return Sinks::GetInstance().GetAll(vec);
|
||||
}
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
using namespace cs;
|
||||
|
||||
std::vector<VideoProperty> VideoSource::EnumerateProperties() const {
|
||||
llvm::SmallVector<CS_Property, 32> handles_buf;
|
||||
wpi::SmallVector<CS_Property, 32> handles_buf;
|
||||
CS_Status status = 0;
|
||||
auto handles = EnumerateSourceProperties(m_handle, handles_buf, &status);
|
||||
|
||||
@@ -22,7 +22,7 @@ std::vector<VideoProperty> VideoSource::EnumerateProperties() const {
|
||||
}
|
||||
|
||||
std::vector<VideoSink> VideoSource::EnumerateSinks() {
|
||||
llvm::SmallVector<CS_Sink, 16> handles_buf;
|
||||
wpi::SmallVector<CS_Sink, 16> handles_buf;
|
||||
CS_Status status = 0;
|
||||
auto handles = EnumerateSourceSinks(m_handle, handles_buf, &status);
|
||||
|
||||
@@ -33,7 +33,7 @@ std::vector<VideoSink> VideoSource::EnumerateSinks() {
|
||||
}
|
||||
|
||||
std::vector<VideoSource> VideoSource::EnumerateSources() {
|
||||
llvm::SmallVector<CS_Source, 16> handles_buf;
|
||||
wpi::SmallVector<CS_Source, 16> handles_buf;
|
||||
CS_Status status = 0;
|
||||
auto handles = ::cs::EnumerateSourceHandles(handles_buf, &status);
|
||||
|
||||
@@ -44,7 +44,7 @@ std::vector<VideoSource> VideoSource::EnumerateSources() {
|
||||
}
|
||||
|
||||
std::vector<VideoSink> VideoSink::EnumerateSinks() {
|
||||
llvm::SmallVector<CS_Sink, 16> handles_buf;
|
||||
wpi::SmallVector<CS_Sink, 16> handles_buf;
|
||||
CS_Status status = 0;
|
||||
auto handles = ::cs::EnumerateSinkHandles(handles_buf, &status);
|
||||
|
||||
|
||||
@@ -5,9 +5,9 @@
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
#include <llvm/SmallString.h>
|
||||
#include <llvm/raw_ostream.h>
|
||||
#include <support/jni_util.h>
|
||||
#include <wpi/SmallString.h>
|
||||
#include <wpi/jni_util.h>
|
||||
#include <wpi/raw_ostream.h>
|
||||
|
||||
#include "cscore_cpp.h"
|
||||
#include "edu_wpi_cscore_CameraServerJNI.h"
|
||||
@@ -132,7 +132,7 @@ class JCSGlobal {
|
||||
|
||||
static void ReportError(JNIEnv* env, CS_Status status) {
|
||||
if (status == CS_OK) return;
|
||||
llvm::SmallString<64> msg;
|
||||
wpi::SmallString<64> msg;
|
||||
switch (status) {
|
||||
case CS_PROPERTY_WRITE_FAILED:
|
||||
msg = "property write failed";
|
||||
@@ -165,7 +165,7 @@ static void ReportError(JNIEnv* env, CS_Status status) {
|
||||
msg = "telemetry not enabled";
|
||||
break;
|
||||
default: {
|
||||
llvm::raw_svector_ostream oss{msg};
|
||||
wpi::raw_svector_ostream oss{msg};
|
||||
oss << "unknown error code=" << status;
|
||||
break;
|
||||
}
|
||||
@@ -248,7 +248,7 @@ JNIEXPORT jstring JNICALL Java_edu_wpi_cscore_CameraServerJNI_getPropertyName
|
||||
(JNIEnv* env, jclass, jint property)
|
||||
{
|
||||
CS_Status status = 0;
|
||||
llvm::SmallString<128> buf;
|
||||
wpi::SmallString<128> buf;
|
||||
auto str = cs::GetPropertyName(property, buf, &status);
|
||||
if (!CheckStatus(env, status)) return nullptr;
|
||||
return MakeJString(env, str);
|
||||
@@ -346,7 +346,7 @@ JNIEXPORT jstring JNICALL Java_edu_wpi_cscore_CameraServerJNI_getStringProperty
|
||||
(JNIEnv* env, jclass, jint property)
|
||||
{
|
||||
CS_Status status = 0;
|
||||
llvm::SmallString<128> buf;
|
||||
wpi::SmallString<128> buf;
|
||||
auto str = cs::GetStringProperty(property, buf, &status);
|
||||
if (!CheckStatus(env, status)) return nullptr;
|
||||
return MakeJString(env, str);
|
||||
@@ -475,7 +475,7 @@ JNIEXPORT jint JNICALL Java_edu_wpi_cscore_CameraServerJNI_createHttpCameraMulti
|
||||
return 0;
|
||||
}
|
||||
size_t len = env->GetArrayLength(urls);
|
||||
llvm::SmallVector<std::string, 8> vec;
|
||||
wpi::SmallVector<std::string, 8> vec;
|
||||
vec.reserve(len);
|
||||
for (size_t i = 0; i < len; ++i) {
|
||||
JLocal<jstring> elem{
|
||||
@@ -541,7 +541,7 @@ JNIEXPORT jstring JNICALL Java_edu_wpi_cscore_CameraServerJNI_getSourceName
|
||||
(JNIEnv* env, jclass, jint source)
|
||||
{
|
||||
CS_Status status = 0;
|
||||
llvm::SmallString<128> buf;
|
||||
wpi::SmallString<128> buf;
|
||||
auto str = cs::GetSourceName(source, buf, &status);
|
||||
if (!CheckStatus(env, status)) return nullptr;
|
||||
return MakeJString(env, str);
|
||||
@@ -556,7 +556,7 @@ JNIEXPORT jstring JNICALL Java_edu_wpi_cscore_CameraServerJNI_getSourceDescripti
|
||||
(JNIEnv* env, jclass, jint source)
|
||||
{
|
||||
CS_Status status = 0;
|
||||
llvm::SmallString<128> buf;
|
||||
wpi::SmallString<128> buf;
|
||||
auto str = cs::GetSourceDescription(source, buf, &status);
|
||||
if (!CheckStatus(env, status)) return nullptr;
|
||||
return MakeJString(env, str);
|
||||
@@ -617,7 +617,7 @@ JNIEXPORT jintArray JNICALL Java_edu_wpi_cscore_CameraServerJNI_enumerateSourceP
|
||||
(JNIEnv* env, jclass, jint source)
|
||||
{
|
||||
CS_Status status = 0;
|
||||
llvm::SmallVector<CS_Property, 32> buf;
|
||||
wpi::SmallVector<CS_Property, 32> buf;
|
||||
auto arr = cs::EnumerateSourceProperties(source, buf, &status);
|
||||
if (!CheckStatus(env, status)) return nullptr;
|
||||
return MakeJIntArray(env, arr);
|
||||
@@ -728,7 +728,7 @@ JNIEXPORT jintArray JNICALL Java_edu_wpi_cscore_CameraServerJNI_enumerateSourceS
|
||||
(JNIEnv* env, jclass, jint source)
|
||||
{
|
||||
CS_Status status = 0;
|
||||
llvm::SmallVector<CS_Sink, 16> buf;
|
||||
wpi::SmallVector<CS_Sink, 16> buf;
|
||||
auto arr = cs::EnumerateSourceSinks(source, buf, &status);
|
||||
if (!CheckStatus(env, status)) return nullptr;
|
||||
return MakeJIntArray(env, arr);
|
||||
@@ -912,7 +912,7 @@ JNIEXPORT void JNICALL Java_edu_wpi_cscore_CameraServerJNI_setHttpCameraUrls
|
||||
return;
|
||||
}
|
||||
size_t len = env->GetArrayLength(urls);
|
||||
llvm::SmallVector<std::string, 8> vec;
|
||||
wpi::SmallVector<std::string, 8> vec;
|
||||
vec.reserve(len);
|
||||
for (size_t i = 0; i < len; ++i) {
|
||||
JLocal<jstring> elem{
|
||||
@@ -1033,7 +1033,7 @@ JNIEXPORT void JNICALL Java_edu_wpi_cscore_CameraServerJNI_setSourceEnumProperty
|
||||
return;
|
||||
}
|
||||
size_t len = env->GetArrayLength(choices);
|
||||
llvm::SmallVector<std::string, 8> vec;
|
||||
wpi::SmallVector<std::string, 8> vec;
|
||||
vec.reserve(len);
|
||||
for (size_t i = 0; i < len; ++i) {
|
||||
JLocal<jstring> elem{
|
||||
@@ -1113,7 +1113,7 @@ JNIEXPORT jstring JNICALL Java_edu_wpi_cscore_CameraServerJNI_getSinkName
|
||||
(JNIEnv* env, jclass, jint sink)
|
||||
{
|
||||
CS_Status status = 0;
|
||||
llvm::SmallString<128> buf;
|
||||
wpi::SmallString<128> buf;
|
||||
auto str = cs::GetSinkName(sink, buf, &status);
|
||||
if (!CheckStatus(env, status)) return nullptr;
|
||||
return MakeJString(env, str);
|
||||
@@ -1128,7 +1128,7 @@ JNIEXPORT jstring JNICALL Java_edu_wpi_cscore_CameraServerJNI_getSinkDescription
|
||||
(JNIEnv* env, jclass, jint sink)
|
||||
{
|
||||
CS_Status status = 0;
|
||||
llvm::SmallString<128> buf;
|
||||
wpi::SmallString<128> buf;
|
||||
auto str = cs::GetSinkDescription(sink, buf, &status);
|
||||
if (!CheckStatus(env, status)) return nullptr;
|
||||
return MakeJString(env, str);
|
||||
@@ -1290,7 +1290,7 @@ JNIEXPORT jstring JNICALL Java_edu_wpi_cscore_CameraServerJNI_getSinkError
|
||||
(JNIEnv* env, jclass, jint sink)
|
||||
{
|
||||
CS_Status status = 0;
|
||||
llvm::SmallString<128> buf;
|
||||
wpi::SmallString<128> buf;
|
||||
auto str = cs::GetSinkError(sink, buf, &status);
|
||||
if (!CheckStatus(env, status)) return nullptr;
|
||||
return MakeJString(env, str);
|
||||
@@ -1464,7 +1464,7 @@ JNIEXPORT jintArray JNICALL Java_edu_wpi_cscore_CameraServerJNI_enumerateSources
|
||||
(JNIEnv* env, jclass)
|
||||
{
|
||||
CS_Status status = 0;
|
||||
llvm::SmallVector<CS_Source, 16> buf;
|
||||
wpi::SmallVector<CS_Source, 16> buf;
|
||||
auto arr = cs::EnumerateSourceHandles(buf, &status);
|
||||
if (!CheckStatus(env, status)) return nullptr;
|
||||
return MakeJIntArray(env, arr);
|
||||
@@ -1479,7 +1479,7 @@ JNIEXPORT jintArray JNICALL Java_edu_wpi_cscore_CameraServerJNI_enumerateSinks
|
||||
(JNIEnv* env, jclass)
|
||||
{
|
||||
CS_Status status = 0;
|
||||
llvm::SmallVector<CS_Sink, 16> buf;
|
||||
wpi::SmallVector<CS_Sink, 16> buf;
|
||||
auto arr = cs::EnumerateSinkHandles(buf, &status);
|
||||
if (!CheckStatus(env, status)) return nullptr;
|
||||
return MakeJIntArray(env, arr);
|
||||
|
||||
Reference in New Issue
Block a user