Move over to upstream c++ style
This patchset moves bmcweb over to the upstream style naming
conventions for variables, classes, and functions, as well as imposes
the latest clang-format file.
This changeset was mostly built automatically by the included
.clang-tidy file, which has the ability to autoformat and auto rename
variables. At some point in the future I would like to see this in
greater use, but for now, we will impose it on bmcweb, and see how it
goes.
Tested: Code still compiles, and appears to run, although other issues
are possible and likely.
Change-Id: If422a2e36df924e897736b3feffa89f411d9dac1
Signed-off-by: Ed Tanous <ed.tanous@intel.com>
diff --git a/include/ast_video_puller.hpp b/include/ast_video_puller.hpp
index 6cd7f37..c2ccea2 100644
--- a/include/ast_video_puller.hpp
+++ b/include/ast_video_puller.hpp
@@ -1,31 +1,31 @@
#pragma once
-#include <cassert>
#include <ast_video_types.hpp>
+#include <cassert>
#include <iostream>
#include <mutex>
#include <vector>
#include <boost/asio.hpp>
-namespace AstVideo {
+namespace ast_video {
//
// Cursor struct is used in User Mode
//
-struct AST_CUR_ATTRIBUTION_TAG {
+struct AstCurAttributionTag {
unsigned int posX;
unsigned int posY;
- unsigned int cur_width;
- unsigned int cur_height;
- unsigned int cur_type; // 0:mono 1:color 2:disappear cursor
- unsigned int cur_change_flag;
+ unsigned int curWidth;
+ unsigned int curHeight;
+ unsigned int curType; // 0:mono 1:color 2:disappear cursor
+ unsigned int curChangeFlag;
};
//
// For storing Cursor Information
//
-struct AST_CURSOR_TAG {
- AST_CUR_ATTRIBUTION_TAG attr;
+struct AstCursorTag {
+ AstCurAttributionTag attr;
// unsigned char icon[MAX_CUR_OFFSETX*MAX_CUR_OFFSETY*2];
unsigned char *icon; //[64*64*2];
};
@@ -34,11 +34,11 @@
// For select image format, i.e. 422 JPG420, 444 JPG444, lumin/chrom table, 0
// ~ 11, low to high
//
-struct FEATURES_TAG {
- short jpg_fmt; // 422:JPG420, 444:JPG444
- short lumin_tbl;
- short chrom_tbl;
- short tolerance_noise;
+struct FeaturesTag {
+ short jpgFmt; // 422:JPG420, 444:JPG444
+ short luminTbl;
+ short chromTbl;
+ short toleranceNoise;
int w;
int h;
unsigned char *buf;
@@ -47,48 +47,48 @@
//
// For configure video engine control registers
//
-struct IMAGE_INFO {
- short do_image_refresh; // Action 0:motion 1:fullframe 2:quick cursor
- char qc_valid; // quick cursor enable/disable
+struct ImageInfo {
+ short doImageRefresh; // Action 0:motion 1:fullframe 2:quick cursor
+ char qcValid; // quick cursor enable/disable
unsigned int len;
int crypttype;
char cryptkey[16];
union {
- FEATURES_TAG features;
- AST_CURSOR_TAG cursor_info;
+ FeaturesTag features;
+ AstCursorTag cursorInfo;
} parameter;
};
class SimpleVideoPuller {
public:
- SimpleVideoPuller() : image_info(){};
+ SimpleVideoPuller() : imageInfo(){};
void initialize() {
std::cout << "Opening /dev/video\n";
- video_fd = open("/dev/video", O_RDWR);
- if (video_fd == 0) {
+ videoFd = open("/dev/video", O_RDWR);
+ if (videoFd == 0) {
std::cout << "Failed to open /dev/video\n";
throw std::runtime_error("Failed to open /dev/video");
}
std::cout << "Opened successfully\n";
}
- RawVideoBuffer read_video() {
- assert(video_fd != 0);
+ RawVideoBuffer readVideo() {
+ assert(videoFd != 0);
RawVideoBuffer raw;
- image_info.do_image_refresh = 1; // full frame refresh
- image_info.qc_valid = 0; // quick cursor disabled
- image_info.parameter.features.buf =
+ imageInfo.doImageRefresh = 1; // full frame refresh
+ imageInfo.qcValid = 0; // quick cursor disabled
+ imageInfo.parameter.features.buf =
reinterpret_cast<unsigned char *>(raw.buffer.data());
- image_info.crypttype = -1;
+ imageInfo.crypttype = -1;
std::cout << "Writing\n";
int status;
/*
- status = write(video_fd, reinterpret_cast<char*>(&image_info),
- sizeof(image_info));
- if (status != sizeof(image_info)) {
+ status = write(videoFd, reinterpret_cast<char*>(&imageInfo),
+ sizeof(imageInfo));
+ if (status != sizeof(imageInfo)) {
std::cout << "Write failed. Return: " << status << "\n";
perror("perror output:");
}
@@ -96,19 +96,19 @@
std::cout << "Write done\n";
*/
std::cout << "Reading\n";
- status = read(video_fd, reinterpret_cast<char *>(&image_info),
- sizeof(image_info));
+ status =
+ read(videoFd, reinterpret_cast<char *>(&imageInfo), sizeof(imageInfo));
std::cout << "Done reading\n";
if (status != 0) {
std::cerr << "Read failed with status " << status << "\n";
}
- raw.buffer.resize(image_info.len);
+ raw.buffer.resize(imageInfo.len);
- raw.height = image_info.parameter.features.h;
- raw.width = image_info.parameter.features.w;
- if (image_info.parameter.features.jpg_fmt == 422) {
+ raw.height = imageInfo.parameter.features.h;
+ raw.width = imageInfo.parameter.features.w;
+ if (imageInfo.parameter.features.jpgFmt == 422) {
raw.mode = YuvMode::YUV420;
} else {
raw.mode = YuvMode::YUV444;
@@ -117,57 +117,58 @@
}
private:
- int video_fd{};
- IMAGE_INFO image_info;
+ int videoFd{};
+ ImageInfo imageInfo;
};
#if defined(BOOST_ASIO_HAS_POSIX_STREAM_DESCRIPTOR)
class AsyncVideoPuller {
public:
- using video_callback = std::function<void (RawVideoBuffer &)>;
+ using video_callback = std::function<void(RawVideoBuffer &)>;
- explicit AsyncVideoPuller(boost::asio::io_service &io_service)
- : image_info(), dev_video(io_service, open("/dev/video", O_RDWR)) {
+ explicit AsyncVideoPuller(boost::asio::io_service &ioService)
+ : imageInfo(), devVideo(ioService, open("/dev/video", O_RDWR)) {
videobuf = std::make_shared<RawVideoBuffer>();
- image_info.do_image_refresh = 1; // full frame refresh
- image_info.qc_valid = 0; // quick cursor disabled
- image_info.parameter.features.buf =
+ imageInfo.doImageRefresh = 1; // full frame refresh
+ imageInfo.qcValid = 0; // quick cursor disabled
+ imageInfo.parameter.features.buf =
reinterpret_cast<unsigned char *>(videobuf->buffer.data());
- image_info.crypttype = -1;
+ imageInfo.crypttype = -1;
};
- void register_callback(video_callback &callback) {
- std::lock_guard<std::mutex> lock(callback_mutex);
+ void registerCallback(video_callback &callback) {
+ std::lock_guard<std::mutex> lock(callbackMutex);
callbacks.push_back(callback);
- start_read();
+ startRead();
}
- void start_read() {
- auto mutable_buffer = boost::asio::buffer(&image_info, sizeof(image_info));
- boost::asio::async_read(
- dev_video, mutable_buffer, [this](const boost::system::error_code &ec,
- std::size_t bytes_transferred) {
- if (ec) {
- std::cerr << "Read failed with status " << ec << "\n";
- } else {
- this->read_done();
- }
- });
+ void startRead() {
+ auto mutableBuffer = boost::asio::buffer(&imageInfo, sizeof(imageInfo));
+ boost::asio::async_read(devVideo, mutableBuffer,
+ [this](const boost::system::error_code &ec,
+ std::size_t bytes_transferred) {
+ if (ec) {
+ std::cerr << "Read failed with status " << ec
+ << "\n";
+ } else {
+ this->readDone();
+ }
+ });
}
- void read_done() {
+ void readDone() {
std::cout << "Done reading\n";
- videobuf->buffer.resize(image_info.len);
+ videobuf->buffer.resize(imageInfo.len);
- videobuf->height = image_info.parameter.features.h;
- videobuf->width = image_info.parameter.features.w;
- if (image_info.parameter.features.jpg_fmt == 422) {
+ videobuf->height = imageInfo.parameter.features.h;
+ videobuf->width = imageInfo.parameter.features.w;
+ if (imageInfo.parameter.features.jpgFmt == 422) {
videobuf->mode = YuvMode::YUV420;
} else {
videobuf->mode = YuvMode::YUV444;
}
- std::lock_guard<std::mutex> lock(callback_mutex);
+ std::lock_guard<std::mutex> lock(callbackMutex);
for (auto &callback : callbacks) {
// TODO(ed) call callbacks async and double buffer frames
callback(*videobuf);
@@ -176,10 +177,10 @@
private:
std::shared_ptr<RawVideoBuffer> videobuf;
- boost::asio::posix::stream_descriptor dev_video;
- IMAGE_INFO image_info;
- std::mutex callback_mutex;
+ boost::asio::posix::stream_descriptor devVideo;
+ ImageInfo imageInfo;
+ std::mutex callbackMutex;
std::vector<video_callback> callbacks;
};
#endif // defined(BOOST_ASIO_HAS_POSIX_STREAM_DESCRIPTOR)
-} // namespace AstVideo
+} // namespace ast_video