#ifndef DEPTHGUIDE_IMAGE_STREAMER_IMPL_H #define DEPTHGUIDE_IMAGE_STREAMER_IMPL_H #include "module/image_streamer.h" #include "codec/encoder_nvenc.h" #include "core/async_queue.hpp" #include "network_v3/sender_tcp.h" #include "network_v3/sender_udp_fec.h" #include using boost::asio::post; struct image_streamer::impl { create_config conf; image_streamer *q_this = nullptr; io_context *ctx = nullptr; bool is_running = false; encoder_type chose_encoder_type = ENCODER_NVENC; std::unique_ptr enc_nvenc; // for all encoder bool enc_save_file = false; bool enc_save_length = false; bool enc_idr_requested = false; // for NvEnc cv::Size img_size; float enc_bitrate_mbps = 5.0f; // 5Mbps // for NvJpeg // TODO sender_type chose_sender_type = SENDER_UDP_FEC; std::shared_ptr sender; // for all sender uint16_t sender_listen_port = 5279; // make ImGui happy io_context *sender_ctx = nullptr; bool sender_enable_log = false; bool enable_aux_thread = true; // run sender in another thread std::unique_ptr aux_ctx; // for UDP and UDP (FEC) uint16_t sender_mtu = 1500; // for UDP (FEC) float sender_parity_rate = 0.2f; // for auxiliary thread using frame_queue_type = async_queue; std::shared_ptr frame_queue; std::unique_ptr aux_thread; obj_conn_type img_cb_conn; explicit impl(create_config _conf) { conf = _conf; ctx = conf.asio_ctx; } ~impl() { if (is_running) { stop(); } } void show_config(); void show(); void start(); void change_frame_rate(int fps); void stop(); void create_encoder(); void create_sender(); void image_callback(obj_name_type name); frame_info encode_image(); /* sender may run in the auxiliary thread, * because it may do complex processing in CPU */ void aux_thread_work(); }; #endif //DEPTHGUIDE_IMAGE_STREAMER_IMPL_H