Commit 4dd65a90 authored by Sylvain Berfini's avatar Sylvain Berfini

Improved/added ref count

parent 0d20db69
......@@ -82,7 +82,6 @@ void Globals::StartServer(const Platform::Array<Platform::String^>^ outOfProcSer
throw ref new Platform::COMException(hr, L"An error occurred trying to set an event that indicates that the background process is ready");
}
this->started = true;
gApiLock.Unlock();
}
......
......@@ -179,17 +179,23 @@ Platform::String^ Linphone::Core::LinphoneCall::GetRemoteContact()
return contact;
}
void Linphone::Core::LinphoneCall::CallContext::set(Platform::Object^ cc)
void Linphone::Core::LinphoneCall::CallContext::set(Windows::Phone::Networking::Voip::VoipPhoneCall^ cc)
{
this->callContext = cc;
}
Platform::Object^ Linphone::Core::LinphoneCall::GetCallStartTimeFromContext()
{
if (this->callContext != nullptr) {
return ((Windows::Phone::Networking::Voip::VoipPhoneCall^)this->callContext)->StartTime;
Platform::Object^ result = nullptr;
try {
if (this->callContext != nullptr) {
result = this->callContext->StartTime;
}
}
return nullptr;
catch (Platform::COMException^ ex) {
}
return result;
}
Platform::Boolean Linphone::Core::LinphoneCall::IsCameraEnabled()
......@@ -222,7 +228,7 @@ void Linphone::Core::LinphoneCall::SendVFURequest()
gApiLock.Unlock();
}
Platform::Object^ Linphone::Core::LinphoneCall::CallContext::get()
Windows::Phone::Networking::Voip::VoipPhoneCall^ Linphone::Core::LinphoneCall::CallContext::get()
{
return this->callContext;
}
......@@ -233,12 +239,15 @@ Linphone::Core::LinphoneCall::LinphoneCall(::LinphoneCall *call) :
gApiLock.Lock();
RefToPtrProxy<LinphoneCall^> *proxy = new RefToPtrProxy<LinphoneCall^>(this);
linphone_call_set_user_pointer(this->call, proxy);
this->callContext = nullptr;
gApiLock.Unlock();
}
Linphone::Core::LinphoneCall::~LinphoneCall()
{
gApiLock.Lock();
this->callContext = nullptr;
linphone_call_unref(call);
RefToPtrProxy<LinphoneCall^> *proxy = reinterpret_cast< RefToPtrProxy<LinphoneCall^> *>(linphone_call_get_user_pointer(this->call));
delete proxy;
gApiLock.Unlock();
......
......@@ -192,10 +192,10 @@ namespace Linphone
/// <summary>
/// Gets the CallContext object (native VoipPhoneCall)
/// </summary>
property Platform::Object^ CallContext
property Windows::Phone::Networking::Voip::VoipPhoneCall^ CallContext
{
Platform::Object^ get();
void set(Platform::Object^ cc);
Windows::Phone::Networking::Voip::VoipPhoneCall^ get();
void set(Windows::Phone::Networking::Voip::VoipPhoneCall^ cc);
}
private:
......@@ -206,7 +206,7 @@ namespace Linphone
LinphoneCall(::LinphoneCall *call);
~LinphoneCall();
Platform::Object^ callContext;
Windows::Phone::Networking::Voip::VoipPhoneCall^ callContext;
::LinphoneCall *call;
};
}
......
......@@ -50,6 +50,7 @@ Linphone::Core::LinphoneChatMessage::LinphoneChatMessage(::LinphoneChatMessage *
Linphone::Core::LinphoneChatMessage::~LinphoneChatMessage()
{
linphone_chat_message_unref(message);
RefToPtrProxy<LinphoneChatMessage^> *chat_message = reinterpret_cast< RefToPtrProxy<LinphoneChatMessage^> *>(linphone_chat_message_get_user_data(this->message));
delete chat_message;
}
\ No newline at end of file
......@@ -310,6 +310,7 @@ Linphone::Core::LinphoneCall^ Linphone::Core::LinphoneCore::Invite(Platform::Str
Linphone::Core::LinphoneCall^ lCall = nullptr;
const char *cc = Linphone::Core::Utils::pstoccs(destination);
::LinphoneCall *call = linphone_core_invite(this->lc, cc);
call = linphone_call_ref(call);
delete(cc);
if (call != NULL) {
Linphone::Core::RefToPtrProxy<Linphone::Core::LinphoneCall^> *proxy = reinterpret_cast< Linphone::Core::RefToPtrProxy<Linphone::Core::LinphoneCall^> *>(linphone_call_get_user_pointer(call));
......@@ -326,6 +327,7 @@ Linphone::Core::LinphoneCall^ Linphone::Core::LinphoneCore::InviteAddress(Linpho
gApiLock.Lock();
Linphone::Core::LinphoneCall^ lCall = nullptr;
::LinphoneCall *call = linphone_core_invite_address(this->lc, destination->address);
call = linphone_call_ref(call);
if (call != NULL) {
Linphone::Core::RefToPtrProxy<Linphone::Core::LinphoneCall^> *proxy = reinterpret_cast< Linphone::Core::RefToPtrProxy<Linphone::Core::LinphoneCall^> *>(linphone_call_get_user_pointer(call));
lCall = (proxy) ? proxy->Ref() : nullptr;
......@@ -341,6 +343,7 @@ Linphone::Core::LinphoneCall^ Linphone::Core::LinphoneCore::InviteAddressWithPar
gApiLock.Lock();
Linphone::Core::LinphoneCall^ lCall = nullptr;
::LinphoneCall *call = linphone_core_invite_address_with_params(this->lc, destination->address, params->params);
call = linphone_call_ref(call);
if (call != NULL) {
Linphone::Core::RefToPtrProxy<Linphone::Core::LinphoneCall^> *proxy = reinterpret_cast< Linphone::Core::RefToPtrProxy<Linphone::Core::LinphoneCall^> *>(linphone_call_get_user_pointer(call));
lCall = (proxy) ? proxy->Ref() : nullptr;
......@@ -1426,6 +1429,7 @@ void call_state_changed(::LinphoneCore *lc, ::LinphoneCall *call, ::LinphoneCall
Linphone::Core::RefToPtrProxy<Linphone::Core::LinphoneCall^> *proxy = reinterpret_cast< Linphone::Core::RefToPtrProxy<Linphone::Core::LinphoneCall^> *>(linphone_call_get_user_pointer(call));
Linphone::Core::LinphoneCall^ lCall = (proxy) ? proxy->Ref() : nullptr;
if (lCall == nullptr) {
call = linphone_call_ref(call);
lCall = (Linphone::Core::LinphoneCall^)Linphone::Core::Utils::CreateLinphoneCall(call);
}
......@@ -1573,7 +1577,7 @@ void message_received(LinphoneCore *lc, LinphoneChatRoom* chat_room, LinphoneCha
Linphone::Core::RefToPtrProxy<Linphone::Core::LinphoneChatMessage^> *proxy = reinterpret_cast< Linphone::Core::RefToPtrProxy<Linphone::Core::LinphoneChatMessage^> *>(linphone_chat_message_get_user_data(message));
Linphone::Core::LinphoneChatMessage^ lMessage = (proxy) ? proxy->Ref() : nullptr;
if (lMessage == nullptr) {
linphone_chat_message_ref(message);
message = linphone_chat_message_ref(message);
lMessage = (Linphone::Core::LinphoneChatMessage^)Linphone::Core::Utils::CreateLinphoneChatMessage(message);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment