예제 #1
0
void linphone_gtk_in_call_view_show_encryption(LinphoneCall *call){
	GtkWidget *callview=(GtkWidget*)linphone_call_get_user_pointer(call);
	GtkWidget *encryption_box=linphone_gtk_get_widget(callview,"encryption_box");
	GtkWidget *label=linphone_gtk_get_widget(callview,"encryption_label");
	GtkWidget *status_icon=linphone_gtk_get_widget(callview,"encryption_status_icon");
	GtkWidget *verify_button=linphone_gtk_get_widget(callview,"encryption_verify_button");
	LinphoneMediaEncryption me=linphone_call_params_get_media_encryption(linphone_call_get_current_params(call));
	bool_t verified=linphone_call_get_authentication_token_verified(call);
	switch(me){
		case LinphoneMediaEncryptionSRTP:
			gtk_widget_show_all(encryption_box);
			gtk_label_set_markup(GTK_LABEL(label),_("Secured by SRTP"));
			gtk_widget_hide(status_icon);
			gtk_widget_hide(verify_button);
		break;
		case LinphoneMediaEncryptionZRTP:
		{
			gchar *text=g_strdup_printf(_("Secured by ZRTP - [auth token: %s]"),linphone_call_get_authentication_token(call));
			gtk_label_set_markup(GTK_LABEL(label),text);
			g_free(text);
			gtk_image_set_from_stock(GTK_IMAGE(status_icon),
			                          verified ? GTK_STOCK_APPLY : GTK_STOCK_DIALOG_WARNING,GTK_ICON_SIZE_MENU);
			gtk_button_set_label(GTK_BUTTON(verify_button),
			                     verified ? _("Set unverified") : _("Set verified"));
			gtk_widget_show_all(encryption_box);
		}	
		break;
		default:
			gtk_widget_hide_all(encryption_box);
	}
}
void CallStatsModel::updateStats(LinphoneCall *call)
{
    if (!call) {
        return;
    }

    float quality = linphone_call_get_current_quality(call);
    if (quality >= 4) {
        _currentCallQualityIcon = "/images/statusbar/call_quality_indicator_4.png";
    } else if (quality >= 3) {
        _currentCallQualityIcon = "/images/statusbar/call_quality_indicator_3.png";
    } else if (quality >= 2) {
        _currentCallQualityIcon = "/images/statusbar/call_quality_indicator_2.png";
    } else if (quality >= 1) {
        _currentCallQualityIcon = "/images/statusbar/call_quality_indicator_1.png";
    } else {
        _currentCallQualityIcon = "/images/statusbar/call_quality_indicator_0.png";
    }

    const LinphoneCallParams *params = linphone_call_get_current_params(call);
    if (!params) {
        return;
    }

    LinphoneMediaEncryption encryption = linphone_call_params_get_media_encryption(params);
    _currentCallSecurityIcon = "/images/statusbar/security_ko.png";
    if (encryption == LinphoneMediaEncryptionSRTP || encryption == LinphoneMediaEncryptionDTLS) {
        _currentCallSecurityIcon = "/images/statusbar/security_ok.png";
    } else if (encryption == LinphoneMediaEncryptionZRTP) {
        _callSecurityToken = tr("ZRTP token is %1.\r\nYou should only accept if you have the same token as your correspondent.").arg(linphone_call_get_authentication_token(call));

        bool isAuthTokenVerified = linphone_call_get_authentication_token_verified(call);
        if (isAuthTokenVerified) {
            _currentCallSecurityIcon = "/images/statusbar/security_ok.png";
        } else {
            _currentCallSecurityIcon = "/images/statusbar/security_pending.png";
        }
        emit zrtpUpdated();
    }

    const LinphoneCallStats *audioStats = linphone_call_get_audio_stats(call);
    if (audioStats) {
        _iceStatus = IceStateToString(linphone_call_stats_get_ice_state(audioStats));
        _downloadAudioBandwidth = QString("<html>&#x2193; %1 kbits/s</html>").arg(QString::number((int)linphone_call_stats_get_download_bandwidth(audioStats)));
        _uploadAudioBandwidth = QString("<html>&#x2191; %1 kbits/s</html>").arg(QString::number((int)linphone_call_stats_get_upload_bandwidth(audioStats)));
    }

    const LinphonePayloadType *audioPayload = linphone_call_params_get_used_audio_codec(params);
    if (audioPayload) {
        _audioCodec = QString(linphone_payload_type_get_mime_type(audioPayload)) + "/" +  QString::number(payload_type_get_rate(audioPayload)) + "/" + QString::number(linphone_payload_type_get_channels(audioPayload));
    }

    if (linphone_call_params_video_enabled(params)) {
        const LinphoneCallStats *videoStats = linphone_call_get_video_stats(call);
        if (videoStats) {
            _downloadVideoBandwidth = QString("<html>&#x2193; %1 kbits/s</html>").arg(QString::number((int)linphone_call_stats_get_download_bandwidth(videoStats)));
            _uploadVideoBandwidth = QString("<html>&#x2191; %1 kbits/s</html>").arg(QString::number((int)linphone_call_stats_get_upload_bandwidth(videoStats)));
        }

        const LinphonePayloadType *videoPayload = linphone_call_params_get_used_video_codec(params);
        if (videoPayload) {
            _videoCodec = QString(linphone_payload_type_get_mime_type(videoPayload));
        }

        MSVideoSize sentVideoSize = linphone_call_params_get_sent_video_size(params);
        float framerate = linphone_call_params_get_sent_framerate(params);
        _sentVideoSize = QString("%1x%2 @ %3 fps").arg(QString::number(sentVideoSize.width), QString::number(sentVideoSize.height), QString::number((int)framerate));

        MSVideoSize receivedVideoSize = linphone_call_params_get_received_video_size(params);
        framerate = linphone_call_params_get_received_framerate(params);
        _receivedVideoSize = QString("%1x%2 @ %3 fps").arg(QString::number(receivedVideoSize.width), QString::number(receivedVideoSize.height), QString::number((int)framerate));
    }

    emit statsUpdated();
}
void CallStatsModel::showZRTPDialog(LinphoneCall *call)
{
    const LinphoneCallParams *params = linphone_call_get_current_params(call);
    if (!params) {
        return;
    }

    LinphoneMediaEncryption encryption = linphone_call_params_get_media_encryption(params);
    if (encryption == LinphoneMediaEncryptionZRTP) {
        _callSecurityToken = tr("ZRTP token is %1.\r\nYou should only accept if you have the same token as your correspondent.").arg(linphone_call_get_authentication_token(call));
        _zrtpDialogVisible = true;
        emit zrtpUpdated();
    }
}