diff --git a/include/linphone/api/c-types.h b/include/linphone/api/c-types.h index 6051e50fcf0ff28f4da880ba1f555131361c9168..2d96128cc738ccb93d0bd957accc11b1906a2075 100644 --- a/include/linphone/api/c-types.h +++ b/include/linphone/api/c-types.h @@ -647,10 +647,12 @@ typedef struct _LinphoneDictionary LinphoneDictionary; /** * @brief Object that represents an alert. * Alerts are raised at run-time when particular conditions are met, for example bad network quality. - * The full list of available alert types is described by the #LinphoneAlertTypes enum. + * The full list of available alert types is described by the #LinphoneAlertType enum. * An application is notified of new alerts through the #LinphoneCoreCbs interface. * Once raised, the application may use the #LinphoneAlertCbs interface to get notified * when the alert stops. + * For each kind of alert, a #LinphoneDictionary is filled with relevant informations, returned by + * linphone_alert_get_informations(). The keys available are documented per-type in #LinphoneAlertType enum. * @ingroup alert */ typedef struct _LinphoneAlert LinphoneAlert; @@ -681,14 +683,14 @@ typedef enum _LinphoneAlertTypes { */ LinphoneAlertQoSVideoStalled, /** A received media stream suffers from high loss or late rate. Information provided is: - - float loss_rate - - float late_rate - - string media_type {audio, video, text} + * - loss-rate (float) + * - late-rate (float) + * - media-type (string) with values {audio, video, text} * @note Use the key "loss_rate_interval" in the section "alerts::network" to set or get the interval at which the problem is checked in a #LinphoneConfig. */ LinphoneAlertQoSHighLossLateRate, - /** A report of high loss rate is received from remote party. Information provided: float loss_rate. + /** A report of high loss rate is received from remote party. Information provided: loss-rate (float). * @note Use the key "remote_loss_rate_interval" in the section "alerts::network" to set or get the interval at * which the problem is checked in a #LinphoneConfig. */ @@ -698,33 +700,38 @@ typedef enum _LinphoneAlertTypes { * the problem is checked in a #LinphoneConfig. */ LinphoneAlertQoSBurstOccured, - /** Loss rate is significant but retransmissions fail to arrive on time + /** Loss rate is significant but retransmissions fail to arrive on time. + * Information provided: nack-performance (float) the fraction of lost packets recovered thanks to nack-triggered + * retransmissions. * @note Use the key "nack_check_interval" in the section "alerts::network" to set or get the interval at which the * problem is checked in a #LinphoneConfig. */ LinphoneAlertQoSRetransmissionFailures, - /** Low bandwidth detected. Information provided: float bandwidth; in kbit/s. + /** Low bandwidth detected. Information provided: bandwidth (float) in kbit/s. * @note Use the key "download_bandwidth_interval" in the section "alerts::video" to set or get the interval at * which the problem is checked in a #LinphoneConfig. */ LinphoneAlertQoSLowDownloadBandwidthEstimation, - /** Low quality (bitrate) video received. Information provided: float bitrate in kbit/s, int width, int height + /** Low quality (bitrate) video received. Information provided: bitrate (float) in kbit/s, width (integer), int + * height (integer). * @note Use the key "low_quality_received_interval" in the section "alerts::video" to set or get the interval at * which the problem is checked in a #LinphoneConfig. */ LinphoneAlertQoSLowQualityReceivedVideo, - /** Low quality video is being sent. Information provided: float bitrate in kbit/s, int width, int height - * @note Use the key "quality_sent_interval" in the section "alerts::camera" to set or get the interval at which + /** Low quality video is being sent. Information provided: bitrate (float)in kbit/s, width (integer), height + * (integer). + * @note Use the key "quality_sent_interval" in the section "alerts::camera" to set or get the interval at which * the problem is checked in a #LinphoneConfig. */ LinphoneAlertQoSLowQualitySentVideo, /** The operating system reports a low radio signal (wifi or mobile) - * @note Use the key "low_signal_interval" in the section "alerts::network" to set or get the interval at which the + * @note Use the key "low_signal_interval" in the section "alerts::network" to set or get the interval at which the * problem is checked in a #LinphoneConfig. */ LinphoneAlertQoSLowSignal, - /** The operating system reports a loss of radio signal (wifi or mobile) - * @note Use the key "lost_signal_interval" in the section "alerts::network" to set or get the interval at which + /** The operating system reports a loss of radio signal (wifi or mobile). + * Information provided: rssi-value (float), signal-type (string) with values {"wifi", "mobile", "other"}. + * @note Use the key "lost_signal_interval" in the section "alerts::network" to set or get the interval at which * the problem is checked in a #LinphoneConfig. */ LinphoneAlertQoSLostSignal diff --git a/src/alert/alert.cpp b/src/alert/alert.cpp index 840722a22b4e5f26177c6cddd52318c51385cc49..e91e9c87c40a0c0a32daa7d2a1994f56324dd3f3 100644 --- a/src/alert/alert.cpp +++ b/src/alert/alert.cpp @@ -278,9 +278,9 @@ void NetworkQualityAlertMonitor::checkLocalLossRate(float lossRate, float lateRa handleAlert(LinphoneAlertQoSHighLossLateRate, condition, [lossRate, lateRate, streamType]() { auto properties = (new Dictionary())->toSharedPtr(); - properties->setProperty("loss rate", lossRate); - properties->setProperty("late rate", lateRate); - properties->setProperty("media type", streamType); + properties->setProperty("loss-rate", lossRate); + properties->setProperty("late-rate", lateRate); + properties->setProperty("media-type", streamType); return properties; }); } @@ -290,7 +290,7 @@ void NetworkQualityAlertMonitor::checkRemoteLossRate(float receivedLossRate) { handleAlert(LinphoneAlertQoSHighRemoteLossRate, condition, [receivedLossRate]() { auto properties = (new Dictionary())->toSharedPtr(); - properties->setProperty("loss rate", receivedLossRate); + properties->setProperty("loss-rate", receivedLossRate); return properties; }); } @@ -328,7 +328,7 @@ void NetworkQualityAlertMonitor::checkNackQuality(RtpSession *session) { mLastTotalLoss = currentTotalLoss; handleAlert(LinphoneAlertQoSRetransmissionFailures, mNackIndicator <= mNackPerformanceThreshold, [this]() { auto properties = (new Dictionary())->toSharedPtr(); - properties->setProperty("nack indicator", mNackIndicator); + properties->setProperty("nack-performance", mNackIndicator); return properties; }); } @@ -343,9 +343,10 @@ void NetworkQualityAlertMonitor::checkSignalQuality() { value = information->getStrength(); condition = (value <= mSignalThreshold); } - handleAlert(LinphoneAlertQoSLowSignal, condition, [value]() { + handleAlert(LinphoneAlertQoSLowSignal, condition, [value, information]() { auto properties = (new Dictionary())->toSharedPtr(); - properties->setProperty("Rssi value", value); + properties->setProperty("rssi-value", value); + properties->setProperty("network-type", SignalInformation::signalTypeToString(information->getSignalType())); return properties; }); } diff --git a/src/signal-information/signal-information.cpp b/src/signal-information/signal-information.cpp index 4a514e5b2e25c1266ab10737508710a38f364973..fb808eaa6368d42516a348e2b4596ca21eb286f2 100644 --- a/src/signal-information/signal-information.cpp +++ b/src/signal-information/signal-information.cpp @@ -61,4 +61,17 @@ void SignalInformation::setDetails(const std::string &details) { std::string SignalInformation::getDetails() { return mDetails; } -LINPHONE_END_NAMESPACE \ No newline at end of file + +const char *SignalInformation::signalTypeToString(LinphoneSignalType type) { + switch (type) { + case LinphoneSignalTypeWifi: + return "wifi"; + case LinphoneSignalTypeMobile: + return "mobile"; + case LinphoneSignalTypeOther: + return "other"; + } + return "invalid"; +} + +LINPHONE_END_NAMESPACE diff --git a/src/signal-information/signal-information.h b/src/signal-information/signal-information.h index b7f7d662a9208383153f2f87224bdb6cfc3ed500..06ea3d5c084de4af563cba82df351753914923e5 100644 --- a/src/signal-information/signal-information.h +++ b/src/signal-information/signal-information.h @@ -46,6 +46,8 @@ public: void setDetails(const std::string &details); std::string getDetails(); + static const char *signalTypeToString(LinphoneSignalType type); + private: LinphoneSignalType mType; LinphoneSignalStrengthUnit mUnit; @@ -54,4 +56,4 @@ private: }; LINPHONE_END_NAMESPACE -#endif // SIGNAL_INFORMATION_H \ No newline at end of file +#endif // SIGNAL_INFORMATION_H