CallStats.cpp 3.36 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13
/*
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
14
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
15 16 17 18 19
*/

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

20
using namespace BelledonneCommunications::Linphone::Native;
21

22
float CallStats::DownloadBandwidth::get()
23
{
24
	return linphone_call_stats_get_download_bandwidth(this->stats);
25 26
}

27
IceState CallStats::IceState::get()
28
{
29
	return (BelledonneCommunications::Linphone::Native::IceState)linphone_call_stats_get_ice_state(this->stats);
30 31
}

32
float CallStats::JitterBufferSize::get()
33
{
34
	return linphone_call_stats_get_jitter_buffer_size_ms(this->stats);
35 36
}

37
int64 CallStats::LatePacketsCumulativeNumber::get()
38
{
39
	return linphone_call_stats_get_late_packets_cumulative_number(this->stats);
40 41
}

42
float CallStats::LocalLateRate::get()
43
{
44
	return linphone_call_stats_get_local_late_rate(this->stats);
45 46
}

47
float CallStats::LocalLossRate::get()
48
{
49
	return linphone_call_stats_get_local_loss_rate(this->stats);
50 51
}

52
MediaType CallStats::MediaType::get()
53
{
54
	return (BelledonneCommunications::Linphone::Native::MediaType)linphone_call_stats_get_type(this->stats);
55 56
}

57
float CallStats::ReceiverInterarrivalJitter::get()
58
{
59
	return linphone_call_stats_get_receiver_interarrival_jitter(this->stats);
60 61
}

62
float CallStats::ReceiverLossRate::get()
63
{
64
	return linphone_call_stats_get_receiver_loss_rate(this->stats);
65 66
}

67
float CallStats::RoundTripDelay::get()
68
{
69
	return linphone_call_stats_get_round_trip_delay(this->stats);
70 71
}

72
float CallStats::SenderInterarrivalJitter::get()
73
{
74
	return linphone_call_stats_get_sender_interarrival_jitter(this->stats);
75 76
}

77
float CallStats::SenderLossRate::get()
78
{
79
	return linphone_call_stats_get_sender_loss_rate(this->stats);
80 81
}

82
float CallStats::UploadBandwidth::get()
83
{
84
	return linphone_call_stats_get_upload_bandwidth(this->stats);
85 86
}

87
CallStats::CallStats(::LinphoneCall *call, BelledonneCommunications::Linphone::Native::MediaType mediaType)
88 89
{
	API_LOCK;
90
	RefToPtrProxy<CallStats^> *proxy = new RefToPtrProxy<CallStats^>(this);
91
	const ::LinphoneCallStats *stats = nullptr;
92
	if (mediaType == BelledonneCommunications::Linphone::Native::MediaType::Audio) {
93
		stats = linphone_call_get_audio_stats(call);
94
	} else {
95
		stats = linphone_call_get_video_stats(call);
96
	}
97 98
	linphone_call_stats_ref(this->stats);
	linphone_call_stats_set_user_data(this->stats, proxy);
99 100
}

101
CallStats::CallStats(::LinphoneCallStats *callStats)
102 103
{
	API_LOCK;
104 105 106 107
	RefToPtrProxy<CallStats^> *proxy = new RefToPtrProxy<CallStats^>(this);
	this->stats = callStats;
	linphone_call_stats_ref(this->stats);
	linphone_call_stats_set_user_data(this->stats, proxy);
108 109
}

110
CallStats::~CallStats()
111
{
112 113 114
	linphone_call_stats_unref(this->stats);
	RefToPtrProxy<CallStats^> *proxy = reinterpret_cast< RefToPtrProxy<CallStats^> *>(linphone_call_stats_get_user_data(this->stats));
	delete proxy;
115
}