Loading...
Searching...
No Matches
stream.h
Go to the documentation of this file.
/* SPDX-License-Identifier: LGPL-2.1-or-later */
/*
* Copyright (C) 2019, Google Inc.
*
* Video stream for a Camera
*/
#pragma once
#include <map>
#include <ostream>
#include <string>
#include <vector>
#include <libcamera/color_space.h>
#include <libcamera/framebuffer.h>
#include <libcamera/geometry.h>
#include <libcamera/pixel_format.h>
namespace libcamera {
class Camera;
class Stream;
class StreamFormats
{
public:
StreamFormats();
StreamFormats(const std::map<PixelFormat, std::vector<SizeRange>> &formats);
std::vector<PixelFormat> pixelformats() const;
std::vector<Size> sizes(const PixelFormat &pixelformat) const;
SizeRange range(const PixelFormat &pixelformat) const;
private:
std::map<PixelFormat, std::vector<SizeRange>> formats_;
};
struct StreamConfiguration {
StreamConfiguration();
StreamConfiguration(const StreamFormats &formats);
PixelFormat pixelFormat;
Size size;
unsigned int stride;
unsigned int frameSize;
unsigned int bufferCount;
std::optional<ColorSpace> colorSpace;
Stream *stream() const { return stream_; }
void setStream(Stream *stream) { stream_ = stream; }
const StreamFormats &formats() const { return formats_; }
std::string toString() const;
private:
Stream *stream_;
StreamFormats formats_;
};
std::ostream &operator<<(std::ostream &out, const StreamConfiguration &cfg);
enum class StreamRole {
Raw,
StillCapture,
VideoRecording,
Viewfinder,
};
std::ostream &operator<<(std::ostream &out, StreamRole role);
class Stream
{
public:
Stream();
const StreamConfiguration &configuration() const { return configuration_; }
protected:
friend class Camera;
StreamConfiguration configuration_;
};
} /* namespace libcamera */
libcamera::Camera
Camera device.
Definition camera.h:115
libcamera::PixelFormat
libcamera image pixel format
Definition pixel_format.h:17
libcamera::SizeRange
Describe a range of sizes.
Definition geometry.h:205
libcamera::Size
Describe a two-dimensional size.
Definition geometry.h:51
libcamera::StreamFormats
Hold information about supported stream formats.
Definition stream.h:26
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:76
libcamera::Stream::configuration_
StreamConfiguration configuration_
The stream configuration.
Definition stream.h:85
libcamera::Stream::Stream
Stream()
Construct a stream with default parameters.
Definition stream.cpp:478
libcamera::Stream::configuration
const StreamConfiguration & configuration() const
Retrieve the active configuration of the stream.
Definition stream.h:80
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:66
libcamera::StreamRole::Viewfinder
@ Viewfinder
Definition stream.h:70
libcamera::StreamRole::Raw
@ Raw
Definition stream.h:67
libcamera::StreamRole::StillCapture
@ StillCapture
Definition stream.h:68
libcamera::StreamRole::VideoRecording
@ VideoRecording
Definition stream.h:69
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:40
libcamera::StreamConfiguration::setStream
void setStream(Stream *stream)
Associate a stream with a configuration.
Definition stream.h:54
libcamera::StreamConfiguration::colorSpace
std::optional< ColorSpace > colorSpace
The ColorSpace for this stream.
Definition stream.h:51
libcamera::StreamConfiguration::StreamConfiguration
StreamConfiguration()
Definition stream.cpp:282
libcamera::StreamConfiguration::formats
const StreamFormats & formats() const
Retrieve advisory stream format information.
Definition stream.h:55
libcamera::StreamConfiguration::stream
Stream * stream() const
Retrieve the stream associated with the configuration.
Definition stream.h:53
libcamera::StreamConfiguration::bufferCount
unsigned int bufferCount
Requested number of buffers to allocate for the stream.
Definition stream.h:49
libcamera::StreamConfiguration::frameSize
unsigned int frameSize
Frame size for the stream, in bytes.
Definition stream.h:47
libcamera::StreamConfiguration::stride
unsigned int stride
Image stride for the stream, in bytes.
Definition stream.h:46
libcamera::StreamConfiguration::pixelFormat
PixelFormat pixelFormat
Stream pixel format.
Definition stream.h:44
libcamera::StreamConfiguration::toString
std::string toString() const
Assemble and return a string describing the configuration.
Definition stream.cpp:393
libcamera::StreamConfiguration::size
Size size
Stream size in pixels.
Definition stream.h:45