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 #if AVCPP_HAS_AVFORMAT
12 
13 namespace av
14 {
15 class Stream : public FFWrapperPtr<AVStream>
16 {
17 private:
18  friend class FormatContext;
19  Stream(const std::shared_ptr<char> &monitor, AVStream *st = nullptr, Direction direction = Direction::Invalid);
20 
21 public:
22  Stream() = default;
23 
24  bool isValid() const;
25 
26  int index() const;
27  int id() const;
28 
29  Rational frameRate() const;
30  Rational timeBase() const;
31  Rational sampleAspectRatio() const;
32  Rational averageFrameRate() const;
33  Timestamp startTime() const;
34  Timestamp duration() const;
35 
36  [[deprecated("For FFmpeg 5.0+ return NO_PTS")]]
37  Timestamp currentDts() const;
38  AVMediaType mediaType() const;
39 
40  bool isAudio() const;
41  bool isVideo() const;
42  bool isData() const;
43  bool isSubtitle() const;
44  bool isAttachment() const;
45 
46  Direction direction() const { return m_direction; }
47 
48  void setTimeBase(const Rational &timeBase);
49  void setFrameRate(const Rational &frameRate);
50  void setSampleAspectRatio(const Rational &aspectRatio);
51  void setAverageFrameRate(const Rational &frameRate);
52 
53  CodecParametersView codecParameters() const;
54  void setCodecParameters(CodecParametersView codecpar, OptionalErrorCode ec = throws());
55 
62  int eventFlags() const noexcept;
63  bool eventFlags(int flags) const noexcept;
64  void eventFlagsClear(int flags) noexcept;
65 
66  void setupEncodingParameters(const class VideoEncoderContext& ctx, OptionalErrorCode ec = throws());
67 
68 private:
69  std::weak_ptr<char> m_parentMonitor;
70  Direction m_direction = Direction::Invalid;
71 };
72 
73 } // ::av
74 
75 #endif // if AVCPP_HAS_AVFORMAT
Definition: audioresampler.cpp:8
OptionalErrorCode throws()
Helper to construct null OptionalErrorCode object.
Definition: averror.h:179
Direction
Definition: codecparameters.h:16
Definition: averror.h:228
Definition: ffmpeg.h:22