|
52 | 52 | // IWYU pragma: no_include <sys/time.h> # via tv.h |
53 | 53 | // IWYU pragma: no_include <iterator> # std::pair is rather in utility |
54 | 54 |
|
| 55 | +#ifdef _WIN32 |
| 56 | +#include <basetsd.h> // for SSIZE_T |
| 57 | +typedef SSIZE_T ssize_t; |
| 58 | +#else |
| 59 | +#include <sys/types.h> // for ssize_t |
| 60 | +#endif |
55 | 61 |
|
56 | 62 | #include "control_socket.h" |
57 | 63 | #include "debug.h" |
|
76 | 82 | #include "video_rxtx/rtp.hpp" // for rtp_video_rxtx |
77 | 83 | #include "ug_runtime_error.hpp" |
78 | 84 | #include "utils/worker.h" |
79 | | -#include "video_rxtx/rtp.hpp" |
80 | 85 |
|
81 | 86 | constexpr uint32_t MAGIC = to_fourcc('V', 'X', 'u', 'r'); |
82 | 87 |
|
83 | 88 | using namespace std; |
84 | 89 | using ultragrid::pthread_mutex_guard; |
85 | 90 |
|
| 91 | +class ultragrid_rtp_video_rxtx { |
| 92 | +public: |
| 93 | + const uint32_t magic; |
| 94 | + ultragrid_rtp_video_rxtx(const struct vrxtx_params *params, |
| 95 | + const struct common_opts *common); |
| 96 | + virtual ~ultragrid_rtp_video_rxtx(); |
| 97 | + virtual void send_frame(std::shared_ptr<video_frame>) noexcept; |
| 98 | + void join(); |
| 99 | + static void *receiver_thread(void *arg); |
| 100 | + |
| 101 | + // transcoder functions |
| 102 | + friend ssize_t hd_rum_decompress_write(void *state, void *buf, size_t count); |
| 103 | +private: |
| 104 | + struct rtp_rxtx_common *m_rtp_common; |
| 105 | + void *receiver_loop(); |
| 106 | + static void *send_frame_async_callback(void *arg); |
| 107 | + virtual void send_frame_async(std::shared_ptr<video_frame>); |
| 108 | + |
| 109 | + void receiver_process_messages(); |
| 110 | + void remove_display_from_decoders(); |
| 111 | + struct vcodec_state *new_video_decoder(struct display *d); |
| 112 | + static void destroy_video_decoder(void *state); |
| 113 | + |
| 114 | + enum video_mode m_decoder_mode; |
| 115 | + struct display *m_display_device; |
| 116 | + std::list<struct display *> m_display_copies; ///< some displays can be "forked" |
| 117 | + ///< and used simultaneously from |
| 118 | + ///< multiple decoders, here are |
| 119 | + ///< saved forked states |
| 120 | + |
| 121 | + /** |
| 122 | + * This variables serve as a notification when asynchronous sending exits |
| 123 | + * @{ */ |
| 124 | + bool m_async_sending = false; |
| 125 | + std::condition_variable m_async_sending_cv; |
| 126 | + std::mutex m_async_sending_lock; |
| 127 | + /// @} |
| 128 | + |
| 129 | + long long int m_send_bytes_total; |
| 130 | + struct control_state *m_control; |
| 131 | + struct module *m_parent; |
| 132 | + std::string m_encryption; |
| 133 | + |
| 134 | + time_ns_t m_start_time; |
| 135 | + long long int m_nano_per_frame_actual_cumul = 0; |
| 136 | + long long int m_nano_per_frame_expected_cumul = 0; |
| 137 | + long long int m_compress_millis_cumul = 0; |
| 138 | + |
| 139 | + struct module *m_receiver_mod{}; |
| 140 | + |
| 141 | + bool m_should_exit = false; |
| 142 | + static void should_exit(void *state); |
| 143 | + |
| 144 | + friend uint32_t ultragrid_rtp_get_ssrc(void *state); |
| 145 | + friend int ultragrid_rtp_send_raw_rtp_data(void *state, char *buf, |
| 146 | + int count); |
| 147 | +}; |
| 148 | + |
86 | 149 | ultragrid_rtp_video_rxtx::ultragrid_rtp_video_rxtx( |
87 | 150 | const struct vrxtx_params *params, const struct common_opts *common) : |
88 | 151 | magic(MAGIC), |
|
0 commit comments