avcpp  2.0
Wrapper for the FFmpeg that simplify usage from C++ projects.
stream.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <memory>
4 
5 #include "averror.h"
6 #include "ffmpeg.h"
7 #include "rational.h"
8 #include "timestamp.h"
9 #include "codecparameters.h"
10 
11 namespace av
12 {
13 
14 enum class Direction
15 {
16  Invalid = -1,
17  Encoding,
18  Decoding
19 };
20 
21 
22 class Stream : public FFWrapperPtr<AVStream>
23 {
24 private:
25  friend class FormatContext;
26  Stream(const std::shared_ptr<char> &monitor, AVStream *st = nullptr, Direction direction = Direction::Invalid);
27 
28 public:
29  Stream() = default;
30 
31  bool isValid() const;
32 
33  int index() const;
34  int id() const;
35 
36  Rational frameRate() const;
37  Rational timeBase() const;
39  Rational averageFrameRate() const;
40  Timestamp startTime() const;
41  Timestamp duration() const;
42 
43  [[deprecated("For FFmpeg 5.0+ return NO_PTS")]]
44  Timestamp currentDts() const;
45  AVMediaType mediaType() const;
46 
47  bool isAudio() const;
48  bool isVideo() const;
49  bool isData() const;
50  bool isSubtitle() const;
51  bool isAttachment() const;
52 
53  Direction direction() const { return m_direction; }
54 
55  void setTimeBase(const Rational &timeBase);
56  void setFrameRate(const Rational &frameRate);
57  void setSampleAspectRatio(const Rational &aspectRatio);
59 
61  void setCodecParameters(CodecParametersView codecpar, OptionalErrorCode ec = throws());
62 
69  int eventFlags() const noexcept;
70  bool eventFlags(int flags) const noexcept;
71  void eventFlagsClear(int flags) noexcept;
72 
74 
75 private:
76  std::weak_ptr<char> m_parentMonitor;
77  Direction m_direction = Direction::Invalid;
78 };
79 
80 } // ::av
81 
av::Stream::frameRate
Rational frameRate() const
Definition: stream.cpp:30
av::Direction::Decoding
@ Decoding
av::Rational
Definition: rational.h:24
codecparameters.h
rational.h
av::Stream::isAttachment
bool isAttachment() const
Definition: stream.cpp:100
av::Stream::isValid
bool isValid() const
Definition: stream.cpp:15
averror.h
ffmpeg.h
av::Stream::currentDts
Timestamp currentDts() const
Definition: stream.cpp:60
av::Stream::isVideo
bool isVideo() const
Definition: stream.cpp:85
FFWrapperPtr
Definition: ffmpeg.h:68
av::Stream::direction
Direction direction() const
Definition: stream.h:53
av::Stream::Stream
Stream()=default
av::Stream::setSampleAspectRatio
void setSampleAspectRatio(const Rational &aspectRatio)
Definition: stream.cpp:115
av::Stream::isData
bool isData() const
Definition: stream.cpp:90
av::Stream::duration
Timestamp duration() const
Definition: stream.cpp:55
av::OptionalErrorCode
Definition: averror.h:63
av::Direction::Encoding
@ Encoding
av::Stream::timeBase
Rational timeBase() const
Definition: stream.cpp:35
av::CodecParametersView
The CodecParametersView class.
Definition: codecparameters.h:20
av::Stream::setCodecParameters
void setCodecParameters(CodecParametersView codecpar, OptionalErrorCode ec=throws())
Definition: stream.cpp:130
av::Stream::sampleAspectRatio
Rational sampleAspectRatio() const
Definition: stream.cpp:40
av::Stream::codecParameters
CodecParametersView codecParameters() const
Definition: stream.cpp:125
av::Stream::index
int index() const
Definition: stream.cpp:20
av::Stream::setupEncodingParameters
void setupEncodingParameters(const class VideoEncoderContext &ctx, OptionalErrorCode ec=throws())
Definition: stream.cpp:158
av::Stream::isAudio
bool isAudio() const
Definition: stream.cpp:80
av::VideoEncoderContext
Definition: codeccontext.h:442
av::Stream::mediaType
AVMediaType mediaType() const
Definition: stream.cpp:69
av::Stream::isSubtitle
bool isSubtitle() const
Definition: stream.cpp:95
av::Stream::setFrameRate
void setFrameRate(const Rational &frameRate)
Definition: stream.cpp:110
av
Definition: audioresampler.cpp:8
std
Definition: averror.h:228
av::Stream::id
int id() const
Definition: stream.cpp:25
av::Stream::startTime
Timestamp startTime() const
Definition: stream.cpp:50
av::Stream::averageFrameRate
Rational averageFrameRate() const
Definition: stream.cpp:45
av::Direction
Direction
Definition: stream.h:14
av::FormatContext
Definition: formatcontext.h:53
av::Timestamp
The Timestamp class represents timestamp value and it timebase.
Definition: timestamp.h:13
av::throws
OptionalErrorCode throws()
Helper to construct null OptionalErrorCode object.
Definition: averror.h:179
av::Stream::setAverageFrameRate
void setAverageFrameRate(const Rational &frameRate)
Definition: stream.cpp:120
av::Direction::Invalid
@ Invalid
timestamp.h
av::Stream::eventFlags
int eventFlags() const noexcept
Flags to the user to detect events happening on the stream.
Definition: stream.cpp:137
av::Stream
Definition: stream.h:22
av::Stream::eventFlagsClear
void eventFlagsClear(int flags) noexcept
Definition: stream.cpp:151
av::Stream::setTimeBase
void setTimeBase(const Rational &timeBase)
Definition: stream.cpp:105