CallParams.cpp 4.42 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13
/*
CallParams.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 "CallParams.h"
#include "Core.h"
#include "PayloadType.h"
20
#include "VideoSize.h"
21 22

using namespace Platform;
23
using namespace BelledonneCommunications::Linphone::Native;
24 25


26
int CallParams::AudioBandwidthLimit::get()
27 28 29 30 31 32
{
	// TODO
	throw ref new NotImplementedException();
	return 0;
}

33
void CallParams::AudioBandwidthLimit::set(int value)
34 35 36 37 38
{
	API_LOCK;
	linphone_call_params_set_audio_bandwidth_limit(this->params, value);
}

39
MediaDirection CallParams::AudioDirection::get()
40 41
{
	API_LOCK;
42
	return (MediaDirection) linphone_call_params_get_audio_direction(this->params);
43 44
}

45
void CallParams::AudioDirection::set(MediaDirection value)
46 47 48 49 50
{
	API_LOCK;
	linphone_call_params_set_audio_direction(this->params, (LinphoneMediaDirection)value);
}

51
Platform::Boolean CallParams::IsLowBandwidthEnabled::get()
52 53 54 55 56
{
	API_LOCK;
	return (linphone_call_params_low_bandwidth_enabled(this->params) == TRUE);
}

57
void CallParams::IsLowBandwidthEnabled::set(Platform::Boolean enable)
58 59 60 61 62
{
	API_LOCK;
	linphone_call_params_enable_low_bandwidth(this->params, enable);
}

63
Platform::Boolean CallParams::IsVideoEnabled::get()
64 65 66 67 68
{
	API_LOCK;
	return (linphone_call_params_video_enabled(this->params) == TRUE);
}

69
void CallParams::IsVideoEnabled::set(Platform::Boolean enable)
70 71 72 73 74
{
	API_LOCK;
	linphone_call_params_enable_video(this->params, enable);
}

75
MediaEncryption CallParams::MediaEncryption::get()
76 77
{
	API_LOCK;
78
	return (BelledonneCommunications::Linphone::Native::MediaEncryption) linphone_call_params_get_media_encryption(this->params);
79 80
}

81
void CallParams::MediaEncryption::set(BelledonneCommunications::Linphone::Native::MediaEncryption menc)
82 83 84 85 86
{
	API_LOCK;
	linphone_call_params_set_media_encryption(this->params, (LinphoneMediaEncryption) menc);
}

87
VideoSize^ CallParams::ReceivedVideoSize::get()
88 89 90
{
	API_LOCK;
	MSVideoSize vs = linphone_call_params_get_received_video_size(this->params);
91
	return ref new VideoSize(vs.width, vs.height);
92 93
}

94
VideoSize^ CallParams::SentVideoSize::get()
95 96 97
{
	API_LOCK;
	MSVideoSize vs = linphone_call_params_get_sent_video_size(this->params);
98
	return ref new VideoSize(vs.width, vs.height);
99 100
}

101
BelledonneCommunications::Linphone::Native::PayloadType^ CallParams::UsedAudioCodec::get()
102 103
{
	API_LOCK;
104
	PayloadType^ payloadType = nullptr;
105 106
	const ::PayloadType *pt = linphone_call_params_get_used_audio_codec(this->params);
	if (pt != nullptr) {
107
		payloadType = (PayloadType^) Utils::CreatePayloadType((void*)pt);
108 109 110 111
	}
	return payloadType;
}

112
BelledonneCommunications::Linphone::Native::PayloadType^ CallParams::UsedVideoCodec::get()
113 114
{
	API_LOCK;
115
	PayloadType^ payloadType = nullptr;
116 117
	const ::PayloadType *pt = linphone_call_params_get_used_video_codec(this->params);
	if (pt != nullptr) {
118
		payloadType = (PayloadType^) Utils::CreatePayloadType((void*)pt);
119 120 121 122
	}
	return payloadType;
}

123
MediaDirection CallParams::VideoDirection::get()
124 125
{
	API_LOCK;
126
	return (MediaDirection) linphone_call_params_get_video_direction(this->params);
127 128
}

129
void CallParams::VideoDirection::set(MediaDirection value)
130 131 132 133 134
{
	API_LOCK;
	linphone_call_params_set_video_direction(this->params, (LinphoneMediaDirection)value);
}

135
CallParams^ CallParams::Copy()
136
{
137
	::LinphoneCallParams *newParams = linphone_call_params_copy(this->params);
138
	return ref new CallParams(newParams);
139 140
}

141
CallParams::CallParams(::LinphoneCallParams *call_params)
142 143
	: params(call_params)
{
144 145 146 147
	API_LOCK;
	RefToPtrProxy<CallParams^> *proxy = new RefToPtrProxy<CallParams^>(this);
	linphone_call_params_ref(this->params);
	linphone_call_params_set_user_data(this->params, proxy);
148 149
}

150
CallParams::~CallParams()
151
{
152 153 154 155 156
	if (this->params != nullptr) {
		linphone_call_params_unref(this->params);
	}
	RefToPtrProxy<CallParams^> *proxy = reinterpret_cast< RefToPtrProxy<CallParams^> *>(linphone_call_params_get_user_data(this->params));
	delete proxy;
157
}