コード例 #1
0
static void check_payload_type_numbers(LinphoneCall *call1, LinphoneCall *call2, int expected_number){
	const LinphoneCallParams *params=linphone_call_get_current_params(call1);
	const PayloadType *pt=linphone_call_params_get_used_audio_codec(params);
	CU_ASSERT_PTR_NOT_NULL(pt);
	if (pt){
		CU_ASSERT_TRUE(linphone_core_get_payload_type_number(linphone_call_get_core(call1),pt)==expected_number);
	}
	params=linphone_call_get_current_params(call2);
	pt=linphone_call_params_get_used_audio_codec(params);
	CU_ASSERT_PTR_NOT_NULL(pt);
	if (pt){
		CU_ASSERT_TRUE(linphone_core_get_payload_type_number(linphone_call_get_core(call1),pt)==expected_number);
	}
}
コード例 #2
0
ファイル: incall_view.c プロジェクト: mjpak0109/linphone
static void show_used_codecs(GtkWidget *callstats, LinphoneCall *call) {
    const LinphoneCallParams *params=linphone_call_get_current_params(call);
    if (params) {
        const PayloadType *acodec=linphone_call_params_get_used_audio_codec(params);
        const PayloadType *vcodec=linphone_call_params_get_used_video_codec(params);
        GtkWidget *acodec_ui=linphone_gtk_get_widget(callstats,"audio_codec");
        GtkWidget *vcodec_ui=linphone_gtk_get_widget(callstats,"video_codec");
        if (acodec) {
            char tmp[64]= {0};
            snprintf(tmp,sizeof(tmp)-1,"%s/%i/%i",acodec->mime_type,acodec->clock_rate,acodec->channels);
            gtk_label_set_label(GTK_LABEL(acodec_ui),tmp);
        } else gtk_label_set_label(GTK_LABEL(acodec_ui),_("Not used"));
        if (vcodec) {
            gtk_label_set_label(GTK_LABEL(vcodec_ui),vcodec->mime_type);
        } else gtk_label_set_label(GTK_LABEL(vcodec_ui),_("Not used"));
    }
}
コード例 #3
0
void linphone_reporting_update_media_info(LinphoneCall * call, int stats_type) {
	MediaStream * stream = NULL;
	const PayloadType * local_payload = NULL;
	const PayloadType * remote_payload = NULL;
	const LinphoneCallParams * current_params = linphone_call_get_current_params(call);
	reporting_session_report_t * report = call->log->reporting.reports[stats_type];
	char * dialog_id;

	// call->op might be already released if hanging up in state LinphoneCallOutgoingInit
	if (!media_report_enabled(call, stats_type) || call->op == NULL)
		return;

	dialog_id = sal_op_get_dialog_id(call->op);

	STR_REASSIGN(report->info.call_id, ms_strdup(call->log->call_id));

	STR_REASSIGN(report->local_metrics.user_agent, ms_strdup(linphone_core_get_user_agent(call->core)));
	STR_REASSIGN(report->remote_metrics.user_agent, ms_strdup(linphone_call_get_remote_user_agent(call)));

	// RFC states: "LocalGroupID provides the identification for the purposes
	// of aggregation for the local endpoint.".
	STR_REASSIGN(report->info.local_addr.group, ms_strdup_printf("%s-%s-%s"
		, dialog_id ? dialog_id : ""
		, "local"
		, report->local_metrics.user_agent ? report->local_metrics.user_agent : ""
		)
	);
	STR_REASSIGN(report->info.remote_addr.group, ms_strdup_printf("%s-%s-%s"
		, dialog_id ? dialog_id : ""
		, "remote"
		, report->remote_metrics.user_agent ? report->remote_metrics.user_agent : ""
		)
	);


	if (call->dir == LinphoneCallIncoming) {
		STR_REASSIGN(report->info.remote_addr.id, linphone_address_as_string(call->log->from));
		STR_REASSIGN(report->info.local_addr.id, linphone_address_as_string(call->log->to));
		STR_REASSIGN(report->info.orig_id, ms_strdup(report->info.remote_addr.id));
	} else {
		STR_REASSIGN(report->info.remote_addr.id, linphone_address_as_string(call->log->to));
		STR_REASSIGN(report->info.local_addr.id, linphone_address_as_string(call->log->from));
		STR_REASSIGN(report->info.orig_id, ms_strdup(report->info.local_addr.id));
	}


	report->local_metrics.timestamps.start = call->log->start_date_time;
	report->local_metrics.timestamps.stop = call->log->start_date_time + linphone_call_get_duration(call);

	/*we use same timestamps for remote too*/
	report->remote_metrics.timestamps.start = call->log->start_date_time;
	report->remote_metrics.timestamps.stop = call->log->start_date_time + linphone_call_get_duration(call);


	/*yet we use the same payload config for local and remote, since this is the largest use case*/
	if (stats_type == LINPHONE_CALL_STATS_AUDIO && call->audiostream != NULL) {
		stream = &call->audiostream->ms;
		local_payload = linphone_call_params_get_used_audio_codec(current_params);
		remote_payload = local_payload;
	} else if (stats_type == LINPHONE_CALL_STATS_VIDEO && call->videostream != NULL) {
		stream = &call->videostream->ms;
		local_payload = linphone_call_params_get_used_video_codec(current_params);
		remote_payload = local_payload;
	} else if (stats_type == LINPHONE_CALL_STATS_TEXT && call->textstream != NULL) {
		stream = &call->textstream->ms;
		local_payload = linphone_call_params_get_used_text_codec(current_params);
		remote_payload = local_payload;
	}

	if (stream != NULL) {
		RtpSession * session = stream->sessions.rtp_session;

		report->info.local_addr.ssrc = rtp_session_get_send_ssrc(session);
		report->info.remote_addr.ssrc = rtp_session_get_recv_ssrc(session);

		if (stream->qi != NULL){
			report->local_metrics.quality_estimates.moslq = ms_quality_indicator_get_average_lq_rating(stream->qi) >= 0 ?
				MAX(1, ms_quality_indicator_get_average_lq_rating(stream->qi)) : -1;
			report->local_metrics.quality_estimates.moscq = ms_quality_indicator_get_average_rating(stream->qi) >= 0 ?
				MAX(1, ms_quality_indicator_get_average_rating(stream->qi)) : -1;
		}
	}

	STR_REASSIGN(report->dialog_id, ms_strdup_printf("%s;%u", dialog_id ? dialog_id : "", report->info.local_addr.ssrc));

	if (local_payload != NULL) {
		report->local_metrics.session_description.payload_type = local_payload->type;
		if (local_payload->mime_type!=NULL) STR_REASSIGN(report->local_metrics.session_description.payload_desc, ms_strdup(local_payload->mime_type));
		report->local_metrics.session_description.sample_rate = local_payload->clock_rate;
		if (local_payload->recv_fmtp!=NULL) STR_REASSIGN(report->local_metrics.session_description.fmtp, ms_strdup(local_payload->recv_fmtp));
	}

	if (remote_payload != NULL) {
		report->remote_metrics.session_description.payload_type = remote_payload->type;
		STR_REASSIGN(report->remote_metrics.session_description.payload_desc, ms_strdup(remote_payload->mime_type));
		report->remote_metrics.session_description.sample_rate = remote_payload->clock_rate;
		STR_REASSIGN(report->remote_metrics.session_description.fmtp, ms_strdup(remote_payload->recv_fmtp));
	}

	ms_free(dialog_id);
}
コード例 #4
0
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();
}