[libcamera-devel,RFC,4/6] android: camera_device: Implement toString() in Camera3StreamConfig
diff mbox series

Message ID 20210204100541.657503-5-hiroh@chromium.org
State New
Headers show
Series
  • Support stream mapping in Android HAL adaptation layer
Related show

Commit Message

Hirokazu Honda Feb. 4, 2021, 10:05 a.m. UTC
This adds toString() function in Camera3StreamConfig
and Camera3StreamConfig::Camera3Stream for logging.

Signed-off-by: Hirokazu Honda <hiroh@chromium.org>
---
 src/android/camera_device.cpp | 38 +++++++++++++++++++++++++++++++++--
 1 file changed, 36 insertions(+), 2 deletions(-)

--
2.30.0.365.g02bc693789-goog

Patch
diff mbox series

diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp
index 752e17ba..93dfbcdb 100644
--- a/src/android/camera_device.cpp
+++ b/src/android/camera_device.cpp
@@ -140,14 +140,48 @@  const std::map<int, const Camera3Format> camera3FormatsMap = {
  */
 struct Camera3StreamConfig {
 	struct Camera3Stream {
-		camera3_stream_t *stream;
-		CameraStream::Type type;
+		Camera3Stream(camera3_stream_t *stream, CameraStream::Type type)
+			: stream(stream), type(type) {}
+
+		std::string toString() const;
+
+		camera3_stream_t *stream = nullptr;
+		CameraStream::Type type = CameraStream::Type::Direct;
 	};

+	std::string toString() const;
+
 	std::vector<Camera3Stream> streams;
 	StreamConfiguration config;
 };

+std::string Camera3StreamConfig::Camera3Stream::toString() const {
+	std::ostringstream os;
+	os << "format: " << utils::hex(stream->format)
+	    << ", size:" << stream->width << "x" << stream->height;
+	os << ", type: ";
+	switch (type) {
+	case CameraStream::Type::Direct:
+		os << "Direct"; break;
+	case CameraStream::Type::Internal:
+		os << "Internal"; break;
+	case CameraStream::Type::Mapped:
+		os << "Mapped"; break;
+	}
+
+	return os.str();
+}
+
+std::string Camera3StreamConfig::toString() const {
+	std::ostringstream os;
+	for (size_t i = 0; i < streams.size(); ++i) {
+		os << "Stream #" << i << ": " << streams[i].toString() << "}, ";
+	}
+
+	os << "config: " << config.toString();
+	return os.str();
+}
+
 /*
  * Reorder the configurations so that libcamera::Camera can accept them as much
  * as possible. The sort rule is as follows.