avcpp 3.2.1
Wrapper for the FFmpeg that simplify usage from C++ projects.
Loading...
Searching...
No Matches
stream.h
Go to the documentation of this file.
1#pragma once
2
9
10#include <memory>
11
12#include "averror.h"
13#include "ffmpeg.h"
14#include "rational.h"
15#include "timestamp.h"
16#include "codecparameters.h"
17
18#if AVCPP_HAS_AVFORMAT
19
20namespace av
21{
33class Stream : public FFWrapperPtr<AVStream>
34{
35private:
36 friend class FormatContext;
37 Stream(const std::shared_ptr<char> &monitor, AVStream *st = nullptr, Direction direction = Direction::Invalid);
38
39public:
40 Stream() = default;
41
47 bool isValid() const;
48
54 int index() const;
63 int id() const;
64
106
115 [[deprecated("For FFmpeg 5.0+ return NO_PTS")]]
122 AVMediaType mediaType() const;
123
129 bool isAudio() const;
135 bool isVideo() const;
141 bool isData() const;
147 bool isSubtitle() const;
153 bool isAttachment() const;
154
160 Direction direction() const { return m_direction; }
161
180 void setSampleAspectRatio(const Rational &aspectRatio);
187
204
216 int eventFlags() const noexcept;
224 bool eventFlags(int flags) const noexcept;
230 void eventFlagsClear(int flags) noexcept;
231
242
243private:
245 std::weak_ptr<char> m_parentMonitor;
246 Direction m_direction = Direction::Invalid;
247};
248
249} // ::av
250
251#endif // if AVCPP_HAS_AVFORMAT
Error codes, error categories and the OptionalErrorCode convention.
The CodecParametersView class.
Definition codecparameters.h:44
Carries the caller's choice between exceptions and error codes.
Definition averror.h:96
Rational number: a numerator and a denominator.
Definition rational.h:49
int id() const
Stream identifier from the container.
CodecParametersView codecParameters() const
Codec parameters of the stream.
Timestamp duration() const
Duration of the stream.
Rational timeBase() const
Time base of the timestamps in this stream.
bool isData() const
Whether this is a data stream.
Timestamp currentDts() const
Decoding timestamp of the packet currently being processed by this stream.
bool isSubtitle() const
Whether this is a subtitle stream.
void setCodecParameters(CodecParametersView codecpar, OptionalErrorCode ec=throws())
Copy codec parameters into the stream.
void setFrameRate(const Rational &frameRate)
Set the declared frame rate.
void setSampleAspectRatio(const Rational &aspectRatio)
Set the pixel aspect ratio.
Rational frameRate() const
Frame rate declared by the stream.
void setupEncodingParameters(const class VideoEncoderContext &ctx, OptionalErrorCode ec=throws())
Configure an output stream from a video encoder.
bool isAttachment() const
Whether this is an attachment stream, such as an embedded font.
int index() const
Position of the stream in its container.
Rational averageFrameRate() const
Average frame rate of the stream.
Direction direction() const
Direction the stream is used in.
Definition stream.h:160
bool isValid() const
Whether the view refers to a stream.
Rational sampleAspectRatio() const
Pixel aspect ratio declared by the stream.
void eventFlagsClear(int flags) noexcept
Acknowledge events.
int eventFlags() const noexcept
Flags to the user to detect events happening on the stream.
bool isVideo() const
Whether this is a video stream.
void setTimeBase(const Rational &timeBase)
Set the time base of the stream.
Timestamp startTime() const
Timestamp of the first frame in this stream.
void setAverageFrameRate(const Rational &frameRate)
Set the average frame rate.
AVMediaType mediaType() const
Kind of media the stream carries.
bool isAudio() const
Whether this is an audio stream.
The Timestamp class represents timestamp value and it timebase.
Definition timestamp.h:25
Encodes video frames into packets.
Definition codeccontext.h:1338
Codec parameters shared between streams and contexts.
FFmpeg types re-exported for the public API and small value wrappers.
Root namespace of the library.
Definition audioresampler.h:19
OptionalErrorCode throws()
Helper to construct null OptionalErrorCode object.
Definition averror.h:310
Direction
Direction a codec or a stream is used in.
Definition codecparameters.h:29
@ Invalid
Not a direction; the default state of a context that has none.
Definition codecparameters.h:31
STL namespace.
Rational numbers, time bases and arithmetic on them.
Frame timestamps and their arithmetic.