avcpp  2.0
Wrapper for the FFmpeg that simplify usage from C++ projects.
buffersink.h
Go to the documentation of this file.
1 #ifndef AV_BUFFERSINK_H
2 #define AV_BUFFERSINK_H
3 
4 #include <stdint.h>
5 #include <memory>
6 
7 #include "ffmpeg.h"
8 #include "rational.h"
9 #include "filtercontext.h"
10 #include "filter.h"
11 #include "averror.h"
12 #include "frame.h"
13 
14 namespace av {
15 
17 {
18  // To protect access
19  enum {
20  ReqUninited,
21  ReqGetFrame,
22  ReqGetSamples
23  };
24 
25 public:
26  BufferSinkFilterContext() = default;
27  explicit BufferSinkFilterContext(const FilterContext& ctx, OptionalErrorCode ec = throws());
28 
29  void assign(const FilterContext &ctx, OptionalErrorCode ec = throws());
31 
32 
33  bool getVideoFrame(VideoFrame &frame, int flags, OptionalErrorCode ec = throws());
34  bool getVideoFrame(VideoFrame &frame, OptionalErrorCode ec = throws());
35 
36  bool getAudioFrame(AudioSamples &samples, int flags, OptionalErrorCode ec = throws());
37  bool getAudioFrame(AudioSamples &samples, OptionalErrorCode ec = throws());
38  bool getAudioSamples(AudioSamples &samples, size_t samplesCount, OptionalErrorCode ec = throws());
39 
40  void setFrameSize(unsigned size, OptionalErrorCode ec = throws());
41  Rational frameRate(OptionalErrorCode ec = throws());
42 
43  static FilterMediaType checkFilter(const Filter& filter) noexcept;
44 
45 private:
46  // AVERROR_EOF and AVERROR(EAGAIN) never thrown, but can be returned via error_code
47  // if ec == throws(), false returns silently
48  bool getFrame(AVFrame *frame, int flags, OptionalErrorCode ec);
49  bool getSamples(AVFrame *frame, int nbSamples, OptionalErrorCode ec);
50 
51 private:
52  FilterContext m_sink;
54  int m_req = ReqUninited;
55 };
56 
57 
58 } // namespace av
59 
60 #endif // AV_BUFFERSINK_H
filter.h
av::Rational
Definition: rational.h:24
av::BufferSinkFilterContext
Definition: buffersink.h:16
rational.h
av::FilterMediaType
FilterMediaType
Definition: filter.h:15
av::BufferSinkFilterContext::operator=
BufferSinkFilterContext & operator=(const FilterContext &ctx)
Definition: buffersink.cpp:26
averror.h
av::Filter
Definition: filter.h:23
ffmpeg.h
av::BufferSinkFilterContext::getAudioSamples
bool getAudioSamples(AudioSamples &samples, size_t samplesCount, OptionalErrorCode ec=throws())
Definition: buffersink.cpp:65
av::BufferSinkFilterContext::frameRate
Rational frameRate(OptionalErrorCode ec=throws())
Definition: buffersink.cpp:92
av::OptionalErrorCode
Definition: averror.h:63
av::FilterMediaType::Unknown
@ Unknown
filtercontext.h
av::BufferSinkFilterContext::setFrameSize
void setFrameSize(unsigned size, OptionalErrorCode ec=throws())
Definition: buffersink.cpp:74
frame.h
av::AudioSamples
Definition: frame.h:391
av::BufferSinkFilterContext::checkFilter
static FilterMediaType checkFilter(const Filter &filter) noexcept
Definition: buffersink.cpp:111
av::BufferSinkFilterContext::getAudioFrame
bool getAudioFrame(AudioSamples &samples, int flags, OptionalErrorCode ec=throws())
Definition: buffersink.cpp:49
av::VideoFrame
Definition: frame.h:354
av
Definition: audioresampler.cpp:8
av::FilterContext
Definition: filtercontext.h:14
av::BufferSinkFilterContext::assign
void assign(const FilterContext &ctx, OptionalErrorCode ec=throws())
Definition: buffersink.cpp:15
av::BufferSinkFilterContext::BufferSinkFilterContext
BufferSinkFilterContext()=default
av::BufferSinkFilterContext::getVideoFrame
bool getVideoFrame(VideoFrame &frame, int flags, OptionalErrorCode ec=throws())
Definition: buffersink.cpp:32