stream.h
Go to the documentation of this file.
/* SPDX-License-Identifier: LGPL-2.1-or-later */
/*
* Copyright (C) 2019, Google Inc.
*
* stream.h - Video stream for a Camera
*/
#ifndef __LIBCAMERA_STREAM_H__
#define __LIBCAMERA_STREAM_H__
#include <map>
#include <memory>
#include <string>
#include <vector>
#include <libcamera/buffer.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 bufferCount;
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_;
};
enum StreamRole {
StillCapture,
StillCaptureRaw,
VideoRecording,
Viewfinder,
};
using StreamRoles = std::vector<StreamRole>;
class Stream
{
public:
Stream();
const StreamConfiguration &configuration() const { return configuration_; }
protected:
friend class Camera;
StreamConfiguration configuration_;
};
} /* namespace libcamera */
#endif /* __LIBCAMERA_STREAM_H__ */
buffer.h
Buffer handling.
libcamera::Camera
Camera device.
Definition: camera.h:70
libcamera::PixelFormat
libcamera image pixel format
Definition: pixel_format.h:17
libcamera::SizeRange
Describe a range of sizes.
Definition: geometry.h:72
libcamera::StreamFormats
Hold information about supported stream formats.
Definition: stream.h:25
libcamera::StreamFormats::sizes
std::vector< Size > sizes(const PixelFormat &pixelformat) const
Retrieve the list of frame sizes supported for pixelformat.
Definition: stream.cpp:130
libcamera::StreamFormats::range
SizeRange range(const PixelFormat &pixelformat) const
Retrieve the range of minimum and maximum sizes.
Definition: stream.cpp:243
libcamera::StreamFormats::pixelformats
std::vector< PixelFormat > pixelformats() const
Retrieve the list of supported pixel formats.
Definition: stream.cpp:106
libcamera::Stream
Video stream for a camera.
Definition: stream.h:70
libcamera::Stream::configuration
const StreamConfiguration & configuration() const
Retrieve the active configuration of the stream.
Definition: stream.h:74
libcamera::Stream::configuration_
StreamConfiguration configuration_
The stream configuration.
Definition: stream.h:79
libcamera::Stream::Stream
Stream()
Construct a stream with default parameters.
Definition: stream.cpp:417
geometry.h
Data structures related to geometric objects.
pixel_format.h
libcamera pixel format
libcamera::StreamRole
StreamRole
Identify the role a stream is intended to play.
Definition: stream.h:60
libcamera::Viewfinder
@ Viewfinder
Definition: stream.h:64
libcamera::VideoRecording
@ VideoRecording
Definition: stream.h:63
libcamera::StillCapture
@ StillCapture
Definition: stream.h:61
libcamera::StillCaptureRaw
@ StillCaptureRaw
Definition: stream.h:62
libcamera::StreamRoles
std::vector< StreamRole > StreamRoles
A vector of StreamRole.
Definition: stream.h:67
libcamera::Size
Describe a two-dimensional size.
Definition: geometry.h:30
libcamera::StreamConfiguration
Configuration parameters for a stream.
Definition: stream.h:39
libcamera::StreamConfiguration::bufferCount
unsigned int bufferCount
Requested number of buffers to allocate for the stream.
Definition: stream.h:47
libcamera::StreamConfiguration::size
Size size
Stream size in pixels.
Definition: stream.h:44
libcamera::StreamConfiguration::formats
const StreamFormats & formats() const
Retrieve advisory stream format information.
Definition: stream.h:51
libcamera::StreamConfiguration::StreamConfiguration
StreamConfiguration()
Definition: stream.cpp:281
libcamera::StreamConfiguration::setStream
void setStream(Stream *stream)
Associate a stream with a configuration.
Definition: stream.h:50
libcamera::StreamConfiguration::toString
std::string toString() const
Assemble and return a string describing the configuration.
Definition: stream.cpp:362
libcamera::StreamConfiguration::pixelFormat
PixelFormat pixelFormat
Stream pixel format.
Definition: stream.h:43
libcamera::StreamConfiguration::stream
Stream * stream() const
Retrieve the stream associated with the configuration.
Definition: stream.h:49
libcamera::StreamConfiguration::stride
unsigned int stride
Image stride for the stream, in bytes.
Definition: stream.h:45