Ring Daemon 16.0.0
Loading...
Searching...
No Matches
jami::MediaFilter Class Reference

Provides access to libavfilter. More...

#include <media_filter.h>

Collaboration diagram for jami::MediaFilter:
Collaboration graph

Public Member Functions

int feedInput (AVFrame *frame, const std::string &inputName)
 Give the specified source filter an input frame.
 
void flush ()
 Flush filter to indicate EOF.
 
std::string getFilterDesc () const
 Returns the current filter graph string.
 
const MediaStreamgetInputParams (const std::string &inputName) const
 Returns a MediaStream object describing the input specified by @inputName.
 
MediaStream getOutputParams () const
 Returns a MediaStream struct describing the frames that will be output.
 
int initialize (const std::string &filterDesc, const std::vector< MediaStream > &msps)
 Initializes the filter graph with one or more inputs and one output.
 
 MediaFilter ()
 
std::unique_ptr< MediaFramereadOutput ()
 Pull a frame from the filter graph.
 
 ~MediaFilter ()
 

Detailed Description

Provides access to libavfilter.

Can be used for filters with unlimited number of inputs. Multiple outputs are not supported. They add complexity for little gain.

For information on how to write a filter graph description, see: https://ffmpeg.org/ffmpeg-filters.html http://trac.ffmpeg.org/wiki/FilteringGuide

It is required to name each filter graph input. These names are used to feed the correct input. It is the same name that will be passed as second argument to feedInput(AVFrame*, std::string).

Examples:

  • "[in1] scale=320:240" Scales the input to 320x240.
  • "[in1] scale=iw/4:ih/4 [mid]; [in2] [mid] overlay=main_w-overlay_w-10:main_h-overlay_h-10" in1 will be scaled to 1/16th its size and placed over in2 in the bottom right corner. When feeding frames to the filter, you need to specify whether the frame is destined for in1 or in2.

Definition at line 61 of file media_filter.h.

Constructor & Destructor Documentation

◆ MediaFilter()

jami::MediaFilter::MediaFilter ( )

Definition at line 36 of file media_filter.cpp.

◆ ~MediaFilter()

jami::MediaFilter::~MediaFilter ( )

Definition at line 38 of file media_filter.cpp.

Member Function Documentation

◆ feedInput()

int jami::MediaFilter::feedInput ( AVFrame frame,
const std::string &  inputName 
)

Give the specified source filter an input frame.

Caller is responsible for freeing the frame.

NOTE Will fail if @inputName is not found in the graph.

Definition at line 155 of file media_filter.cpp.

References jami::emitSignal().

Here is the call graph for this function:

◆ flush()

void jami::MediaFilter::flush ( )

Flush filter to indicate EOF.

Definition at line 222 of file media_filter.cpp.

References jami::emitSignal(), jami::libav_utils::getError(), and JAMI_ERR.

Here is the call graph for this function:

◆ getFilterDesc()

std::string jami::MediaFilter::getFilterDesc ( ) const

Returns the current filter graph string.

Definition at line 44 of file media_filter.cpp.

◆ getInputParams()

const MediaStream & jami::MediaFilter::getInputParams ( const std::string &  inputName) const

Returns a MediaStream object describing the input specified by @inputName.

Definition at line 111 of file media_filter.cpp.

References jami::emitSignal().

Here is the call graph for this function:

◆ getOutputParams()

MediaStream jami::MediaFilter::getOutputParams ( ) const

Returns a MediaStream struct describing the frames that will be output.

When called in an invalid state, the returned format will be invalid (less than 0).

Definition at line 120 of file media_filter.cpp.

References jami::emitSignal().

Here is the call graph for this function:

◆ initialize()

int jami::MediaFilter::initialize ( const std::string &  filterDesc,
const std::vector< MediaStream > &  msps 
)

Initializes the filter graph with one or more inputs and one output.

Returns a negative code on error.

Definition at line 50 of file media_filter.cpp.

References jami::emitSignal(), and JAMI_DBG.

Here is the call graph for this function:

◆ readOutput()

std::unique_ptr< MediaFrame > jami::MediaFilter::readOutput ( )

Pull a frame from the filter graph.

Caller owns the frame reference.

Returns AVERROR(EAGAIN) if filter graph requires more input.

NOTE Frame reference belongs to the caller

Definition at line 188 of file media_filter.cpp.

References jami::emitSignal(), and JAMI_WARN.

Here is the call graph for this function:

The documentation for this class was generated from the following files: