cam: Pass stream names to FileSink
The FileSink class constructs stream names internally the same way that
the CameraSession does, except that it fails to add the camera name.
This results in files being written without the camera name.
This could be fixed in FileSink, but we would still duplicate code to
construct stream names. Pass the stream names map from CameraSession to
FileSink instead, and store it internally.
Fixes: 02001fecb0 ("cam: Turn BufferWriter into a FrameSink")
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
This commit is contained in:
@@ -193,9 +193,10 @@ int CameraSession::start()
|
||||
|
||||
if (options_.isSet(OptFile)) {
|
||||
if (!options_[OptFile].toString().empty())
|
||||
sink_ = std::make_unique<FileSink>(options_[OptFile]);
|
||||
sink_ = std::make_unique<FileSink>(streamNames_,
|
||||
options_[OptFile]);
|
||||
else
|
||||
sink_ = std::make_unique<FileSink>();
|
||||
sink_ = std::make_unique<FileSink>(streamNames_);
|
||||
}
|
||||
|
||||
if (sink_) {
|
||||
|
||||
@@ -20,8 +20,9 @@
|
||||
|
||||
using namespace libcamera;
|
||||
|
||||
FileSink::FileSink(const std::string &pattern)
|
||||
: pattern_(pattern)
|
||||
FileSink::FileSink(const std::map<const libcamera::Stream *, std::string> &streamNames,
|
||||
const std::string &pattern)
|
||||
: streamNames_(streamNames), pattern_(pattern)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -35,12 +36,6 @@ int FileSink::configure(const libcamera::CameraConfiguration &config)
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
streamNames_.clear();
|
||||
for (unsigned int index = 0; index < config.size(); ++index) {
|
||||
const StreamConfiguration &cfg = config.at(index);
|
||||
streamNames_[cfg.stream()] = "stream" + std::to_string(index);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
+2
-1
@@ -20,7 +20,8 @@ class Image;
|
||||
class FileSink : public FrameSink
|
||||
{
|
||||
public:
|
||||
FileSink(const std::string &pattern = "");
|
||||
FileSink(const std::map<const libcamera::Stream *, std::string> &streamNames,
|
||||
const std::string &pattern = "");
|
||||
~FileSink();
|
||||
|
||||
int configure(const libcamera::CameraConfiguration &config) override;
|
||||
|
||||
Reference in New Issue
Block a user