Ring Daemon 16.0.0
Loading...
Searching...
No Matches
media_filter.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2004-2025 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 <map>
28#include <string>
29#include <vector>
30
31extern "C" {
32struct AVFilterContext;
33struct AVFilterGraph;
34struct AVFilterInOut;
35}
36
37namespace jami {
38
62{
63public:
66
70 std::string getFilterDesc() const;
71
76 int initialize(const std::string& filterDesc, const std::vector<MediaStream>& msps);
77
81 const MediaStream& getInputParams(const std::string& inputName) const;
82
89
97 int feedInput(AVFrame* frame, const std::string& inputName);
98
106 std::unique_ptr<MediaFrame> readOutput();
107
111 void flush();
112
113private:
115
119 int initOutputFilter(AVFilterInOut* out);
120
124 int initInputFilter(AVFilterInOut* in, const MediaStream& msp);
125
131 int reinitialize();
132
138 int fail(std::string_view msg, int err) const;
139
143 void clean();
144
148 AVFilterGraph* graph_ = nullptr;
149
155 AVFilterContext* output_ = nullptr;
156
162 std::vector<AVFilterContext*> inputs_;
163
169 std::vector<MediaStream> inputParams_;
170
174 std::string desc_ {};
175
179 bool initialized_ {false};
180};
181
182}; // 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.
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 ring_signal.h:64
Simple macro to hide class' copy constructor and assignment operator.
#define NON_COPYABLE(ClassName)
Definition noncopyable.h:30