Revamp API.

This commit is contained in:
Peter Johnson
2016-08-19 23:05:28 -07:00
parent e1515299c2
commit b2831347bc
8 changed files with 596 additions and 300 deletions

View File

@@ -1,59 +0,0 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) FIRST 2016. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
/*----------------------------------------------------------------------------*/
#include "CameraSink.h"
using namespace cs;
class CameraSink::Impl {
public:
int id;
std::string description;
};
CameraSink::CameraSink(llvm::StringRef name, std::unique_ptr<Impl> impl)
: m_name(name), m_impl(std::move(impl)) {}
CameraSink::~CameraSink() {}
std::shared_ptr<CameraSink> CameraSink::CreateHTTP(
llvm::StringRef name, llvm::StringRef listenAddress, int port) {
std::unique_ptr<Impl> impl{new Impl};
// TODO
return std::make_shared<CameraSink>(name, std::move(impl));
}
std::shared_ptr<CameraSink> CameraSink::CreateRTSP(
llvm::StringRef name, llvm::StringRef listenAddress, int port) {
std::unique_ptr<Impl> impl{new Impl};
// TODO
return std::make_shared<CameraSink>(name, std::move(impl));
}
std::vector<std::shared_ptr<CameraSink>> CameraSink::EnumerateSinks() {
// TODO
return std::vector<std::shared_ptr<CameraSink>>();
}
int CameraSink::AddCreateListener(
std::function<void(std::shared_ptr<CameraSink>, int)> callback,
int eventMask) {
// TODO
return 0;
}
void CameraSink::RemoveCreateListener(int handle) {
// TODO
}
void CameraSink::SetSource(std::shared_ptr<CameraSource> source, int channel) {
// TODO
}
std::string CameraSink::GetDescription() const {
return m_impl->description;
}

View File

@@ -1,107 +0,0 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) FIRST 2016. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
/*----------------------------------------------------------------------------*/
#include "CameraSource.h"
using namespace cs;
class CameraSource::Impl {
public:
int id;
std::string description;
uint64_t lastFrameTime = 0;
int nChannels = 0;
bool connected = false;
};
CameraSource::CameraSource(llvm::StringRef name, std::unique_ptr<Impl> impl)
: m_name(name), m_impl(std::move(impl)) {}
CameraSource::~CameraSource() {}
std::shared_ptr<CameraSource> CameraSource::CreateUSB(llvm::StringRef name,
int dev) {
std::unique_ptr<Impl> impl{new Impl};
// TODO
return std::make_shared<CameraSource>(name, std::move(impl));
}
std::shared_ptr<CameraSource> CameraSource::CreateUSB(llvm::StringRef name,
llvm::StringRef path) {
std::unique_ptr<Impl> impl{new Impl};
// TODO
return std::make_shared<CameraSource>(name, std::move(impl));
}
std::shared_ptr<CameraSource> CameraSource::CreateHTTP(llvm::StringRef name,
llvm::StringRef url) {
std::unique_ptr<Impl> impl{new Impl};
// TODO
return std::make_shared<CameraSource>(name, std::move(impl));
}
std::shared_ptr<CameraSource> CameraSource::CreateUser(llvm::StringRef name,
int nChannels) {
std::unique_ptr<Impl> impl{new Impl};
// TODO
impl->nChannels = nChannels;
return std::make_shared<CameraSource>(name, std::move(impl));
}
std::vector<std::shared_ptr<CameraSource>> CameraSource::EnumerateSources() {
// TODO
return std::vector<std::shared_ptr<CameraSource>>();
}
std::vector<USBCameraInfo> CameraSource::EnumerateUSB() {
return std::vector<USBCameraInfo>();
}
int CameraSource::AddCreateListener(
std::function<void(std::shared_ptr<CameraSource>, int)> callback,
int eventMask) {
// TODO
return 0;
}
void CameraSource::RemoveCreateListener(int handle) {
// TODO
}
void CameraSource::PutImage(int channel, cv::Mat* image) {
// TODO
}
void CameraSource::NotifyFrame() {
// TODO
}
uint64_t CameraSource::WaitForFrame() const {
// TODO
return 0;
}
uint64_t CameraSource::GetImage(int channel, cv::Mat* image) const {
// TODO
return 0;
}
std::string CameraSource::GetDescription() const {
return m_impl->description;
}
uint64_t CameraSource::GetLastFrameTime() const {
return m_impl->lastFrameTime;
}
int CameraSource::GetNumChannels() const {
return m_impl->nChannels;
}
bool CameraSource::IsConnected() const {
return m_impl->connected;
}

223
src/cameraserver_cpp.cpp Normal file
View File

@@ -0,0 +1,223 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) FIRST 2016. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
/*----------------------------------------------------------------------------*/
#include "cameraserver_cpp.h"
#include <limits>
using namespace cs;
bool Property::GetBoolean() const {
return false; // TODO
}
void Property::SetBoolean(bool value) {
// TODO
}
double Property::GetDouble() const {
return 0; // TODO
}
void Property::SetDouble(double value) {
// TODO
}
double Property::GetMin() const {
return std::numeric_limits<double>::min(); // TODO
}
double Property::GetMax() const {
return std::numeric_limits<double>::max(); // TODO
}
std::string Property::GetString() const {
return ""; // TODO
}
void Property::SetString(llvm::StringRef value) {
// TODO
}
int Property::GetEnum() const {
return 0; // TODO
}
void Property::SetEnum(int value) {
// TODO
}
std::vector<std::string> Property::GetChoices() const {
return std::vector<std::string>(); // TODO
}
VideoSource::~VideoSource() {
// TODO
}
std::string VideoSource::GetDescription() const {
return ""; // TODO
}
uint64_t VideoSource::GetLastFrameTime() const {
return 0; // TODO
}
int VideoSource::GetNumChannels() const {
return 0; // TODO
}
bool VideoSource::IsConnected() const {
return false; // TODO
}
Property VideoSource::GetProperty(llvm::StringRef name) {
return Property(); // TODO
}
std::vector<std::shared_ptr<VideoSource>> VideoSource::EnumerateSources() {
return std::vector<std::shared_ptr<VideoSource>>(); // TODO
}
std::shared_ptr<CameraSource> CameraSource::CreateUSB(llvm::StringRef name,
int dev) {
return nullptr; // TODO
}
std::shared_ptr<CameraSource> CameraSource::CreateUSB(llvm::StringRef name,
llvm::StringRef path) {
return nullptr; // TODO
}
std::shared_ptr<CameraSource> CameraSource::CreateHTTP(llvm::StringRef name,
llvm::StringRef url) {
return nullptr; // TODO
}
std::vector<USBCameraInfo> CameraSource::EnumerateUSBCameras() {
return std::vector<USBCameraInfo>(); // TODO
}
void CvSource::PutImage(int channel, cv::Mat* image) {
// TODO
}
void CvSource::NotifyFrame() {
// TODO
}
void CvSource::PutFrame(cv::Mat* image) {
PutImage(0, image);
NotifyFrame();
}
void CvSource::NotifyError(llvm::StringRef msg) {
// TODO
}
void CvSource::SetConnected(bool connected) {
// TODO
}
Property CvSource::CreateProperty(llvm::StringRef name, Property::Type type) {
return Property(); // TODO
}
Property CvSource::CreateProperty(
llvm::StringRef name, Property::Type type,
std::function<void(llvm::StringRef)> onChange) {
return Property(); // TODO
}
void CvSource::RemoveProperty(llvm::StringRef name) {
// TODO
}
std::shared_ptr<CvSource> CvSource::Create(llvm::StringRef name,
int nChannels) {
return nullptr; // TODO
}
VideoSink::~VideoSink() {
// TODO
}
std::string VideoSink::GetDescription() const {
return ""; // TODO
}
void VideoSink::SetSource(std::shared_ptr<VideoSource> source) {
// TODO
}
Property VideoSink::GetSourceProperty(llvm::StringRef name) {
return Property(); // TODO
}
std::vector<std::shared_ptr<VideoSink>> VideoSink::EnumerateSinks() {
return std::vector<std::shared_ptr<VideoSink>>(); // TODO
}
void ServerSink::SetSourceChannel(int channel) {
// TODO
}
std::shared_ptr<ServerSink> ServerSink::CreateHTTP(
llvm::StringRef name, llvm::StringRef listenAddress, int port) {
return nullptr; // TODO
}
uint64_t CvSink::WaitForFrame() const {
return 0; // TODO
}
bool CvSink::GetImage(int channel, cv::Mat* image) const {
return false; // TODO
}
uint64_t CvSink::FrameGrab(cv::Mat* image) const {
return 0; // TODO
}
std::string CvSink::GetError() const {
return ""; // TODO
}
void CvSink::SetEnabled(bool enabled) {
// TODO
}
std::shared_ptr<CvSink> CvSink::Create(llvm::StringRef name) {
return nullptr; // TODO
}
std::shared_ptr<CvSink> CvSink::Create(
llvm::StringRef name, std::function<void(uint64_t time)> processFrame) {
return nullptr; // TODO
}
int cs::AddSourceListener(
std::function<void(llvm::StringRef name, std::shared_ptr<VideoSource>, int)>
callback,
int eventMask) {
return 0; // TODO
}
void cs::RemoveSourceListener(int handle) {
// TODO
}
int cs::AddSinkListener(
std::function<void(llvm::StringRef name, std::shared_ptr<VideoSink>, int)>
callback,
int eventMask) {
return 0; // TODO
}
void cs::RemoveSinkListener(int handle) {
// TODO
}