From 2288550f7d9cb260021de436bb8ff8c0e8ea86be Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Sun, 17 May 2020 23:58:31 +0300 Subject: cam: Add support for viewfinder through DRM/KMS Use the KMSSink class to display the viewfinder stream, if any, through DRM/KMS. The output connector is selected through the new -D/--display argument. Signed-off-by: Laurent Pinchart Reviewed-by: Paul Elder Reviewed-by: Umang Jain Reviewed-by: Kieran Bingham --- src/cam/camera_session.cpp | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'src/cam/camera_session.cpp') diff --git a/src/cam/camera_session.cpp b/src/cam/camera_session.cpp index f34a6ed5..60d640f2 100644 --- a/src/cam/camera_session.cpp +++ b/src/cam/camera_session.cpp @@ -16,6 +16,9 @@ #include "camera_session.h" #include "event_loop.h" #include "file_sink.h" +#ifdef HAVE_KMS +#include "kms_sink.h" +#endif #include "main.h" #include "stream_options.h" @@ -66,6 +69,28 @@ CameraSession::CameraSession(CameraManager *cm, bool strictFormats = options_.isSet(OptStrictFormats); +#ifdef HAVE_KMS + if (options_.isSet(OptDisplay)) { + if (options_.isSet(OptFile)) { + std::cerr << "--display and --file options are mutually exclusive" + << std::endl; + return; + } + + if (roles.size() != 1) { + std::cerr << "Display doesn't support multiple streams" + << std::endl; + return; + } + + if (roles[0] != StreamRole::Viewfinder) { + std::cerr << "Display requires a viewfinder stream" + << std::endl; + return; + } + } +#endif + switch (config->validate()) { case CameraConfiguration::Valid: break; @@ -161,6 +186,11 @@ int CameraSession::start() camera_->requestCompleted.connect(this, &CameraSession::requestComplete); +#ifdef HAVE_KMS + if (options_.isSet(OptDisplay)) + sink_ = std::make_unique(options_[OptDisplay].toString()); +#endif + if (options_.isSet(OptFile)) { if (!options_[OptFile].toString().empty()) sink_ = std::make_unique(options_[OptFile]); -- cgit v1.2.1