Call.cpp 6.65 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13
/*
Call.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 20 21 22 23 24
*/

#include "Address.h"
#include "ApiLock.h"
#include "Call.h"
#include "CallLog.h"
#include "CallParams.h"
#include "CallStats.h"


25
using namespace BelledonneCommunications::Linphone::Native;
26 27 28
//using namespace Windows::Phone::Networking::Voip;


29
CallStats^ Call::AudioStats::get()
30 31
{
	API_LOCK;
32
	return (CallStats^) Utils::CreateCallStats(this->call, (int)MediaType::Audio);
33 34
}

35
Platform::String^ Call::AuthenticationToken::get()
36 37
{
	API_LOCK;
38
	return Utils::cctops(linphone_call_get_authentication_token(this->call));
39 40
}

41
Platform::Boolean Call::AuthenticationTokenVerified::get()
42 43 44 45 46
{
	API_LOCK;
	return (linphone_call_get_authentication_token_verified(this->call) == TRUE);
}

47
void Call::AuthenticationTokenVerified::set(Platform::Boolean verified)
48 49 50 51 52
{
	API_LOCK;
	linphone_call_set_authentication_token_verified(this->call, verified);
}

53
float Call::AverageQuality::get()
54 55 56 57 58
{
	API_LOCK;
	return linphone_call_get_average_quality(this->call);
}

59
CallLog^ Call::CallLog::get()
60 61
{
	API_LOCK;
62
	return (BelledonneCommunications::Linphone::Native::CallLog^) Utils::GetCallLog(linphone_call_get_call_log(this->call));
63 64
}

65
Platform::Boolean Call::CameraEnabled::get()
66 67 68 69 70
{
	API_LOCK;
	return (linphone_call_camera_enabled(this->call) == TRUE);
}

71
void Call::CameraEnabled::set(Platform::Boolean enable)
72 73 74 75 76
{
	API_LOCK;
	linphone_call_enable_camera(this->call, enable);
}

77
CallParams^ Call::CurrentParams::get()
78 79
{
	API_LOCK;
80
	return (CallParams^) Utils::GetCallParams((void *)linphone_call_get_current_params(this->call));
81 82
}

83
float Call::CurrentQuality::get()
84 85 86 87 88
{
	API_LOCK;
	return linphone_call_get_current_quality(this->call);
}

89
CallDirection Call::Direction::get()
90 91
{
	API_LOCK;
92
	return (CallDirection)linphone_call_get_dir(this->call);
93 94
}

95
int Call::Duration::get()
96 97 98 99 100
{
	API_LOCK;
	return linphone_call_get_duration(this->call);
}

101
Platform::Boolean Call::EchoCancellationEnabled::get()
102 103 104 105 106
{
	API_LOCK;
	return (linphone_call_echo_cancellation_enabled(this->call) == TRUE);
}

107
void Call::EchoCancellationEnabled::set(Platform::Boolean enable)
108 109 110 111 112
{
	API_LOCK;
	linphone_call_enable_echo_cancellation(this->call, enable);
}

113
Platform::Boolean Call::EchoLimiterEnabled::get()
114 115 116 117 118
{
	API_LOCK;
	return (linphone_call_echo_limiter_enabled(this->call) == TRUE);
}

119
void Call::EchoLimiterEnabled::set(Platform::Boolean enable)
120 121 122 123 124
{
	API_LOCK;
	linphone_call_enable_echo_limiter(this->call, enable);
}

125 126 127 128 129 130
Platform::Boolean Call::HasTransferPending::get()
{
	API_LOCK;
	return (linphone_call_has_transfer_pending(this->call) == TRUE);
}

131
Platform::Boolean Call::IsInConference::get()
132 133 134 135 136
{
	API_LOCK;
	return (linphone_call_is_in_conference(this->call) == TRUE);
}

137 138 139 140 141 142
Platform::Boolean Call::MediaInProgress::get()
{
	API_LOCK;
	return (linphone_call_media_in_progress(this->call) == TRUE);
}

143
Platform::Object^ Call::NativeVideoWindowId::get()
144 145 146 147
{
	API_LOCK;
	void *id = linphone_call_get_native_video_window_id(this->call);
	if (id == NULL) return nullptr;
148
	RefToPtrProxy<Platform::Object^> *proxy = reinterpret_cast<RefToPtrProxy<Platform::Object^>*>(id);
149 150 151 152
	Platform::Object^ nativeWindowId = (proxy) ? proxy->Ref() : nullptr;
	return nativeWindowId;
}

153
void Call::NativeVideoWindowId::set(Platform::Object^ value)
154 155
{
	API_LOCK;
156
	RefToPtrProxy<Platform::Object^> *nativeWindowId = new RefToPtrProxy<Platform::Object^>(value);
157 158 159
	linphone_call_set_native_video_window_id(this->call, nativeWindowId);
}

160
float Call::PlayVolume::get()
161 162 163 164 165
{
	API_LOCK;
	return linphone_call_get_play_volume(this->call);
}

166
Reason Call::Reason::get()
167 168
{
	API_LOCK;
169
	return (BelledonneCommunications::Linphone::Native::Reason)linphone_call_get_reason(this->call);
170 171
}

172 173 174 175 176 177
Platform::String^ Call::ReferTo::get()
{
	API_LOCK;
	return Utils::cctops(linphone_call_get_refer_to(this->call));
}

178
Platform::String^ Call::RemoteContact::get()
179 180
{
	API_LOCK;
181
	return Utils::cctops(linphone_call_get_remote_contact(this->call));
182 183
}

184
Address^ Call::RemoteAddress::get()
185 186 187
{
	API_LOCK;
	const ::LinphoneAddress *addr = linphone_call_get_remote_address(this->call);
188
	return (Address^)Utils::CreateAddress((void*)addr);
189 190
}

191
CallParams^ Call::RemoteParams::get()
192 193
{
	API_LOCK;
194
	return (CallParams^) Utils::GetCallParams((void *)linphone_call_get_remote_params(this->call));
195 196
}

197
Platform::String^ Call::RemoteUserAgent::get()
198 199
{
	API_LOCK;
200
	return Utils::cctops(linphone_call_get_remote_user_agent(this->call));
201 202
}

203 204 205 206 207 208
Call^ Call::ReplacedCall::get()
{
	API_LOCK;
	return (Call^)Utils::GetCall((void *)linphone_call_get_replaced_call(this->call));
}

209
CallState Call::State::get()
210 211
{
	API_LOCK;
212
	return (CallState)linphone_call_get_state(this->call);
213 214
}

215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232
Call^ Call::TransfererCall::get()
{
	API_LOCK;
	return (Call^)Utils::GetCall((void *)linphone_call_get_transferer_call(this->call));
}

CallState Call::TransferState::get()
{
	API_LOCK;
	return (CallState)linphone_call_get_transfer_state(this->call);
}

Call^ Call::TransferTargetCall::get()
{
	API_LOCK;
	return (Call^)Utils::GetCall((void *)linphone_call_get_transfer_target_call(this->call));
}

233
CallStats^ Call::VideoStats::get()
234 235
{
	API_LOCK;
236
	return (CallStats^) Utils::CreateCallStats(this->call, (int)MediaType::Video);
237 238
}

239
void Call::SendVFURequest()
240 241 242 243 244 245
{
	API_LOCK;
	linphone_call_send_vfu_request(this->call);
}

#if 0
246
Platform::Object^ Call::CallStartTimeFromContext::get()
247 248 249 250 251 252 253 254 255 256 257 258
{
	API_LOCK;
	Platform::Object^ result = nullptr;
	try {
		if (this->callContext != nullptr) {
			result = this->callContext->StartTime;
		}
	}
	catch (Platform::COMException^ ex) {
	}
	return result;
}
259
#endif
260

261
Windows::ApplicationModel::Calls::VoipPhoneCall^ Call::CallContext::get()
262 263 264
{
	return this->callContext;
}
265 266 267 268 269 270

void Call::CallContext::set(Windows::ApplicationModel::Calls::VoipPhoneCall^ cc)
{
	API_LOCK;
	this->callContext = cc;
}
271

272
Call::Call(::LinphoneCall *call)
273 274 275 276
	: call(call)
{
	API_LOCK;
	RefToPtrProxy<Call^> *proxy = new RefToPtrProxy<Call^>(this);
277
	linphone_call_ref(this->call);
278 279 280
	linphone_call_set_user_data(this->call, proxy);
}

281
Call::~Call()
282 283 284 285 286 287
{
	API_LOCK;
	linphone_call_unref(call);
	RefToPtrProxy<Call^> *proxy = reinterpret_cast< RefToPtrProxy<Call^> *>(linphone_call_get_user_data(this->call));
	delete proxy;
}