libcamera: include/libcamera/stream.h Source File

libcamera v0.2.0 Supporting cameras in Linux since 2019

Loading...
Searching...
No Matches
stream.h
Go to the documentation of this file.
1/* SPDX-License-Identifier: LGPL-2.1-or-later */
2/*
3 * Copyright (C) 2019, Google Inc.
4 *
5 * stream.h - Video stream for a Camera
6 */
7
8#pragma once
9
10#include <map>
11#include <memory>
12#include <ostream>
13#include <string>
14#include <vector>
15
16#include <libcamera/color_space.h>
17#include <libcamera/framebuffer.h>
18#include <libcamera/geometry.h>
19#include <libcamera/pixel_format.h>
20
21namespace libcamera {
22
23class Camera;
24class Stream;
25
26 class StreamFormats
27{
28public:
29 StreamFormats();
30 StreamFormats(const std::map<PixelFormat, std::vector<SizeRange>> &formats);
31
32 std::vector<PixelFormat> pixelformats() const;
33 std::vector<Size> sizes(const PixelFormat &pixelformat) const;
34
35 SizeRange range(const PixelFormat &pixelformat) const;
36
37private:
38 std::map<PixelFormat, std::vector<SizeRange>> formats_;
39};
40
41 struct StreamConfiguration {
42 StreamConfiguration();
43 StreamConfiguration(const StreamFormats &formats);
44
45 PixelFormat pixelFormat;
46 Size size;
47 unsigned int stride;
48 unsigned int frameSize;
49
50 unsigned int bufferCount;
51
52 std::optional<ColorSpace> colorSpace;
53
54 Stream *stream() const { return stream_; }
55 void setStream(Stream *stream) { stream_ = stream; }
56 const StreamFormats &formats() const { return formats_; }
57
58 std::string toString() const;
59
60private:
61 Stream *stream_;
62 StreamFormats formats_;
63};
64
65 enum class StreamRole {
66 Raw,
67 StillCapture,
68 VideoRecording,
69 Viewfinder,
70};
71
72std::ostream &operator<<(std::ostream &out, StreamRole role);
73
74 class Stream
75{
76public:
77 Stream();
78
79 const StreamConfiguration &configuration() const { return configuration_; }
80
81protected:
82 friend class Camera;
83
84 StreamConfiguration configuration_;
85};
86
87} /* namespace libcamera */
libcamera::Camera
Camera device.
Definition camera.h:115
libcamera::PixelFormat
libcamera image pixel format
Definition pixel_format.h:18
libcamera::SizeRange
Describe a range of sizes.
Definition geometry.h:201
libcamera::Size
Describe a two-dimensional size.
Definition geometry.h:53
libcamera::StreamFormats
Hold information about supported stream formats.
Definition stream.h:27
libcamera::StreamFormats::sizes
std::vector< Size > sizes(const PixelFormat &pixelformat) const
Retrieve the list of frame sizes supported for pixelformat.
Definition stream.cpp:131
libcamera::StreamFormats::range
SizeRange range(const PixelFormat &pixelformat) const
Retrieve the range of minimum and maximum sizes.
Definition stream.cpp:244
libcamera::StreamFormats::pixelformats
std::vector< PixelFormat > pixelformats() const
Retrieve the list of supported pixel formats.
Definition stream.cpp:107
libcamera::Stream
Video stream for a camera.
Definition stream.h:75
libcamera::Stream::configuration
const StreamConfiguration & configuration() const
Retrieve the active configuration of the stream.
Definition stream.h:79
libcamera::Stream::configuration_
StreamConfiguration configuration_
The stream configuration.
Definition stream.h:84
libcamera::Stream::Stream
Stream()
Construct a stream with default parameters.
Definition stream.cpp:461
color_space.h
Class and enums to represent color spaces.
framebuffer.h
Frame buffer handling.
geometry.h
Data structures related to geometric objects.
libcamera
Top-level libcamera namespace.
Definition backtrace.h:17
libcamera::StreamRole
StreamRole
Identify the role a stream is intended to play.
Definition stream.h:65
libcamera::StreamRole::Viewfinder
@ Viewfinder
libcamera::StreamRole::Raw
@ Raw
libcamera::StreamRole::StillCapture
@ StillCapture
libcamera::StreamRole::VideoRecording
@ VideoRecording
libcamera::operator<<
std::ostream & operator<<(std::ostream &out, const Point &p)
Insert a text representation of a Point into an output stream.
Definition geometry.cpp:91
pixel_format.h
libcamera pixel format
libcamera::StreamConfiguration
Configuration parameters for a stream.
Definition stream.h:41
libcamera::StreamConfiguration::bufferCount
unsigned int bufferCount
Requested number of buffers to allocate for the stream.
Definition stream.h:50
libcamera::StreamConfiguration::size
Size size
Stream size in pixels.
Definition stream.h:46
libcamera::StreamConfiguration::formats
const StreamFormats & formats() const
Retrieve advisory stream format information.
Definition stream.h:56
libcamera::StreamConfiguration::StreamConfiguration
StreamConfiguration()
Definition stream.cpp:282
libcamera::StreamConfiguration::setStream
void setStream(Stream *stream)
Associate a stream with a configuration.
Definition stream.h:55
libcamera::StreamConfiguration::colorSpace
std::optional< ColorSpace > colorSpace
The ColorSpace for this stream.
Definition stream.h:52
libcamera::StreamConfiguration::toString
std::string toString() const
Assemble and return a string describing the configuration.
Definition stream.cpp:393
libcamera::StreamConfiguration::pixelFormat
PixelFormat pixelFormat
Stream pixel format.
Definition stream.h:45
libcamera::StreamConfiguration::stream
Stream * stream() const
Retrieve the stream associated with the configuration.
Definition stream.h:54
libcamera::StreamConfiguration::frameSize
unsigned int frameSize
Frame size for the stream, in bytes.
Definition stream.h:48
libcamera::StreamConfiguration::stride
unsigned int stride
Image stride for the stream, in bytes.
Definition stream.h:47