diff --git a/include/cameraserver_c.h b/include/cameraserver_c.h index 9bce541a87..ee4f74924d 100644 --- a/include/cameraserver_c.h +++ b/include/cameraserver_c.h @@ -88,8 +88,7 @@ CS_Source CS_CreateUSBSourcePath(const char* name, const char* path, CS_Status* status); CS_Source CS_CreateHTTPSource(const char* name, const char* url, CS_Status* status); -CS_Source CS_CreateCvSource(const char* name, int numChannels, - CS_Status* status); +CS_Source CS_CreateCvSource(const char* name, CS_Status* status); // // Source Functions @@ -97,7 +96,6 @@ CS_Source CS_CreateCvSource(const char* name, int numChannels, char* CS_GetSourceName(CS_Source source, CS_Status* status); char* CS_GetSourceDescription(CS_Source source, CS_Status* status); uint64_t CS_GetSourceLastFrameTime(CS_Source source, CS_Status* status); -int CS_GetSourceNumChannels(CS_Source source, CS_Status* status); CS_Bool CS_IsSourceConnected(CS_Source source, CS_Status* status); CS_Property CS_GetSourceProperty(CS_Source source, const char* name, CS_Status* status); @@ -109,9 +107,6 @@ void CS_ReleaseSource(CS_Source source, CS_Status* status); // // OpenCV Source Functions // -void CS_PutSourceImage(CS_Source source, int channel, struct CvMat* image, - CS_Status* status); -void CS_NotifySourceFrame(CS_Source source, CS_Status* status); void CS_PutSourceFrame(CS_Source source, struct CvMat* image, CS_Status* status); void CS_NotifySourceError(CS_Source source, const char* msg, CS_Status* status); @@ -150,17 +145,9 @@ CS_Source CS_GetSinkSource(CS_Sink sink, CS_Status* status); CS_Sink CS_CopySink(CS_Sink sink, CS_Status* status); void CS_ReleaseSink(CS_Sink sink, CS_Status* status); -// -// Server Sink (e.g. HTTP) Functions -// -void CS_SetSinkSourceChannel(CS_Sink sink, int channel, CS_Status* status); - // // OpenCV Sink Functions // -uint64_t CS_SinkWaitForFrame(CS_Sink sink, CS_Status* status); -CS_Bool CS_GetSinkImage(CS_Sink sink, int channel, struct CvMat* image, - CS_Status* status); uint64_t CS_GrabSinkFrame(CS_Sink sink, struct CvMat* image, CS_Status* status); char* CS_GetSinkError(CS_Sink sink, CS_Status* status); void CS_SetSinkEnabled(CS_Sink sink, CS_Bool enabled, CS_Status* status); @@ -203,7 +190,6 @@ typedef struct CS_USBCameraInfo { int dev; char* path; char* name; - int channels; } CS_USBCameraInfo; CS_USBCameraInfo* CS_EnumerateUSBCameras(int* count, CS_Status* status); diff --git a/include/cameraserver_cpp.h b/include/cameraserver_cpp.h index 7691c42b91..57f5359920 100644 --- a/include/cameraserver_cpp.h +++ b/include/cameraserver_cpp.h @@ -40,9 +40,6 @@ struct USBCameraInfo { std::string path; /// Vendor/model name of the camera as provided by the USB driver std::string name; - /// Number of channels the camera provides (usually 1, but some cameras such - /// as stereo or depth cameras may provide multiple channels). - int channels; }; // @@ -79,8 +76,7 @@ CS_Source CreateUSBSourcePath(llvm::StringRef name, llvm::StringRef path, CS_Status* status); CS_Source CreateHTTPSource(llvm::StringRef name, llvm::StringRef url, CS_Status* status); -CS_Source CreateCvSource(llvm::StringRef name, int numChannels, - CS_Status* status); +CS_Source CreateCvSource(llvm::StringRef name, CS_Status* status); // // Source Functions @@ -94,7 +90,6 @@ llvm::StringRef GetSourceDescription(CS_Source source, llvm::SmallVectorImpl& buf, CS_Status* status); uint64_t GetSourceLastFrameTime(CS_Source source, CS_Status* status); -int GetSourceNumChannels(CS_Source source, CS_Status* status); bool IsSourceConnected(CS_Source source, CS_Status* status); CS_Property GetSourceProperty(CS_Source source, llvm::StringRef name, CS_Status* status); @@ -107,9 +102,6 @@ void ReleaseSource(CS_Source source, CS_Status* status); // // OpenCV Source Functions // -void PutSourceImage(CS_Source source, int channel, cv::Mat* image, - CS_Status* status); -void NotifySourceFrame(CS_Source source, CS_Status* status); void PutSourceFrame(CS_Source source, cv::Mat* image, CS_Status* status); void NotifySourceError(CS_Source source, llvm::StringRef msg, CS_Status* status); @@ -151,16 +143,9 @@ CS_Source GetSinkSource(CS_Sink sink, CS_Status* status); CS_Sink CopySink(CS_Sink sink, CS_Status* status); void ReleaseSink(CS_Sink sink, CS_Status* status); -// -// Server Sink (e.g. HTTP) Functions -// -void SetSinkSourceChannel(CS_Sink sink, int channel, CS_Status* status); - // // OpenCV Sink Functions // -uint64_t SinkWaitForFrame(CS_Sink sink, CS_Status* status); -bool GetSinkImage(CS_Sink sink, int channel, cv::Mat* image, CS_Status* status); uint64_t GrabSinkFrame(CS_Sink sink, cv::Mat* image, CS_Status* status); std::string GetSinkError(CS_Sink sink, CS_Status* status); llvm::StringRef GetSinkError(CS_Sink sink, llvm::SmallVectorImpl& buf, diff --git a/include/cameraserver_oo.h b/include/cameraserver_oo.h index 93eaf6fe57..8e5fd7b32d 100644 --- a/include/cameraserver_oo.h +++ b/include/cameraserver_oo.h @@ -81,9 +81,7 @@ class VideoProperty { Type m_type; }; -/// A source for video that provides a sequence of frames. Each frame may -/// consist of multiple images (e.g. from a stereo or depth camera); these -/// are called channels. +/// A source for video that provides a sequence of frames. class VideoSource { friend class SourceListener; friend class VideoSink; @@ -107,9 +105,6 @@ class VideoSource { /// Get the last time a frame was captured. uint64_t GetLastFrameTime() const; - /// Get the number of channels this source provides. - int GetNumChannels() const; - /// Is the source currently connected to whatever is providing the images? bool IsConnected() const; @@ -167,19 +162,9 @@ class CvSource : public VideoSource { public: /// Create an OpenCV source. /// @param name Source name (arbitrary unique identifier) - /// @param numChannels Number of channels - CvSource(llvm::StringRef name, int numChannels = 1); + CvSource(llvm::StringRef name); - /// Put an OpenCV image onto the specified channel. - /// @param channel Channel number (range 0 to numChannels-1) - /// @param image OpenCV image - void PutImage(int channel, cv::Mat* image); - - /// Signal sinks connected to this source that all new channel images have - /// been put to the stream and are ready to be read. - void NotifyFrame(); - - /// Put an OpenCV image onto channel 0 and notify sinks. + /// Put an OpenCV image and notify sinks. /// This is identical in behavior to calling PutImage(0, image) followed by /// NotifyFrame(). /// @param image OpenCV image @@ -217,9 +202,7 @@ class CvSource : public VideoSource { void RemoveProperty(llvm::StringRef name); }; -/// A sink for video that accepts a sequence of frames. Each frame may -/// consist of multiple images (e.g. from a stereo or depth camera); these are -/// called channels. +/// A sink for video that accepts a sequence of frames. class VideoSink { friend class SinkListener; @@ -281,12 +264,6 @@ class HTTPSink : public VideoSink { /// @param name Sink name (arbitrary unique identifier) /// @param port TCP port number HTTPSink(llvm::StringRef name, int port) : HTTPSink(name, "", port) {} - - /// Set what video channel should be served. - /// MJPEG-HTTP can only serve a single channel of video. - /// By default, channel 0 is served. - /// @param channel video channel to serve to clients - void SetSourceChannel(int channel); }; /// A sink for user code to accept video frames as OpenCV images. @@ -308,18 +285,7 @@ class CvSink : public VideoSink { /// unusual circumstances) WaitForImage(). CvSink(llvm::StringRef name, std::function processFrame); - /// Wait for the next frame. This is a blocking call. - /// @return Frame time, or 0 on error (call GetError() to obtain the error - /// message). - uint64_t WaitForFrame() const; - - /// Get an OpenCV image from the specified channel. - /// @return False if image could not be obtained for some reason (e.g. - /// channel out of range) - bool GetImage(int channel, cv::Mat* image) const; - - /// Wait for the next frame and get the image from channel 0. Equivalent - /// to calling WaitForFrame() followed by GetImage(0, image). + /// Wait for the next frame and get the image. /// @return Frame time, or 0 on error (call GetError() to obtain the error /// message); uint64_t GrabFrame(cv::Mat* image) const; diff --git a/include/cameraserver_oo.inl b/include/cameraserver_oo.inl index 66aef29e40..a6d8645811 100644 --- a/include/cameraserver_oo.inl +++ b/include/cameraserver_oo.inl @@ -122,11 +122,6 @@ inline uint64_t VideoSource::GetLastFrameTime() const { return GetSourceLastFrameTime(m_handle, &m_status); } -inline int VideoSource::GetNumChannels() const { - m_status = 0; - return GetSourceNumChannels(m_handle, &m_status); -} - inline bool VideoSource::IsConnected() const { m_status = 0; return IsSourceConnected(m_handle, &m_status); @@ -154,18 +149,8 @@ inline HTTPCamera::HTTPCamera(llvm::StringRef name, llvm::StringRef url) { m_handle = CreateHTTPSource(name, url, &m_status); } -inline CvSource::CvSource(llvm::StringRef name, int numChannels) { - m_handle = CreateCvSource(name, numChannels, &m_status); -} - -inline void CvSource::PutImage(int channel, cv::Mat* image) { - m_status = 0; - PutSourceImage(m_handle, channel, image, &m_status); -} - -inline void CvSource::NotifyFrame() { - m_status = 0; - NotifySourceFrame(m_handle, &m_status); +inline CvSource::CvSource(llvm::StringRef name) { + m_handle = CreateCvSource(name, &m_status); } inline void CvSource::PutFrame(cv::Mat* image) { @@ -265,11 +250,6 @@ inline HTTPSink::HTTPSink(llvm::StringRef name, llvm::StringRef listenAddress, m_handle = CreateHTTPSink(name, listenAddress, port, &m_status); } -inline void HTTPSink::SetSourceChannel(int channel) { - m_status = 0; - SetSinkSourceChannel(m_handle, channel, &m_status); -} - inline CvSink::CvSink(llvm::StringRef name) { m_handle = CreateCvSink(name, &m_status); } @@ -279,16 +259,6 @@ inline CvSink::CvSink(llvm::StringRef name, m_handle = CreateCvSinkCallback(name, processFrame, &m_status); } -inline uint64_t CvSink::WaitForFrame() const { - m_status = 0; - return SinkWaitForFrame(m_handle, &m_status); -} - -inline bool CvSink::GetImage(int channel, cv::Mat* image) const { - m_status = 0; - return GetSinkImage(m_handle, channel, image, &m_status); -} - inline uint64_t CvSink::GrabFrame(cv::Mat* image) const { m_status = 0; return GrabSinkFrame(m_handle, image, &m_status); diff --git a/java/lib/CameraServerJNI.cpp b/java/lib/CameraServerJNI.cpp index 21acad92e9..dd6462dd40 100644 --- a/java/lib/CameraServerJNI.cpp +++ b/java/lib/CameraServerJNI.cpp @@ -66,12 +66,11 @@ static inline bool CheckStatus(JNIEnv *env, CS_Status status, static jobject MakeJObject(JNIEnv *env, const cs::USBCameraInfo &info) { static jmethodID constructor = env->GetMethodID( - usbCameraInfoCls, "", "(ILjava/lang/String;Ljava/lang/String;I)V"); + usbCameraInfoCls, "", "(ILjava/lang/String;Ljava/lang/String;)V"); JLocal path(env, MakeJString(env, info.path)); JLocal name(env, MakeJString(env, info.name)); return env->NewObject(usbCameraInfoCls, constructor, - static_cast(info.dev), path.obj(), name.obj(), - static_cast(info.channels)); + static_cast(info.dev), path.obj(), name.obj()); } extern "C" { @@ -303,13 +302,13 @@ JNIEXPORT jint JNICALL Java_edu_wpi_cameraserver_CameraServerJNI_createHTTPSourc /* * Class: edu_wpi_cameraserver_CameraServerJNI * Method: createCvSource - * Signature: (Ljava/lang/String;I)I + * Signature: (Ljava/lang/String;)I */ JNIEXPORT jint JNICALL Java_edu_wpi_cameraserver_CameraServerJNI_createCvSource - (JNIEnv *env, jclass, jstring name, jint numChannels) + (JNIEnv *env, jclass, jstring name) { CS_Status status; - auto val = cs::CreateCvSource(JStringRef{env, name}, numChannels, &status); + auto val = cs::CreateCvSource(JStringRef{env, name}, &status); CheckStatus(env, status); return val; } @@ -358,20 +357,6 @@ JNIEXPORT jlong JNICALL Java_edu_wpi_cameraserver_CameraServerJNI_getSourceLastF return val; } -/* - * Class: edu_wpi_cameraserver_CameraServerJNI - * Method: getSourceNumChannels - * Signature: (I)I - */ -JNIEXPORT jint JNICALL Java_edu_wpi_cameraserver_CameraServerJNI_getSourceNumChannels - (JNIEnv *env, jclass, jint source) -{ - CS_Status status; - auto val = cs::GetSourceNumChannels(source, &status); - CheckStatus(env, status); - return val; -} - /* * Class: edu_wpi_cameraserver_CameraServerJNI * Method: isSourceConnected @@ -442,19 +427,6 @@ JNIEXPORT void JNICALL Java_edu_wpi_cameraserver_CameraServerJNI_releaseSource CheckStatus(env, status); } -/* - * Class: edu_wpi_cameraserver_CameraServerJNI - * Method: notifySourceFrame - * Signature: (I)V - */ -JNIEXPORT void JNICALL Java_edu_wpi_cameraserver_CameraServerJNI_notifySourceFrame - (JNIEnv *env, jclass, jint source) -{ - CS_Status status; - cs::NotifySourceFrame(source, &status); - CheckStatus(env, status); -} - /* * Class: edu_wpi_cameraserver_CameraServerJNI * Method: notifySourceError @@ -651,33 +623,6 @@ JNIEXPORT void JNICALL Java_edu_wpi_cameraserver_CameraServerJNI_releaseSink CheckStatus(env, status); } -/* - * Class: edu_wpi_cameraserver_CameraServerJNI - * Method: setSinkSourceChannel - * Signature: (II)V - */ -JNIEXPORT void JNICALL Java_edu_wpi_cameraserver_CameraServerJNI_setSinkSourceChannel - (JNIEnv *env, jclass, jint sink, jint channel) -{ - CS_Status status; - cs::SetSinkSourceChannel(sink, channel, &status); - CheckStatus(env, status); -} - -/* - * Class: edu_wpi_cameraserver_CameraServerJNI - * Method: sinkWaitForFrame - * Signature: (I)J - */ -JNIEXPORT jlong JNICALL Java_edu_wpi_cameraserver_CameraServerJNI_sinkWaitForFrame - (JNIEnv *env, jclass, jint sink) -{ - CS_Status status; - auto val = cs::SinkWaitForFrame(sink, &status); - CheckStatus(env, status); - return val; -} - /* * Class: edu_wpi_cameraserver_CameraServerJNI * Method: getSinkError diff --git a/java/src/edu/wpi/cameraserver/CameraServerJNI.java b/java/src/edu/wpi/cameraserver/CameraServerJNI.java index 87a6709c33..f451747259 100644 --- a/java/src/edu/wpi/cameraserver/CameraServerJNI.java +++ b/java/src/edu/wpi/cameraserver/CameraServerJNI.java @@ -95,7 +95,7 @@ public class CameraServerJNI { public static native int createUSBSourceDev(String name, int dev); public static native int createUSBSourcePath(String name, String path); public static native int createHTTPSource(String name, String url); - public static native int createCvSource(String name, int numChannels); + public static native int createCvSource(String name); // // Source Functions @@ -103,7 +103,6 @@ public class CameraServerJNI { public static native String getSourceName(int source); public static native String getSourceDescription(int source); public static native long getSourceLastFrameTime(int source); - public static native int getSourceNumChannels(int source); public static native boolean isSourceConnected(int source); public static native int getSourceProperty(int source, String name); public static native int[] enumerateSourceProperties(int source); @@ -113,8 +112,6 @@ public class CameraServerJNI { // // OpenCV Source Functions // - //public static native void putSourceImage(int source, int channel, CvMat image); - public static native void notifySourceFrame(int source); //public static native void putSourceFrame(int source, CvMat image); public static native void notifySourceError(int source, String msg); public static native void setSourceConnected(int source, boolean connected); @@ -145,16 +142,9 @@ public class CameraServerJNI { public static native int copySink(int sink); public static native void releaseSink(int sink); - // - // Server Sink (e.g. HTTP) Functions - // - public static native void setSinkSourceChannel(int sink, int channel); - // // OpenCV Sink Functions // - public static native long sinkWaitForFrame(int sink); - //public static native int getSinkImage(int sink, CvMat image); //public static native int grabSinkFrame(int sink, CvMat image); public static native String getSinkError(int sink); public static native void setSinkEnabled(int sink, boolean enabled); diff --git a/java/src/edu/wpi/cameraserver/CvSink.java b/java/src/edu/wpi/cameraserver/CvSink.java index 7cc46a9e44..1be9c3ddfb 100644 --- a/java/src/edu/wpi/cameraserver/CvSink.java +++ b/java/src/edu/wpi/cameraserver/CvSink.java @@ -30,22 +30,7 @@ public class CvSink extends VideoSink { // super(CameraServerJNI.createCvSinkCallback(name, processFrame)); //} - /// Wait for the next frame. This is a blocking call. - /// @return Frame time, or 0 on error (call GetError() to obtain the error - /// message). - public long waitForFrame() { - return CameraServerJNI.sinkWaitForFrame(m_handle); - } - - /// Get an OpenCV image from the specified channel. - /// @return False if image could not be obtained for some reason (e.g. - /// channel out of range) - //public boolean getImage(int channel, CvMat image) { - // return CameraServerJNI.getSinkImage(m_handle, channel, image); - //} - - /// Wait for the next frame and get the image from channel 0. Equivalent - /// to calling WaitForFrame() followed by GetImage(0, image). + /// Wait for the next frame and get the image. /// @return Frame time, or 0 on error (call GetError() to obtain the error /// message); //public long grabFrame(CvMat image) { diff --git a/java/src/edu/wpi/cameraserver/CvSource.java b/java/src/edu/wpi/cameraserver/CvSource.java index d6e9f7e469..82cd2b156c 100644 --- a/java/src/edu/wpi/cameraserver/CvSource.java +++ b/java/src/edu/wpi/cameraserver/CvSource.java @@ -9,33 +9,13 @@ package edu.wpi.cameraserver; /// A source that represents a video camera. public class CvSource extends VideoSource { - /// Create an OpenCV source with a single channel. - /// @param name Source name (arbitrary unique identifier) - public CvSource(String name) { - super(CameraServerJNI.createCvSource(name, 1)); - } - /// Create an OpenCV source. /// @param name Source name (arbitrary unique identifier) - /// @param numChannels Number of channels - public CvSource(String name, int numChannels) { - super(CameraServerJNI.createCvSource(name, numChannels)); + public CvSource(String name) { + super(CameraServerJNI.createCvSource(name)); } - /// Put an OpenCV image onto the specified channel. - /// @param channel Channel number (range 0 to nChannels-1) - /// @param image OpenCV image - //public void putImage(int channel, Mat image); - - /// Signal sinks connected to this source that all new channel images have - /// been put to the stream and are ready to be read. - public void notifyFrame() { - CameraServerJNI.notifySourceFrame(m_handle); - } - - /// Put an OpenCV image onto channel 0 and notify sinks. - /// This is identical in behavior to calling PutImage(0, image) followed by - /// NotifyFrame(). + /// Put an OpenCV image and notify sinks. /// @param image OpenCV image //public void putFrame(Mat image); diff --git a/java/src/edu/wpi/cameraserver/HTTPSink.java b/java/src/edu/wpi/cameraserver/HTTPSink.java index f2fecdbed8..4ede4d27bf 100644 --- a/java/src/edu/wpi/cameraserver/HTTPSink.java +++ b/java/src/edu/wpi/cameraserver/HTTPSink.java @@ -23,12 +23,4 @@ public class HTTPSink extends VideoSink { public HTTPSink(String name, int port) { this(name, "", port); } - - /// Set what video channel should be served. - /// MJPEG-HTTP can only serve a single channel of video. - /// By default, channel 0 is served. - /// @param channel video channel to serve to clients - public void setSourceChannel(int channel) { - CameraServerJNI.setSinkSourceChannel(m_handle, channel); - } } diff --git a/java/src/edu/wpi/cameraserver/USBCameraInfo.java b/java/src/edu/wpi/cameraserver/USBCameraInfo.java index 3dabe4f6e5..491d7a4d23 100644 --- a/java/src/edu/wpi/cameraserver/USBCameraInfo.java +++ b/java/src/edu/wpi/cameraserver/USBCameraInfo.java @@ -9,11 +9,10 @@ package edu.wpi.cameraserver; /// USB camera information public class USBCameraInfo { - public USBCameraInfo(int dev, String path, String name, int channels) { + public USBCameraInfo(int dev, String path, String name) { this.dev = dev; this.path = path; this.name = name; - this.channels = channels; } /// Device number (e.g. N in '/dev/videoN' on Linux) @@ -22,7 +21,4 @@ public class USBCameraInfo { public String path; /// Vendor/model name of the camera as provided by the USB driver public String name; - /// Number of channels the camera provides (usually 1, but some cameras such - /// as stereo or depth cameras may provide multiple channels). - public int channels; } diff --git a/java/src/edu/wpi/cameraserver/VideoSource.java b/java/src/edu/wpi/cameraserver/VideoSource.java index 93e0c059f4..5ab99c90de 100644 --- a/java/src/edu/wpi/cameraserver/VideoSource.java +++ b/java/src/edu/wpi/cameraserver/VideoSource.java @@ -42,11 +42,6 @@ public class VideoSource { return CameraServerJNI.getSourceLastFrameTime(m_handle); } - /// Get the number of channels this source provides. - public int getNumChannels() { - return CameraServerJNI.getSourceNumChannels(m_handle); - } - /// Is the source currently connected to whatever is providing the images? public boolean isConnected() { return CameraServerJNI.isSourceConnected(m_handle); diff --git a/src/Frame.h b/src/Frame.h index 0072fe838b..97ae7a6d72 100644 --- a/src/Frame.h +++ b/src/Frame.h @@ -25,7 +25,7 @@ class Frame { struct Data { std::atomic_int refcount{0}; std::chrono::system_clock::time_point timestamp; - llvm::SmallVector images; + Image image; }; public: @@ -53,14 +53,14 @@ class Frame { explicit operator bool() const { return m_data; } - std::size_t size(std::size_t channel) const { - if (!m_data || channel >= m_data->images.size()) return 0; - return m_data->images[channel].size(); + std::size_t size() const { + if (!m_data) return 0; + return m_data->image.size(); } - const char* data(std::size_t channel) const { - if (!m_data || channel >= m_data->images.size()) return nullptr; - return m_data->images[channel].data(); + const char* data() const { + if (!m_data) return nullptr; + return m_data->image.data(); } std::chrono::system_clock::time_point time() const { diff --git a/src/HTTPSinkImpl.cpp b/src/HTTPSinkImpl.cpp index 1df78435c3..3f003bb581 100644 --- a/src/HTTPSinkImpl.cpp +++ b/src/HTTPSinkImpl.cpp @@ -321,11 +321,11 @@ void HTTPSinkImpl::SendStream(wpi::raw_socket_ostream& os) { .count(); header.clear(); oss << "Content-Type: image/jpeg\r\n" - << "Content-Length: " << frame.size(m_sourceChannel) << "\r\n" + << "Content-Length: " << frame.size() << "\r\n" << "X-Timestamp: " << timestamp << "\r\n" << "\r\n"; os << oss.str(); - os << frame.data(m_sourceChannel); + os << frame.data(); os << "\r\n--" BOUNDARY "\r\n"; // os.flush(); } @@ -454,19 +454,6 @@ CS_Sink CreateHTTPSink(llvm::StringRef name, llvm::StringRef listenAddress, return Sinks::GetInstance().Allocate(SinkData::kHTTP, sink); } -void SetSinkSourceChannel(CS_Sink sink, int channel, CS_Status* status) { - auto data = Sinks::GetInstance().Get(sink); - if (!data) { - *status = CS_INVALID_HANDLE; - return; - } - if (data->type != SinkData::kHTTP) { - *status = CS_WRONG_HANDLE_SUBTYPE; - return; - } - static_cast(data->sink.get())->SetSourceChannel(channel); -} - } // namespace cs extern "C" { @@ -476,8 +463,4 @@ CS_Sink CS_CreateHTTPSink(const char* name, const char* listenAddress, int port, return cs::CreateHTTPSink(name, listenAddress, port, status); } -void CS_SetSinkSourceChannel(CS_Sink sink, int channel, CS_Status* status) { - return cs::SetSinkSourceChannel(sink, channel, status); -} - } // extern "C" diff --git a/src/HTTPSinkImpl.h b/src/HTTPSinkImpl.h index ab9e995e01..53509914e6 100644 --- a/src/HTTPSinkImpl.h +++ b/src/HTTPSinkImpl.h @@ -38,8 +38,6 @@ class HTTPSinkImpl : public SinkImpl { llvm::StringRef GetDescription( llvm::SmallVectorImpl& buf) const override; - void SetSourceChannel(int channel) { m_sourceChannel.store(channel); } - void Stop(); static void SendHeader(llvm::raw_ostream& os, int code, @@ -64,7 +62,6 @@ class HTTPSinkImpl : public SinkImpl { std::string m_description; std::unique_ptr m_acceptor; - std::atomic_int m_sourceChannel; std::atomic_bool m_active; // set to false to terminate threads std::thread m_serverThread; diff --git a/src/SourceImpl.cpp b/src/SourceImpl.cpp index 7b2ea503f6..04eb4f4d02 100644 --- a/src/SourceImpl.cpp +++ b/src/SourceImpl.cpp @@ -49,7 +49,7 @@ void SourceImpl::StartFrame() { } } -//TODO: Image& SourceImpl::AddImage(std::size_t channel, std::size_t size) {} +//TODO: Image& SourceImpl::AddImage(std::size_t size) {} void SourceImpl::FinishFrame() { { @@ -62,9 +62,8 @@ void SourceImpl::FinishFrame() { void SourceImpl::ReleaseFrame(Frame::Data* data) { std::lock_guard lock{m_mutex}; - // Return the images to the pool - for (auto&& image : data->images) - m_imagesAvail.emplace_back(std::move(image)); + // Return the image to the pool + m_imagesAvail.emplace_back(std::move(data->image)); // Return the frame to the pool m_framesAvail.emplace_back(data); } diff --git a/src/SourceImpl.h b/src/SourceImpl.h index cade571e50..0009759cac 100644 --- a/src/SourceImpl.h +++ b/src/SourceImpl.h @@ -34,7 +34,6 @@ class SourceImpl { llvm::StringRef GetName() const { return m_name; } virtual llvm::StringRef GetDescription( llvm::SmallVectorImpl& buf) const = 0; - int GetNumChannels() const { return m_numChannels; } bool IsConnected() const { return m_connected; } // Functions to keep track of the overall number of sinks connected to this @@ -101,10 +100,9 @@ class SourceImpl { protected: void StartFrame(); - Image& AddImage(std::size_t channel, std::size_t size); + Image& AddImage(std::size_t size); void FinishFrame(); - std::atomic_int m_numChannels{0}; std::atomic_bool m_connected{false}; std::atomic_int m_numSinks{0}; diff --git a/src/cameraserver_c.cpp b/src/cameraserver_c.cpp index a9a5bc95ca..b4ce47efd6 100644 --- a/src/cameraserver_c.cpp +++ b/src/cameraserver_c.cpp @@ -108,9 +108,8 @@ CS_Source CS_CreateHTTPSource(const char* name, const char* url, return cs::CreateHTTPSource(name, url, status); } -CS_Source CS_CreateCvSource(const char* name, int numChannels, - CS_Status* status) { - return cs::CreateCvSource(name, numChannels, status); +CS_Source CS_CreateCvSource(const char* name, CS_Status* status) { + return cs::CreateCvSource(name, status); } char* CS_GetSourceName(CS_Source source, CS_Status* status) { @@ -131,10 +130,6 @@ uint64_t CS_GetSourceLastFrameTime(CS_Source source, CS_Status* status) { return cs::GetSourceLastFrameTime(source, status); } -int CS_GetSourceNumChannels(CS_Source source, CS_Status* status) { - return cs::GetSourceNumChannels(source, status); -} - CS_Bool CS_IsSourceConnected(CS_Source source, CS_Status* status) { return cs::IsSourceConnected(source, status); } @@ -163,15 +158,6 @@ void CS_ReleaseSource(CS_Source source, CS_Status* status) { return cs::ReleaseSource(source, status); } -void CS_PutSourceImage(CS_Source source, int channel, struct CvMat* image, - CS_Status* status) { - //TODO: return cs::PutSourceImage(source, channel, image, status); -} - -void CS_NotifySourceFrame(CS_Source source, CS_Status* status) { - return cs::NotifySourceFrame(source, status); -} - void CS_PutSourceFrame(CS_Source source, struct CvMat* image, CS_Status* status) { //TODO: return cs::PutSourceFrame(source, image, status); @@ -258,15 +244,6 @@ void CS_ReleaseSink(CS_Sink sink, CS_Status* status) { return cs::ReleaseSink(sink, status); } -uint64_t CS_SinkWaitForFrame(CS_Sink sink, CS_Status* status) { - return cs::SinkWaitForFrame(sink, status); -} - -CS_Bool CS_GetSinkImage(CS_Sink sink, int channel, struct CvMat* image, - CS_Status* status) { - return 0; //TODO: cs::GetSinkImage(sink, channel, image, status); -} - uint64_t CS_GrabSinkFrame(CS_Sink sink, struct CvMat* image, CS_Status* status) { return 0; // TODO: cs::GrabSinkFrame(sink, image, status); @@ -334,7 +311,6 @@ CS_USBCameraInfo* CS_EnumerateUSBCameras(int* count, CS_Status* status) { out[i].dev = cameras[i].dev; out[i].path = ConvertToC(cameras[i].path); out[i].name = ConvertToC(cameras[i].name); - out[i].channels = cameras[i].channels; } return out; } diff --git a/src/cameraserver_cpp.cpp b/src/cameraserver_cpp.cpp index 063f465e2e..525b89ef89 100644 --- a/src/cameraserver_cpp.cpp +++ b/src/cameraserver_cpp.cpp @@ -172,8 +172,7 @@ CS_Source CreateHTTPSource(llvm::StringRef name, llvm::StringRef url, return 0; // TODO } -CS_Source CreateCvSource(llvm::StringRef name, int numChannels, - CS_Status* status) { +CS_Source CreateCvSource(llvm::StringRef name, CS_Status* status) { return 0; // TODO } @@ -226,15 +225,6 @@ uint64_t GetSourceLastFrameTime(CS_Source source, CS_Status* status) { return 0; // TODO } -int GetSourceNumChannels(CS_Source source, CS_Status* status) { - auto data = Sources::GetInstance().Get(source); - if (!data) { - *status = CS_INVALID_HANDLE; - return 0; - } - return data->source->GetNumChannels(); -} - bool IsSourceConnected(CS_Source source, CS_Status* status) { auto data = Sources::GetInstance().Get(source); if (!data) { @@ -292,15 +282,6 @@ void ReleaseSource(CS_Source source, CS_Status* status) { // OpenCV Source Functions // -void PutSourceImage(CS_Source source, int channel, cv::Mat* image, - CS_Status* status) { - // TODO -} - -void NotifySourceFrame(CS_Source source, CS_Status* status) { - // TODO -} - void PutSourceFrame(CS_Source source, cv::Mat* image, CS_Status* status) { // TODO } @@ -452,15 +433,6 @@ void ReleaseSink(CS_Sink sink, CS_Status* status) { // OpenCV Sink Functions // -uint64_t SinkWaitForFrame(CS_Sink sink, CS_Status* status) { - return 0; // TODO -} - -bool GetSinkImage(CS_Sink sink, int channel, cv::Mat* image, - CS_Status* status) { - return false; // TODO -} - uint64_t GrabSinkFrame(CS_Sink sink, cv::Mat* image, CS_Status* status) { return 0; // TODO }