WPILibC++ 2024.3.2
cs::MjpegServer Class Reference

A sink that acts as a MJPEG-over-HTTP network server. More...

#include <cscore_oo.h>

Inheritance diagram for cs::MjpegServer:
cs::VideoSink

Public Member Functions

 MjpegServer ()=default
 
 MjpegServer (std::string_view name, std::string_view listenAddress, int port)
 Create a MJPEG-over-HTTP server sink. More...
 
 MjpegServer (std::string_view name, int port)
 Create a MJPEG-over-HTTP server sink. More...
 
std::string GetListenAddress () const
 Get the listen address of the server. More...
 
int GetPort () const
 Get the port number of the server. More...
 
void SetResolution (int width, int height)
 Set the stream resolution for clients that don't specify it. More...
 
void SetFPS (int fps)
 Set the stream frames per second (FPS) for clients that don't specify it. More...
 
void SetCompression (int quality)
 Set the compression for clients that don't specify it. More...
 
void SetDefaultCompression (int quality)
 Set the default compression used for non-MJPEG sources. More...
 
- Public Member Functions inherited from cs::VideoSink
 VideoSink () noexcept=default
 
 VideoSink (const VideoSink &sink)
 
 VideoSink (VideoSink &&sink) noexcept
 
VideoSinkoperator= (VideoSink other) noexcept
 
 ~VideoSink ()
 
 operator bool () const
 Returns true if the VideoSink is valid. More...
 
int GetHandle () const
 Returns the VideoSink handle. More...
 
bool operator== (const VideoSink &other) const
 
Kind GetKind () const
 Get the kind of the sink. More...
 
std::string GetName () const
 Get the name of the sink. More...
 
std::string GetDescription () const
 Get the sink description. More...
 
VideoProperty GetProperty (std::string_view name)
 Get a property of the sink. More...
 
std::vector< VideoPropertyEnumerateProperties () const
 Enumerate all properties of this sink. More...
 
bool SetConfigJson (std::string_view config)
 Set properties from a JSON configuration string. More...
 
bool SetConfigJson (const wpi::json &config)
 Set properties from a JSON configuration object. More...
 
std::string GetConfigJson () const
 Get a JSON configuration string. More...
 
wpi::json GetConfigJsonObject () const
 Get a JSON configuration object. More...
 
void SetSource (VideoSource source)
 Configure which source should provide frames to this sink. More...
 
VideoSource GetSource () const
 Get the connected source. More...
 
VideoProperty GetSourceProperty (std::string_view name)
 Get a property of the associated source. More...
 
CS_Status GetLastStatus () const
 

Additional Inherited Members

- Public Types inherited from cs::VideoSink
enum  Kind { kUnknown = CS_SINK_UNKNOWN , kMjpeg = CS_SINK_MJPEG , kCv = CS_SINK_CV }
 
- Static Public Member Functions inherited from cs::VideoSink
static std::vector< VideoSinkEnumerateSinks ()
 Enumerate all existing sinks. More...
 
- Protected Member Functions inherited from cs::VideoSink
 VideoSink (CS_Sink handle)
 
- Protected Attributes inherited from cs::VideoSink
CS_Status m_status = 0
 
CS_Sink m_handle {0}
 

Detailed Description

A sink that acts as a MJPEG-over-HTTP network server.

Constructor & Destructor Documentation

◆ MjpegServer() [1/3]

cs::MjpegServer::MjpegServer ( )
default

◆ MjpegServer() [2/3]

cs::MjpegServer::MjpegServer ( std::string_view  name,
std::string_view  listenAddress,
int  port 
)
inline

Create a MJPEG-over-HTTP server sink.

Parameters
nameSink name (arbitrary unique identifier)
listenAddressTCP listen address (empty string for all addresses)
portTCP port number

◆ MjpegServer() [3/3]

cs::MjpegServer::MjpegServer ( std::string_view  name,
int  port 
)
inline

Create a MJPEG-over-HTTP server sink.

Parameters
nameSink name (arbitrary unique identifier)
portTCP port number

Member Function Documentation

◆ GetListenAddress()

std::string cs::MjpegServer::GetListenAddress ( ) const
inline

Get the listen address of the server.

◆ GetPort()

int cs::MjpegServer::GetPort ( ) const
inline

Get the port number of the server.

◆ SetCompression()

void cs::MjpegServer::SetCompression ( int  quality)
inline

Set the compression for clients that don't specify it.

Setting this will result in increased CPU usage for MJPEG source cameras as it will decompress and recompress the image instead of using the camera's MJPEG image directly.

Parameters
qualityJPEG compression quality (0-100), -1 for unspecified

◆ SetDefaultCompression()

void cs::MjpegServer::SetDefaultCompression ( int  quality)
inline

Set the default compression used for non-MJPEG sources.

If not set, 80 is used. This function has no effect on MJPEG source cameras; use SetCompression() instead to force recompression of MJPEG source images.

Parameters
qualityJPEG compression quality (0-100)

◆ SetFPS()

void cs::MjpegServer::SetFPS ( int  fps)
inline

Set the stream frames per second (FPS) for clients that don't specify it.

It is not necessary to set this if it is the same as the source FPS.

Parameters
fpsFPS, 0 for unspecified

◆ SetResolution()

void cs::MjpegServer::SetResolution ( int  width,
int  height 
)
inline

Set the stream resolution for clients that don't specify it.

It is not necessary to set this if it is the same as the source resolution.

Setting this different than the source resolution will result in increased CPU usage, particularly for MJPEG source cameras, as it will decompress, resize, and recompress the image, instead of using the camera's MJPEG image directly.

Parameters
widthwidth, 0 for unspecified
heightheight, 0 for unspecified

The documentation for this class was generated from the following files: