MCPcopy Create free account
hub / github.com/OpenHD/OpenHD / wt_update_statistics

Method wt_update_statistics

OpenHD/ohd_interface/src/wb_link.cpp:896–1112  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

894}
895
896void WBLink::wt_update_statistics() {
897 const auto elapsed_since_last =
898 std::chrono::steady_clock::now() - m_last_stats_recalculation;
899 if (elapsed_since_last < RECALCULATE_STATISTICS_INTERVAL) {
900 return;
901 }
902 m_last_stats_recalculation = std::chrono::steady_clock::now();
903 // telemetry is available on both air and ground
904 openhd::link_statistics::StatsAirGround stats{};
905 if (m_wb_tele_tx) {
906 const auto curr_tx_stats = m_wb_tele_tx->get_latest_stats();
907 const auto curr_rx_stats = m_wb_tele_rx->get_latest_stats();
908 stats.telemetry.curr_tx_bps =
909 curr_tx_stats.current_provided_bits_per_second;
910 stats.telemetry.curr_tx_pps =
911 curr_tx_stats.current_injected_packets_per_second;
912 stats.telemetry.curr_rx_bps = curr_rx_stats.curr_in_bits_per_second;
913 stats.telemetry.curr_rx_pps = curr_rx_stats.curr_in_packets_per_second;
914 }
915 if (m_profile.is_air) {
916 // video on air
917 for (int i = 0; i < m_wb_video_tx_list.size(); i++) {
918 auto& wb_tx = *m_wb_video_tx_list.at(i);
919 // auto& air_video=i==0 ? stats.air_video0 : stats.air_video1;
920 const auto curr_tx_stats = wb_tx.get_latest_stats();
921 // optimization - only send for active video links
922 if (curr_tx_stats.n_injected_packets == 0) continue;
923 openhd::link_statistics::Xmavlink_openhd_stats_wb_video_air_t air_video{};
924 openhd::link_statistics::
925 Xmavlink_openhd_stats_wb_video_air_fec_performance_t air_fec{};
926 air_video.link_index = i;
927 int rec_bitrate = 0;
928 auto cam_stats = openhd::LinkActionHandler::instance().get_cam_info(i);
929 rec_bitrate = cam_stats.encoding_bitrate_kbits;
930 air_video.curr_recommended_bitrate = rec_bitrate;
931 air_video.curr_measured_encoder_bitrate =
932 curr_tx_stats.current_provided_bits_per_second;
933 air_video.curr_injected_bitrate =
934 curr_tx_stats.current_injected_bits_per_second;
935 air_video.curr_injected_pps =
936 curr_tx_stats.current_injected_packets_per_second;
937 const int tx_dropped_frames =
938 i == 0 ? m_primary_total_dropped_frames.load()
939 : m_secondary_total_dropped_frames.load();
940 // const int tx_dropped_frames = curr_tx_stats.n_dropped_frames;
941 air_video.curr_dropped_frames = tx_dropped_frames;
942 air_video.dummy0 =
943 (int8_t)m_thermal_protection_level.load(std::memory_order_relaxed);
944 air_video.dummy1 = 776;
945 air_video.dummy2 = 673;
946 const auto curr_tx_fec_stats = wb_tx.get_latest_fec_stats();
947 air_fec.curr_fec_encode_time_avg_us =
948 openhd::util::get_micros(curr_tx_fec_stats.curr_fec_encode_time.avg);
949 air_fec.curr_fec_encode_time_min_us =
950 openhd::util::get_micros(curr_tx_fec_stats.curr_fec_encode_time.min);
951 air_fec.curr_fec_encode_time_max_us =
952 openhd::util::get_micros(curr_tx_fec_stats.curr_fec_encode_time.max);
953 air_fec.curr_fec_block_size_min =

Callers

nothing calls this directly

Calls 9

wifi_card_type_to_intFunction · 0.85
sizeMethod · 0.80
get_cam_infoMethod · 0.80
loadMethod · 0.80
push_backMethod · 0.80
update_link_statsMethod · 0.80
is_groundMethod · 0.80

Tested by

no test coverage detected