cscore: Support multiple levels of JPEG compression (#1223)

This allows two streams with different compression levels, and also allows
a stream to receive a different compression level than provided by a JPEG
camera (decompress and recompress).
This commit is contained in:
Peter Johnson
2018-07-27 21:51:40 -07:00
committed by GitHub
parent 04ee8dbe79
commit c9a75a119a
4 changed files with 89 additions and 27 deletions

View File

@@ -114,7 +114,7 @@ class MjpegServerImpl::ConnThread : public wpi::SafeThread {
int m_width{0};
int m_height{0};
int m_compression{80};
int m_compression{-1};
int m_fps{0};
};
@@ -635,8 +635,8 @@ void MjpegServerImpl::ConnThread::SendStream(wpi::raw_socket_ostream& os) {
int width = m_width != 0 ? m_width : frame.GetOriginalWidth();
int height = m_height != 0 ? m_height : frame.GetOriginalHeight();
Image* image =
frame.GetImage(width, height, VideoMode::kMJPEG, m_compression);
Image* image = frame.GetImageMJPEG(
width, height, m_compression, m_compression == -1 ? 80 : m_compression);
if (!image) {
// Shouldn't happen, but just in case...
std::this_thread::sleep_for(std::chrono::milliseconds(20));
@@ -695,7 +695,7 @@ void MjpegServerImpl::ConnThread::ProcessRequest() {
// Reset per-request settings
m_width = 0;
m_height = 0;
m_compression = 80;
m_compression = -1;
m_fps = 0;
// Read the request string from the stream