![]() |
UltraGrid
UltraGrid Low-Latency High-Resolution Transmission System
|
#include "messaging.h"#include <condition_variable>#include <iostream>#include <memory>#include <mutex>#include <unordered_map>#include "debug.h"#include "module.h"#include "utils/list.h"#include "utils/lock_guard.h"
Go to the source code of this file.
Classes | |
| struct | response |
Macros | |
| #define | MAX_MESSAGES 100 |
| #define | MAX_MESSAGES_FOR_NOT_EXISTING_RECV 10 |
| #define | MOD_NAME "[messaging] " |
Functions | |
| struct message * | check_message (struct module *mod) |
| void | free_message (struct message *msg, struct response *r) |
| void | free_message_for_child (void *m, struct response *r) |
| void | free_response (struct response *r) |
| void | module_check_undelivered_messages (struct module *node) |
| Sends message with waiting for response. | |
| void | module_store_message (struct module *node, struct message *m) |
| struct message * | new_message (size_t len) |
| struct response * | new_response (int status, const char *text) |
| int | response_get_status (struct response *r) |
| const char * | response_get_text (struct response *r) |
| const char * | response_status_to_text (int status) |
| struct response * | send_message (struct module *root, const char *const_path, struct message *msg) |
| Sends message without waiting for response. | |
| static struct response * | send_message_common (struct module *root, const char *const_path, struct message *msg, bool sync, int timeout_ms, int flags) |
| struct response * | send_message_sync (struct module *root, const char *const_path, struct message *msg, int timeout_ms, int flags) |
| Sends message without waiting for response. | |
| struct response * | send_message_to_receiver (struct module *receiver, struct message *msg) |
Communication infrastructure for passing messages between individual UltraGrid modules.
Definition in file messaging.cpp.
| #define MAX_MESSAGES 100 |
Definition at line 59 of file messaging.cpp.
Referenced by send_message_common().
| #define MAX_MESSAGES_FOR_NOT_EXISTING_RECV 10 |
Definition at line 60 of file messaging.cpp.
Referenced by send_message_common().
| #define MOD_NAME "[messaging] " |
Definition at line 61 of file messaging.cpp.
Referenced by send_message_common().
Definition at line 394 of file messaging.cpp.
References module::msg_queue, module::msg_queue_lock, simple_linked_list_pop(), and simple_linked_list_size().
Referenced by audio_decoder_process_message(), audio_done(), audio_receiver_thread(), audio_sender_thread(), capture_filter(), video_rxtx::check_sender_messages(), compress_frame(), decoder_process_message(), display_conference_worker(), display_get_frame(), display_sdl2_run(), display_sdl_run(), fec_check_messages(), filter(), filter(), filter(), Filter_chain::filter(), gl_process_frames(), module_done(), keyboard_control::impl::msg_received(), process_messages(), process_messages(), ultragrid_rtp_video_rxtx::receiver_process_messages(), vidcap_file_process_messages(), vidcap_import_new_message(), vidcap_switcher_grab(), and writer().

Frees message
Additionally, it enforces user to pass response to be sent to sender.
Definition at line 318 of file messaging.cpp.
References free_response().
Referenced by audio_decoder_process_message(), audio_done(), audio_receiver_thread(), audio_sender_thread(), capture_filter(), video_rxtx::check_sender_messages(), compress_process_message(), decoder_process_message(), display_conference_worker(), display_get_frame(), display_sdl2_run(), display_sdl_run(), fec_check_messages(), filter(), filter(), filter(), Filter_chain::filter(), free_message_for_child(), gl_process_frames(), module_done(), keyboard_control::impl::msg_received(), process_audio_message(), process_messages(), process_messages(), ultragrid_rtp_video_rxtx::receiver_process_messages(), send_message_common(), set_fec(), vidcap_file_process_messages(), vidcap_import_new_message(), vidcap_switcher_grab(), and writer().

| void free_message_for_child | ( | void * | m, |
| struct response * | r ) |
Definition at line 99 of file messaging.cpp.
References free_message().
Referenced by module_done(), and send_message_common().

| void free_response | ( | struct response * | r | ) |
Definition at line 361 of file messaging.cpp.
Referenced by compress_process_message(), BasicRTSPOnlySubsession::deleteStream(), keyboard_control::impl::exec_external_commands(), free_message(), keyboard_control::impl::info(), keycontrol_register_key(), keycontrol_send_key(), module_check_undelivered_messages(), process_msg(), reconfigure_decoder(), keyboard_control::impl::run(), sdp_send_change_address_message(), h264_sdp_video_rxtx::send_frame(), send_response(), set_fec(), BasicRTSPOnlySubsession::startStream(), Participant_manager::tick(), tx_update(), AudioDriftFixer::update(), and vidcap_switcher_register_keyboard_ctl().
| void module_check_undelivered_messages | ( | struct module * | node | ) |
Sends message with waiting for response.
Stores message to module message box. If new_message callback is present it is called. Otherwise it may take a long time until module reads the message therefore setting timeout_ms is strongly recommended to prevent freeze (unless knowing that module implements synchronnous message processing via module::new_message callback).
If not set otherwise, when receiver doesn't exist, message is stored by nearest existing parent until it starts (this may be disabled with flag SEND_MESSAGE_FLAG_NO_STORE).
| sync | wait for response timeout_ms milliseconds, if false, 202 is immediately returned (or 404 if NO_STORE flag is set and receiver doesn't exist) |
| timeout_ms | if sync==true number of ms to wait for response (-1 means infinitely), ignored if sync is false, @params flags bit mask of SEND_MESSAGE_FLAG_NO_STORE and SEND_MESSAGE_FLAG_QUIET |
Definition at line 265 of file messaging.cpp.
References free_response(), get_matching_child(), module::lock, module::msg_queue_children, send_message_to_receiver(), simple_linked_list_it_init(), simple_linked_list_it_next(), and simple_linked_list_remove().
Referenced by module_register().

Definition at line 283 of file messaging.cpp.
References module::msg_queue, module::msg_queue_lock, and simple_linked_list_append().

| struct message * new_message | ( | size_t | len | ) |
Definition at line 303 of file messaging.cpp.
References len.
| struct response * new_response | ( | int | status, |
| const char * | text ) |
Creates new response
| status | status |
| text | optional text contained in message |
Definition at line 349 of file messaging.cpp.
References response::status, and response::text.
Referenced by audio_decoder_process_message(), audio_receiver_process_message(), audio_sender_process_message(), change_replica_type(), compress_process_message(), decoder_process_message(), display_conference_worker(), display_sdl2_run(), display_sdl_run(), fec_check_messages(), filter(), filter(), Filter_chain::filter(), gl_process_frames(), keyboard_control::impl::msg_received(), process_audio_message(), process_message(), process_message(), process_message(), process_messages(), process_messages(), process_msg(), rtp_video_rxtx::process_sender_message(), ultragrid_rtp_video_rxtx::receiver_process_messages(), send_message_common(), send_message_to_receiver(), vidcap_file_process_messages(), vidcap_import_new_message(), vidcap_switcher_grab(), and writer().
| int response_get_status | ( | struct response * | r | ) |
Definition at line 365 of file messaging.cpp.
References response::status.
Referenced by keyboard_control::impl::exec_external_commands(), keyboard_control::impl::info(), keycontrol_register_key(), keycontrol_send_key(), sdp_send_change_address_message(), send_response(), Participant_manager::tick(), AudioDriftFixer::update(), and vidcap_switcher_register_keyboard_ctl().
| const char * response_get_text | ( | struct response * | r | ) |
Definition at line 369 of file messaging.cpp.
References response::text.
Referenced by keyboard_control::impl::info(), send_response(), and AudioDriftFixer::update().
| const char * response_status_to_text | ( | int | status | ) |
Definition at line 373 of file messaging.cpp.
References mapping, RESPONSE_ACCEPTED, RESPONSE_BAD_REQUEST, RESPONSE_INT_SERV_ERR, RESPONSE_NO_CONTENT, RESPONSE_NOT_FOUND, RESPONSE_NOT_IMPL, RESPONSE_OK, and RESPONSE_REQ_TIMEOUT.
Referenced by send_response().
| struct response * send_message | ( | struct module * | root, |
| const char * | const_path, | ||
| struct message * | msg ) |
Sends message without waiting for response.
Stores message to module message box. If new_message callback is present it is called. Otherwise it may take a long time until module reads the message therefore setting timeout_ms is strongly recommended to prevent freeze (unless knowing that module implements synchronnous message processing via module::new_message callback).
If not set otherwise, when receiver doesn't exist, message is stored by nearest existing parent until it starts (this may be disabled with flag SEND_MESSAGE_FLAG_NO_STORE).
| sync | wait for response timeout_ms milliseconds, if false, 202 is immediately returned (or 404 if NO_STORE flag is set and receiver doesn't exist) |
| timeout_ms | if sync==true number of ms to wait for response (-1 means infinitely), ignored if sync is false, @params flags bit mask of SEND_MESSAGE_FLAG_NO_STORE and SEND_MESSAGE_FLAG_QUIET |
Definition at line 249 of file messaging.cpp.
References send_message_common().
Referenced by BasicRTSPOnlySubsession::deleteStream(), process_audio_message(), process_msg(), keyboard_control::impl::run(), sdp_send_change_address_message(), h264_sdp_video_rxtx::send_frame(), and BasicRTSPOnlySubsession::startStream().

|
static |
Stores message to module message box. If new_message callback is present it is called. Otherwise it may take a long time until module reads the message therefore setting timeout_ms is strongly recommended to prevent freeze (unless knowing that module implements synchronnous message processing via module::new_message callback).
If not set otherwise, when receiver doesn't exist, message is stored by nearest existing parent until it starts (this may be disabled with flag SEND_MESSAGE_FLAG_NO_STORE).
| sync | wait for response timeout_ms milliseconds, if false, 202 is immediately returned (or 404 if NO_STORE flag is set and receiver doesn't exist) |
| timeout_ms | if sync==true number of ms to wait for response (-1 means infinitely), ignored if sync is false, @params flags bit mask of SEND_MESSAGE_FLAG_NO_STORE and SEND_MESSAGE_FLAG_QUIET |
Definition at line 121 of file messaging.cpp.
References flags, free_message(), free_message_for_child(), get_matching_child(), module::lock, LOG_LEVEL_WARNING, log_msg(), MAX_MESSAGES, MAX_MESSAGES_FOR_NOT_EXISTING_RECV, MOD_NAME, msg, module::msg_queue, module::msg_queue_children, module::msg_queue_lock, module::new_message, new_response(), RESPONSE_ACCEPTED, RESPONSE_INT_SERV_ERR, RESPONSE_NOT_FOUND, SEND_MESSAGE_FLAG_NO_STORE, SEND_MESSAGE_FLAG_QUIET, simple_linked_list_append(), simple_linked_list_pop(), and simple_linked_list_size().
Referenced by send_message(), and send_message_sync().

| struct response * send_message_sync | ( | struct module * | root, |
| const char * | const_path, | ||
| struct message * | msg, | ||
| int | timeout_ms, | ||
| int | flags ) |
Sends message without waiting for response.
Stores message to module message box. If new_message callback is present it is called. Otherwise it may take a long time until module reads the message therefore setting timeout_ms is strongly recommended to prevent freeze (unless knowing that module implements synchronnous message processing via module::new_message callback).
If not set otherwise, when receiver doesn't exist, message is stored by nearest existing parent until it starts (this may be disabled with flag SEND_MESSAGE_FLAG_NO_STORE).
| sync | wait for response timeout_ms milliseconds, if false, 202 is immediately returned (or 404 if NO_STORE flag is set and receiver doesn't exist) |
| timeout_ms | if sync==true number of ms to wait for response (-1 means infinitely), ignored if sync is false, @params flags bit mask of SEND_MESSAGE_FLAG_NO_STORE and SEND_MESSAGE_FLAG_QUIET |
Definition at line 257 of file messaging.cpp.
References flags, and send_message_common().
Referenced by keyboard_control::impl::exec_external_commands(), keyboard_control::impl::info(), keycontrol_register_key(), keycontrol_send_key(), AudioDriftFixer::update(), and vidcap_switcher_register_keyboard_ctl().

Definition at line 289 of file messaging.cpp.
References module::lock, module::msg_queue, module::msg_queue_lock, module::new_message, new_response(), RESPONSE_ACCEPTED, and simple_linked_list_append().
Referenced by compress_process_message(), module_check_undelivered_messages(), reconfigure_decoder(), set_fec(), Participant_manager::tick(), and tx_update().
