CallStats.cpp 4.23 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150
/*
CallStats.cpp
Copyright (C) 2015  Belledonne Communications, Grenoble, France
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
*/

#include "ApiLock.h"
#include "CallStats.h"


float Linphone::Native::CallStats::DownloadBandwidth::get()
{
	return this->downloadBandwidth;
}

Linphone::Native::IceState Linphone::Native::CallStats::IceState::get()
{
	return this->iceState;
}

float Linphone::Native::CallStats::JitterBufferSize::get()
{
	return this->jitterBufferSize;
}

int64 Linphone::Native::CallStats::LatePacketsCumulativeNumber::get()
{
	return this->cumulativeLatePackets;
}

float Linphone::Native::CallStats::LocalLateRate::get()
{
	return this->localLateRate;
}

float Linphone::Native::CallStats::LocalLossRate::get()
{
	return this->localLossRate;
}

Linphone::Native::MediaType Linphone::Native::CallStats::MediaType::get()
{
	return this->mediaType;
}

float Linphone::Native::CallStats::ReceiverInterarrivalJitter::get()
{
	return this->receiverInterarrivalJitter;
}

float Linphone::Native::CallStats::ReceiverLossRate::get()
{
	return this->receiverLossRate;
}

float Linphone::Native::CallStats::RoundTripDelay::get()
{
	return this->roundTripDelay;
}

float Linphone::Native::CallStats::SenderInterarrivalJitter::get()
{
	return this->senderInterarrivalJitter;
}

float Linphone::Native::CallStats::SenderLossRate::get()
{
	return this->senderLossRate;
}

float Linphone::Native::CallStats::UploadBandwidth::get()
{
	return this->uploadBandwidth;
}

Linphone::Native::CallStats::CallStats(::LinphoneCall *call, Linphone::Native::MediaType mediaType)
	: call(call)
{
	API_LOCK;
	const ::LinphoneCallStats *stats = nullptr;
	if (mediaType == Linphone::Native::MediaType::Audio) {
		stats = linphone_call_get_audio_stats(this->call);
	} else {
		stats = linphone_call_get_video_stats(this->call);
	}
	FillStats(stats);
}

Linphone::Native::CallStats::CallStats(::LinphoneCallStats *callStats)
{
	API_LOCK;
	FillStats(callStats);
}

Linphone::Native::CallStats::~CallStats()
{
	
}

float Linphone::Native::CallStats::GetSenderLossRate(const ::LinphoneCallStats *stats)
{
	return linphone_call_stats_get_sender_loss_rate(stats);
}

float Linphone::Native::CallStats::GetReceiverLossRate(const ::LinphoneCallStats *stats)
{
	return linphone_call_stats_get_receiver_loss_rate(stats);
}

float Linphone::Native::CallStats::GetSenderInterarrivalJitter(const ::LinphoneCallStats *stats)
{
	return linphone_call_stats_get_sender_interarrival_jitter(stats, this->call);
}

float Linphone::Native::CallStats::GetReceiverInterarrivalJitter(const ::LinphoneCallStats *stats)
{
	return linphone_call_stats_get_receiver_interarrival_jitter(stats, this->call);
}

int64 Linphone::Native::CallStats::GetLatePacketsCumulativeNumber(const ::LinphoneCallStats *stats)
{
	return linphone_call_stats_get_late_packets_cumulative_number(stats, this->call);
}

void Linphone::Native::CallStats::FillStats(const ::LinphoneCallStats *stats)
{
	this->mediaType = (Linphone::Native::MediaType) stats->type;
	this->iceState = (Linphone::Native::IceState) stats->ice_state;
	this->downloadBandwidth = stats->download_bandwidth;
	this->uploadBandwidth = stats->upload_bandwidth;
	this->senderLossRate = GetSenderLossRate(stats);
	this->receiverLossRate = GetReceiverLossRate(stats);
	this->senderInterarrivalJitter = GetSenderInterarrivalJitter(stats);
	this->receiverInterarrivalJitter = GetReceiverInterarrivalJitter(stats);
	this->roundTripDelay = stats->round_trip_delay;
	this->cumulativeLatePackets = GetLatePacketsCumulativeNumber(stats);
	this->jitterBufferSize = stats->jitter_stats.jitter_buffer_size_ms;
	this->localLossRate = stats->local_loss_rate;
	this->localLateRate = stats->local_late_rate;
}