diff --git a/app/telemetry/models/camerastreammodel.cpp b/app/telemetry/models/camerastreammodel.cpp index e85af8de0..6c1101612 100644 --- a/app/telemetry/models/camerastreammodel.cpp +++ b/app/telemetry/models/camerastreammodel.cpp @@ -34,6 +34,50 @@ CameraStreamModel &CameraStreamModel::instance(int cam_index) assert(false); } +QString CameraStreamModel::camera_type_to_string(int camera_type) +{ + if(camera_type<=0)return "Unknown"; + if(camera_type==1)return "DUMMY"; + if(camera_type==2)return "RPI_CSI_MMAL"; + if(camera_type==3)return "RPI_CSI_VEYE_V4l2"; + if(camera_type==4)return "RPI_CSI_LIBCAMERA"; + if(camera_type==5)return "JETSON_CSI"; + if(camera_type==6)return "ROCKCHIP_CSI"; + if(camera_type==7)return "ALLWINNER_CSI"; + if(camera_type==8)return "UVC (USB)"; + if(camera_type==9)return "UVC_H264"; + if(camera_type==10)return "IP"; + if(camera_type==11)return "ROCK_HDMI"; + if(camera_type==12)return "CUSTOM UNMANAGED"; + return "ERROR"; +} + +QString CameraStreamModel::camera_status_to_string(int camera_status) +{ + if(camera_status<0)return "N/A"; + if(camera_status==0)return "X"; + if(camera_status==1)return "streaming"; + if(camera_status==2)return "restarting"; + return "ERROR"; +} + +QString CameraStreamModel::camera_codec_to_string(int camera_codec) +{ + if(camera_codec<0)return "ERROR"; + if(camera_codec==0)return "h264"; + if(camera_codec==1)return "h265"; + if(camera_codec==2)return "mjpeg"; + return "ERROR"; +} + +QString CameraStreamModel::camera_recording_mode_to_string(int recording_mode) +{ + if(recording_mode<0)return "n/a"; + if(recording_mode==0)return "not active"; + if(recording_mode==1)return "active"; + return "error"; +} + void CameraStreamModel::update_mavlink_openhd_stats_wb_video_air(const mavlink_openhd_stats_wb_video_air_t &msg) { const auto curr_recommended_bitrate_kbits=msg.curr_recommended_bitrate; @@ -88,6 +132,7 @@ void CameraStreamModel::update_mavlink_openhd_camera_status_air(const mavlink_op set_curr_curr_keyframe_interval(msg.encoding_keyframe_interval); set_air_recording_active(msg.air_recording_active); set_camera_type(msg.cam_type); + set_encoding_codec(msg.encoding_format); { std::stringstream ss; ss<<(int)msg.stream_w<<"x"<<(int)msg.stream_h<<"@"<=std::chrono::seconds(3)){ - m_last_hud_message_camera_status=std::chrono::steady_clock::now(); - std::stringstream log; - log<<(secondary ? "CAM2" : "CAM1"); - log<<" is restarting, please wait"; - HUDLogMessagesModel::instance().add_message_info(log.str().c_str()); - } - } } void CameraStreamModel::update_mavlink_openhd_stats_wb_video_air_fec_performance(const mavlink_openhd_stats_wb_video_air_fec_performance_t &msg) diff --git a/app/telemetry/models/camerastreammodel.h b/app/telemetry/models/camerastreammodel.h index 7531f207e..7263e5ca1 100644 --- a/app/telemetry/models/camerastreammodel.h +++ b/app/telemetry/models/camerastreammodel.h @@ -54,7 +54,8 @@ class CameraStreamModel : public QObject L_RO_PROP(QString,air_tx_packets_per_second_and_bits_per_second,set_air_tx_packets_per_second_and_bits_per_second,"N/A") // UI might change slightly depending on the camera type L_RO_PROP(int,camera_type,set_camera_type,-1) - L_RO_PROP(int,camera_status,set_camera_status,-1) + L_RO_PROP(int,camera_status,set_camera_status,-1) + L_RO_PROP(int,encoding_codec,set_encoding_codec,-1) // // These are generated by the OpenHD ground unit // @@ -64,6 +65,11 @@ class CameraStreamModel : public QObject L_RO_PROP(qint64,count_blocks_recovered,set_count_blocks_recovered,-1) L_RO_PROP(qint64,count_fragments_recovered,set_count_fragments_recovered,-1) L_RO_PROP(QString,curr_fec_decode_time_avg_min_max,set_curr_fec_decode_time_avg_min_max,"avg na, min na, max na") +public: + Q_INVOKABLE QString camera_type_to_string(int camera_type); + Q_INVOKABLE QString camera_status_to_string(int camera_status); + Q_INVOKABLE QString camera_codec_to_string(int camera_codec); + Q_INVOKABLE QString camera_recording_mode_to_string(int recording_mode); // public: // generated by wb / link diff --git a/app/telemetry/settings/wblinksettingshelper.cpp b/app/telemetry/settings/wblinksettingshelper.cpp index 69ac4cdc5..ec14ac3e0 100644 --- a/app/telemetry/settings/wblinksettingshelper.cpp +++ b/app/telemetry/settings/wblinksettingshelper.cpp @@ -319,7 +319,7 @@ void WBLinkSettingsHelper::change_param_air_async(const int comp_id,const std::s if(std::holds_alternative(param_value)){ ss<(param_value); }else{ - ss<(param_value); + ss<(param_value); } ss<<",please check uplink"; HUDLogMessagesModel::instance().add_message_warning(ss.str().c_str()); diff --git a/qml/ui/elements/AppSettings.qml b/qml/ui/elements/AppSettings.qml index 9217bf5b1..52daf95fb 100644 --- a/qml/ui/elements/AppSettings.qml +++ b/qml/ui/elements/AppSettings.qml @@ -137,6 +137,7 @@ Settings { property bool bitrate_declutter: false property double bitrate_warn: 0 property double bitrate_caution: 0 + property bool camera_bitrate_widget_show_recording: true // property bool qrenderstats_show: false property bool qrenderstats_declutter: false diff --git a/qml/ui/elements/SimpleLeftRightText.qml b/qml/ui/elements/SimpleLeftRightText.qml index 87784663b..2d824585d 100644 --- a/qml/ui/elements/SimpleLeftRightText.qml +++ b/qml/ui/elements/SimpleLeftRightText.qml @@ -2,7 +2,8 @@ import QtQuick 2.12 Item { width: parent.width - height: 24 + //height: 24 + height: 20 property string m_left_text: "FILL ME" property string m_right_text: "FILL ME" diff --git a/qml/ui/widgets/VideoBitrateWidgetGeneric.qml b/qml/ui/widgets/VideoBitrateWidgetGeneric.qml index dc0a5ed87..051b49f3b 100644 --- a/qml/ui/widgets/VideoBitrateWidgetGeneric.qml +++ b/qml/ui/widgets/VideoBitrateWidgetGeneric.qml @@ -29,7 +29,7 @@ BaseWidget { hasWidgetDetail: true hasWidgetAction: true - widgetActionHeight: 400 + widgetActionHeight: 450 property var m_camera_stream_model: m_is_for_primary_camera ? _cameraStreamModelPrimary : _cameraStreamModelSecondary @@ -108,6 +108,17 @@ BaseWidget { } } + ListModel{ + id: resolutions_model + ListElement {title: "480p60(16:9)"; value: "848x480@60"} + ListElement {title: "480p60(4:3)"; value: "640x480@60"} + ListElement {title: "720p49(16:9)"; value: "1280x720@49"} + ListElement {title: "720p60(4:3)"; value: "960x720@60"} + ListElement {title: "1080p30(16:9)"; value: "1920x1080@30"} + ListElement {title: "1080p30(4:3)"; value: "1440x1080@30"} + ListElement {title: "1080p49(4:3)"; value: "1440x1080@49"} + } + //----------------------------- DETAIL BELOW ---------------------------------- @@ -120,6 +131,27 @@ BaseWidget { BaseWidgetDefaultUiControlElements{ id: idBaseWidgetDefaultUiControlElements + Item { + width: 230 + height: 32 + Text { + text: qsTr("Show RED recording active") + color: "white" + height: parent.height + font.bold: true + font.pixelSize: detailPanelFontPixels + anchors.left: parent.left + verticalAlignment: Text.AlignVCenter + } + Switch { + width: 32 + height: parent.height + anchors.rightMargin: 6 + anchors.right: parent.right + checked: settings.camera_bitrate_widget_show_recording + onCheckedChanged: settings.camera_bitrate_widget_show_recording = checked + } + } } } @@ -134,15 +166,50 @@ BaseWidget { width:200 SimpleLeftRightText{ - m_left_text: qsTr("Res@Framerate:") - m_right_text: m_camera_stream_model.curr_set_video_format_and_codec + m_left_text: qsTr("Status:") + m_right_text: { + if(!_ohdSystemAir.is_alive)return "no air"; + return _cameraStreamModelPrimary.camera_status_to_string(m_camera_stream_model.camera_status); + } + } + SimpleLeftRightText{ + m_left_text: qsTr("Type:") + m_right_text: { + if(!_ohdSystemAir.is_alive)return "n/a"; + return _cameraStreamModelPrimary.camera_type_to_string(m_camera_stream_model.camera_type); + } + } + SimpleLeftRightText{ + m_left_text: qsTr("Codec:") + m_right_text: { + if(!_ohdSystemAir.is_alive)return "n/a"; + return _cameraStreamModelPrimary.camera_codec_to_string(m_camera_stream_model.encoding_codec); + } } - //SimpleLeftRightText{ - // m_left_text: "" - // m_right_text: "" - //} - Item{ + ComboBox{ + id: resolution_fps_cb + model: resolutions_model + textRole: "title" + width: 200 + Layout.preferredWidth: 200 + Layout.minimumWidth: 200 + height: 50 + currentIndex: 0 + displayText: { + if(!_ohdSystemAir.is_alive)return "Res@fps N/A"; + return m_curr_video_format; + } + onActivated: { + console.log("onActivated:"+currentIndex); + if(currentIndex<0)return; + const resolution=model.get(currentIndex).value + console.log("Selected resolution: "+resolution); + set_camera_resolution(resolution); + } + enabled: _ohdSystemAir.is_alive; + } + /*Item{ width: parent.width height: 150 //color: "green" @@ -187,7 +254,7 @@ BaseWidget { highlighted: m_curr_video_format=="1440x1080@30" } } - } + }*/ SimpleLeftRightText{ m_left_text: qsTr("Bitrate SET:") m_right_text: m_camera_stream_model.curr_recomended_video_bitrate_string @@ -236,10 +303,7 @@ BaseWidget { m_left_text: qsTr("AIR RECORD:"); m_right_text: { if(!_ohdSystemAir.is_alive)return "N/A"; - if(m_camera_recording_mode){ - return "RECORDING"; - } - return "NOT ACTIVE" + return _cameraStreamModelPrimary.camera_recording_mode_to_string(m_camera_stream_model.air_recording_active); } } // For camera 1 @@ -275,12 +339,6 @@ BaseWidget { } } } - - /*Item{ - id: placeholder - width:parent.width - height: 10 - }*/ Item { width: parent.width height: 32 @@ -338,5 +396,17 @@ BaseWidget { style: Text.Outline styleColor: settings.color_glow } + + Rectangle{ + width: 12 + height: width + radius: width + color: "red"; + anchors.right: camera_icon.left + anchors.rightMargin: 2 + anchors.verticalCenter: parent.verticalCenter + visible: settings.camera_bitrate_widget_show_recording && m_camera_is_currently_recording + } + } }