avcpp 3.2.1
Wrapper for the FFmpeg that simplify usage from C++ projects.
Loading...
Searching...
No Matches
buffersink.h
Go to the documentation of this file.
1#pragma once
2
9
10#include "avcpp/avconfig.h"
11
12#if AVCPP_HAS_AVFILTER
13
14#include <stdint.h>
15#include <memory>
16
17#include "avcpp/ffmpeg.h"
18#include "avcpp/rational.h"
19#include "avcpp/averror.h"
20#include "avcpp/frame.h"
21#include "filter.h"
22#include "filtercontext.h"
23
24namespace av {
25
33class BufferSinkFilterContext
34{
35 // To protect access
36 enum {
37 ReqUninited,
38 ReqGetFrame,
39 ReqGetSamples
40 };
41
42public:
43 BufferSinkFilterContext() = default;
50 explicit BufferSinkFilterContext(const FilterContext& ctx, OptionalErrorCode ec = throws());
51
58 void assign(const FilterContext &ctx, OptionalErrorCode ec = throws());
66 BufferSinkFilterContext& operator=(const FilterContext &ctx);
67
68
78 bool getVideoFrame(VideoFrame &frame, int flags, OptionalErrorCode ec = throws());
87 bool getVideoFrame(VideoFrame &frame, OptionalErrorCode ec = throws());
88
98 bool getAudioFrame(AudioSamples &samples, int flags, OptionalErrorCode ec = throws());
107 bool getAudioFrame(AudioSamples &samples, OptionalErrorCode ec = throws());
117 bool getAudioSamples(AudioSamples &samples, size_t samplesCount, OptionalErrorCode ec = throws());
118
125 void setFrameSize(unsigned size, OptionalErrorCode ec = throws());
134
142 static FilterMediaType checkFilter(const Filter& filter) noexcept;
143
144private:
145 // AVERROR_EOF and AVERROR(EAGAIN) never thrown, but can be returned via error_code
146 // if ec == throws(), false returns silently
147 bool getFrame(AVFrame *frame, int flags, OptionalErrorCode ec);
148 bool getSamples(AVFrame *frame, int nbSamples, OptionalErrorCode ec);
149
150private:
151 FilterContext m_sink;
153 int m_req = ReqUninited;
154};
155
156
157} // namespace av
158
159#endif
Error codes, error categories and the OptionalErrorCode convention.
One buffer of decoded audio samples.
Definition frame.h:892
BufferSinkFilterContext(const FilterContext &ctx, OptionalErrorCode ec=throws())
Wrap a sink context created by a graph.
Rational frameRate(OptionalErrorCode ec=throws())
Frame rate the sink reports.
bool getAudioFrame(AudioSamples &samples, OptionalErrorCode ec=throws())
Read one buffer of samples from the graph.
static FilterMediaType checkFilter(const Filter &filter) noexcept
Media type a filter would accept as a sink.
bool getVideoFrame(VideoFrame &frame, OptionalErrorCode ec=throws())
Read one frame from the graph.
bool getVideoFrame(VideoFrame &frame, int flags, OptionalErrorCode ec=throws())
Read one frame with explicit AV_BUFFERSINK_FLAG_* flags.
void assign(const FilterContext &ctx, OptionalErrorCode ec=throws())
Point the wrapper at another sink context.
bool getAudioFrame(AudioSamples &samples, int flags, OptionalErrorCode ec=throws())
Read one buffer of samples with explicit sink flags.
bool getAudioSamples(AudioSamples &samples, size_t samplesCount, OptionalErrorCode ec=throws())
Read an exact number of samples.
BufferSinkFilterContext & operator=(const FilterContext &ctx)
Assign from a filter context.
void setFrameSize(unsigned size, OptionalErrorCode ec=throws())
Ask the sink to deliver frames of a fixed size.
One filter instance inside a graph.
Definition filtercontext.h:30
A filter descriptor: the static description of one filter.
Definition filter.h:48
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
One video frame.
Definition frame.h:578
FFmpeg types re-exported for the public API and small value wrappers.
A single filter instance and its pads.
Source and sink filter contexts.
Video frames, audio samples and their common frame interface.
Root namespace of the library.
Definition audioresampler.h:19
FilterMediaType
Media type a filter works with.
Definition filter.h:30
@ Unknown
The filter did not declare a type, or it was not inspected yet.
Definition filter.h:32
Rational numbers, time bases and arithmetic on them.