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:
Peter Johnson
2018-04-29 23:33:19 -07:00
parent 93859eb84f
commit f84018af5f
377 changed files with 2747 additions and 2742 deletions

View File

@@ -7,9 +7,9 @@
#include "CameraServer.h"
#include <llvm/SmallString.h>
#include <llvm/raw_ostream.h>
#include <networktables/NetworkTableInstance.h>
#include <wpi/SmallString.h>
#include <wpi/raw_ostream.h>
#include "CameraServerShared.h"
#include "ntcore_cpp.h"
@@ -21,14 +21,14 @@ CameraServer* CameraServer::GetInstance() {
return &instance;
}
static llvm::StringRef MakeSourceValue(CS_Source source,
llvm::SmallVectorImpl<char>& buf) {
static wpi::StringRef MakeSourceValue(CS_Source source,
wpi::SmallVectorImpl<char>& buf) {
CS_Status status = 0;
buf.clear();
switch (cs::GetSourceKind(source, &status)) {
#ifdef __linux__
case cs::VideoSource::kUsb: {
llvm::StringRef prefix{"usb:"};
wpi::StringRef prefix{"usb:"};
buf.append(prefix.begin(), prefix.end());
auto path = cs::GetUsbCameraPath(source, &status);
buf.append(path.begin(), path.end());
@@ -36,7 +36,7 @@ static llvm::StringRef MakeSourceValue(CS_Source source,
}
#endif
case cs::VideoSource::kHttp: {
llvm::StringRef prefix{"ip:"};
wpi::StringRef prefix{"ip:"};
buf.append(prefix.begin(), prefix.end());
auto urls = cs::GetHttpCameraUrls(source, &status);
if (!urls.empty()) buf.append(urls[0].begin(), urls[0].end());
@@ -50,12 +50,12 @@ static llvm::StringRef MakeSourceValue(CS_Source source,
return "unknown:";
}
return llvm::StringRef{buf.begin(), buf.size()};
return wpi::StringRef{buf.begin(), buf.size()};
}
static std::string MakeStreamValue(llvm::StringRef address, int port) {
static std::string MakeStreamValue(wpi::StringRef address, int port) {
std::string rv;
llvm::raw_string_ostream stream(rv);
wpi::raw_string_ostream stream(rv);
stream << "mjpg:http://" << address << ':' << port << "/?action=stream";
stream.flush();
return rv;
@@ -178,7 +178,7 @@ static std::string PixelFormatToString(int pixelFormat) {
static std::string VideoModeToString(const cs::VideoMode& mode) {
std::string rv;
llvm::raw_string_ostream oss{rv};
wpi::raw_string_ostream oss{rv};
oss << mode.width << "x" << mode.height;
oss << " " << PixelFormatToString(mode.pixelFormat) << " ";
oss << mode.fps << " fps";
@@ -193,20 +193,20 @@ static std::vector<std::string> GetSourceModeValues(int source) {
return rv;
}
static inline llvm::StringRef Concatenate(llvm::StringRef lhs,
llvm::StringRef rhs,
llvm::SmallVectorImpl<char>& buf) {
static inline wpi::StringRef Concatenate(wpi::StringRef lhs,
wpi::StringRef rhs,
wpi::SmallVectorImpl<char>& buf) {
buf.clear();
llvm::raw_svector_ostream oss{buf};
wpi::raw_svector_ostream oss{buf};
oss << lhs << rhs;
return oss.str();
}
static void PutSourcePropertyValue(nt::NetworkTable* table,
const cs::VideoEvent& event, bool isNew) {
llvm::SmallString<64> name;
llvm::SmallString<64> infoName;
if (llvm::StringRef{event.name}.startswith("raw_")) {
wpi::SmallString<64> name;
wpi::SmallString<64> infoName;
if (wpi::StringRef{event.name}.startswith("raw_")) {
name = "RawProperty/";
name += event.name;
infoName = "RawPropertyInfo/";
@@ -218,7 +218,7 @@ static void PutSourcePropertyValue(nt::NetworkTable* table,
infoName += event.name;
}
llvm::SmallString<64> buf;
wpi::SmallString<64> buf;
CS_Status status = 0;
nt::NetworkTableEntry entry = table->GetEntry(name);
switch (event.propertyKind) {
@@ -282,10 +282,10 @@ CameraServer::CameraServer()
std::lock_guard<wpi::mutex> lock(m_mutex);
m_tables.insert(std::make_pair(event.sourceHandle, table));
}
llvm::SmallString<64> buf;
wpi::SmallString<64> buf;
table->GetEntry("source").SetString(
MakeSourceValue(event.sourceHandle, buf));
llvm::SmallString<64> descBuf;
wpi::SmallString<64> descBuf;
table->GetEntry("description")
.SetString(cs::GetSourceDescription(event.sourceHandle, descBuf,
&status));
@@ -314,7 +314,7 @@ CameraServer::CameraServer()
auto table = GetSourceTable(event.sourceHandle);
if (table) {
// update the description too (as it may have changed)
llvm::SmallString<64> descBuf;
wpi::SmallString<64> descBuf;
table->GetEntry("description")
.SetString(cs::GetSourceDescription(event.sourceHandle,
descBuf, &status));
@@ -353,7 +353,7 @@ CameraServer::CameraServer()
case cs::VideoEvent::kSourcePropertyChoicesUpdated: {
auto table = GetSourceTable(event.sourceHandle);
if (table) {
llvm::SmallString<64> name{"PropertyInfo/"};
wpi::SmallString<64> name{"PropertyInfo/"};
name += event.name;
name += "/choices";
auto choices =
@@ -380,17 +380,17 @@ CameraServer::CameraServer()
// We don't currently support changing settings via NT due to
// synchronization issues, so just update to current setting if someone
// else tries to change it.
llvm::SmallString<64> buf;
wpi::SmallString<64> buf;
m_tableListener = nt::NetworkTableInstance::GetDefault().AddEntryListener(
Concatenate(kPublishName, "/", buf),
[=](const nt::EntryNotification& event) {
llvm::StringRef relativeKey =
event.name.substr(llvm::StringRef(kPublishName).size() + 1);
wpi::StringRef relativeKey =
event.name.substr(wpi::StringRef(kPublishName).size() + 1);
// get source (sourceName/...)
auto subKeyIndex = relativeKey.find('/');
if (subKeyIndex == llvm::StringRef::npos) return;
llvm::StringRef sourceName = relativeKey.slice(0, subKeyIndex);
if (subKeyIndex == wpi::StringRef::npos) return;
wpi::StringRef sourceName = relativeKey.slice(0, subKeyIndex);
auto sourceIt = m_sources.find(sourceName);
if (sourceIt == m_sources.end()) return;
@@ -398,7 +398,7 @@ CameraServer::CameraServer()
relativeKey = relativeKey.substr(subKeyIndex + 1);
// handle standard names
llvm::StringRef propName;
wpi::StringRef propName;
nt::NetworkTableEntry entry{event.entry};
if (relativeKey == "mode") {
// reset to current mode
@@ -442,8 +442,8 @@ cs::UsbCamera CameraServer::StartAutomaticCapture() {
}
cs::UsbCamera CameraServer::StartAutomaticCapture(int dev) {
llvm::SmallString<64> buf;
llvm::raw_svector_ostream name{buf};
wpi::SmallString<64> buf;
wpi::raw_svector_ostream name{buf};
name << "USB Camera " << dev;
cs::UsbCamera camera{name.str(), dev};
@@ -453,7 +453,7 @@ cs::UsbCamera CameraServer::StartAutomaticCapture(int dev) {
return camera;
}
cs::UsbCamera CameraServer::StartAutomaticCapture(llvm::StringRef name,
cs::UsbCamera CameraServer::StartAutomaticCapture(wpi::StringRef name,
int dev) {
cs::UsbCamera camera{name, dev};
StartAutomaticCapture(camera);
@@ -462,8 +462,8 @@ cs::UsbCamera CameraServer::StartAutomaticCapture(llvm::StringRef name,
return camera;
}
cs::UsbCamera CameraServer::StartAutomaticCapture(llvm::StringRef name,
llvm::StringRef path) {
cs::UsbCamera CameraServer::StartAutomaticCapture(wpi::StringRef name,
wpi::StringRef path) {
cs::UsbCamera camera{name, path};
StartAutomaticCapture(camera);
auto csShared = GetCameraServerShared();
@@ -472,7 +472,7 @@ cs::UsbCamera CameraServer::StartAutomaticCapture(llvm::StringRef name,
}
#endif
cs::AxisCamera CameraServer::AddAxisCamera(llvm::StringRef host) {
cs::AxisCamera CameraServer::AddAxisCamera(wpi::StringRef host) {
return AddAxisCamera("Axis Camera", host);
}
@@ -484,12 +484,12 @@ cs::AxisCamera CameraServer::AddAxisCamera(const std::string& host) {
return AddAxisCamera("Axis Camera", host);
}
cs::AxisCamera CameraServer::AddAxisCamera(llvm::ArrayRef<std::string> hosts) {
cs::AxisCamera CameraServer::AddAxisCamera(wpi::ArrayRef<std::string> hosts) {
return AddAxisCamera("Axis Camera", hosts);
}
cs::AxisCamera CameraServer::AddAxisCamera(llvm::StringRef name,
llvm::StringRef host) {
cs::AxisCamera CameraServer::AddAxisCamera(wpi::StringRef name,
wpi::StringRef host) {
cs::AxisCamera camera{name, host};
StartAutomaticCapture(camera);
auto csShared = GetCameraServerShared();
@@ -497,7 +497,7 @@ cs::AxisCamera CameraServer::AddAxisCamera(llvm::StringRef name,
return camera;
}
cs::AxisCamera CameraServer::AddAxisCamera(llvm::StringRef name,
cs::AxisCamera CameraServer::AddAxisCamera(wpi::StringRef name,
const char* host) {
cs::AxisCamera camera{name, host};
StartAutomaticCapture(camera);
@@ -506,7 +506,7 @@ cs::AxisCamera CameraServer::AddAxisCamera(llvm::StringRef name,
return camera;
}
cs::AxisCamera CameraServer::AddAxisCamera(llvm::StringRef name,
cs::AxisCamera CameraServer::AddAxisCamera(wpi::StringRef name,
const std::string& host) {
cs::AxisCamera camera{name, host};
StartAutomaticCapture(camera);
@@ -515,8 +515,8 @@ cs::AxisCamera CameraServer::AddAxisCamera(llvm::StringRef name,
return camera;
}
cs::AxisCamera CameraServer::AddAxisCamera(llvm::StringRef name,
llvm::ArrayRef<std::string> hosts) {
cs::AxisCamera CameraServer::AddAxisCamera(wpi::StringRef name,
wpi::ArrayRef<std::string> hosts) {
cs::AxisCamera camera{name, hosts};
StartAutomaticCapture(camera);
auto csShared = GetCameraServerShared();
@@ -525,7 +525,7 @@ cs::AxisCamera CameraServer::AddAxisCamera(llvm::StringRef name,
}
void CameraServer::StartAutomaticCapture(const cs::VideoSource& camera) {
llvm::SmallString<64> name{"serve_"};
wpi::SmallString<64> name{"serve_"};
name += camera.GetName();
AddCamera(camera);
@@ -553,7 +553,7 @@ cs::CvSink CameraServer::GetVideo() {
}
cs::CvSink CameraServer::GetVideo(const cs::VideoSource& camera) {
llvm::SmallString<64> name{"opencv_"};
wpi::SmallString<64> name{"opencv_"};
name += camera.GetName();
{
@@ -562,8 +562,8 @@ cs::CvSink CameraServer::GetVideo(const cs::VideoSource& camera) {
if (it != m_sinks.end()) {
auto kind = it->second.GetKind();
if (kind != cs::VideoSink::kCv) {
llvm::SmallString<64> buf;
llvm::raw_svector_ostream err{buf};
wpi::SmallString<64> buf;
wpi::raw_svector_ostream err{buf};
err << "expected OpenCV sink, but got " << kind;
auto csShared = GetCameraServerShared();
csShared->SetCameraServerError(err.str());
@@ -579,14 +579,14 @@ cs::CvSink CameraServer::GetVideo(const cs::VideoSource& camera) {
return newsink;
}
cs::CvSink CameraServer::GetVideo(llvm::StringRef name) {
cs::CvSink CameraServer::GetVideo(wpi::StringRef name) {
cs::VideoSource source;
{
std::lock_guard<wpi::mutex> lock(m_mutex);
auto it = m_sources.find(name);
if (it == m_sources.end()) {
llvm::SmallString<64> buf;
llvm::raw_svector_ostream err{buf};
wpi::SmallString<64> buf;
wpi::raw_svector_ostream err{buf};
err << "could not find camera " << name;
auto csShared = GetCameraServerShared();
csShared->SetCameraServerError(err.str());
@@ -597,14 +597,14 @@ cs::CvSink CameraServer::GetVideo(llvm::StringRef name) {
return GetVideo(source);
}
cs::CvSource CameraServer::PutVideo(llvm::StringRef name, int width,
cs::CvSource CameraServer::PutVideo(wpi::StringRef name, int width,
int height) {
cs::CvSource source{name, cs::VideoMode::kMJPEG, width, height, 30};
StartAutomaticCapture(source);
return source;
}
cs::MjpegServer CameraServer::AddServer(llvm::StringRef name) {
cs::MjpegServer CameraServer::AddServer(wpi::StringRef name) {
int port;
{
std::lock_guard<wpi::mutex> lock(m_mutex);
@@ -613,7 +613,7 @@ cs::MjpegServer CameraServer::AddServer(llvm::StringRef name) {
return AddServer(name, port);
}
cs::MjpegServer CameraServer::AddServer(llvm::StringRef name, int port) {
cs::MjpegServer CameraServer::AddServer(wpi::StringRef name, int port) {
cs::MjpegServer server{name, port};
AddServer(server);
return server;
@@ -624,13 +624,13 @@ void CameraServer::AddServer(const cs::VideoSink& server) {
m_sinks.emplace_second(server.GetName(), server);
}
void CameraServer::RemoveServer(llvm::StringRef name) {
void CameraServer::RemoveServer(wpi::StringRef name) {
std::lock_guard<wpi::mutex> lock(m_mutex);
m_sinks.erase(name);
}
cs::VideoSink CameraServer::GetServer() {
llvm::SmallString<64> name;
wpi::SmallString<64> name;
{
std::lock_guard<wpi::mutex> lock(m_mutex);
if (m_primarySourceName.empty()) {
@@ -644,12 +644,12 @@ cs::VideoSink CameraServer::GetServer() {
return GetServer(name);
}
cs::VideoSink CameraServer::GetServer(llvm::StringRef name) {
cs::VideoSink CameraServer::GetServer(wpi::StringRef name) {
std::lock_guard<wpi::mutex> lock(m_mutex);
auto it = m_sinks.find(name);
if (it == m_sinks.end()) {
llvm::SmallString<64> buf;
llvm::raw_svector_ostream err{buf};
wpi::SmallString<64> buf;
wpi::raw_svector_ostream err{buf};
err << "could not find server " << name;
auto csShared = GetCameraServerShared();
csShared->SetCameraServerError(err.str());
@@ -665,7 +665,7 @@ void CameraServer::AddCamera(const cs::VideoSource& camera) {
m_sources.emplace_second(name, camera);
}
void CameraServer::RemoveCamera(llvm::StringRef name) {
void CameraServer::RemoveCamera(wpi::StringRef name) {
std::lock_guard<wpi::mutex> lock(m_mutex);
m_sources.erase(name);
}

View File

@@ -7,7 +7,7 @@
#include "CameraServerShared.h"
#include <support/mutex.h>
#include <wpi/mutex.h>
namespace {
class DefaultCameraServerShared : public frc::CameraServerShared {
@@ -15,9 +15,9 @@ class DefaultCameraServerShared : public frc::CameraServerShared {
void ReportUsbCamera(int id) override {}
void ReportAxisCamera(int id) override {}
void ReportVideoServer(int id) override {}
void SetCameraServerError(llvm::StringRef error) override {}
void SetVisionRunnerError(llvm::StringRef error) override {}
void ReportDriverStationError(llvm::StringRef error) override {}
void SetCameraServerError(wpi::StringRef error) override {}
void SetVisionRunnerError(wpi::StringRef error) override {}
void ReportDriverStationError(wpi::StringRef error) override {}
std::pair<std::thread::id, bool> GetRobotMainThreadId() const override {
return std::make_pair(std::thread::id(), false);
}

View File

@@ -14,11 +14,11 @@
#include <string>
#include <vector>
#include <llvm/DenseMap.h>
#include <llvm/StringMap.h>
#include <llvm/StringRef.h>
#include <networktables/NetworkTable.h>
#include <support/mutex.h>
#include <wpi/DenseMap.h>
#include <wpi/StringMap.h>
#include <wpi/StringRef.h>
#include <wpi/mutex.h>
#include "cscore.h"
@@ -72,7 +72,7 @@ class CameraServer {
* @param name The name to give the camera
* @param dev The device number of the camera interface
*/
cs::UsbCamera StartAutomaticCapture(llvm::StringRef name, int dev);
cs::UsbCamera StartAutomaticCapture(wpi::StringRef name, int dev);
/**
* Start automatically capturing images to send to the dashboard.
@@ -80,8 +80,8 @@ class CameraServer {
* @param name The name to give the camera
* @param path The device path (e.g. "/dev/video0") of the camera
*/
cs::UsbCamera StartAutomaticCapture(llvm::StringRef name,
llvm::StringRef path);
cs::UsbCamera StartAutomaticCapture(wpi::StringRef name,
wpi::StringRef path);
#endif
/**
@@ -99,7 +99,7 @@ class CameraServer {
*
* @param host Camera host IP or DNS name (e.g. "10.x.y.11")
*/
cs::AxisCamera AddAxisCamera(llvm::StringRef host);
cs::AxisCamera AddAxisCamera(wpi::StringRef host);
/**
* Adds an Axis IP camera.
@@ -126,7 +126,7 @@ class CameraServer {
*
* @param hosts Array of Camera host IPs/DNS names
*/
cs::AxisCamera AddAxisCamera(llvm::ArrayRef<std::string> hosts);
cs::AxisCamera AddAxisCamera(wpi::ArrayRef<std::string> hosts);
/**
* Adds an Axis IP camera.
@@ -144,7 +144,7 @@ class CameraServer {
* @param name The name to give the camera
* @param host Camera host IP or DNS name (e.g. "10.x.y.11")
*/
cs::AxisCamera AddAxisCamera(llvm::StringRef name, llvm::StringRef host);
cs::AxisCamera AddAxisCamera(wpi::StringRef name, wpi::StringRef host);
/**
* Adds an Axis IP camera.
@@ -152,7 +152,7 @@ class CameraServer {
* @param name The name to give the camera
* @param host Camera host IP or DNS name (e.g. "10.x.y.11")
*/
cs::AxisCamera AddAxisCamera(llvm::StringRef name, const char* host);
cs::AxisCamera AddAxisCamera(wpi::StringRef name, const char* host);
/**
* Adds an Axis IP camera.
@@ -160,7 +160,7 @@ class CameraServer {
* @param name The name to give the camera
* @param host Camera host IP or DNS name (e.g. "10.x.y.11")
*/
cs::AxisCamera AddAxisCamera(llvm::StringRef name, const std::string& host);
cs::AxisCamera AddAxisCamera(wpi::StringRef name, const std::string& host);
/**
* Adds an Axis IP camera.
@@ -168,8 +168,8 @@ class CameraServer {
* @param name The name to give the camera
* @param hosts Array of Camera host IPs/DNS names
*/
cs::AxisCamera AddAxisCamera(llvm::StringRef name,
llvm::ArrayRef<std::string> hosts);
cs::AxisCamera AddAxisCamera(wpi::StringRef name,
wpi::ArrayRef<std::string> hosts);
/**
* Adds an Axis IP camera.
@@ -178,7 +178,7 @@ class CameraServer {
* @param hosts Array of Camera host IPs/DNS names
*/
template <typename T>
cs::AxisCamera AddAxisCamera(llvm::StringRef name,
cs::AxisCamera AddAxisCamera(wpi::StringRef name,
std::initializer_list<T> hosts);
/**
@@ -204,7 +204,7 @@ class CameraServer {
*
* @param name Camera name
*/
cs::CvSink GetVideo(llvm::StringRef name);
cs::CvSink GetVideo(wpi::StringRef name);
/**
* Create a MJPEG stream with OpenCV input. This can be called to pass custom
@@ -214,21 +214,21 @@ class CameraServer {
* @param width Width of the image being sent
* @param height Height of the image being sent
*/
cs::CvSource PutVideo(llvm::StringRef name, int width, int height);
cs::CvSource PutVideo(wpi::StringRef name, int width, int height);
/**
* Adds a MJPEG server at the next available port.
*
* @param name Server name
*/
cs::MjpegServer AddServer(llvm::StringRef name);
cs::MjpegServer AddServer(wpi::StringRef name);
/**
* Adds a MJPEG server.
*
* @param name Server name
*/
cs::MjpegServer AddServer(llvm::StringRef name, int port);
cs::MjpegServer AddServer(wpi::StringRef name, int port);
/**
* Adds an already created server.
@@ -242,7 +242,7 @@ class CameraServer {
*
* @param name Server name
*/
void RemoveServer(llvm::StringRef name);
void RemoveServer(wpi::StringRef name);
/**
* Get server for the primary camera feed.
@@ -257,7 +257,7 @@ class CameraServer {
*
* @param name Server name
*/
cs::VideoSink GetServer(llvm::StringRef name);
cs::VideoSink GetServer(wpi::StringRef name);
/**
* Adds an already created camera.
@@ -271,7 +271,7 @@ class CameraServer {
*
* @param name Camera name
*/
void RemoveCamera(llvm::StringRef name);
void RemoveCamera(wpi::StringRef name);
/**
* Sets the size of the image to use. Use the public kSize constants to set
@@ -297,9 +297,9 @@ class CameraServer {
wpi::mutex m_mutex;
std::atomic<int> m_defaultUsbDevice;
std::string m_primarySourceName;
llvm::StringMap<cs::VideoSource> m_sources;
llvm::StringMap<cs::VideoSink> m_sinks;
llvm::DenseMap<CS_Source, std::shared_ptr<nt::NetworkTable>> m_tables;
wpi::StringMap<cs::VideoSource> m_sources;
wpi::StringMap<cs::VideoSink> m_sinks;
wpi::DenseMap<CS_Source, std::shared_ptr<nt::NetworkTable>> m_tables;
std::shared_ptr<nt::NetworkTable> m_publishTable;
cs::VideoListener m_videoListener;
int m_tableListener;

View File

@@ -20,7 +20,7 @@ inline cs::AxisCamera CameraServer::AddAxisCamera(
template <typename T>
inline cs::AxisCamera CameraServer::AddAxisCamera(
llvm::StringRef name, std::initializer_list<T> hosts) {
wpi::StringRef name, std::initializer_list<T> hosts) {
std::vector<std::string> vec;
vec.reserve(hosts.size());
for (const auto& host : hosts) vec.emplace_back(host);

View File

@@ -11,7 +11,7 @@
#include <thread>
#include <utility>
#include <llvm/StringRef.h>
#include <wpi/StringRef.h>
namespace frc {
class CameraServerShared {
@@ -19,9 +19,9 @@ class CameraServerShared {
virtual void ReportUsbCamera(int id) = 0;
virtual void ReportAxisCamera(int id) = 0;
virtual void ReportVideoServer(int id) = 0;
virtual void SetCameraServerError(llvm::StringRef error) = 0;
virtual void SetVisionRunnerError(llvm::StringRef error) = 0;
virtual void ReportDriverStationError(llvm::StringRef error) = 0;
virtual void SetCameraServerError(wpi::StringRef error) = 0;
virtual void SetVisionRunnerError(wpi::StringRef error) = 0;
virtual void ReportDriverStationError(wpi::StringRef error) = 0;
virtual std::pair<std::thread::id, bool> GetRobotMainThreadId() const = 0;
};

View File

@@ -31,7 +31,7 @@ public class CvSink extends VideoSink {
/// time=0 if an error occurred. processFrame should call GetImage()
/// or GetError() as needed, but should not call (except in very
/// unusual circumstances) WaitForImage().
//public CvSink(llvm::StringRef name,
//public CvSink(wpi::StringRef name,
// std::function<void(uint64_t time)> processFrame) {
// super(CameraServerJNI.createCvSinkCallback(name, processFrame));
//}

View File

@@ -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);

View File

@@ -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;

View File

@@ -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);

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;
}

View File

@@ -12,7 +12,7 @@
#include <memory>
#include <utility>
#include <llvm/StringRef.h>
#include <wpi/StringRef.h>
#include "UnlimitedHandleResource.h"
#include "cscore_c.h"

View File

@@ -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);

View File

@@ -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:

View File

@@ -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());

View File

@@ -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));
}

View File

@@ -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);

View File

@@ -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(); }

View File

@@ -8,7 +8,7 @@
#ifndef CSCORE_LOG_H_
#define CSCORE_LOG_H_
#include <support/Logger.h>
#include <wpi/Logger.h>
namespace cs {

View File

@@ -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&param2=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>(

View File

@@ -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;

View File

@@ -8,7 +8,7 @@
#ifndef CSCORE_NETWORKLISTENER_H_
#define CSCORE_NETWORKLISTENER_H_
#include <support/SafeThread.h>
#include <wpi/SafeThread.h>
namespace cs {

View File

@@ -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;

View File

@@ -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();

View File

@@ -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;
}

View File

@@ -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) {}

View File

@@ -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);

View File

@@ -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();

View File

@@ -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;

View File

@@ -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;

View File

@@ -8,7 +8,7 @@
#ifndef CSCORE_TELEMETRY_H_
#define CSCORE_TELEMETRY_H_
#include <support/SafeThread.h>
#include <wpi/SafeThread.h>
#include "cscore_cpp.h"

View File

@@ -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;
}

View File

@@ -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();

View File

@@ -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

View File

@@ -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;

View File

@@ -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

View File

@@ -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));

View File

@@ -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);

View File

@@ -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';

View File

@@ -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)));

View File

@@ -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);
}

View File

@@ -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);

View File

@@ -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);

View File

@@ -14,9 +14,9 @@
#include <string>
#include <vector>
#include <llvm/ArrayRef.h>
#include <llvm/SmallVector.h>
#include <llvm/StringRef.h>
#include <wpi/ArrayRef.h>
#include <wpi/SmallVector.h>
#include <wpi/StringRef.h>
#include "cscore_c.h"
@@ -90,7 +90,7 @@ struct RawEvent {
RawEvent() = default;
explicit RawEvent(RawEvent::Kind kind_) : kind{kind_} {}
RawEvent(llvm::StringRef name_, CS_Handle handle_, RawEvent::Kind kind_)
RawEvent(wpi::StringRef name_, CS_Handle handle_, RawEvent::Kind kind_)
: kind{kind_}, name{name_} {
if (kind_ == kSinkCreated || kind_ == kSinkDestroyed ||
kind_ == kSinkEnabled || kind_ == kSinkDisabled)
@@ -98,14 +98,14 @@ struct RawEvent {
else
sourceHandle = handle_;
}
RawEvent(llvm::StringRef name_, CS_Source source_, const VideoMode& mode_)
RawEvent(wpi::StringRef name_, CS_Source source_, const VideoMode& mode_)
: kind{kSourceVideoModeChanged},
sourceHandle{source_},
name{name_},
mode{mode_} {}
RawEvent(llvm::StringRef name_, CS_Source source_, RawEvent::Kind kind_,
RawEvent(wpi::StringRef name_, CS_Source source_, RawEvent::Kind kind_,
CS_Property property_, CS_PropertyKind propertyKind_, int value_,
llvm::StringRef valueStr_)
wpi::StringRef valueStr_)
: kind{kind_},
sourceHandle{source_},
name{name_},
@@ -138,9 +138,9 @@ struct RawEvent {
//
CS_PropertyKind GetPropertyKind(CS_Property property, CS_Status* status);
std::string GetPropertyName(CS_Property property, CS_Status* 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 GetProperty(CS_Property property, CS_Status* status);
void SetProperty(CS_Property property, int value, CS_Status* status);
int GetPropertyMin(CS_Property property, CS_Status* status);
@@ -148,10 +148,10 @@ int GetPropertyMax(CS_Property property, CS_Status* status);
int GetPropertyStep(CS_Property property, CS_Status* status);
int GetPropertyDefault(CS_Property property, CS_Status* status);
std::string GetStringProperty(CS_Property property, CS_Status* status);
llvm::StringRef GetStringProperty(CS_Property property,
llvm::SmallVectorImpl<char>& buf,
CS_Status* status);
void SetStringProperty(CS_Property property, llvm::StringRef value,
wpi::StringRef GetStringProperty(CS_Property property,
wpi::SmallVectorImpl<char>& buf,
CS_Status* status);
void SetStringProperty(CS_Property property, wpi::StringRef value,
CS_Status* status);
std::vector<std::string> GetEnumPropertyChoices(CS_Property property,
CS_Status* status);
@@ -159,15 +159,15 @@ std::vector<std::string> GetEnumPropertyChoices(CS_Property property,
//
// Source Creation Functions
//
CS_Source CreateUsbCameraDev(llvm::StringRef name, int dev, CS_Status* status);
CS_Source CreateUsbCameraPath(llvm::StringRef name, llvm::StringRef path,
CS_Source CreateUsbCameraDev(wpi::StringRef name, int dev, CS_Status* status);
CS_Source CreateUsbCameraPath(wpi::StringRef name, wpi::StringRef path,
CS_Status* status);
CS_Source CreateHttpCamera(llvm::StringRef name, llvm::StringRef url,
CS_Source CreateHttpCamera(wpi::StringRef name, wpi::StringRef url,
CS_HttpCameraKind kind, CS_Status* status);
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);
CS_Source CreateCvSource(llvm::StringRef name, const VideoMode& mode,
CS_Source CreateCvSource(wpi::StringRef name, const VideoMode& mode,
CS_Status* status);
//
@@ -175,19 +175,19 @@ CS_Source CreateCvSource(llvm::StringRef name, const VideoMode& mode,
//
CS_SourceKind GetSourceKind(CS_Source source, CS_Status* status);
std::string GetSourceName(CS_Source source, CS_Status* status);
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);
std::string GetSourceDescription(CS_Source source, CS_Status* status);
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);
uint64_t GetSourceLastFrameTime(CS_Source source, CS_Status* status);
bool IsSourceConnected(CS_Source source, CS_Status* status);
CS_Property GetSourceProperty(CS_Source source, llvm::StringRef name,
CS_Property GetSourceProperty(CS_Source source, wpi::StringRef name,
CS_Status* status);
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);
VideoMode GetSourceVideoMode(CS_Source source, CS_Status* status);
bool SetSourceVideoMode(CS_Source source, const VideoMode& mode,
@@ -199,8 +199,8 @@ bool SetSourceResolution(CS_Source source, int width, int height,
bool SetSourceFPS(CS_Source source, int fps, CS_Status* status);
std::vector<VideoMode> EnumerateSourceVideoModes(CS_Source source,
CS_Status* 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);
CS_Source CopySource(CS_Source source, CS_Status* status);
void ReleaseSource(CS_Source source, CS_Status* status);
@@ -226,7 +226,7 @@ std::string GetUsbCameraPath(CS_Source source, CS_Status* status);
// HttpCamera Source Functions
//
CS_HttpCameraKind GetHttpCameraKind(CS_Source source, CS_Status* status);
void SetHttpCameraUrls(CS_Source source, llvm::ArrayRef<std::string> urls,
void SetHttpCameraUrls(CS_Source source, wpi::ArrayRef<std::string> urls,
CS_Status* status);
std::vector<std::string> GetHttpCameraUrls(CS_Source source, CS_Status* status);
@@ -234,26 +234,26 @@ std::vector<std::string> GetHttpCameraUrls(CS_Source source, CS_Status* status);
// OpenCV Source Functions
//
void PutSourceFrame(CS_Source source, cv::Mat& image, CS_Status* status);
void NotifySourceError(CS_Source source, llvm::StringRef msg,
void NotifySourceError(CS_Source source, wpi::StringRef msg,
CS_Status* status);
void SetSourceConnected(CS_Source source, bool connected, CS_Status* status);
void SetSourceDescription(CS_Source source, llvm::StringRef description,
void SetSourceDescription(CS_Source source, wpi::StringRef description,
CS_Status* status);
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);
void SetSourceEnumPropertyChoices(CS_Source source, CS_Property property,
llvm::ArrayRef<std::string> choices,
wpi::ArrayRef<std::string> choices,
CS_Status* status);
//
// Sink Creation Functions
//
CS_Sink CreateMjpegServer(llvm::StringRef name, llvm::StringRef listenAddress,
CS_Sink CreateMjpegServer(wpi::StringRef name, wpi::StringRef listenAddress,
int port, CS_Status* status);
CS_Sink CreateCvSink(llvm::StringRef name, CS_Status* status);
CS_Sink CreateCvSinkCallback(llvm::StringRef name,
CS_Sink CreateCvSink(wpi::StringRef name, CS_Status* status);
CS_Sink CreateCvSinkCallback(wpi::StringRef name,
std::function<void(uint64_t time)> processFrame,
CS_Status* status);
@@ -262,14 +262,14 @@ CS_Sink CreateCvSinkCallback(llvm::StringRef name,
//
CS_SinkKind GetSinkKind(CS_Sink sink, CS_Status* status);
std::string GetSinkName(CS_Sink sink, CS_Status* status);
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);
std::string GetSinkDescription(CS_Sink sink, CS_Status* status);
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);
void SetSinkSource(CS_Sink sink, CS_Source source, CS_Status* status);
CS_Property GetSinkSourceProperty(CS_Sink sink, llvm::StringRef name,
CS_Property GetSinkSourceProperty(CS_Sink sink, wpi::StringRef name,
CS_Status* status);
CS_Source GetSinkSource(CS_Sink sink, CS_Status* status);
CS_Sink CopySink(CS_Sink sink, CS_Status* status);
@@ -284,14 +284,14 @@ int GetMjpegServerPort(CS_Sink sink, CS_Status* status);
//
// OpenCV Sink Functions
//
void SetSinkDescription(CS_Sink sink, llvm::StringRef description,
void SetSinkDescription(CS_Sink sink, wpi::StringRef description,
CS_Status* status);
uint64_t GrabSinkFrame(CS_Sink sink, cv::Mat& image, CS_Status* status);
uint64_t GrabSinkFrameTimeout(CS_Sink sink, cv::Mat& image, double timeout,
CS_Status* status);
std::string GetSinkError(CS_Sink sink, CS_Status* status);
llvm::StringRef GetSinkError(CS_Sink sink, llvm::SmallVectorImpl<char>& buf,
CS_Status* status);
wpi::StringRef GetSinkError(CS_Sink sink, wpi::SmallVectorImpl<char>& buf,
CS_Status* status);
void SetSinkEnabled(CS_Sink sink, bool enabled, CS_Status* status);
//
@@ -331,10 +331,10 @@ void SetDefaultLogger(unsigned int min_level);
//
std::vector<UsbCameraInfo> EnumerateUsbCameras(CS_Status* status);
llvm::ArrayRef<CS_Source> EnumerateSourceHandles(
llvm::SmallVectorImpl<CS_Source>& vec, CS_Status* status);
llvm::ArrayRef<CS_Sink> EnumerateSinkHandles(
llvm::SmallVectorImpl<CS_Sink>& vec, CS_Status* status);
wpi::ArrayRef<CS_Source> EnumerateSourceHandles(
wpi::SmallVectorImpl<CS_Source>& vec, CS_Status* status);
wpi::ArrayRef<CS_Sink> EnumerateSinkHandles(
wpi::SmallVectorImpl<CS_Sink>& vec, CS_Status* status);
std::string GetHostname();

View File

@@ -65,8 +65,8 @@ class VideoProperty {
// String-specific functions
std::string GetString() const;
llvm::StringRef GetString(llvm::SmallVectorImpl<char>& buf) const;
void SetString(llvm::StringRef value);
wpi::StringRef GetString(wpi::SmallVectorImpl<char>& buf) const;
void SetString(wpi::StringRef value);
// Enum-specific functions
std::vector<std::string> GetChoices() const;
@@ -133,7 +133,7 @@ class VideoSource {
/// @param name Property name
/// @return Property contents (of kind Property::kNone if no property with
/// the given name exists)
VideoProperty GetProperty(llvm::StringRef name);
VideoProperty GetProperty(wpi::StringRef name);
/// Enumerate all properties of this source.
std::vector<VideoProperty> EnumerateProperties() const;
@@ -255,12 +255,12 @@ class UsbCamera : public VideoCamera {
/// Create a source for a USB camera based on device number.
/// @param name Source name (arbitrary unique identifier)
/// @param dev Device number (e.g. 0 for /dev/video0)
UsbCamera(llvm::StringRef name, int dev);
UsbCamera(wpi::StringRef name, int dev);
/// Create a source for a USB camera based on device path.
/// @param name Source name (arbitrary unique identifier)
/// @param path Path to device (e.g. "/dev/video0" on Linux)
UsbCamera(llvm::StringRef name, llvm::StringRef path);
UsbCamera(wpi::StringRef name, wpi::StringRef path);
/// Enumerate USB cameras on the local system.
/// @return Vector of USB camera information (one for each camera)
@@ -284,28 +284,28 @@ class HttpCamera : public VideoCamera {
/// @param name Source name (arbitrary unique identifier)
/// @param url Camera URL (e.g. "http://10.x.y.11/video/stream.mjpg")
/// @param kind Camera kind (e.g. kAxis)
HttpCamera(llvm::StringRef name, llvm::StringRef url,
HttpCamera(wpi::StringRef name, wpi::StringRef url,
HttpCameraKind kind = kUnknown);
/// Create a source for a MJPEG-over-HTTP (IP) camera.
/// @param name Source name (arbitrary unique identifier)
/// @param url Camera URL (e.g. "http://10.x.y.11/video/stream.mjpg")
/// @param kind Camera kind (e.g. kAxis)
HttpCamera(llvm::StringRef name, const char* url,
HttpCamera(wpi::StringRef name, const char* url,
HttpCameraKind kind = kUnknown);
/// Create a source for a MJPEG-over-HTTP (IP) camera.
/// @param name Source name (arbitrary unique identifier)
/// @param url Camera URL (e.g. "http://10.x.y.11/video/stream.mjpg")
/// @param kind Camera kind (e.g. kAxis)
HttpCamera(llvm::StringRef name, const std::string& url,
HttpCamera(wpi::StringRef name, const std::string& url,
HttpCameraKind kind = kUnknown);
/// Create a source for a MJPEG-over-HTTP (IP) camera.
/// @param name Source name (arbitrary unique identifier)
/// @param urls Array of Camera URLs
/// @param kind Camera kind (e.g. kAxis)
HttpCamera(llvm::StringRef name, llvm::ArrayRef<std::string> urls,
HttpCamera(wpi::StringRef name, wpi::ArrayRef<std::string> urls,
HttpCameraKind kind = kUnknown);
/// Create a source for a MJPEG-over-HTTP (IP) camera.
@@ -313,7 +313,7 @@ class HttpCamera : public VideoCamera {
/// @param urls Array of Camera URLs
/// @param kind Camera kind (e.g. kAxis)
template <typename T>
HttpCamera(llvm::StringRef name, std::initializer_list<T> urls,
HttpCamera(wpi::StringRef name, std::initializer_list<T> urls,
HttpCameraKind kind = kUnknown);
/// Get the kind of HTTP camera.
@@ -322,7 +322,7 @@ class HttpCamera : public VideoCamera {
HttpCameraKind GetHttpCameraKind() const;
/// Change the URLs used to connect to the camera.
void SetUrls(llvm::ArrayRef<std::string> urls);
void SetUrls(wpi::ArrayRef<std::string> urls);
/// Change the URLs used to connect to the camera.
template <typename T>
@@ -334,8 +334,8 @@ class HttpCamera : public VideoCamera {
/// A source that represents an Axis IP camera.
class AxisCamera : public HttpCamera {
static std::string HostToUrl(llvm::StringRef host);
static std::vector<std::string> HostToUrl(llvm::ArrayRef<std::string> hosts);
static std::string HostToUrl(wpi::StringRef host);
static std::vector<std::string> HostToUrl(wpi::ArrayRef<std::string> hosts);
template <typename T>
static std::vector<std::string> HostToUrl(std::initializer_list<T> hosts);
@@ -344,32 +344,32 @@ class AxisCamera : public HttpCamera {
/// @param name Source name (arbitrary unique identifier)
/// @param host Camera host IP or DNS name (e.g. "10.x.y.11")
/// @param kind Camera kind (e.g. kAxis)
AxisCamera(llvm::StringRef name, llvm::StringRef host);
AxisCamera(wpi::StringRef name, wpi::StringRef host);
/// Create a source for an Axis IP camera.
/// @param name Source name (arbitrary unique identifier)
/// @param host Camera host IP or DNS name (e.g. "10.x.y.11")
/// @param kind Camera kind (e.g. kAxis)
AxisCamera(llvm::StringRef name, const char* host);
AxisCamera(wpi::StringRef name, const char* host);
/// Create a source for an Axis IP camera.
/// @param name Source name (arbitrary unique identifier)
/// @param host Camera host IP or DNS name (e.g. "10.x.y.11")
/// @param kind Camera kind (e.g. kAxis)
AxisCamera(llvm::StringRef name, const std::string& host);
AxisCamera(wpi::StringRef name, const std::string& host);
/// Create a source for an Axis IP camera.
/// @param name Source name (arbitrary unique identifier)
/// @param hosts Array of Camera host IPs/DNS names
/// @param kind Camera kind (e.g. kAxis)
AxisCamera(llvm::StringRef name, llvm::ArrayRef<std::string> hosts);
AxisCamera(wpi::StringRef name, wpi::ArrayRef<std::string> hosts);
/// Create a source for an Axis IP camera.
/// @param name Source name (arbitrary unique identifier)
/// @param hosts Array of Camera host IPs/DNS names
/// @param kind Camera kind (e.g. kAxis)
template <typename T>
AxisCamera(llvm::StringRef name, std::initializer_list<T> hosts);
AxisCamera(wpi::StringRef name, std::initializer_list<T> hosts);
};
/// A source for user code to provide OpenCV images as video frames.
@@ -380,7 +380,7 @@ class CvSource : public VideoSource {
/// Create an OpenCV source.
/// @param name Source name (arbitrary unique identifier)
/// @param mode Video mode being generated
CvSource(llvm::StringRef name, const VideoMode& mode);
CvSource(wpi::StringRef name, const VideoMode& mode);
/// Create an OpenCV source.
/// @param name Source name (arbitrary unique identifier)
@@ -388,7 +388,7 @@ class CvSource : public VideoSource {
/// @param width width
/// @param height height
/// @param fps fps
CvSource(llvm::StringRef name, VideoMode::PixelFormat pixelFormat, int width,
CvSource(wpi::StringRef name, VideoMode::PixelFormat pixelFormat, int width,
int height, int fps);
/// Put an OpenCV image and notify sinks.
@@ -400,7 +400,7 @@ class CvSource : public VideoSource {
/// Signal sinks that an error has occurred. This should be called instead
/// of NotifyFrame when an error occurs.
void NotifyError(llvm::StringRef msg);
void NotifyError(wpi::StringRef msg);
/// Set source connection status. Defaults to true.
/// @param connected True for connected, false for disconnected
@@ -408,7 +408,7 @@ class CvSource : public VideoSource {
/// Set source description.
/// @param description Description
void SetDescription(llvm::StringRef description);
void SetDescription(wpi::StringRef description);
/// Create a property.
/// @param name Property name
@@ -419,7 +419,7 @@ class CvSource : public VideoSource {
/// @param defaultValue Default value
/// @param value Current value
/// @return Property
VideoProperty CreateProperty(llvm::StringRef name, VideoProperty::Kind kind,
VideoProperty CreateProperty(wpi::StringRef name, VideoProperty::Kind kind,
int minimum, int maximum, int step,
int defaultValue, int value);
@@ -431,7 +431,7 @@ class CvSource : public VideoSource {
/// @param defaultValue Default value
/// @param value Current value
/// @return Property
VideoProperty CreateIntegerProperty(llvm::StringRef name, int minimum,
VideoProperty CreateIntegerProperty(wpi::StringRef name, int minimum,
int maximum, int step, int defaultValue,
int value);
@@ -440,7 +440,7 @@ class CvSource : public VideoSource {
/// @param defaultValue Default value
/// @param value Current value
/// @return Property
VideoProperty CreateBooleanProperty(llvm::StringRef name, bool defaultValue,
VideoProperty CreateBooleanProperty(wpi::StringRef name, bool defaultValue,
bool value);
/// Create a string property.
@@ -448,14 +448,14 @@ class CvSource : public VideoSource {
/// @param defaultValue Default value
/// @param value Current value
/// @return Property
VideoProperty CreateStringProperty(llvm::StringRef name,
llvm::StringRef value);
VideoProperty CreateStringProperty(wpi::StringRef name,
wpi::StringRef value);
/// Configure enum property choices.
/// @param property Property
/// @param choices Choices
void SetEnumPropertyChoices(const VideoProperty& property,
llvm::ArrayRef<std::string> choices);
wpi::ArrayRef<std::string> choices);
/// Configure enum property choices.
/// @param property Property
@@ -517,7 +517,7 @@ class VideoSink {
/// @param name Property name
/// @return Property (kind Property::kNone if no property with
/// the given name exists or no source connected)
VideoProperty GetSourceProperty(llvm::StringRef name);
VideoProperty GetSourceProperty(wpi::StringRef name);
CS_Status GetLastStatus() const { return m_status; }
@@ -547,12 +547,12 @@ class MjpegServer : public VideoSink {
/// @param name Sink name (arbitrary unique identifier)
/// @param listenAddress TCP listen address (empty string for all addresses)
/// @param port TCP port number
MjpegServer(llvm::StringRef name, llvm::StringRef listenAddress, int port);
MjpegServer(wpi::StringRef name, wpi::StringRef listenAddress, int port);
/// Create a MJPEG-over-HTTP server sink.
/// @param name Sink name (arbitrary unique identifier)
/// @param port TCP port number
MjpegServer(llvm::StringRef name, int port) : MjpegServer(name, "", port) {}
MjpegServer(wpi::StringRef name, int port) : MjpegServer(name, "", port) {}
/// Get the listen address of the server.
std::string GetListenAddress() const;
@@ -570,7 +570,7 @@ class CvSink : public VideoSink {
/// WaitForFrame() must be called on the created sink to get each new
/// image.
/// @param name Source name (arbitrary unique identifier)
explicit CvSink(llvm::StringRef name);
explicit CvSink(wpi::StringRef name);
/// Create a sink for accepting OpenCV images in a separate thread.
/// A thread will be created that calls WaitForFrame() and calls the
@@ -580,11 +580,11 @@ class CvSink : public VideoSink {
/// time=0 if an error occurred. processFrame should call GetImage()
/// or GetError() as needed, but should not call (except in very
/// unusual circumstances) WaitForImage().
CvSink(llvm::StringRef name, std::function<void(uint64_t time)> processFrame);
CvSink(wpi::StringRef name, std::function<void(uint64_t time)> processFrame);
/// Set sink description.
/// @param description Description
void SetDescription(llvm::StringRef description);
void SetDescription(wpi::StringRef description);
/// Wait for the next frame and get the image.
/// Times out (returning 0) after timeout seconds.

View File

@@ -50,13 +50,13 @@ inline std::string VideoProperty::GetString() const {
return GetStringProperty(m_handle, &m_status);
}
inline llvm::StringRef VideoProperty::GetString(
llvm::SmallVectorImpl<char>& buf) const {
inline wpi::StringRef VideoProperty::GetString(
wpi::SmallVectorImpl<char>& buf) const {
m_status = 0;
return GetStringProperty(m_handle, buf, &m_status);
}
inline void VideoProperty::SetString(llvm::StringRef value) {
inline void VideoProperty::SetString(wpi::StringRef value) {
m_status = 0;
SetStringProperty(m_handle, value, &m_status);
}
@@ -121,7 +121,7 @@ inline bool VideoSource::IsConnected() const {
return IsSourceConnected(m_handle, &m_status);
}
inline VideoProperty VideoSource::GetProperty(llvm::StringRef name) {
inline VideoProperty VideoSource::GetProperty(wpi::StringRef name) {
m_status = 0;
return VideoProperty{GetSourceProperty(m_handle, name, &m_status)};
}
@@ -215,11 +215,11 @@ inline void VideoCamera::SetExposureManual(int value) {
SetCameraExposureManual(m_handle, value, &m_status);
}
inline UsbCamera::UsbCamera(llvm::StringRef name, int dev) {
inline UsbCamera::UsbCamera(wpi::StringRef name, int dev) {
m_handle = CreateUsbCameraDev(name, dev, &m_status);
}
inline UsbCamera::UsbCamera(llvm::StringRef name, llvm::StringRef path) {
inline UsbCamera::UsbCamera(wpi::StringRef name, wpi::StringRef path) {
m_handle = CreateUsbCameraPath(name, path, &m_status);
}
@@ -233,26 +233,26 @@ inline std::string UsbCamera::GetPath() const {
return ::cs::GetUsbCameraPath(m_handle, &m_status);
}
inline HttpCamera::HttpCamera(llvm::StringRef name, llvm::StringRef url,
inline HttpCamera::HttpCamera(wpi::StringRef name, wpi::StringRef url,
HttpCameraKind kind) {
m_handle = CreateHttpCamera(
name, url, static_cast<CS_HttpCameraKind>(static_cast<int>(kind)),
&m_status);
}
inline HttpCamera::HttpCamera(llvm::StringRef name, const char* url,
inline HttpCamera::HttpCamera(wpi::StringRef name, const char* url,
HttpCameraKind kind) {
m_handle = CreateHttpCamera(
name, url, static_cast<CS_HttpCameraKind>(static_cast<int>(kind)),
&m_status);
}
inline HttpCamera::HttpCamera(llvm::StringRef name, const std::string& url,
inline HttpCamera::HttpCamera(wpi::StringRef name, const std::string& url,
HttpCameraKind kind)
: HttpCamera(name, llvm::StringRef{url}, kind) {}
: HttpCamera(name, wpi::StringRef{url}, kind) {}
inline HttpCamera::HttpCamera(llvm::StringRef name,
llvm::ArrayRef<std::string> urls,
inline HttpCamera::HttpCamera(wpi::StringRef name,
wpi::ArrayRef<std::string> urls,
HttpCameraKind kind) {
m_handle = CreateHttpCamera(
name, urls, static_cast<CS_HttpCameraKind>(static_cast<int>(kind)),
@@ -260,7 +260,7 @@ inline HttpCamera::HttpCamera(llvm::StringRef name,
}
template <typename T>
inline HttpCamera::HttpCamera(llvm::StringRef name,
inline HttpCamera::HttpCamera(wpi::StringRef name,
std::initializer_list<T> urls,
HttpCameraKind kind) {
std::vector<std::string> vec;
@@ -277,7 +277,7 @@ inline HttpCamera::HttpCameraKind HttpCamera::GetHttpCameraKind() const {
static_cast<int>(::cs::GetHttpCameraKind(m_handle, &m_status)));
}
inline void HttpCamera::SetUrls(llvm::ArrayRef<std::string> urls) {
inline void HttpCamera::SetUrls(wpi::ArrayRef<std::string> urls) {
m_status = 0;
::cs::SetHttpCameraUrls(m_handle, urls, &m_status);
}
@@ -296,7 +296,7 @@ inline std::vector<std::string> HttpCamera::GetUrls() const {
return ::cs::GetHttpCameraUrls(m_handle, &m_status);
}
inline std::string AxisCamera::HostToUrl(llvm::StringRef host) {
inline std::string AxisCamera::HostToUrl(wpi::StringRef host) {
std::string rv{"http://"};
rv += host;
rv += "/mjpg/video.mjpg";
@@ -304,11 +304,11 @@ inline std::string AxisCamera::HostToUrl(llvm::StringRef host) {
}
inline std::vector<std::string> AxisCamera::HostToUrl(
llvm::ArrayRef<std::string> hosts) {
wpi::ArrayRef<std::string> hosts) {
std::vector<std::string> rv;
rv.reserve(hosts.size());
for (const auto& host : hosts)
rv.emplace_back(HostToUrl(llvm::StringRef{host}));
rv.emplace_back(HostToUrl(wpi::StringRef{host}));
return rv;
}
@@ -318,33 +318,33 @@ inline std::vector<std::string> AxisCamera::HostToUrl(
std::vector<std::string> rv;
rv.reserve(hosts.size());
for (const auto& host : hosts)
rv.emplace_back(HostToUrl(llvm::StringRef{host}));
rv.emplace_back(HostToUrl(wpi::StringRef{host}));
return rv;
}
inline AxisCamera::AxisCamera(llvm::StringRef name, llvm::StringRef host)
inline AxisCamera::AxisCamera(wpi::StringRef name, wpi::StringRef host)
: HttpCamera(name, HostToUrl(host), kAxis) {}
inline AxisCamera::AxisCamera(llvm::StringRef name, const char* host)
inline AxisCamera::AxisCamera(wpi::StringRef name, const char* host)
: HttpCamera(name, HostToUrl(host), kAxis) {}
inline AxisCamera::AxisCamera(llvm::StringRef name, const std::string& host)
: HttpCamera(name, HostToUrl(llvm::StringRef{host}), kAxis) {}
inline AxisCamera::AxisCamera(wpi::StringRef name, const std::string& host)
: HttpCamera(name, HostToUrl(wpi::StringRef{host}), kAxis) {}
inline AxisCamera::AxisCamera(llvm::StringRef name,
llvm::ArrayRef<std::string> hosts)
inline AxisCamera::AxisCamera(wpi::StringRef name,
wpi::ArrayRef<std::string> hosts)
: HttpCamera(name, HostToUrl(hosts), kAxis) {}
template <typename T>
inline AxisCamera::AxisCamera(llvm::StringRef name,
inline AxisCamera::AxisCamera(wpi::StringRef name,
std::initializer_list<T> hosts)
: HttpCamera(name, HostToUrl(hosts), kAxis) {}
inline CvSource::CvSource(llvm::StringRef name, const VideoMode& mode) {
inline CvSource::CvSource(wpi::StringRef name, const VideoMode& mode) {
m_handle = CreateCvSource(name, mode, &m_status);
}
inline CvSource::CvSource(llvm::StringRef name, VideoMode::PixelFormat format,
inline CvSource::CvSource(wpi::StringRef name, VideoMode::PixelFormat format,
int width, int height, int fps) {
m_handle =
CreateCvSource(name, VideoMode{format, width, height, fps}, &m_status);
@@ -355,7 +355,7 @@ inline void CvSource::PutFrame(cv::Mat& image) {
PutSourceFrame(m_handle, image, &m_status);
}
inline void CvSource::NotifyError(llvm::StringRef msg) {
inline void CvSource::NotifyError(wpi::StringRef msg) {
m_status = 0;
NotifySourceError(m_handle, msg, &m_status);
}
@@ -365,12 +365,12 @@ inline void CvSource::SetConnected(bool connected) {
SetSourceConnected(m_handle, connected, &m_status);
}
inline void CvSource::SetDescription(llvm::StringRef description) {
inline void CvSource::SetDescription(wpi::StringRef description) {
m_status = 0;
SetSourceDescription(m_handle, description, &m_status);
}
inline VideoProperty CvSource::CreateProperty(llvm::StringRef name,
inline VideoProperty CvSource::CreateProperty(wpi::StringRef name,
VideoProperty::Kind kind,
int minimum, int maximum,
int step, int defaultValue,
@@ -381,7 +381,7 @@ inline VideoProperty CvSource::CreateProperty(llvm::StringRef name,
minimum, maximum, step, defaultValue, value, &m_status)};
}
inline VideoProperty CvSource::CreateIntegerProperty(llvm::StringRef name,
inline VideoProperty CvSource::CreateIntegerProperty(wpi::StringRef name,
int minimum, int maximum,
int step, int defaultValue,
int value) {
@@ -391,7 +391,7 @@ inline VideoProperty CvSource::CreateIntegerProperty(llvm::StringRef name,
minimum, maximum, step, defaultValue, value, &m_status)};
}
inline VideoProperty CvSource::CreateBooleanProperty(llvm::StringRef name,
inline VideoProperty CvSource::CreateBooleanProperty(wpi::StringRef name,
bool defaultValue,
bool value) {
m_status = 0;
@@ -400,8 +400,8 @@ inline VideoProperty CvSource::CreateBooleanProperty(llvm::StringRef name,
0, 1, 1, defaultValue ? 1 : 0, value ? 1 : 0, &m_status)};
}
inline VideoProperty CvSource::CreateStringProperty(llvm::StringRef name,
llvm::StringRef value) {
inline VideoProperty CvSource::CreateStringProperty(wpi::StringRef name,
wpi::StringRef value) {
m_status = 0;
auto prop = VideoProperty{CreateSourceProperty(
m_handle, name, static_cast<CS_PropertyKind>(static_cast<int>(VideoProperty::Kind::kString)),
@@ -412,7 +412,7 @@ inline VideoProperty CvSource::CreateStringProperty(llvm::StringRef name,
inline void CvSource::SetEnumPropertyChoices(
const VideoProperty& property, llvm::ArrayRef<std::string> choices) {
const VideoProperty& property, wpi::ArrayRef<std::string> choices) {
m_status = 0;
SetSourceEnumPropertyChoices(m_handle, property.m_handle, choices, &m_status);
}
@@ -473,13 +473,13 @@ inline VideoSource VideoSink::GetSource() const {
return VideoSource{handle == 0 ? 0 : CopySource(handle, &m_status)};
}
inline VideoProperty VideoSink::GetSourceProperty(llvm::StringRef name) {
inline VideoProperty VideoSink::GetSourceProperty(wpi::StringRef name) {
m_status = 0;
return VideoProperty{GetSinkSourceProperty(m_handle, name, &m_status)};
}
inline MjpegServer::MjpegServer(llvm::StringRef name,
llvm::StringRef listenAddress, int port) {
inline MjpegServer::MjpegServer(wpi::StringRef name,
wpi::StringRef listenAddress, int port) {
m_handle = CreateMjpegServer(name, listenAddress, port, &m_status);
}
@@ -493,16 +493,16 @@ inline int MjpegServer::GetPort() const {
return cs::GetMjpegServerPort(m_handle, &m_status);
}
inline CvSink::CvSink(llvm::StringRef name) {
inline CvSink::CvSink(wpi::StringRef name) {
m_handle = CreateCvSink(name, &m_status);
}
inline CvSink::CvSink(llvm::StringRef name,
inline CvSink::CvSink(wpi::StringRef name,
std::function<void(uint64_t time)> processFrame) {
m_handle = CreateCvSinkCallback(name, processFrame, &m_status);
}
inline void CvSink::SetDescription(llvm::StringRef description) {
inline void CvSink::SetDescription(wpi::StringRef description) {
m_status = 0;
SetSinkDescription(m_handle, description, &m_status);
}

View File

@@ -8,7 +8,7 @@
#include "HAL/AnalogInput.h"
#include <FRC_NetworkCommunication/AICalibration.h>
#include <support/mutex.h>
#include <wpi/mutex.h>
#include "AnalogInternal.h"
#include "HAL/AnalogAccumulator.h"

View File

@@ -9,7 +9,7 @@
#include <atomic>
#include <support/mutex.h>
#include <wpi/mutex.h>
#include "HAL/AnalogInput.h"
#include "HAL/ChipObject.h"

View File

@@ -11,7 +11,7 @@
#include <memory>
#include <support/mutex.h>
#include <wpi/mutex.h>
#include "HAL/ChipObject.h"
#include "HAL/Ports.h"

View File

@@ -11,7 +11,7 @@
#include <thread>
#include <FRC_NetworkCommunication/LoadOut.h>
#include <support/mutex.h>
#include <wpi/mutex.h>
#include "ConstantsInternal.h"
#include "HAL/AnalogTrigger.h"

View File

@@ -11,7 +11,7 @@
#include <memory>
#include <support/mutex.h>
#include <wpi/mutex.h>
#include "HAL/AnalogTrigger.h"
#include "HAL/ChipObject.h"

View File

@@ -13,9 +13,9 @@
#include <FRC_NetworkCommunication/FRCComm.h>
#include <FRC_NetworkCommunication/NetCommRPCProxy_Occur.h>
#include <llvm/raw_ostream.h>
#include <support/condition_variable.h>
#include <support/mutex.h>
#include <wpi/condition_variable.h>
#include <wpi/mutex.h>
#include <wpi/raw_ostream.h>
#include "HAL/DriverStation.h"
@@ -73,12 +73,12 @@ int32_t HAL_SendError(HAL_Bool isError, int32_t errorCode, HAL_Bool isLVCode,
details, location, callStack);
if (printMsg) {
if (location && location[0] != '\0') {
llvm::errs() << (isError ? "Error" : "Warning") << " at " << location
<< ": ";
wpi::errs() << (isError ? "Error" : "Warning") << " at " << location
<< ": ";
}
llvm::errs() << details << "\n";
wpi::errs() << details << "\n";
if (callStack && callStack[0] != '\0') {
llvm::errs() << callStack << "\n";
wpi::errs() << callStack << "\n";
}
}
if (i == KEEP_MSGS) {

View File

@@ -18,9 +18,9 @@
#include <FRC_NetworkCommunication/FRCComm.h>
#include <FRC_NetworkCommunication/LoadOut.h>
#include <llvm/raw_ostream.h>
#include <support/mutex.h>
#include <support/timestamp.h>
#include <wpi/mutex.h>
#include <wpi/raw_ostream.h>
#include <wpi/timestamp.h>
#include "HAL/ChipObject.h"
#include "HAL/DriverStation.h"
@@ -329,20 +329,20 @@ static bool killExistingProgram(int timeout, int mode) {
// see if the pid is around, but we don't want to mess with init id=1, or
// ourselves
if (pid >= 2 && kill(pid, 0) == 0 && pid != getpid()) {
llvm::outs() << "Killing previously running FRC program...\n";
wpi::outs() << "Killing previously running FRC program...\n";
kill(pid, SIGTERM); // try to kill it
std::this_thread::sleep_for(std::chrono::milliseconds(timeout));
if (kill(pid, 0) == 0) {
// still not successfull
if (mode == 0) {
llvm::outs() << "FRC pid " << pid << " did not die within " << timeout
<< "ms. Aborting\n";
wpi::outs() << "FRC pid " << pid << " did not die within " << timeout
<< "ms. Aborting\n";
return 0; // just fail
} else if (mode == 1) { // kill -9 it
kill(pid, SIGKILL);
} else {
llvm::outs() << "WARNING: FRC pid " << pid << " did not die within "
<< timeout << "ms.\n";
wpi::outs() << "WARNING: FRC pid " << pid << " did not die within "
<< timeout << "ms.\n";
}
}
}
@@ -374,7 +374,7 @@ HAL_Bool HAL_Initialize(int32_t timeout, int32_t mode) {
setlinebuf(stdin);
setlinebuf(stdout);
llvm::outs().SetUnbuffered();
wpi::outs().SetUnbuffered();
prctl(PR_SET_PDEATHSIG, SIGTERM);
@@ -401,10 +401,10 @@ HAL_Bool HAL_Initialize(int32_t timeout, int32_t mode) {
int32_t status = 0;
uint64_t rv = HAL_GetFPGATime(&status);
if (status != 0) {
llvm::errs()
wpi::errs()
<< "Call to HAL_GetFPGATime failed."
<< "Initialization might have failed. Time will not be correct\n";
llvm::errs().flush();
wpi::errs().flush();
return 0u;
}
return rv;

View File

@@ -9,7 +9,7 @@
#include <memory>
#include <support/SafeThread.h>
#include <wpi/SafeThread.h>
#include "DigitalInternal.h"
#include "HAL/ChipObject.h"

View File

@@ -11,8 +11,8 @@
#include <cstdlib> // For std::atexit()
#include <memory>
#include <support/condition_variable.h>
#include <support/mutex.h>
#include <wpi/condition_variable.h>
#include <wpi/mutex.h>
#include "HAL/ChipObject.h"
#include "HAL/Errors.h"

View File

@@ -217,9 +217,9 @@ int32_t HAL_ReadOSSerial(HAL_SerialPort port, char* buffer, int32_t count,
std::memcpy(&buffer[bytesRead], buf, rx);
bytesRead += rx;
if (bytesRead >= count) break;
llvm::StringRef tmp(buffer, bytesRead);
wpi::StringRef tmp(buffer, bytesRead);
auto loc = tmp.find('\n');
if (loc != llvm::StringRef::npos) {
if (loc != wpi::StringRef::npos) {
bytesRead = loc;
break;
}

View File

@@ -16,8 +16,8 @@
#include <atomic>
#include <cstring>
#include <llvm/raw_ostream.h>
#include <support/mutex.h>
#include <wpi/raw_ostream.h>
#include <wpi/mutex.h>
#include "DigitalInternal.h"
#include "HAL/DIO.h"
@@ -196,20 +196,20 @@ void HAL_InitializeSPI(HAL_SPIPort port, int32_t* status) {
if ((digitalHandles[5] = HAL_InitializeDIOPort(createPortHandleForSPI(14),
false, status)) ==
HAL_kInvalidHandle) {
llvm::outs() << "Failed to allocate DIO 14\n";
wpi::outs() << "Failed to allocate DIO 14\n";
return;
}
if ((digitalHandles[6] = HAL_InitializeDIOPort(createPortHandleForSPI(15),
false, status)) ==
HAL_kInvalidHandle) {
llvm::outs() << "Failed to allocate DIO 15\n";
wpi::outs() << "Failed to allocate DIO 15\n";
HAL_FreeDIOPort(digitalHandles[5]); // free the first port allocated
return;
}
if ((digitalHandles[7] = HAL_InitializeDIOPort(createPortHandleForSPI(16),
false, status)) ==
HAL_kInvalidHandle) {
llvm::outs() << "Failed to allocate DIO 16\n";
wpi::outs() << "Failed to allocate DIO 16\n";
HAL_FreeDIOPort(digitalHandles[5]); // free the first port allocated
HAL_FreeDIOPort(digitalHandles[6]); // free the second port allocated
return;
@@ -217,7 +217,7 @@ void HAL_InitializeSPI(HAL_SPIPort port, int32_t* status) {
if ((digitalHandles[8] = HAL_InitializeDIOPort(createPortHandleForSPI(17),
false, status)) ==
HAL_kInvalidHandle) {
llvm::outs() << "Failed to allocate DIO 17\n";
wpi::outs() << "Failed to allocate DIO 17\n";
HAL_FreeDIOPort(digitalHandles[5]); // free the first port allocated
HAL_FreeDIOPort(digitalHandles[6]); // free the second port allocated
HAL_FreeDIOPort(digitalHandles[7]); // free the third port allocated

View File

@@ -11,8 +11,8 @@
#include <cstdio>
#include <cstring>
#include <llvm/FileSystem.h>
#include <llvm/StringRef.h>
#include <wpi/FileSystem.h>
#include <wpi/StringRef.h>
#include "../visa/visa.h"
#include "HAL/Errors.h"
@@ -137,22 +137,22 @@ void SerialHelper::SortHubPathVector() {
m_sortedHubPath.clear();
m_sortedHubPath = m_unsortedHubPath;
std::sort(m_sortedHubPath.begin(), m_sortedHubPath.end(),
[](const llvm::SmallVectorImpl<char>& lhs,
const llvm::SmallVectorImpl<char>& rhs) -> int {
llvm::StringRef lhsRef(lhs.begin(), lhs.size());
llvm::StringRef rhsRef(rhs.begin(), rhs.size());
[](const wpi::SmallVectorImpl<char>& lhs,
const wpi::SmallVectorImpl<char>& rhs) -> int {
wpi::StringRef lhsRef(lhs.begin(), lhs.size());
wpi::StringRef rhsRef(rhs.begin(), rhs.size());
return lhsRef.compare(rhsRef);
});
}
void SerialHelper::CoiteratedSort(
llvm::SmallVectorImpl<llvm::SmallString<16>>& vec) {
llvm::SmallVector<llvm::SmallString<16>, 4> sortedVec;
wpi::SmallVectorImpl<wpi::SmallString<16>>& vec) {
wpi::SmallVector<wpi::SmallString<16>, 4> sortedVec;
for (auto& str : m_sortedHubPath) {
for (size_t i = 0; i < m_unsortedHubPath.size(); i++) {
if (llvm::StringRef{m_unsortedHubPath[i].begin(),
if (wpi::StringRef{m_unsortedHubPath[i].begin(),
m_unsortedHubPath[i].size()}
.equals(llvm::StringRef{str.begin(), str.size()})) {
.equals(wpi::StringRef{str.begin(), str.size()})) {
sortedVec.push_back(vec[i]);
break;
}
@@ -206,26 +206,26 @@ void SerialHelper::QueryHubPaths(int32_t* status) {
*status = 0;
// split until (/dev/
llvm::StringRef devNameRef = llvm::StringRef{osName}.split("(/dev/").second;
wpi::StringRef devNameRef = wpi::StringRef{osName}.split("(/dev/").second;
// String not found, continue
if (devNameRef.equals("")) continue;
// Split at )
llvm::StringRef matchString = devNameRef.split(')').first;
wpi::StringRef matchString = devNameRef.split(')').first;
if (matchString.equals(devNameRef)) continue;
// Search directories to get a list of system accessors
std::error_code ec;
for (auto p = llvm::sys::fs::recursive_directory_iterator(
for (auto p = wpi::sys::fs::recursive_directory_iterator(
"/sys/devices/soc0", ec);
p != llvm::sys::fs::recursive_directory_iterator(); p.increment(ec)) {
p != wpi::sys::fs::recursive_directory_iterator(); p.increment(ec)) {
if (ec) break;
llvm::StringRef path{p->path()};
if (path.find("amba") == llvm::StringRef::npos) continue;
if (path.find("usb") == llvm::StringRef::npos) continue;
if (path.find(matchString) == llvm::StringRef::npos) continue;
wpi::StringRef path{p->path()};
if (path.find("amba") == wpi::StringRef::npos) continue;
if (path.find("usb") == wpi::StringRef::npos) continue;
if (path.find(matchString) == wpi::StringRef::npos) continue;
llvm::SmallVector<llvm::StringRef, 16> pathSplitVec;
wpi::SmallVector<wpi::StringRef, 16> pathSplitVec;
// Split path into individual directories
path.split(pathSplitVec, '/', -1, false);
@@ -255,10 +255,10 @@ void SerialHelper::QueryHubPaths(int32_t* status) {
// Add our devices to our list
m_unsortedHubPath.emplace_back(
llvm::StringRef{pathSplitVec[hubIndex - 2]});
wpi::StringRef{pathSplitVec[hubIndex - 2]});
m_visaResource.emplace_back(desc);
m_osResource.emplace_back(
llvm::StringRef{osName}.split("(").second.split(")").first);
wpi::StringRef{osName}.split("(").second.split(")").first);
break;
}
}
@@ -277,7 +277,7 @@ int32_t SerialHelper::GetIndexForPort(HAL_SerialPort port, int32_t* status) {
std::string portString = m_usbNames[port - 2];
llvm::SmallVector<int32_t, 4> indices;
wpi::SmallVector<int32_t, 4> indices;
// If port has not been assigned, find the one to assign
if (portString.empty()) {

View File

@@ -4,7 +4,7 @@
#include <map>
#include <string.h> // memcpy
#include <sys/time.h>
#include <support/mutex.h>
#include <wpi/mutex.h>
class CtreCanNode
{
public:

View File

@@ -7,7 +7,7 @@
#include "HAL/cpp/fpga_clock.h"
#include <llvm/raw_ostream.h>
#include <wpi/raw_ostream.h>
#include "HAL/HAL.h"
@@ -20,10 +20,10 @@ fpga_clock::time_point fpga_clock::now() noexcept {
int32_t status = 0;
uint64_t currentTime = HAL_GetFPGATime(&status);
if (status != 0) {
llvm::errs()
wpi::errs()
<< "Call to HAL_GetFPGATime failed."
<< "Initialization might have failed. Time will not be correct\n";
llvm::errs().flush();
wpi::errs().flush();
return epoch();
}
return time_point(std::chrono::microseconds(currentTime));

View File

@@ -9,14 +9,14 @@
#include <algorithm>
#include <llvm/SmallVector.h>
#include <support/mutex.h>
#include <wpi/SmallVector.h>
#include <wpi/mutex.h>
namespace hal {
static llvm::SmallVector<HandleBase*, 32>* globalHandles = nullptr;
static wpi::SmallVector<HandleBase*, 32>* globalHandles = nullptr;
static wpi::mutex globalHandleMutex;
HandleBase::HandleBase() {
static llvm::SmallVector<HandleBase*, 32> gH;
static wpi::SmallVector<HandleBase*, 32> gH;
std::lock_guard<wpi::mutex> lock(globalHandleMutex);
if (!globalHandles) {
globalHandles = &gH;

View File

@@ -12,9 +12,9 @@
#include "HAL/CAN.h"
#include "HALUtil.h"
#include "edu_wpi_first_wpilibj_can_CANJNI.h"
#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"
using namespace frc;
using namespace wpi::java;
@@ -53,8 +53,8 @@ Java_edu_wpi_first_wpilibj_can_CANJNI_FRCNetCommCANSessionMuxSendMessage(
if (logDEBUG <= canJNILogLevel) {
if (dataBuffer) {
llvm::SmallString<128> buf;
llvm::raw_svector_ostream str(buf);
wpi::SmallString<128> buf;
wpi::raw_svector_ostream str(buf);
for (int32_t i = 0; i < dataSize; i++) {
str.write_hex(dataBuffer[i]) << ' ';
}
@@ -102,8 +102,8 @@ Java_edu_wpi_first_wpilibj_can_CANJNI_FRCNetCommCANSessionMuxReceiveMessage(
CANJNI_LOG(logDEBUG).write_hex(*messageIDPtr);
if (logDEBUG <= canJNILogLevel) {
llvm::SmallString<128> buf;
llvm::raw_svector_ostream str(buf);
wpi::SmallString<128> buf;
wpi::raw_svector_ostream str(buf);
for (int32_t i = 0; i < dataSize; i++) {
// Pad one-digit data with a zero
@@ -121,7 +121,7 @@ Java_edu_wpi_first_wpilibj_can_CANJNI_FRCNetCommCANSessionMuxReceiveMessage(
CANJNI_LOG(logDEBUG) << "Status: " << status;
if (!CheckCANStatus(env, status, *messageIDPtr)) return nullptr;
return MakeJByteArray(env, llvm::StringRef{reinterpret_cast<const char*>(buffer),
return MakeJByteArray(env, wpi::StringRef{reinterpret_cast<const char*>(buffer),
static_cast<size_t>(dataSize)});
}

View File

@@ -15,7 +15,7 @@
#include "HAL/DriverStation.h"
#include "edu_wpi_first_wpilibj_hal_HAL.h"
#include "HALUtil.h"
#include "support/jni_util.h"
#include "wpi/jni_util.h"
using namespace frc;
using namespace wpi::java;

View File

@@ -21,9 +21,9 @@
#include "HAL/Errors.h"
#include "HAL/cpp/Log.h"
#include "edu_wpi_first_wpilibj_hal_HALUtil.h"
#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"
using namespace wpi::java;
@@ -64,8 +64,8 @@ namespace frc {
void ThrowAllocationException(JNIEnv *env, int32_t minRange, int32_t maxRange,
int32_t requestedValue, int32_t status) {
const char *message = HAL_GetErrorMessage(status);
llvm::SmallString<1024> buf;
llvm::raw_svector_ostream oss(buf);
wpi::SmallString<1024> buf;
wpi::raw_svector_ostream oss(buf);
oss << " Code: " << status << ". " << message << ", Minimum Value: "
<< minRange << ", Maximum Value: " << maxRange << ", Requested Value: "
<< requestedValue;
@@ -75,8 +75,8 @@ void ThrowAllocationException(JNIEnv *env, int32_t minRange, int32_t maxRange,
void ThrowHalHandleException(JNIEnv *env, int32_t status) {
const char *message = HAL_GetErrorMessage(status);
llvm::SmallString<1024> buf;
llvm::raw_svector_ostream oss(buf);
wpi::SmallString<1024> buf;
wpi::raw_svector_ostream oss(buf);
oss << " Code: " << status << ". " << message;
halHandleExCls.Throw(env, buf.c_str());
}
@@ -88,8 +88,8 @@ void ReportError(JNIEnv *env, int32_t status, bool doThrow) {
}
const char *message = HAL_GetErrorMessage(status);
if (doThrow && status < 0) {
llvm::SmallString<1024> buf;
llvm::raw_svector_ostream oss(buf);
wpi::SmallString<1024> buf;
wpi::raw_svector_ostream oss(buf);
oss << " Code: " << status << ". " << message;
runtimeExCls.Throw(env, buf.c_str());
} else {
@@ -111,8 +111,8 @@ void ThrowError(JNIEnv *env, int32_t status, int32_t minRange, int32_t maxRange,
ThrowHalHandleException(env, status);
}
const char *message = HAL_GetErrorMessage(status);
llvm::SmallString<1024> buf;
llvm::raw_svector_ostream oss(buf);
wpi::SmallString<1024> buf;
wpi::raw_svector_ostream oss(buf);
oss << " Code: " << status << ". " << message;
runtimeExCls.Throw(env, buf.c_str());
}
@@ -147,8 +147,8 @@ void ReportCANError(JNIEnv *env, int32_t status, int message_id) {
}
case HAL_ERR_CANSessionMux_NotAllowed:
case kRIOStatusFeatureNotSupported: {
llvm::SmallString<100> buf;
llvm::raw_svector_ostream oss(buf);
wpi::SmallString<100> buf;
wpi::raw_svector_ostream oss(buf);
oss << "MessageID = " << message_id;
canMessageNotAllowedExCls.Throw(env, buf.c_str());
break;
@@ -165,8 +165,8 @@ void ReportCANError(JNIEnv *env, int32_t status, int message_id) {
break;
}
default: {
llvm::SmallString<100> buf;
llvm::raw_svector_ostream oss(buf);
wpi::SmallString<100> buf;
wpi::raw_svector_ostream oss(buf);
oss << "Fatal status code detected: " << status;
uncleanStatusExCls.Throw(env, buf.c_str());
break;

View File

@@ -13,7 +13,7 @@
#include "HAL/I2C.h"
#include "HALUtil.h"
#include "support/jni_util.h"
#include "wpi/jni_util.h"
using namespace frc;
using namespace wpi::java;
@@ -83,7 +83,7 @@ JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_I2CJNI_i2CTransactionB(
I2CJNI_LOG(logDEBUG) << "Port = " << port;
I2CJNI_LOG(logDEBUG) << "Address = " << (jint)address;
I2CJNI_LOG(logDEBUG) << "SendSize = " << (jint)sendSize;
llvm::SmallVector<uint8_t, 128> recvBuf;
wpi::SmallVector<uint8_t, 128> recvBuf;
recvBuf.resize(receiveSize);
I2CJNI_LOG(logDEBUG) << "ReceiveSize = " << (jint)receiveSize;
jint returnValue =
@@ -173,7 +173,7 @@ JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_I2CJNI_i2CReadB(
I2CJNI_LOG(logDEBUG) << "Port = " << port;
I2CJNI_LOG(logDEBUG) << "Address = " << address;
I2CJNI_LOG(logDEBUG) << "ReceiveSize = " << receiveSize;
llvm::SmallVector<uint8_t, 128> recvBuf;
wpi::SmallVector<uint8_t, 128> recvBuf;
recvBuf.resize(receiveSize);
jint returnValue = HAL_ReadI2C(static_cast<HAL_I2CPort>(port), address, recvBuf.data(), receiveSize);
env->SetByteArrayRegion(dataReceived, 0, receiveSize,

View File

@@ -10,14 +10,14 @@
#include <atomic>
#include <thread>
#include <support/mutex.h>
#include <wpi/SafeThread.h>
#include <wpi/mutex.h>
#include "HAL/cpp/Log.h"
#include "HAL/Interrupts.h"
#include "HALUtil.h"
#include "edu_wpi_first_wpilibj_hal_InterruptJNI.h"
#include "support/SafeThread.h"
using namespace frc;

View File

@@ -13,7 +13,7 @@
#include "HAL/OSSerialPort.h"
#include "HALUtil.h"
#include "support/jni_util.h"
#include "wpi/jni_util.h"
using namespace frc;
using namespace wpi::java;
@@ -244,7 +244,7 @@ Java_edu_wpi_first_wpilibj_hal_OSSerialPortJNI_serialGetBytesReceived(
JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_OSSerialPortJNI_serialRead(
JNIEnv* env, jclass, jbyte port, jbyteArray dataReceived, jint size) {
SERIALJNI_LOG(logDEBUG) << "Serial Read";
llvm::SmallVector<char, 128> recvBuf;
wpi::SmallVector<char, 128> recvBuf;
recvBuf.resize(size);
int32_t status = 0;
jint retVal = HAL_ReadOSSerial(static_cast<HAL_SerialPort>(port), recvBuf.data(),

View File

@@ -13,7 +13,7 @@
#include "HAL/SPI.h"
#include "HALUtil.h"
#include "support/jni_util.h"
#include "wpi/jni_util.h"
using namespace frc;
using namespace wpi::java;
@@ -79,7 +79,7 @@ JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_SPIJNI_spiTransactionB(
SPIJNI_LOG(logDEBUG) << "Calling SPIJNI spiTransactionB";
SPIJNI_LOG(logDEBUG) << "Port = " << (jint)port;
SPIJNI_LOG(logDEBUG) << "Size = " << (jint)size;
llvm::SmallVector<uint8_t, 128> recvBuf;
wpi::SmallVector<uint8_t, 128> recvBuf;
recvBuf.resize(size);
jint retVal =
HAL_TransactionSPI(static_cast<HAL_SPIPort>(port),
@@ -146,7 +146,7 @@ JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_SPIJNI_spiRead(
SPIJNI_LOG(logDEBUG) << "DataReceivedPtr = " << dataReceivedPtr;
jint retVal;
if (initiate) {
llvm::SmallVector<uint8_t, 128> sendBuf;
wpi::SmallVector<uint8_t, 128> sendBuf;
sendBuf.resize(size);
retVal = HAL_TransactionSPI(static_cast<HAL_SPIPort>(port), sendBuf.data(), dataReceivedPtr, size);
} else {
@@ -168,10 +168,10 @@ JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_SPIJNI_spiReadB(
SPIJNI_LOG(logDEBUG) << "Initiate = " << (jboolean)initiate;
SPIJNI_LOG(logDEBUG) << "Size = " << (jint)size;
jint retVal;
llvm::SmallVector<uint8_t, 128> recvBuf;
wpi::SmallVector<uint8_t, 128> recvBuf;
recvBuf.resize(size);
if (initiate) {
llvm::SmallVector<uint8_t, 128> sendBuf;
wpi::SmallVector<uint8_t, 128> sendBuf;
sendBuf.resize(size);
retVal = HAL_TransactionSPI(static_cast<HAL_SPIPort>(port), sendBuf.data(), recvBuf.data(), size);
} else {
@@ -404,7 +404,7 @@ JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_SPIJNI_spiReadAutoReceived
SPIJNI_LOG(logDEBUG) << "Port = " << port;
SPIJNI_LOG(logDEBUG) << "NumToRead = " << numToRead;
SPIJNI_LOG(logDEBUG) << "Timeout = " << timeout;
llvm::SmallVector<uint8_t, 128> recvBuf;
wpi::SmallVector<uint8_t, 128> recvBuf;
recvBuf.resize(numToRead);
int32_t status = 0;
jint retval = HAL_ReadSPIAutoReceivedData(static_cast<HAL_SPIPort>(port), recvBuf.data(), numToRead, timeout, &status);

View File

@@ -13,7 +13,7 @@
#include "HAL/SerialPort.h"
#include "HALUtil.h"
#include "support/jni_util.h"
#include "wpi/jni_util.h"
using namespace frc;
using namespace wpi::java;
@@ -263,7 +263,7 @@ Java_edu_wpi_first_wpilibj_hal_SerialPortJNI_serialGetBytesReceived(
JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_SerialPortJNI_serialRead(
JNIEnv* env, jclass, jbyte port, jbyteArray dataReceived, jint size) {
SERIALJNI_LOG(logDEBUG) << "Serial Read";
llvm::SmallVector<char, 128> recvBuf;
wpi::SmallVector<char, 128> recvBuf;
recvBuf.resize(size);
int32_t status = 0;
jint retVal = HAL_ReadSerial(static_cast<HAL_SerialPort>(port), recvBuf.data(),

View File

@@ -10,8 +10,8 @@
#include <chrono>
#include <string>
#include <llvm/SmallString.h>
#include <llvm/raw_ostream.h>
#include <wpi/SmallString.h>
#include <wpi/raw_ostream.h>
inline std::string NowTime();
@@ -31,7 +31,7 @@ class Log {
public:
Log();
virtual ~Log();
llvm::raw_ostream& Get(TLogLevel level = logINFO);
wpi::raw_ostream& Get(TLogLevel level = logINFO);
public:
static TLogLevel& ReportingLevel();
@@ -39,8 +39,8 @@ class Log {
static TLogLevel FromString(const std::string& level);
protected:
llvm::SmallString<128> buf;
llvm::raw_svector_ostream oss{buf};
wpi::SmallString<128> buf;
wpi::raw_svector_ostream oss{buf};
private:
Log(const Log&);
@@ -49,7 +49,7 @@ class Log {
inline Log::Log() {}
inline llvm::raw_ostream& Log::Get(TLogLevel level) {
inline wpi::raw_ostream& Log::Get(TLogLevel level) {
oss << "- " << NowTime();
oss << " " << ToString(level) << ": ";
if (level > logDEBUG) {
@@ -60,7 +60,7 @@ inline llvm::raw_ostream& Log::Get(TLogLevel level) {
inline Log::~Log() {
oss << "\n";
llvm::errs() << oss.str();
wpi::errs() << oss.str();
}
inline TLogLevel& Log::ReportingLevel() {
@@ -99,8 +99,8 @@ typedef Log FILELog;
Log().Get(level)
inline std::string NowTime() {
llvm::SmallString<128> buf;
llvm::raw_svector_ostream oss(buf);
wpi::SmallString<128> buf;
wpi::raw_svector_ostream oss(buf);
using std::chrono::duration_cast;

View File

@@ -12,9 +12,9 @@
#include <string>
#include <vector>
#include <llvm/SmallString.h>
#include <llvm/SmallVector.h>
#include <support/mutex.h>
#include <wpi/SmallString.h>
#include <wpi/SmallVector.h>
#include <wpi/mutex.h>
#include "HAL/SerialPort.h"
@@ -31,7 +31,7 @@ class SerialHelper {
private:
void SortHubPathVector();
void CoiteratedSort(llvm::SmallVectorImpl<llvm::SmallString<16>>& vec);
void CoiteratedSort(wpi::SmallVectorImpl<wpi::SmallString<16>>& vec);
void QueryHubPaths(int32_t* status);
int32_t GetIndexForPort(HAL_SerialPort port, int32_t* status);
@@ -39,10 +39,10 @@ class SerialHelper {
// Vectors to hold data before sorting.
// Note we will most likely have at max 2 instances, and the longest string
// is around 12, so these should never touch the heap;
llvm::SmallVector<llvm::SmallString<16>, 4> m_visaResource;
llvm::SmallVector<llvm::SmallString<16>, 4> m_osResource;
llvm::SmallVector<llvm::SmallString<16>, 4> m_unsortedHubPath;
llvm::SmallVector<llvm::SmallString<16>, 4> m_sortedHubPath;
wpi::SmallVector<wpi::SmallString<16>, 4> m_visaResource;
wpi::SmallVector<wpi::SmallString<16>, 4> m_osResource;
wpi::SmallVector<wpi::SmallString<16>, 4> m_unsortedHubPath;
wpi::SmallVector<wpi::SmallString<16>, 4> m_sortedHubPath;
int32_t m_resourceHandle;

View File

@@ -7,7 +7,7 @@
#pragma once
#include <support/mutex.h>
#include <wpi/mutex.h>
#include "HAL/ChipObject.h"
#include "HAL/Types.h"

View File

@@ -12,7 +12,7 @@
#include <array>
#include <memory>
#include <support/mutex.h>
#include <wpi/mutex.h>
#include "HAL/Errors.h"
#include "HAL/Types.h"

View File

@@ -13,7 +13,7 @@
#include <memory>
#include <vector>
#include <support/mutex.h>
#include <wpi/mutex.h>
#include "HAL/Errors.h"
#include "HAL/Types.h"

View File

@@ -12,7 +12,7 @@
#include <array>
#include <memory>
#include <support/mutex.h>
#include <wpi/mutex.h>
#include "HAL/Errors.h"
#include "HAL/Types.h"

View File

@@ -12,7 +12,7 @@
#include <array>
#include <memory>
#include <support/mutex.h>
#include <wpi/mutex.h>
#include "HAL/Types.h"
#include "HAL/cpp/make_unique.h"

View File

@@ -12,7 +12,7 @@
#include <array>
#include <memory>
#include <support/mutex.h>
#include <wpi/mutex.h>
#include "HAL/Types.h"
#include "HAL/cpp/make_unique.h"

View File

@@ -13,7 +13,7 @@
#include <utility>
#include <vector>
#include <support/mutex.h>
#include <wpi/mutex.h>
#include "HAL/Types.h"
#include "HAL/handles/HandlesInternal.h"

View File

@@ -16,8 +16,8 @@
#include <cstring>
#include <string>
#include <support/condition_variable.h>
#include <support/mutex.h>
#include <wpi/condition_variable.h>
#include <wpi/mutex.h>
#include "MockData/DriverStationDataInternal.h"
#include "MockData/MockHooks.h"

View File

@@ -7,8 +7,8 @@
#include "HAL/Extensions.h"
#include <llvm/SmallString.h>
#include <llvm/StringRef.h>
#include <wpi/SmallString.h>
#include <wpi/StringRef.h>
#include "HAL/HAL.h"
@@ -46,7 +46,7 @@ int HAL_LoadOneExtension(const char* library) {
HTYPE handle = DLOPEN(library);
#if !defined(WIN32) && !defined(_WIN32)
if (!handle) {
llvm::SmallString<128> libraryName("lib");
wpi::SmallString<128> libraryName("lib");
libraryName += library;
#if defined(__APPLE__)
libraryName += ".dylib";
@@ -73,13 +73,13 @@ int HAL_LoadOneExtension(const char* library) {
*/
int HAL_LoadExtensions(void) {
int rc = 1;
llvm::SmallVector<llvm::StringRef, 2> libraries;
wpi::SmallVector<wpi::StringRef, 2> libraries;
const char* e = std::getenv("HALSIM_EXTENSIONS");
if (!e) return rc;
llvm::StringRef env{e};
wpi::StringRef env{e};
env.split(libraries, DELIM, -1, false);
for (auto& libref : libraries) {
llvm::SmallString<128> library(libref);
wpi::SmallString<128> library(libref);
rc = HAL_LoadOneExtension(library.c_str());
if (rc < 0) break;
}

View File

@@ -7,7 +7,7 @@
#include "HAL/HAL.h"
#include <llvm/raw_ostream.h>
#include <wpi/raw_ostream.h>
#include "ErrorsInternal.h"
#include "HAL/DriverStation.h"
@@ -263,7 +263,7 @@ HAL_Bool HAL_Initialize(int32_t timeout, int32_t mode) {
hal::init::InitializeHAL();
llvm::outs().SetUnbuffered();
wpi::outs().SetUnbuffered();
if (HAL_LoadExtensions() < 0) return false;
hal::RestartTiming();
HAL_InitializeDriverStation();

View File

@@ -9,7 +9,7 @@
#include <memory>
#include <support/condition_variable.h>
#include <wpi/condition_variable.h>
#include "AnalogInternal.h"
#include "DigitalInternal.h"

View File

@@ -10,7 +10,7 @@
#include <atomic>
#include <memory>
#include <support/mutex.h>
#include <wpi/mutex.h>
#include "MockData/AccelerometerData.h"
#include "MockData/NotifyListenerVector.h"

View File

@@ -10,7 +10,7 @@
#include <atomic>
#include <memory>
#include <support/mutex.h>
#include <wpi/mutex.h>
#include "MockData/AnalogGyroData.h"
#include "MockData/NotifyListenerVector.h"

View File

@@ -10,7 +10,7 @@
#include <atomic>
#include <memory>
#include <support/mutex.h>
#include <wpi/mutex.h>
#include "MockData/AnalogInData.h"
#include "MockData/NotifyListenerVector.h"

View File

@@ -10,7 +10,7 @@
#include <atomic>
#include <memory>
#include <support/mutex.h>
#include <wpi/mutex.h>
#include "MockData/AnalogOutData.h"
#include "MockData/NotifyListenerVector.h"

View File

@@ -10,7 +10,7 @@
#include <atomic>
#include <memory>
#include <support/mutex.h>
#include <wpi/mutex.h>
#include "MockData/AnalogTriggerData.h"
#include "MockData/NotifyListenerVector.h"

View File

@@ -11,7 +11,7 @@
#include <limits>
#include <memory>
#include <support/mutex.h>
#include <wpi/mutex.h>
#include "MockData/CanData.h"
#include "MockData/NotifyCallbackHelpers.h"

View File

@@ -10,7 +10,7 @@
#include <atomic>
#include <memory>
#include <support/mutex.h>
#include <wpi/mutex.h>
#include "MockData/DIOData.h"
#include "MockData/NotifyListenerVector.h"

View File

@@ -10,7 +10,7 @@
#include <atomic>
#include <memory>
#include <support/mutex.h>
#include <wpi/mutex.h>
#include "MockData/DigitalPWMData.h"
#include "MockData/NotifyListenerVector.h"

View File

@@ -11,7 +11,7 @@
#include <atomic>
#include <memory>
#include <support/mutex.h>
#include <wpi/mutex.h>
#include "MockData/DriverStationData.h"
#include "MockData/NotifyListenerVector.h"

View File

@@ -11,7 +11,7 @@
#include <limits>
#include <memory>
#include <support/mutex.h>
#include <wpi/mutex.h>
#include "MockData/EncoderData.h"
#include "MockData/NotifyListenerVector.h"

View File

@@ -11,7 +11,7 @@
#include <string>
#include "MockData/HALValue.h"
#include "MockData/llvm/StringRef.h"
#include "MockData/wpi/StringRef.h"
namespace hal {
@@ -19,9 +19,9 @@ class Value;
void ConvertToC(const Value& in, HAL_Value* out);
std::shared_ptr<Value> ConvertFromC(const HAL_Value& value);
void ConvertToC(llvm::StringRef in, HALString* out);
inline llvm::StringRef ConvertFromC(const HALString& str) {
return llvm::StringRef(str.str, str.len);
void ConvertToC(wpi::StringRef in, HALString* out);
inline wpi::StringRef ConvertFromC(const HALString& str) {
return wpi::StringRef(str.str, str.len);
}
} // namespace hal

View File

@@ -11,7 +11,7 @@
#include <limits>
#include <memory>
#include <support/mutex.h>
#include <wpi/mutex.h>
#include "MockData/I2CData.h"
#include "MockData/NotifyListenerVector.h"

View File

@@ -10,7 +10,7 @@
#include <atomic>
#include <memory>
#include <support/mutex.h>
#include <wpi/mutex.h>
#include "../PortsInternal.h"
#include "MockData/NotifyListenerVector.h"

View File

@@ -10,7 +10,7 @@
#include <atomic>
#include <memory>
#include <support/mutex.h>
#include <wpi/mutex.h>
#include "../PortsInternal.h"
#include "MockData/NotifyListenerVector.h"

View File

@@ -10,7 +10,7 @@
#include <atomic>
#include <memory>
#include <support/mutex.h>
#include <wpi/mutex.h>
#include "MockData/NotifyListenerVector.h"
#include "MockData/PWMData.h"

View File

@@ -10,7 +10,7 @@
#include <atomic>
#include <memory>
#include <support/mutex.h>
#include <wpi/mutex.h>
#include "MockData/NotifyListenerVector.h"
#include "MockData/RelayData.h"

View File

@@ -10,7 +10,7 @@
#include <atomic>
#include <memory>
#include <support/mutex.h>
#include <wpi/mutex.h>
#include "MockData/NotifyListenerVector.h"
#include "MockData/RoboRioData.h"

Some files were not shown because too many files have changed in this diff Show More