Call.cpp 6.74 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
/*
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
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
*/

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


//using namespace Windows::Phone::Networking::Voip;


Linphone::Native::CallStats^ Linphone::Native::Call::AudioStats::get()
{
	API_LOCK;
31
	return (Linphone::Native::CallStats^) Linphone::Native::Utils::CreateCallStats(this->call, (int)Linphone::Native::MediaType::Audio);
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
}

Platform::String^ Linphone::Native::Call::AuthenticationToken::get()
{
	API_LOCK;
	return Linphone::Native::Utils::cctops(linphone_call_get_authentication_token(this->call));
}

Platform::Boolean Linphone::Native::Call::AuthenticationTokenVerified::get()
{
	API_LOCK;
	return (linphone_call_get_authentication_token_verified(this->call) == TRUE);
}

void Linphone::Native::Call::AuthenticationTokenVerified::set(Platform::Boolean verified)
{
	API_LOCK;
	linphone_call_set_authentication_token_verified(this->call, verified);
}

float Linphone::Native::Call::AverageQuality::get()
{
	API_LOCK;
	return linphone_call_get_average_quality(this->call);
}

Linphone::Native::CallLog^ Linphone::Native::Call::CallLog::get()
{
	API_LOCK;
61
	return (Linphone::Native::CallLog^) Linphone::Native::Utils::GetCallLog(linphone_call_get_call_log(this->call));
62 63 64 65 66 67 68 69 70 71 72 73 74 75
}

Platform::Boolean Linphone::Native::Call::CameraEnabled::get()
{
	API_LOCK;
	return (linphone_call_camera_enabled(this->call) == TRUE);
}

void Linphone::Native::Call::CameraEnabled::set(Platform::Boolean enable)
{
	API_LOCK;
	linphone_call_enable_camera(this->call, enable);
}

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

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
float Linphone::Native::Call::CurrentQuality::get()
{
	API_LOCK;
	return linphone_call_get_current_quality(this->call);
}

Linphone::Native::CallDirection Linphone::Native::Call::Direction::get()
{
	API_LOCK;
	return (Linphone::Native::CallDirection)linphone_call_get_dir(this->call);
}

int Linphone::Native::Call::Duration::get()
{
	API_LOCK;
	return linphone_call_get_duration(this->call);
}

Platform::Boolean Linphone::Native::Call::EchoCancellationEnabled::get()
{
	API_LOCK;
	return (linphone_call_echo_cancellation_enabled(this->call) == TRUE);
}

void Linphone::Native::Call::EchoCancellationEnabled::set(Platform::Boolean enable)
{
	API_LOCK;
	linphone_call_enable_echo_cancellation(this->call, enable);
}

Platform::Boolean Linphone::Native::Call::EchoLimiterEnabled::get()
{
	API_LOCK;
	return (linphone_call_echo_limiter_enabled(this->call) == TRUE);
}

void Linphone::Native::Call::EchoLimiterEnabled::set(Platform::Boolean enable)
{
	API_LOCK;
	linphone_call_enable_echo_limiter(this->call, enable);
}

124
Platform::Boolean Linphone::Native::Call::IsInConference::get()
125 126 127 128 129
{
	API_LOCK;
	return (linphone_call_is_in_conference(this->call) == TRUE);
}

130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146
Platform::Object^ Linphone::Native::Call::NativeVideoWindowId::get()
{
	API_LOCK;
	void *id = linphone_call_get_native_video_window_id(this->call);
	if (id == NULL) return nullptr;
	Linphone::Native::RefToPtrProxy<Platform::Object^> *proxy = reinterpret_cast<Linphone::Native::RefToPtrProxy<Platform::Object^>*>(id);
	Platform::Object^ nativeWindowId = (proxy) ? proxy->Ref() : nullptr;
	return nativeWindowId;
}

void Linphone::Native::Call::NativeVideoWindowId::set(Platform::Object^ value)
{
	API_LOCK;
	Linphone::Native::RefToPtrProxy<Platform::Object^> *nativeWindowId = new Linphone::Native::RefToPtrProxy<Platform::Object^>(value);
	linphone_call_set_native_video_window_id(this->call, nativeWindowId);
}

147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174
float Linphone::Native::Call::PlayVolume::get()
{
	API_LOCK;
	return linphone_call_get_play_volume(this->call);
}

Linphone::Native::Reason Linphone::Native::Call::Reason::get()
{
	API_LOCK;
	return (Linphone::Native::Reason)linphone_call_get_reason(this->call);
}

Platform::String^ Linphone::Native::Call::RemoteContact::get()
{
	API_LOCK;
	return Linphone::Native::Utils::cctops(linphone_call_get_remote_contact(this->call));
}

Linphone::Native::Address^ Linphone::Native::Call::RemoteAddress::get()
{
	API_LOCK;
	const ::LinphoneAddress *addr = linphone_call_get_remote_address(this->call);
	return (Linphone::Native::Address^)Linphone::Native::Utils::CreateAddress((void*)addr);
}

Linphone::Native::CallParams^ Linphone::Native::Call::RemoteParams::get()
{
	API_LOCK;
175
	return (Linphone::Native::CallParams^) Linphone::Native::Utils::GetCallParams((void *)linphone_call_get_remote_params(this->call));
176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192
}

Platform::String^ Linphone::Native::Call::RemoteUserAgent::get()
{
	API_LOCK;
	return Linphone::Native::Utils::cctops(linphone_call_get_remote_user_agent(this->call));
}

Linphone::Native::CallState Linphone::Native::Call::State::get()
{
	API_LOCK;
	return (Linphone::Native::CallState)linphone_call_get_state(this->call);
}

Linphone::Native::CallStats^ Linphone::Native::Call::VideoStats::get()
{
	API_LOCK;
193
	return (Linphone::Native::CallStats^) Linphone::Native::Utils::CreateCallStats(this->call, (int)Linphone::Native::MediaType::Video);
194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243
}

void Linphone::Native::Call::SendVFURequest()
{
	API_LOCK;
	linphone_call_send_vfu_request(this->call);
}

#if 0
void Linphone::Native::Call::CallContext::set(Windows::Phone::Networking::Voip::VoipPhoneCall^ cc)
{
	API_LOCK;
	this->callContext = cc;
}

Platform::Object^ Linphone::Native::Call::CallStartTimeFromContext::get()
{
	API_LOCK;
	Platform::Object^ result = nullptr;
	try {
		if (this->callContext != nullptr) {
			result = this->callContext->StartTime;
		}
	}
	catch (Platform::COMException^ ex) {
	}
	return result;
}

Windows::Phone::Networking::Voip::VoipPhoneCall^ Linphone::Native::Call::CallContext::get()
{
	return this->callContext;
}
#endif

Linphone::Native::Call::Call(::LinphoneCall *call)
	: call(call)
{
	API_LOCK;
	RefToPtrProxy<Call^> *proxy = new RefToPtrProxy<Call^>(this);
	linphone_call_set_user_data(this->call, proxy);
}

Linphone::Native::Call::~Call()
{
	API_LOCK;
	linphone_call_unref(call);
	RefToPtrProxy<Call^> *proxy = reinterpret_cast< RefToPtrProxy<Call^> *>(linphone_call_get_user_data(this->call));
	delete proxy;
}