UltraGrid
UltraGrid Low-Latency High-Resolution Transmission System
Loading...
Searching...
No Matches
video_rxtx Struct Referenceabstract

#include <video_rxtx.hpp>

Inheritance diagram for video_rxtx:
Inheritance graph
Collaboration diagram for video_rxtx:
Collaboration graph

Public Member Functions

virtual ~video_rxtx ()
 
virtual void join ()
 
void send (std::shared_ptr< struct video_frame >)
 
virtual void set_audio_spec (const struct audio_desc *desc, int audio_rx_port, int audio_tx_port, bool ipv6)
 
bool supports_receiving ()
 

Static Public Member Functions

static video_rxtx * create (std::string const &name, std::map< std::string, param_u > const &)
 
static const char * get_long_name (std::string const &short_name)
 
static void list (bool full)
 
static void * receiver_thread (void *arg)
 

Public Attributes

std::string m_port_id
 

Protected Member Functions

 video_rxtx (std::map< std::string, param_u > const &)
 
void check_sender_messages ()
 

Protected Attributes

struct common_opts m_common
 
unsigned long long int m_frames_sent
 
struct module m_receiver_mod
 
int m_rxtx_mode
 
struct module m_sender_mod
 
bool m_should_exit = false
 

Private Member Functions

virtual struct response * process_sender_message (struct msg_sender *)
 
virtual void send_frame (std::shared_ptr< video_frame >) noexcept=0
 
void * sender_loop ()
 
void start ()
 

Static Private Member Functions

static void * sender_thread (void *args)
 
static void should_exit (void *state)
 

Private Attributes

virtual void *(*)(void *arg) get_receiver_thread () noexcept
 
struct compress_state * m_compression = nullptr
 
bool m_joined
 
pthread_mutex_t m_lock
 
bool m_poisoned
 
pthread_t m_thread_id
 

Detailed Description

Definition at line 77 of file video_rxtx.hpp.

Constructor & Destructor Documentation

◆ ~video_rxtx()

video_rxtx::~video_rxtx ( )
virtual

Definition at line 115 of file video_rxtx.cpp.

115 {
116 join();
117 if (!m_poisoned && m_compression) {
118 send(NULL);
120 }
124}
void module_done(struct module *module_data)
Definition module.c:93
shared_ptr< video_frame > compress_pop(struct compress_state *proxy)
void compress_done(struct compress_state *proxy)
Video compression cleanup function.
struct compress_state * m_compression
struct module m_sender_mod
struct module m_receiver_mod
void send(std::shared_ptr< struct video_frame >)
virtual void join()

References compress_done(), compress_pop(), join(), m_compression, m_poisoned, m_receiver_mod, m_sender_mod, module_done(), and send().

Here is the call graph for this function:

◆ video_rxtx()

video_rxtx::video_rxtx ( std::map< std::string, param_u > const & )
protected

Definition at line 70 of file video_rxtx.cpp.

70 : m_port_id("default"),
71 m_rxtx_mode(params.at("rxtx_mode").i),
72 m_frames_sent(0ull),
73 m_common(*static_cast<struct common_opts const *>(params.at("common").cptr)),
74 m_thread_id(), m_poisoned(false), m_joined(true) {
75
79
83
84 try {
85 int ret = compress_init(&m_sender_mod, static_cast<const char *>(params.at("compression").ptr),
87 if(ret != 0) {
88 if(ret < 0) {
89 throw string("Error initializing compression.");
90 }
91 if(ret > 0) {
92 throw EXIT_SUCCESS;
93 }
94 }
95
96 pthread_mutex_init(&m_lock, NULL);
97
98 } catch (...) {
99 if (m_compression) {
101 }
102
105
106 throw;
107 }
108}
void module_init_default(struct module *module_data)
Definition module.c:48
void module_register(struct module *module_data, struct module *parent)
Definition module.c:82
@ MODULE_CLASS_RECEIVER
Definition module.h:88
@ MODULE_CLASS_SENDER
Definition module.h:87
int compress_init(struct module *parent, const char *config_string, struct compress_state **state)
This function initializes video compression.
struct module * parent
Definition host.h:171
enum module_class cls
Definition module.h:115
std::string m_port_id
pthread_t m_thread_id
unsigned long long int m_frames_sent
pthread_mutex_t m_lock
struct common_opts m_common

References module::cls, compress_done(), compress_init(), m_common, m_compression, m_lock, m_receiver_mod, m_sender_mod, MODULE_CLASS_RECEIVER, MODULE_CLASS_SENDER, module_done(), module_init_default(), module_register(), and common_opts::parent.

Here is the call graph for this function:

Member Function Documentation

◆ check_sender_messages()

void video_rxtx::check_sender_messages ( )
protected

Definition at line 169 of file video_rxtx.cpp.

169 {
170 // process external messages
171 struct message *msg_external;
172 while((msg_external = check_message(&m_sender_mod))) {
173 struct response *r = process_sender_message((struct msg_sender *) msg_external);
174 free_message(msg_external, r);
175 }
176}
void free_message(struct message *msg, struct response *r)
struct message * check_message(struct module *mod)
virtual struct response * process_sender_message(struct msg_sender *)

References check_message(), free_message(), m_sender_mod, and process_sender_message().

Referenced by rtp_video_rxtx::rtp_video_rxtx(), and sender_loop().

Here is the call graph for this function:

◆ create()

video_rxtx * video_rxtx::create ( std::string const & name,
std::map< std::string, param_u > const &  )
static

Definition at line 204 of file video_rxtx.cpp.

205{
206 auto vri = static_cast<const video_rxtx_info *>(load_library(proto.c_str(), LIBRARY_CLASS_VIDEO_RXTX, VIDEO_RXTX_ABI_VERSION));
207 if (!vri) {
208 return nullptr;
209 }
210 auto ret = vri->create(params);
211 if (!ret) {
212 return nullptr;
213 }
214 ret->start();
215 return ret;
216}
const void * load_library(const char *name, enum library_class cls, int abi_version)
@ LIBRARY_CLASS_VIDEO_RXTX
Definition lib_common.h:84
struct video_rxtx *(* create)(std::map< std::string, param_u > const &params)
#define VIDEO_RXTX_ABI_VERSION

References video_rxtx_info::create, LIBRARY_CLASS_VIDEO_RXTX, load_library(), start(), and VIDEO_RXTX_ABI_VERSION.

Referenced by recompress_output_port::recompress_output_port(), hd_rum_decompress_init(), main(), and vidcap_ug_input_init().

Here is the call graph for this function:

◆ get_long_name()

const char * video_rxtx::get_long_name ( std::string const & short_name)
static

Definition at line 146 of file video_rxtx.cpp.

146 {
147 auto vri = static_cast<const video_rxtx_info *>(load_library(short_name.c_str(), LIBRARY_CLASS_VIDEO_RXTX, VIDEO_RXTX_ABI_VERSION));
148 if (vri) {
149 return vri->long_name;
150 } else {
151 return "";
152 }
153}

References LIBRARY_CLASS_VIDEO_RXTX, load_library(), and VIDEO_RXTX_ABI_VERSION.

Referenced by main().

Here is the call graph for this function:

◆ join()

void video_rxtx::join ( )
virtual

If overriden, childern must call also video_rxtx::join()

Reimplemented in h264_rtp_video_rxtx, and ultragrid_rtp_video_rxtx.

Definition at line 136 of file video_rxtx.cpp.

136 {
137 if (m_joined) {
138 return;
139 }
140 send(NULL); // pass poisoned pill
141 pthread_join(m_thread_id, NULL);
143 m_joined = true;
144}
void unregister_should_exit_callback(struct module *mod, void(*callback)(void *), void *udata)
Definition host.cpp:1158
static void should_exit(void *state)

References m_common, m_joined, m_thread_id, common_opts::parent, send(), should_exit(), and unregister_should_exit_callback().

Referenced by ~video_rxtx(), h264_rtp_video_rxtx::join(), and ultragrid_rtp_video_rxtx::join().

Here is the call graph for this function:

◆ list()

void video_rxtx::list ( bool full)
static

Definition at line 218 of file video_rxtx.cpp.

219{
220 printf("Available TX protocols:\n");
222}
void list_modules(enum library_class cls, int abi_version, bool full)

References LIBRARY_CLASS_VIDEO_RXTX, list_modules(), and VIDEO_RXTX_ABI_VERSION.

Referenced by parse_protocol().

Here is the call graph for this function:

◆ process_sender_message()

virtual struct response * video_rxtx::process_sender_message ( struct msg_sender * )
inlineprivatevirtual

Reimplemented in rtp_video_rxtx.

Definition at line 115 of file video_rxtx.hpp.

115 {
116 return NULL;
117 }

Referenced by check_sender_messages().

◆ receiver_thread()

static void * video_rxtx::receiver_thread ( void * arg)
inlinestatic

Definition at line 82 of file video_rxtx.hpp.

82 {
83 video_rxtx *rxtx = static_cast<video_rxtx *>(arg);
84 return rxtx->get_receiver_thread()(arg);
85 }
virtual void *(*)(void *arg) get_receiver_thread() noexcept

References get_receiver_thread.

Referenced by hd_rum_decompress_init(), main(), and vidcap_ug_input_init().

◆ send()

void video_rxtx::send ( std::shared_ptr< struct video_frame > frame)

Definition at line 155 of file video_rxtx.cpp.

155 {
156 if (!frame && m_poisoned) {
157 return;
158 }
160 if (!frame) {
161 m_poisoned = true;
162 }
163}
struct video_frame * frame
void compress_frame(struct compress_state *proxy, shared_ptr< video_frame > frame)

References compress_frame(), frame, m_compression, and m_poisoned.

Referenced by ~video_rxtx(), and join().

Here is the call graph for this function:

◆ send_frame()

virtual void video_rxtx::send_frame ( std::shared_ptr< video_frame > )
privatepure virtualnoexcept

◆ sender_loop()

void * video_rxtx::sender_loop ( )
private

Definition at line 178 of file video_rxtx.cpp.

178 {
179 set_thread_name(__func__);
180 struct video_desc saved_vid_desc;
181
182 memset(&saved_vid_desc, 0, sizeof(saved_vid_desc));
183
184 while(1) {
186
187 shared_ptr<video_frame> tx_frame;
188
189 tx_frame = compress_pop(m_compression);
190 if (!tx_frame) {
191 break;
192 }
193
194 export_video(m_common.exporter, tx_frame.get());
195
196 send_frame(std::move(tx_frame));
197 m_frames_sent += 1;
198 }
199
201 return NULL;
202}
void export_video(struct exporter *s, struct video_frame *frame)
Definition export.c:356
struct exporter * exporter
Definition host.h:177
void check_sender_messages()
virtual void send_frame(std::shared_ptr< video_frame >) noexcept=0
void set_thread_name(const char *name)
Definition thread.c:72

References check_sender_messages(), compress_pop(), export_video(), common_opts::exporter, m_common, m_compression, m_frames_sent, send_frame(), and set_thread_name().

Referenced by sender_thread().

Here is the call graph for this function:

◆ sender_thread()

void * video_rxtx::sender_thread ( void * args)
staticprivate

Definition at line 165 of file video_rxtx.cpp.

165 {
166 return static_cast<video_rxtx *>(args)->sender_loop();
167}
void * sender_loop()

References sender_loop().

Referenced by start().

Here is the call graph for this function:

◆ set_audio_spec()

void video_rxtx::set_audio_spec ( const struct audio_desc * desc,
int audio_rx_port,
int audio_tx_port,
bool ipv6 )
virtual

Reimplemented in h264_rtp_video_rxtx, and h264_sdp_video_rxtx.

Definition at line 225 of file video_rxtx.cpp.

228{
229 MSG(INFO, "video RXTX not h264_rtp, not setting audio...\n");
230}
#define MSG(l, fmt,...)
Definition debug.h:96

References MSG.

Referenced by set_audio_spec_to_vrxtx().

◆ should_exit()

void video_rxtx::should_exit ( void * state)
staticprivate

Definition at line 110 of file video_rxtx.cpp.

110 {
111 video_rxtx *s = (video_rxtx *) state;
112 s->m_should_exit = true;
113}
void ** state
bool m_should_exit

References m_should_exit, and state.

Referenced by join(), and start().

◆ start()

void video_rxtx::start ( )
private

Definition at line 126 of file video_rxtx.cpp.

126 {
128 this);
129 if (pthread_create(&m_thread_id, NULL, video_rxtx::sender_thread,
130 (void *) this) != 0) {
131 throw string("Unable to create sender thread!\n");
132 }
133 m_joined = false;
134}
void register_should_exit_callback(struct module *mod, void(*callback)(void *), void *udata)
Definition host.cpp:1144
static void * sender_thread(void *args)

References m_common, m_joined, m_thread_id, common_opts::parent, register_should_exit_callback(), sender_thread(), and should_exit().

Referenced by create().

Here is the call graph for this function:

◆ supports_receiving()

bool video_rxtx::supports_receiving ( )
inline

Definition at line 86 of file video_rxtx.hpp.

86 {
87 return get_receiver_thread() != NULL;
88 }

References get_receiver_thread.

Member Data Documentation

◆ get_receiver_thread

virtual void *(*)(void *arg) video_rxtx::get_receiver_thread() noexcept
private

Definition at line 112 of file video_rxtx.hpp.

Referenced by receiver_thread(), and supports_receiving().

◆ m_common

◆ m_compression

struct compress_state* video_rxtx::m_compression = nullptr
private

Definition at line 120 of file video_rxtx.hpp.

Referenced by video_rxtx(), ~video_rxtx(), send(), and sender_loop().

◆ m_frames_sent

unsigned long long int video_rxtx::m_frames_sent
protected

Definition at line 105 of file video_rxtx.hpp.

Referenced by rtp_video_rxtx::process_sender_message(), and sender_loop().

◆ m_joined

bool video_rxtx::m_joined
private

Definition at line 124 of file video_rxtx.hpp.

Referenced by join(), and start().

◆ m_lock

pthread_mutex_t video_rxtx::m_lock
private

Definition at line 121 of file video_rxtx.hpp.

Referenced by video_rxtx().

◆ m_poisoned

bool video_rxtx::m_poisoned
private

Definition at line 124 of file video_rxtx.hpp.

Referenced by ~video_rxtx(), and send().

◆ m_port_id

std::string video_rxtx::m_port_id

Definition at line 98 of file video_rxtx.hpp.

◆ m_receiver_mod

struct module video_rxtx::m_receiver_mod
protected

◆ m_rxtx_mode

◆ m_sender_mod

struct module video_rxtx::m_sender_mod
protected

◆ m_should_exit

◆ m_thread_id

pthread_t video_rxtx::m_thread_id
private

Definition at line 123 of file video_rxtx.hpp.

Referenced by join(), and start().


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