diff --git a/src/transmit.cpp b/src/transmit.cpp index 147737045..4c7a526da 100644 --- a/src/transmit.cpp +++ b/src/transmit.cpp @@ -1071,3 +1071,10 @@ void tx_send_h264(struct tx *tx, struct video_frame *frame, frame->color_spec, frame->fps, frame->interlacing, 0, 0); } + +int tx_get_buffer_id(struct tx *tx) +{ + return tx->buffer; + +} + diff --git a/src/transmit.h b/src/transmit.h index a78bfed56..fe4ada0d0 100644 --- a/src/transmit.h +++ b/src/transmit.h @@ -81,6 +81,8 @@ struct tx *tx_init_h264(struct module *parent, unsigned mtu, enum tx_media_type const char *fec, const char *encryption, long packet_rate); void tx_send_h264(struct tx *tx_session, struct video_frame *frame, struct rtp *rtp_session); +int tx_get_buffer_id(struct tx *tx_session); + #ifdef __cplusplus } #endif diff --git a/src/video_rxtx/ultragrid_rtp.cpp b/src/video_rxtx/ultragrid_rtp.cpp index 3320005dd..4ee649653 100644 --- a/src/video_rxtx/ultragrid_rtp.cpp +++ b/src/video_rxtx/ultragrid_rtp.cpp @@ -73,12 +73,13 @@ #include "utils/worker.h" #include +#include #include using namespace std; ultragrid_rtp_video_rxtx::ultragrid_rtp_video_rxtx(const map ¶ms) : - rtp_video_rxtx(params), m_stat_nanoperframeactual((struct module *) params.at("parent").ptr, "nanoperframeactual"), m_t0(std::chrono::steady_clock::now()), m_duration(std::chrono::nanoseconds::zero()), m_frames(0) + rtp_video_rxtx(params), m_stat_nanoperframeactual((struct module *) params.at("parent").ptr, "nanoperframeactual"), m_t0(std::chrono::steady_clock::now()), m_duration(std::chrono::nanoseconds::zero()), m_frames(0), m_send_bytes_total(0) { if ((params.at("postprocess").ptr != NULL && strstr((const char *) params.at("postprocess").ptr, "help") != NULL)) { @@ -93,6 +94,14 @@ ultragrid_rtp_video_rxtx::ultragrid_rtp_video_rxtx(const map &p m_display_device = (struct display *) params.at("display_device").ptr; m_requested_encryption = (const char *) params.at("encryption").ptr; m_async_sending = false; + + m_control = (struct control_state *) get_module(get_root_module(static_cast(params.at("parent").ptr)), "control"); + uint32_t id; + if (get_port_id(get_root_module(static_cast(params.at("parent").ptr)), &id)) { + m_port_id = id; + } else { + m_port_id = -1; + } } ultragrid_rtp_video_rxtx::~ultragrid_rtp_video_rxtx() @@ -183,6 +192,21 @@ void ultragrid_rtp_video_rxtx::send_frame_async(shared_ptr tx_frame m_async_sending_cv.notify_all(); std::chrono::steady_clock::time_point t1 = std::chrono::steady_clock::now(); + + int buffer_id = tx_get_buffer_id(m_tx); + int dropped_frames = 0; + auto nanoseconds = std::chrono::duration_cast(t1 - t0).count(); + int send_bytes = tx_frame->tiles[0].data_len; + m_send_bytes_total += send_bytes; + + ostringstream oss; + oss << "bufferId " << buffer_id << + " droppedFrames " << dropped_frames << + " nanoperframeactual " << nanoseconds << + " sendBytes " << send_bytes << + " sendBytesTotal " << m_send_bytes_total; + control_report_stats(m_control, oss.str(), m_port_id); + m_frames += 1; m_duration += std::chrono::duration_cast(t1 - t0); auto seconds = diff --git a/src/video_rxtx/ultragrid_rtp.h b/src/video_rxtx/ultragrid_rtp.h index 2cd2e3b61..8003024ca 100644 --- a/src/video_rxtx/ultragrid_rtp.h +++ b/src/video_rxtx/ultragrid_rtp.h @@ -47,6 +47,8 @@ #include #include +struct control_state; + class ultragrid_rtp_video_rxtx : public rtp_video_rxtx { public: ultragrid_rtp_video_rxtx(std::map const &); @@ -86,6 +88,10 @@ private: std::chrono::steady_clock::time_point m_t0; std::chrono::nanoseconds m_duration; int m_frames; + + long long int m_send_bytes_total; + struct control_state *m_control; + int32_t m_port_id; }; video_rxtx *create_video_rxtx_ultragrid_rtp(std::map const ¶ms);