UltraGrid
UltraGrid Low-Latency High-Resolution Transmission System
Loading...
Searching...
No Matches
Filter_chain Class Reference

#include <filter_chain.hpp>

Collaboration diagram for Filter_chain:
Collaboration graph

Public Member Functions

 Filter_chain (const Filter_chain &)=delete
 
 Filter_chain (struct module *parent)
 
 ~Filter_chain ()
 
void clear ()
 
bool emplace_new (std::string_view cfg)
 
af_result_code filter (struct audio_frame **frame)
 
struct module * get_module ()
 
Filter_chain & operator= (const Filter_chain &)=delete
 
void push_back (struct audio_filter filter)
 
af_result_code reconfigure (int bps, int ch_count, int sample_rate)
 

Private Attributes

int bps = 0
 
int ch_count = 0
 
std::vector< struct audio_filter > filters
 
module_raii mod
 
int sample_rate = 0
 

Detailed Description

Definition at line 48 of file filter_chain.hpp.

Constructor & Destructor Documentation

◆ Filter_chain() [1/2]

Filter_chain::Filter_chain ( struct module * parent)

Definition at line 48 of file filter_chain.cpp.

48 :
module_raii mod
@ MODULE_CLASS_FILTER
Definition module.h:93
const char * parent
Definition settings.cpp:198

◆ Filter_chain() [2/2]

Filter_chain::Filter_chain ( const Filter_chain & )
delete

◆ ~Filter_chain()

Filter_chain::~Filter_chain ( )

Definition at line 51 of file filter_chain.cpp.

51 {
52 clear();
53}

References clear().

Here is the call graph for this function:

Member Function Documentation

◆ clear()

void Filter_chain::clear ( )

Definition at line 78 of file filter_chain.cpp.

78 {
79 for(auto& i : filters){
81 }
82}
void audio_filter_destroy(struct audio_filter *state)
std::vector< struct audio_filter > filters

References audio_filter_destroy(), and filters.

Referenced by ~Filter_chain().

Here is the call graph for this function:

◆ emplace_new()

bool Filter_chain::emplace_new ( std::string_view cfg)

Definition at line 59 of file filter_chain.cpp.

59 {
60 std::string filter_name(tokenize(cfg, ':'));
61 if(!cfg.empty() && cfg[0] == ':')
62 cfg.remove_prefix(1);
63 std::string config(cfg);
64
65 struct audio_filter afilter;
67 filter_name.c_str(),
68 config.c_str(),
69 &afilter) != AF_OK)
70 {
71 return false;
72 }
73
74 push_back(afilter);
75 return true;
76}
af_result_code audio_filter_init(struct module *parent, const char *name, const char *cfg, struct audio_filter *filter)
@ AF_OK
struct module * get_module()
void push_back(struct audio_filter filter)
std::string_view tokenize(std::string_view &str, char delim, char quot)
Tokenizer for string_view.

References AF_OK, audio_filter_init(), get_module(), push_back(), and tokenize().

Referenced by audio_init(), and filter().

Here is the call graph for this function:

◆ filter()

af_result_code Filter_chain::filter ( struct audio_frame ** frame)

Definition at line 84 of file filter_chain.cpp.

84 {
85 struct message *msg;
86 while ((msg = check_message(mod.get()))) {
87 std::string_view text = ((msg_universal *) msg)->text;
88
89 if(!emplace_new(text)) {
90 log_msg(LOG_LEVEL_ERROR, "Failed to init audio filter\n");
92 continue;
93 }
94
96 }
97
98 auto f = *frame;
99 af_result_code res = reconfigure(f->bps, f->ch_count, f->sample_rate);
100 if(res != AF_OK)
101 return AF_MISCONFIGURED;
102
103 for(auto& i : filters){
104 res = audio_filter(&i, frame);
105 if(res != AF_OK)
106 return res;
107 }
108
109 return res;
110}
struct video_frame * frame
af_result_code audio_filter(struct audio_filter *state, struct audio_frame **frame)
af_result_code
@ AF_MISCONFIGURED
bool emplace_new(std::string_view cfg)
af_result_code reconfigure(int bps, int ch_count, int sample_rate)
void log_msg(int level, const char *format,...)
Definition debug.cpp:130
#define LOG_LEVEL_ERROR
general errors
Definition debug.h:59
void free_message(struct message *msg, struct response *r)
struct response * new_response(int status, const char *text)
struct message * check_message(struct module *mod)
#define RESPONSE_OK
Definition messaging.h:57
#define RESPONSE_INT_SERV_ERR
Definition messaging.h:63
struct msghdr msg

References AF_MISCONFIGURED, AF_OK, audio_filter(), check_message(), emplace_new(), filters, frame, free_message(), LOG_LEVEL_ERROR, log_msg(), mod, msg, new_response(), reconfigure(), RESPONSE_INT_SERV_ERR, and RESPONSE_OK.

Referenced by audio_sender_thread(), and push_back().

Here is the call graph for this function:

◆ get_module()

struct module * Filter_chain::get_module ( )
inline

Definition at line 64 of file filter_chain.hpp.

64{ return mod.get(); }

References mod.

Referenced by emplace_new().

◆ operator=()

Filter_chain & Filter_chain::operator= ( const Filter_chain & )
delete

◆ push_back()

void Filter_chain::push_back ( struct audio_filter filter)

Definition at line 55 of file filter_chain.cpp.

55 {
56 filters.push_back(filter);
57}
af_result_code filter(struct audio_frame **frame)

References filter(), and filters.

Referenced by emplace_new().

Here is the call graph for this function:

◆ reconfigure()

af_result_code Filter_chain::reconfigure ( int bps,
int ch_count,
int sample_rate )

Definition at line 112 of file filter_chain.cpp.

112 {
113 if(this->bps == bps
114 && this->ch_count == ch_count
115 && this->sample_rate == sample_rate)
116 {
117 return AF_OK;
118 }
119
120 this->bps = bps;
121 this->ch_count = ch_count;
122 this->sample_rate = sample_rate;
123
124 af_result_code res = AF_OK;
125 for(auto& i : filters){
127 if(res != AF_OK)
128 return res;
129
131 }
132
133 return res;
134}
af_result_code audio_filter_configure(struct audio_filter *state, int bps, int ch_count, int sample_rate)
void audio_filter_get_configured_out(struct audio_filter *state, int *bps, int *ch_count, int *sample_rate)

References AF_OK, audio_filter_configure(), audio_filter_get_configured_out(), bps, ch_count, filters, and sample_rate.

Referenced by filter().

Here is the call graph for this function:

Member Data Documentation

◆ bps

int Filter_chain::bps = 0
private

Definition at line 67 of file filter_chain.hpp.

Referenced by reconfigure().

◆ ch_count

int Filter_chain::ch_count = 0
private

Definition at line 68 of file filter_chain.hpp.

Referenced by reconfigure().

◆ filters

std::vector<struct audio_filter> Filter_chain::filters
private

Definition at line 66 of file filter_chain.hpp.

Referenced by clear(), filter(), push_back(), and reconfigure().

◆ mod

module_raii Filter_chain::mod
private

Definition at line 71 of file filter_chain.hpp.

Referenced by filter(), and get_module().

◆ sample_rate

int Filter_chain::sample_rate = 0
private

Definition at line 69 of file filter_chain.hpp.

Referenced by reconfigure().


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