1 /*
2 LinphoneCallParamsImpl.java
3 Copyright (C) 2010  Belledonne Communications, Grenoble, France
4 
5 This program is free software; you can redistribute it and/or
6 modify it under the terms of the GNU General Public License
7 as published by the Free Software Foundation; either version 2
8 of the License, or (at your option) any later version.
9 
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 GNU General Public License for more details.
14 
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
18 */
19 package org.linphone.core;
20 
21 import org.linphone.core.LinphoneCore.MediaDirection;
22 import org.linphone.core.LinphoneCore.MediaEncryption;
23 import org.linphone.core.LinphoneCore.StreamType;
24 
25 public class LinphoneCallParamsImpl implements LinphoneCallParams {
26 	protected final long nativePtr;
27 
LinphoneCallParamsImpl(long nativePtr)28 	public LinphoneCallParamsImpl(long nativePtr) {
29 		this.nativePtr = nativePtr;
30 	}
31 
enableVideo(long nativePtr, boolean b)32 	private native void enableVideo(long nativePtr, boolean b);
getVideoEnabled(long nativePtr)33 	private native boolean getVideoEnabled(long nativePtr);
audioBandwidth(long nativePtr, int bw)34 	private native void audioBandwidth(long nativePtr, int bw);
setMediaEncryption(long nativePtr, int menc)35 	private native void setMediaEncryption(long nativePtr, int menc);
getMediaEncryption(long nativePtr)36 	private native int getMediaEncryption(long nativePtr);
getUsedAudioCodec(long nativePtr)37 	private native long getUsedAudioCodec(long nativePtr);
getUsedVideoCodec(long nativePtr)38 	private native long getUsedVideoCodec(long nativePtr);
destroy(long nativePtr)39 	private native void destroy(long nativePtr);
enableLowBandwidth(long nativePtr, boolean enable)40 	private native void enableLowBandwidth(long nativePtr, boolean enable);
isLowBandwidthEnabled(long nativePtr)41 	private native boolean isLowBandwidthEnabled(long nativePtr);
42 
getVideoEnabled()43 	public boolean getVideoEnabled() {
44 		return getVideoEnabled(nativePtr);
45 	}
46 
setVideoEnabled(boolean b)47 	public void setVideoEnabled(boolean b) {
48 		enableVideo(nativePtr, b);
49 	}
50 
51 	@Override
finalize()52 	protected void finalize() throws Throwable {
53 		destroy(nativePtr);
54 		super.finalize();
55 	}
56 
setAudioBandwidth(int value)57 	public void setAudioBandwidth(int value) {
58 		audioBandwidth(nativePtr, value);
59 	}
60 
getMediaEncryption()61 	public MediaEncryption getMediaEncryption() {
62 		return MediaEncryption.fromInt(getMediaEncryption(nativePtr));
63 	}
64 
setMediaEnctyption(MediaEncryption menc)65 	public void setMediaEnctyption(MediaEncryption menc) {
66 		setMediaEncryption(nativePtr, menc.mValue);
67 	}
68 
getUsedAudioCodec()69 	public PayloadType getUsedAudioCodec() {
70 		long ptr = getUsedAudioCodec(nativePtr);
71 		if (ptr == 0) return null;
72 		return new PayloadTypeImpl(ptr);
73 	}
74 
getUsedVideoCodec()75 	public PayloadType getUsedVideoCodec() {
76 		long ptr = getUsedVideoCodec(nativePtr);
77 		if (ptr == 0) return null;
78 		return new PayloadTypeImpl(ptr);
79 	}
80 
localConferenceMode(long nativePtr)81 	private native boolean localConferenceMode(long nativePtr);
localConferenceMode()82 	public boolean localConferenceMode() {
83 		return localConferenceMode(nativePtr);
84 	}
85 
enableLowBandwidth(boolean enable)86 	public void enableLowBandwidth(boolean enable) {
87 		enableLowBandwidth(nativePtr, enable);
88 	}
89 
isLowBandwidthEnabled()90 	public boolean isLowBandwidthEnabled() {
91 		return isLowBandwidthEnabled(nativePtr);
92 	}
93 
setRecordFile(long nativePtr, String path)94 	private native void setRecordFile(long nativePtr, String path);
95 	@Override
setRecordFile(String path)96 	public void setRecordFile(String path) {
97 		setRecordFile(nativePtr,path);
98 	}
99 
addCustomHeader(long nativePtr, String name, String value)100 	private native void addCustomHeader(long nativePtr, String name, String value);
101 	@Override
addCustomHeader(String name, String value)102 	public void addCustomHeader(String name, String value) {
103 		addCustomHeader(nativePtr,name,value);
104 	}
105 
getCustomHeader(long nativePtr, String name)106 	private native String getCustomHeader(long nativePtr, String name);
107 	@Override
getCustomHeader(String name)108 	public String getCustomHeader(String name) {
109 		return getCustomHeader(nativePtr,name);
110 	}
111 
addCustomSdpAttribute(long nativePtr, String name, String value)112 	private native void addCustomSdpAttribute(long nativePtr, String name, String value);
113 	@Override
addCustomSdpAttribute(String name, String value)114 	public void addCustomSdpAttribute(String name, String value) {
115 		addCustomSdpAttribute(nativePtr, name, value);
116 	}
117 
addCustomSdpMediaAttribute(long nativePtr, int type, String name, String value)118 	private native void addCustomSdpMediaAttribute(long nativePtr, int type, String name, String value);
119 	@Override
addCustomSdpMediaAttribute(StreamType type, String name, String value)120 	public void addCustomSdpMediaAttribute(StreamType type, String name, String value) {
121 		addCustomSdpMediaAttribute(nativePtr, type.mValue, name, value);
122 	}
123 
getCustomSdpAttribute(long nativePtr, String name)124 	private native String getCustomSdpAttribute(long nativePtr, String name);
125 	@Override
getCustomSdpAttribute(String name)126 	public String getCustomSdpAttribute(String name) {
127 		return getCustomSdpAttribute(nativePtr, name);
128 	}
129 
getCustomSdpMediaAttribute(long nativePtr, int type, String name)130 	private native String getCustomSdpMediaAttribute(long nativePtr, int type, String name);
131 	@Override
getCustomSdpMediaAttribute(StreamType type, String name)132 	public String getCustomSdpMediaAttribute(StreamType type, String name) {
133 		return getCustomSdpMediaAttribute(nativePtr, type.mValue, name);
134 	}
135 
clearCustomSdpAttributes(long nativePtr)136 	private native void clearCustomSdpAttributes(long nativePtr);
137 	@Override
clearCustomSdpAttributes()138 	public void clearCustomSdpAttributes() {
139 		clearCustomSdpAttributes(nativePtr);
140 	}
141 
clearCustomSdpMediaAttributes(long nativePtr, int type)142 	private native void clearCustomSdpMediaAttributes(long nativePtr, int type);
143 	@Override
clearCustomSdpMediaAttributes(StreamType type)144 	public void clearCustomSdpMediaAttributes(StreamType type) {
145 		clearCustomSdpMediaAttributes(nativePtr, type.mValue);
146 	}
147 
setPrivacy(long nativePtr, int mask)148 	private native void setPrivacy(long nativePtr, int mask);
149 	@Override
setPrivacy(int privacy_mask)150 	public void setPrivacy(int privacy_mask) {
151 		setPrivacy(nativePtr,privacy_mask);
152 	}
153 
getPrivacy(long nativePtr)154 	private native int getPrivacy(long nativePtr);
155 	@Override
getPrivacy()156 	public int getPrivacy() {
157 		return getPrivacy(nativePtr);
158 	}
159 
setSessionName(long nativePtr, String name)160 	private native void setSessionName(long nativePtr, String name);
161 	@Override
setSessionName(String name)162 	public void setSessionName(String name) {
163 		setSessionName(nativePtr,name);
164 	}
165 
getSessionName(long nativePtr)166 	private native String getSessionName(long nativePtr);
167 	@Override
getSessionName()168 	public String getSessionName() {
169 		return getSessionName(nativePtr);
170 	}
171 
getSentVideoSize(long nativePtr)172 	private native int[] getSentVideoSize(long nativePtr);
173 	@Override
getSentVideoSize()174 	public VideoSize getSentVideoSize() {
175 		int[] nativeSize = getSentVideoSize(nativePtr);
176 		VideoSize vSize = new VideoSize();
177 		vSize.width = nativeSize[0];
178 		vSize.height = nativeSize[1];
179 		return vSize;
180 	}
181 
getReceivedVideoSize(long nativePtr)182 	private native int[] getReceivedVideoSize(long nativePtr);
183 	@Override
getReceivedVideoSize()184 	public VideoSize getReceivedVideoSize() {
185 		int[] nativeSize = getReceivedVideoSize(nativePtr);
186 		VideoSize vSize = new VideoSize();
187 		vSize.width = nativeSize[0];
188 		vSize.height = nativeSize[1];
189 		return vSize;
190 	}
enableAudioMulticast(long ptr,boolean yesno)191 	private native void enableAudioMulticast(long ptr,boolean yesno);
192 	@Override
enableAudioMulticast(boolean yesno)193 	public void enableAudioMulticast(boolean yesno) {
194 		enableAudioMulticast(nativePtr,yesno);
195 	}
audioMulticastEnabled(long ptr)196 	private native boolean audioMulticastEnabled(long ptr);
197 	@Override
audioMulticastEnabled()198 	public boolean audioMulticastEnabled() {
199 		return audioMulticastEnabled(nativePtr);
200 	}
enableVideoMulticast(long ptr,boolean yesno)201 	private native void enableVideoMulticast(long ptr,boolean yesno);
202 
203 	@Override
enableVideoMulticast(boolean yesno)204 	public void enableVideoMulticast(boolean yesno) {
205 		enableVideoMulticast(nativePtr,yesno);
206 	}
videoMulticastEnabled(long ptr)207 	private native boolean videoMulticastEnabled(long ptr);
208 	@Override
videoMulticastEnabled()209 	public boolean videoMulticastEnabled() {
210 		return videoMulticastEnabled(nativePtr);
211 	}
212 
enableRealTimeText(long nativePtr, boolean yesno)213 	private native void enableRealTimeText(long nativePtr, boolean yesno);
214 	@Override
enableRealTimeText(boolean yesno)215 	public void enableRealTimeText(boolean yesno) {
216 		enableRealTimeText(nativePtr, yesno);
217 	}
218 
realTimeTextEnabled(long nativePtr)219 	private native boolean realTimeTextEnabled(long nativePtr);
220 	@Override
realTimeTextEnabled()221 	public boolean realTimeTextEnabled() {
222 		return realTimeTextEnabled(nativePtr);
223 	}
224 
getAudioDirection(long nativePtr)225 	private native int getAudioDirection(long nativePtr);
226 	@Override
getAudioDirection()227 	public MediaDirection getAudioDirection() {
228 		return MediaDirection.fromInt(getAudioDirection(nativePtr));
229 	}
230 
getVideoDirection(long nativePtr)231 	private native int getVideoDirection(long nativePtr);
232 	@Override
getVideoDirection()233 	public MediaDirection getVideoDirection() {
234 		return MediaDirection.fromInt(getVideoDirection(nativePtr));
235 	}
236 
setAudioDirection(long nativePtr, int direction)237 	private native void setAudioDirection(long nativePtr, int direction);
238 	@Override
setAudioDirection(MediaDirection direction)239 	public void setAudioDirection(MediaDirection direction) {
240 		setAudioDirection(nativePtr, direction.mValue);
241 	}
242 
setVideoDirection(long nativePtr, int direction)243 	private native void setVideoDirection(long nativePtr, int direction);
244 	@Override
setVideoDirection(MediaDirection direction)245 	public void setVideoDirection(MediaDirection direction) {
246 		setVideoDirection(nativePtr, direction.mValue);
247 	}
248 
getSentFramerate(long nativePtr)249 	private native float getSentFramerate(long nativePtr);
250 	@Override
getSentFramerate()251 	public float getSentFramerate() {
252 		return getSentFramerate(nativePtr);
253 	}
254 
getReceivedFramerate(long nativePtr)255 	private native float getReceivedFramerate(long nativePtr);
256 	@Override
getReceivedFramerate()257 	public float getReceivedFramerate() {
258 		return getReceivedFramerate(nativePtr);
259 	}
260 }
261