![]() |
UltraGrid
UltraGrid Low-Latency High-Resolution Transmission System
|
#include <array>#include <chrono>#include <cmath>#include <cstdlib>#include <execinfo.h>#include <getopt.h>#include <iostream>#include <list>#include <memory>#include <mutex>#include <pthread.h>#include <stdexcept>#include <string>#include <string.h>#include <thread>#include <tuple>#include <utility>#include "compat/misc.h"#include "control_socket.h"#include "cuda_wrapper.h"#include "debug.h"#include "host.h"#include "keyboard_control.h"#include "lib_common.h"#include "messaging.h"#include "module.h"#include "playback.h"#include "rtp/rtp.h"#include "rtsp/rtsp_utils.h"#include "tv.h"#include "ug_runtime_error.hpp"#include "utils/color_out.h"#include "utils/misc.h"#include "utils/nat.h"#include "utils/net.h"#include "utils/sdp.h"#include "utils/string_view_utils.hpp"#include "utils/thread.h"#include "utils/wait_obj.h"#include "utils/udp_holepunch.h"#include "video.h"#include "video_capture.h"#include "video_display.h"#include "video_compress.h"#include "export.h"#include "video_rxtx.hpp"#include "audio/audio.h"#include "audio/audio_capture.h"#include "audio/audio_playback.h"#include "audio/codec.h"#include "audio/utils.h"Go to the source code of this file.
Classes | |
| struct | state_uv |
| struct | ug_options |
Macros | |
| #define | EXIT(expr) |
| #define | MAX_CAPTURE_COUNT 17 |
| #define | MOD_NAME "[main] " |
| #define | OPT_AUDIO_CAPTURE_CHANNELS (('a' << 8) | 'c') |
| #define | OPT_AUDIO_DELAY (('A' << 8) | 'D') |
| #define | OPT_AUDIO_HOST (('A' << 8) | 'H') |
| #define | OPT_AUDIO_PROTOCOL (('A' << 8) | 'P') |
| #define | OPT_AUDIO_SCALE (('a' << 8) | 's') |
| #define | OPT_CONTROL_PORT (('C' << 8) | 'P') |
| #define | OPT_ECHO_CANCELLATION (('E' << 8) | 'C') |
| #define | OPT_MCAST_IF (('M' << 8) | 'I') |
| #define | OPT_PIX_FMTS (('P' << 8) | 'F') |
| #define | OPT_PIXFMT_CONV_POLICY (('P' << 8) | 'C') |
| #define | OPT_RTSP_SERVER (('R' << 8) | 'S') |
| #define | OPT_VIDEO_CODECS (('V' << 8) | 'C') |
| #define | OPT_VIDEO_PROTOCOL (('V' << 8) | 'P') |
| #define | OPT_WINDOW_TITLE (('W' << 8) | 'T') |
| #define | PORT_BASE 5004 |
Functions | |
| static int | adjust_params (struct ug_options *opt) |
| static void * | capture_thread (void *arg) |
| template<int N> | |
| static void | copy_sv_to_c_buf (char(&dest)[N], std::string_view sv) |
| int | main (int argc, char *argv[]) |
| static int | parse_audio_capture (struct ug_options *opt, char *optarg) |
| static bool | parse_control_port (char *optarg, struct ug_options *opt) |
| static int | parse_cuda_device (char *optarg) |
| static bool | parse_holepunch_conf (char *conf, struct Holepunch_config *punch_c) |
| static int | parse_options (int argc, char *argv[], struct ug_options *opt) |
| static int | parse_options_internal (int argc, char *argv[], struct ug_options *opt) |
| static bool | parse_port (char *optarg, struct ug_options *opt) |
| static bool | parse_protocol (int ch, char *optarg, struct ug_options *opt) |
| static void | print_fps (const char *prefix, steady_clock::time_point *t0, int *frames, double nominal_fps) |
| static void | print_help_item (const string &name, const vector< string > &help) |
| static void | signal_handler (int signum) |
| static void | usage (const char *exec_path, bool full=false) |
Variables | |
| static constexpr const char * | DEFAULT_AUDIO_CODEC = "PCM" |
| static constexpr const char * | DEFAULT_VIDEO_COMPRESSION = "none" |
| #define EXIT | ( | expr | ) |
Definition at line 1251 of file main.cpp.
Referenced by main().
| #define MOD_NAME "[main] " |
Definition at line 121 of file main.cpp.
Referenced by parse_options(), parse_port(), and parse_protocol().
| #define OPT_AUDIO_CAPTURE_CHANNELS (('a' << 8) | 'c') |
Definition at line 127 of file main.cpp.
Referenced by parse_options_internal().
| #define OPT_AUDIO_DELAY (('A' << 8) | 'D') |
Definition at line 128 of file main.cpp.
Referenced by parse_options_internal().
| #define OPT_AUDIO_HOST (('A' << 8) | 'H') |
Definition at line 129 of file main.cpp.
Referenced by parse_options_internal().
| #define OPT_AUDIO_PROTOCOL (('A' << 8) | 'P') |
Definition at line 130 of file main.cpp.
Referenced by parse_options_internal(), and parse_protocol().
| #define OPT_AUDIO_SCALE (('a' << 8) | 's') |
Definition at line 131 of file main.cpp.
Referenced by parse_options_internal().
| #define OPT_CONTROL_PORT (('C' << 8) | 'P') |
Definition at line 132 of file main.cpp.
Referenced by parse_options_internal().
| #define OPT_ECHO_CANCELLATION (('E' << 8) | 'C') |
Definition at line 133 of file main.cpp.
Referenced by parse_options_internal().
| #define OPT_MCAST_IF (('M' << 8) | 'I') |
Definition at line 134 of file main.cpp.
Referenced by parse_options_internal().
| #define OPT_PIX_FMTS (('P' << 8) | 'F') |
Definition at line 135 of file main.cpp.
Referenced by parse_options_internal().
| #define OPT_PIXFMT_CONV_POLICY (('P' << 8) | 'C') |
Definition at line 136 of file main.cpp.
Referenced by parse_options_internal().
Definition at line 137 of file main.cpp.
Referenced by parse_options_internal().
| #define OPT_VIDEO_CODECS (('V' << 8) | 'C') |
Definition at line 138 of file main.cpp.
Referenced by parse_options_internal().
| #define OPT_VIDEO_PROTOCOL (('V' << 8) | 'P') |
Definition at line 139 of file main.cpp.
Referenced by parse_options_internal(), and parse_protocol().
| #define OPT_WINDOW_TITLE (('W' << 8) | 'T') |
Definition at line 140 of file main.cpp.
Referenced by parse_options_internal().
|
static |
Definition at line 1034 of file main.cpp.
References ug_options::audio, audio_capture_channels, Holepunch_config::audio_rx_port, Holepunch_config::audio_tx_port, ug_options::bitrate, audio_options::codec_cfg, commandline_params, ug_options::common, DEFAULT_AUDIO_CODEC, DEFAULT_VIDEO_COMPRESSION, EXIT_FAIL_USAGE, common_opts::force_ip_version, HOLEPUNCH_ABI_VERSION, audio_options::host, Holepunch_config::host_addr, Holepunch_config::host_addr_len, IN6_BLACKHOLE_SERVER_MODE_STR, ug_options::is_client, is_host_loopback(), is_ipv6_supported(), ug_options::is_server, LIBRARY_CLASS_UNDEFINED, load_library(), LOG, LOG_LEVEL_ERROR, LOG_LEVEL_INFO, LOG_LEVEL_WARNING, log_msg(), min, MODE_RECEIVER, MODE_SENDER, common_opts::mtu, ug_options::nat_traverse_config, parse_holepunch_conf(), ug_options::port_base, audio_options::proto, RATE_DEFAULT, RATE_DYNAMIC, RATE_UNLIMITED, audio_options::recv_cfg, audio_options::recv_port, ug_options::requested_compression, ug_options::requested_display, ug_options::requested_receiver, RTP_MAX_MTU, audio_options::send_cfg, audio_options::send_port, set_audio_capture_format(), vidcap_params_allocate_next(), vidcap_params_get_driver(), ug_options::vidcap_params_head, vidcap_params_set_device(), ug_options::vidcap_params_tail, ug_options::video_protocol, Holepunch_config::video_rx_port, ug_options::video_rx_port, ug_options::video_rxtx_mode, Holepunch_config::video_tx_port, and ug_options::video_tx_port.
Referenced by main().

|
static |
This function captures video and possibly compresses it. It then delegates sending to another thread.
| [in] | arg | pointer to UltraGrid (root) module |
Definition at line 330 of file main.cpp.
References audio, AUDIO_FRAME_DISPOSE, audio_sdi_send(), video_frame::callbacks, video_frame_callbacks::dispose, video_frame_callbacks::dispose_udata, video_frame::fps, frame, print_fps(), set_thread_name(), state_uv::state_magic, uv, vidcap_get_fps_print_prefix(), vidcap_grab(), wait_obj_done(), wait_obj_init(), wait_obj_notify(), wait_obj_reset(), and wait_obj_wait().
Referenced by main().

|
static |
| int main | ( | int | argc, |
| char * | argv[] ) |
Definition at line 1253 of file main.cpp.
References AC_NONE, adjust_params(), audio_done(), audio_get_display_flags(), audio_init(), audio_join(), audio_register_aux_data(), audio_start(), capture_thread(), cleanup(), common_cleanup(), common_preinit(), control_done(), control_init(), control_start(), crash_signal_handler(), video_rxtx::create(), display_ctl_property(), display_done(), display_put_audio_frame(), display_reconfigure_audio(), display_run_mainloop(), EXIT, EXIT_FAIL_AUDIO, EXIT_FAIL_CAPTURE, EXIT_FAIL_CONTROL_SOCK, EXIT_FAIL_DISPLAY, exit_uv(), export_destroy(), export_init(), get_exit_status(), video_rxtx::get_long_name(), get_name_to_audio_codec(), get_time_in_ns(), hang_signal_handler(), init(), initialize_video_capture(), initialize_video_display(), LOG, LOG_LEVEL_DEBUG, LOG_LEVEL_ERROR, LOG_LEVEL_FATAL, log_msg(), MODE_RECEIVER, MODE_SENDER, params, parse_audio_codec_params(), parse_options(), print_capabilities(), print_version(), video_rxtx::receiver_thread(), control_state::root_module, rtsp_type_audio, rtsp_type_none, rtsp_type_video, sdp_set_properties(), show_help(), signal_handler(), start_nat_traverse(), start_time, stop_nat_traverse(), TBOLD, tok_in_argv(), uv, uv_argv, vidcap_done(), and vidcap_params_get_driver().

|
static |
Definition at line 550 of file main.cpp.
References audio, ug_options::audio, audio_capture_get_vidcap_flags(), audio_capture_print_help(), EXIT_FAIL_USAGE, LOG_LEVEL_ERROR, log_msg(), audio_options::send_cfg, vidcap_params_add_flags(), and ug_options::vidcap_params_tail.
Referenced by parse_options_internal().

|
static |
Definition at line 654 of file main.cpp.
References ug_options::connection_type, ug_options::control_port, usage(), and uv_argv.
Referenced by parse_options_internal().

|
static |
| <0 | return code whose absolute value will be returned from main() |
| 0 | success |
| 1 | device list was printed |
Definition at line 392 of file main.cpp.
References cuda_devices, cuda_devices_count, cuda_devices_explicit, cuda_wrapper_print_devices_info(), LOG, LOG_LEVEL_ERROR, and MAX_CUDA_DEVICES.
Referenced by parse_options_internal().

|
static |
Definition at line 423 of file main.cpp.
References Holepunch_config::bind_addr, Holepunch_config::client_name, Holepunch_config::coord_srv_addr, Holepunch_config::coord_srv_port, copy_sv_to_c_buf(), key, LOG_LEVEL_ERROR, log_msg(), parse_num(), Holepunch_config::room_name, Holepunch_config::stun_srv_addr, Holepunch_config::stun_srv_port, TBOLD, tokenize(), and val.
Referenced by adjust_params().

|
static |
| -error | error value that should be returned from main |
| 0 | success |
| 1 | success (help written) |
Definition at line 1011 of file main.cpp.
References invalid_arg_is_numeric(), LOG, LOG_LEVEL_ERROR, MOD_NAME, and parse_options_internal().
Referenced by main().

|
static |
| -error | error value that should be returned from main |
| 0 | success |
| 1 | success (help written) |
Definition at line 682 of file main.cpp.
References audio, ug_options::audio, audio_capture_channels, ug_options::audio_filter_cfg, audio_playback_help(), ug_options::bitrate, audio_options::channel_map, audio_options::codec_cfg, commandline_params, ug_options::common, ug_options::decoder_mode, ug_options::display_cfg, audio_options::echo_cancellation, common_opts::encryption, EXIT_FAIL_USAGE, ug_options::export_opts, audio_options::fec_cfg, audio_options::filter_cfg, common_opts::force_ip_version, get_video_mode_from_str(), audio_options::host, ug_options::is_client, ug_options::is_server, list_all_modules(), list_audio_codecs(), list_video_capture_devices(), list_video_display_devices(), LOG_LEVEL_ERROR, LOG_LEVEL_WARNING, log_msg(), common_opts::mcast_if, common_opts::mtu, ug_options::nat_traverse_config, OPT_AUDIO_CAPTURE_CHANNELS, OPT_AUDIO_DELAY, OPT_AUDIO_HOST, OPT_AUDIO_PROTOCOL, OPT_AUDIO_SCALE, OPT_CONTROL_PORT, OPT_ECHO_CANCELLATION, OPT_MCAST_IF, OPT_PIX_FMTS, OPT_PIXFMT_CONV_POLICY, OPT_RTSP_SERVER, OPT_VIDEO_CODECS, OPT_VIDEO_PROTOCOL, OPT_WINDOW_TITLE, parse_audio_capture(), parse_bitrate(), parse_control_port(), parse_cuda_device(), parse_params(), parse_port(), parse_protocol(), playback_set_device(), ug_options::postprocess, print_configuration(), print_pixel_formats(), print_video_codecs(), RATE_DEFAULT, audio_options::recv_cfg, ug_options::requested_capabilities, ug_options::requested_compression, ug_options::requested_display, ug_options::requested_receiver, ug_options::requested_video_fec, audio_options::scale, audio_options::send_cfg, set_audio_capture_format(), set_audio_delay(), set_pixfmt_conv_policy(), ug_options::should_export, snprintf_ch, common_opts::ttl, usage(), uv_argv, val, vidcap_params_allocate_next(), vidcap_params_get_capture_filter(), vidcap_params_set_capture_filter(), vidcap_params_set_device(), ug_options::vidcap_params_tail, ug_options::video_protocol, ug_options::video_protocol_opts, and VIDEO_UNKNOWN.
Referenced by parse_options().

|
static |
Definition at line 571 of file main.cpp.
References ug_options::audio, color_printf(), LOG, LOG_LEVEL_ERROR, MOD_NAME, ug_options::port_base, audio_options::recv_port, audio_options::send_port, TBOLD, usage(), uv_argv, ug_options::video_rx_port, and ug_options::video_tx_port.
Referenced by parse_options_internal().

|
static |
Definition at line 602 of file main.cpp.
References ug_options::audio, AUDIO_PROTOCOLS, video_rxtx::list(), LOG, LOG_LEVEL_ERROR, LOG_LEVEL_WARNING, MOD_NAME, OPT_AUDIO_PROTOCOL, OPT_VIDEO_PROTOCOL, audio_options::proto, audio_options::proto_cfg, SBOLD, TBOLD, ug_options::video_protocol, and ug_options::video_protocol_opts.
Referenced by parse_options_internal().

|
static |
Definition at line 293 of file main.cpp.
References count, LOG_LEVEL_INFO, log_msg(), T256_FG_SYM, T_ARCTIC_LIME, T_DARKER_ORANGE, TERM_BG_BLACK, TERM_BOLD, TERM_FG_BRIGHT_GREEN, and TERM_RESET.
Referenced by capture_thread().

|
static |
Definition at line 197 of file main.cpp.
References max, name, and TBOLD.
Referenced by usage().
|
static |
Definition at line 174 of file main.cpp.
References append_sig_desc(), exit_uv(), log_level, LOG_LEVEL_VERBOSE, strappend(), and write_all().
Referenced by main().

|
static |
Definition at line 217 of file main.cpp.
References DEFAULT_CONTROL_PORT, LOG_LEVEL_MAX, PORT_BASE, print_help_item(), SBOLD, and SRED.

|
staticconstexpr |
Definition at line 125 of file main.cpp.
Referenced by adjust_params().
|
staticconstexpr |
Definition at line 124 of file main.cpp.
Referenced by adjust_params().