Ring Daemon
Loading...
Searching...
No Matches
media_filter.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2004-2026 Savoir-faire Linux Inc.
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <https://www.gnu.org/licenses/>.
16 */
17#pragma once
18
19#ifdef HAVE_CONFIG_H
20#include "config.h"
21#endif
22
23#include "media_stream.h"
24#include "noncopyable.h"
25#include "video/video_base.h"
26
27#include <string>
28#include <vector>
29
30extern "C" {
31struct AVFilterContext;
32struct AVFilterGraph;
33struct AVFilterInOut;
34}
35
36namespace jami {
37
61{
62public:
65
69 std::string getFilterDesc() const;
70
75 int initialize(const std::string& filterDesc, const std::vector<MediaStream>& msps);
76
80 bool needsReinitForNewStream(const std::string& name) const;
81
85 const MediaStream& getInputParams(const std::string& inputName) const;
86
93
101 int feedInput(AVFrame* frame, const std::string& inputName);
102
110 std::unique_ptr<MediaFrame> readOutput();
111
115 void flush();
116
117private:
119
123 int initOutputFilter(AVFilterInOut* out);
124
128 int initInputFilter(AVFilterInOut* in, const MediaStream& msp);
129
135 int reinitialize();
136
142 int fail(std::string_view msg, int err) const;
143
147 void clean();
148
152 AVFilterGraph* graph_ = nullptr;
153
159 AVFilterContext* output_ = nullptr;
160
166 std::vector<AVFilterContext*> inputs_;
167
173 std::vector<MediaStream> inputParams_;
174
178 std::string desc_ {};
179
183 bool initialized_ {false};
184};
185
186}; // namespace jami
Provides access to libavfilter.
std::unique_ptr< MediaFrame > readOutput()
Pull a frame from the filter graph.
MediaStream getOutputParams() const
Returns a MediaStream struct describing the frames that will be output.
std::string getFilterDesc() const
Returns the current filter graph string.
void flush()
Flush filter to indicate EOF.
int initialize(const std::string &filterDesc, const std::vector< MediaStream > &msps)
Initializes the filter graph with one or more inputs and one output.
bool needsReinitForNewStream(const std::string &name) const
Determines if the media filter needs to be reinitialized for a new stream.
int feedInput(AVFrame *frame, const std::string &inputName)
Give the specified source filter an input frame.
const MediaStream & getInputParams(const std::string &inputName) const
Returns a MediaStream object describing the input specified by @inputName.
void emitSignal(Args... args)
Definition jami_signal.h:64
Simple macro to hide class' copy constructor and assignment operator.
#define NON_COPYABLE(ClassName)
Definition noncopyable.h:30