diff options
author | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2021-07-07 03:34:28 +0300 |
---|---|---|
committer | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2021-07-22 17:14:03 +0300 |
commit | 721f4b03d80fc7b65cfb4c7ecebe545ef1fe0565 (patch) | |
tree | bb861e563b26edf1017524f0dd83f1e074420a39 /src | |
parent | 7dab1fa58fb77ace2742dadf860d91f29474225f (diff) |
cam: Add camera index to file name of capture frames
To prepare for multi-camera support, extend the file naming scheme for
captured frames to include the camera index in addition to the stream
name and frame number.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/cam/camera_session.cpp | 9 | ||||
-rw-r--r-- | src/cam/camera_session.h | 4 | ||||
-rw-r--r-- | src/cam/main.cpp | 4 |
3 files changed, 11 insertions, 6 deletions
diff --git a/src/cam/camera_session.cpp b/src/cam/camera_session.cpp index f2383567..90261a8c 100644 --- a/src/cam/camera_session.cpp +++ b/src/cam/camera_session.cpp @@ -22,9 +22,11 @@ using namespace libcamera; CameraSession::CameraSession(CameraManager *cm, const std::string &cameraId, + unsigned int cameraIndex, const OptionsParser::Options &options) - : options_(options), last_(0), queueCount_(0), captureCount_(0), - captureLimit_(0), printMetadata_(false) + : options_(options), cameraIndex_(cameraIndex), last_(0), + queueCount_(0), captureCount_(0), captureLimit_(0), + printMetadata_(false) { char *endptr; unsigned long index = strtoul(cameraId.c_str(), &endptr, 10); @@ -152,7 +154,8 @@ int CameraSession::start() streamName_.clear(); for (unsigned int index = 0; index < config_->size(); ++index) { StreamConfiguration &cfg = config_->at(index); - streamName_[cfg.stream()] = "stream" + std::to_string(index); + streamName_[cfg.stream()] = "cam" + std::to_string(cameraIndex_) + + "-stream" + std::to_string(index); } camera_->requestCompleted.connect(this, &CameraSession::requestComplete); diff --git a/src/cam/camera_session.h b/src/cam/camera_session.h index b3136383..b0f50e7f 100644 --- a/src/cam/camera_session.h +++ b/src/cam/camera_session.h @@ -28,7 +28,7 @@ class CameraSession { public: CameraSession(libcamera::CameraManager *cm, - const std::string &cameraId, + const std::string &cameraId, unsigned int cameraIndex, const OptionsParser::Options &options); ~CameraSession(); @@ -60,6 +60,8 @@ private: std::map<const libcamera::Stream *, std::string> streamName_; std::unique_ptr<BufferWriter> writer_; + unsigned int cameraIndex_; + uint64_t last_; unsigned int queueCount_; diff --git a/src/cam/main.cpp b/src/cam/main.cpp index 7688fa55..96f55831 100644 --- a/src/cam/main.cpp +++ b/src/cam/main.cpp @@ -136,7 +136,7 @@ int CamApp::parseOptions(int argc, char *argv[]) "If the file name ends with a '/', it sets the directory in which\n" "to write files, using the default file name. Otherwise it sets the\n" "full file path and name. The first '#' character in the file name\n" - "is expanded to the stream name and frame sequence number.\n" + "is expanded to the camera index, stream name and frame sequence number.\n" "The default file name is 'frame-#.bin'.", "file", ArgumentOptional, "filename", false, OptCamera); @@ -201,7 +201,7 @@ int CamApp::run() if (options_.isSet(OptCamera)) { const OptionValue &camera = options_[OptCamera]; session = std::make_unique<CameraSession>(cm_.get(), - camera.toString(), + camera.toString(), 0, camera.children()); if (!session->isValid()) { std::cout << "Failed to create camera session" << std::endl; |