Add V4L2_PIX_FMT_RGB24 pixel format support
This is the format used by the gxp v4l2 driver.
Change-Id: Ia78e39b95f1cdffa2df111d1f1af4cb9c290cc9f
Signed-off-by: charles kearney <charles.kearney@hpe.com>
diff --git a/ikvm_server.cpp b/ikvm_server.cpp
index 141f6c6..9274a9b 100644
--- a/ikvm_server.cpp
+++ b/ikvm_server.cpp
@@ -1,5 +1,6 @@
#include "ikvm_server.hpp"
+#include <linux/videodev2.h>
#include <rfb/rfbproto.h>
#include <boost/crc.hpp>
@@ -156,22 +157,33 @@
fu->nRects = Swap16IfLE(1);
}
- fu->type = rfbFramebufferUpdate;
- cl->ublen = sz_rfbFramebufferUpdateMsg;
- rfbSendUpdateBuf(cl);
-
- cl->tightEncoding = rfbEncodingTight;
- rfbSendTightHeader(cl, 0, 0, video.getWidth(), video.getHeight());
-
- cl->updateBuf[cl->ublen++] = (char)(rfbTightJpeg << 4);
- rfbSendCompressedDataTight(cl, data, video.getFrameSize());
-
- if (cl->enableLastRectEncoding)
+ switch (video.getPixelformat())
{
- rfbSendLastRectMarker(cl);
- }
+ case V4L2_PIX_FMT_RGB24:
+ framebuffer.assign(data, data + video.getFrameSize());
+ rfbMarkRectAsModified(server, 0, 0, video.getWidth(),
+ video.getHeight());
+ break;
- rfbSendUpdateBuf(cl);
+ case V4L2_PIX_FMT_JPEG:
+ fu->type = rfbFramebufferUpdate;
+ cl->ublen = sz_rfbFramebufferUpdateMsg;
+ rfbSendUpdateBuf(cl);
+ cl->tightEncoding = rfbEncodingTight;
+ rfbSendTightHeader(cl, 0, 0, video.getWidth(),
+ video.getHeight());
+ cl->updateBuf[cl->ublen++] = (char)(rfbTightJpeg << 4);
+ rfbSendCompressedDataTight(cl, data, video.getFrameSize());
+ if (cl->enableLastRectEncoding)
+ {
+ rfbSendLastRectMarker(cl);
+ }
+ rfbSendUpdateBuf(cl);
+ break;
+
+ default:
+ break;
+ }
}
rfbReleaseClientIterator(it);
diff --git a/ikvm_video.cpp b/ikvm_video.cpp
index 734294e..3445715 100644
--- a/ikvm_video.cpp
+++ b/ikvm_video.cpp
@@ -33,7 +33,7 @@
Video::Video(const std::string& p, Input& input, int fr, int sub) :
resizeAfterOpen(false), timingsError(false), fd(-1), frameRate(fr),
lastFrameIndex(-1), height(600), width(800), subSampling(sub), input(input),
- path(p)
+ path(p), pixelformat(V4L2_PIX_FMT_JPEG)
{}
Video::~Video()
@@ -457,6 +457,13 @@
height = fmt.fmt.pix.height;
width = fmt.fmt.pix.width;
+ pixelformat = fmt.fmt.pix.pixelformat;
+
+ if (pixelformat != V4L2_PIX_FMT_RGB24 && pixelformat != V4L2_PIX_FMT_JPEG)
+ {
+ log<level::ERR>("Pixel Format not supported",
+ entry("PIXELFORMAT=%d", pixelformat));
+ }
resize();
diff --git a/ikvm_video.hpp b/ikvm_video.hpp
index 17477df..449f57e 100644
--- a/ikvm_video.hpp
+++ b/ikvm_video.hpp
@@ -85,6 +85,14 @@
return height;
}
/*
+ * @brief Gets the pixel format of the video frame
+ *
+ * @return Value of the pixel format of video frame */
+ inline uint32_t getPixelformat() const
+ {
+ return pixelformat;
+ }
+ /*
* @brief Gets the width of the video frame
*
* @return Value of the width of video frame in pixels
@@ -166,6 +174,9 @@
const std::string path;
/* @brief Streaming buffer storage */
std::vector<Buffer> buffers;
+
+ /* @brief Pixel Format */
+ uint32_t pixelformat;
};
} // namespace ikvm