1package eu.siacs.conversations.xmpp.jingle;
2
3import android.content.Context;
4import android.os.Build;
5import android.os.Handler;
6import android.os.Looper;
7import android.util.Log;
8
9import com.google.common.base.Optional;
10import com.google.common.base.Preconditions;
11import com.google.common.collect.ImmutableSet;
12import com.google.common.collect.Iterables;
13import com.google.common.util.concurrent.Futures;
14import com.google.common.util.concurrent.ListenableFuture;
15import com.google.common.util.concurrent.MoreExecutors;
16import com.google.common.util.concurrent.SettableFuture;
17
18import org.webrtc.AudioSource;
19import org.webrtc.AudioTrack;
20import org.webrtc.Camera1Enumerator;
21import org.webrtc.Camera2Enumerator;
22import org.webrtc.CameraEnumerationAndroid;
23import org.webrtc.CameraEnumerator;
24import org.webrtc.CameraVideoCapturer;
25import org.webrtc.CandidatePairChangeEvent;
26import org.webrtc.DataChannel;
27import org.webrtc.DefaultVideoDecoderFactory;
28import org.webrtc.DefaultVideoEncoderFactory;
29import org.webrtc.EglBase;
30import org.webrtc.IceCandidate;
31import org.webrtc.MediaConstraints;
32import org.webrtc.MediaStream;
33import org.webrtc.MediaStreamTrack;
34import org.webrtc.PeerConnection;
35import org.webrtc.PeerConnectionFactory;
36import org.webrtc.RtpReceiver;
37import org.webrtc.RtpTransceiver;
38import org.webrtc.SdpObserver;
39import org.webrtc.SessionDescription;
40import org.webrtc.SurfaceTextureHelper;
41import org.webrtc.VideoSource;
42import org.webrtc.VideoTrack;
43import org.webrtc.audio.JavaAudioDeviceModule;
44import org.webrtc.voiceengine.WebRtcAudioEffects;
45
46import java.util.ArrayList;
47import java.util.Collections;
48import java.util.List;
49import java.util.Set;
50
51import javax.annotation.Nonnull;
52import javax.annotation.Nullable;
53
54import eu.siacs.conversations.Config;
55import eu.siacs.conversations.services.AppRTCAudioManager;
56import eu.siacs.conversations.services.XmppConnectionService;
57
58public class WebRTCWrapper {
59
60 private static final String EXTENDED_LOGGING_TAG = WebRTCWrapper.class.getSimpleName();
61
62 //we should probably keep this in sync with: https://github.com/signalapp/Signal-Android/blob/master/app/src/main/java/org/thoughtcrime/securesms/ApplicationContext.java#L296
63 private static final Set<String> HARDWARE_AEC_BLACKLIST = new ImmutableSet.Builder<String>()
64 .add("Pixel")
65 .add("Pixel XL")
66 .add("Moto G5")
67 .add("Moto G (5S) Plus")
68 .add("Moto G4")
69 .add("TA-1053")
70 .add("Mi A1")
71 .add("Mi A2")
72 .add("E5823") // Sony z5 compact
73 .add("Redmi Note 5")
74 .add("FP2") // Fairphone FP2
75 .add("MI 5")
76 .build();
77
78 private static final int CAPTURING_RESOLUTION = 1920;
79 private static final int CAPTURING_MAX_FRAME_RATE = 30;
80
81 private final EventCallback eventCallback;
82 private final AppRTCAudioManager.AudioManagerEvents audioManagerEvents = new AppRTCAudioManager.AudioManagerEvents() {
83 @Override
84 public void onAudioDeviceChanged(AppRTCAudioManager.AudioDevice selectedAudioDevice, Set<AppRTCAudioManager.AudioDevice> availableAudioDevices) {
85 eventCallback.onAudioDeviceChanged(selectedAudioDevice, availableAudioDevices);
86 }
87 };
88 private final Handler mainHandler = new Handler(Looper.getMainLooper());
89 private VideoTrack localVideoTrack = null;
90 private VideoTrack remoteVideoTrack = null;
91 private final PeerConnection.Observer peerConnectionObserver = new PeerConnection.Observer() {
92 @Override
93 public void onSignalingChange(PeerConnection.SignalingState signalingState) {
94 Log.d(EXTENDED_LOGGING_TAG, "onSignalingChange(" + signalingState + ")");
95 //this is called after removeTrack or addTrack
96 //and should then trigger a content-add or content-remove or something
97 //https://developer.mozilla.org/en-US/docs/Web/API/RTCPeerConnection/removeTrack
98 }
99
100 @Override
101 public void onConnectionChange(final PeerConnection.PeerConnectionState newState) {
102 eventCallback.onConnectionChange(newState);
103 }
104
105 @Override
106 public void onIceConnectionChange(PeerConnection.IceConnectionState iceConnectionState) {
107 Log.d(EXTENDED_LOGGING_TAG, "onIceConnectionChange(" + iceConnectionState + ")");
108 }
109
110 @Override
111 public void onSelectedCandidatePairChanged(CandidatePairChangeEvent event) {
112 Log.d(Config.LOGTAG, "remote candidate selected: " + event.remote);
113 Log.d(Config.LOGTAG, "local candidate selected: " + event.local);
114 }
115
116 @Override
117 public void onIceConnectionReceivingChange(boolean b) {
118
119 }
120
121 @Override
122 public void onIceGatheringChange(PeerConnection.IceGatheringState iceGatheringState) {
123 Log.d(EXTENDED_LOGGING_TAG, "onIceGatheringChange(" + iceGatheringState + ")");
124 }
125
126 @Override
127 public void onIceCandidate(IceCandidate iceCandidate) {
128 eventCallback.onIceCandidate(iceCandidate);
129 }
130
131 @Override
132 public void onIceCandidatesRemoved(IceCandidate[] iceCandidates) {
133
134 }
135
136 @Override
137 public void onAddStream(MediaStream mediaStream) {
138 Log.d(EXTENDED_LOGGING_TAG, "onAddStream(numAudioTracks=" + mediaStream.audioTracks.size() + ",numVideoTracks=" + mediaStream.videoTracks.size() + ")");
139 }
140
141 @Override
142 public void onRemoveStream(MediaStream mediaStream) {
143
144 }
145
146 @Override
147 public void onDataChannel(DataChannel dataChannel) {
148
149 }
150
151 @Override
152 public void onRenegotiationNeeded() {
153 Log.d(EXTENDED_LOGGING_TAG, "onRenegotiationNeeded()");
154 final PeerConnection.PeerConnectionState currentState = peerConnection == null ? null : peerConnection.connectionState();
155 if (currentState != null && currentState != PeerConnection.PeerConnectionState.NEW) {
156 eventCallback.onRenegotiationNeeded();
157 }
158 }
159
160 @Override
161 public void onAddTrack(RtpReceiver rtpReceiver, MediaStream[] mediaStreams) {
162 final MediaStreamTrack track = rtpReceiver.track();
163 Log.d(EXTENDED_LOGGING_TAG, "onAddTrack(kind=" + (track == null ? "null" : track.kind()) + ",numMediaStreams=" + mediaStreams.length + ")");
164 if (track instanceof VideoTrack) {
165 remoteVideoTrack = (VideoTrack) track;
166 }
167 }
168
169 @Override
170 public void onTrack(RtpTransceiver transceiver) {
171 Log.d(EXTENDED_LOGGING_TAG, "onTrack(mid=" + transceiver.getMid() + ",media=" + transceiver.getMediaType() + ")");
172 }
173 };
174 @Nullable
175 private PeerConnection peerConnection = null;
176 private AudioTrack localAudioTrack = null;
177 private AppRTCAudioManager appRTCAudioManager = null;
178 private ToneManager toneManager = null;
179 private Context context = null;
180 private EglBase eglBase = null;
181 private CapturerChoice capturerChoice;
182
183 WebRTCWrapper(final EventCallback eventCallback) {
184 this.eventCallback = eventCallback;
185 }
186
187 private static void dispose(final PeerConnection peerConnection) {
188 try {
189 peerConnection.dispose();
190 } catch (final IllegalStateException e) {
191 Log.e(Config.LOGTAG, "unable to dispose of peer connection", e);
192 }
193 }
194
195 @Nullable
196 private static CapturerChoice of(CameraEnumerator enumerator, final String deviceName, Set<String> availableCameras) {
197 final CameraVideoCapturer capturer = enumerator.createCapturer(deviceName, null);
198 if (capturer == null) {
199 return null;
200 }
201 final ArrayList<CameraEnumerationAndroid.CaptureFormat> choices = new ArrayList<>(enumerator.getSupportedFormats(deviceName));
202 Collections.sort(choices, (a, b) -> b.width - a.width);
203 for (final CameraEnumerationAndroid.CaptureFormat captureFormat : choices) {
204 if (captureFormat.width <= CAPTURING_RESOLUTION) {
205 return new CapturerChoice(capturer, captureFormat, availableCameras);
206 }
207 }
208 return null;
209 }
210
211 private static boolean isFrontFacing(final CameraEnumerator cameraEnumerator, final String deviceName) {
212 try {
213 return cameraEnumerator.isFrontFacing(deviceName);
214 } catch (final NullPointerException e) {
215 return false;
216 }
217 }
218
219 public void setup(final XmppConnectionService service, final AppRTCAudioManager.SpeakerPhonePreference speakerPhonePreference) throws InitializationException {
220 try {
221 PeerConnectionFactory.initialize(
222 PeerConnectionFactory.InitializationOptions.builder(service).createInitializationOptions()
223 );
224 } catch (final UnsatisfiedLinkError e) {
225 throw new InitializationException("Unable to initialize PeerConnectionFactory", e);
226 }
227 try {
228 this.eglBase = EglBase.create();
229 } catch (final RuntimeException e) {
230 throw new InitializationException("Unable to create EGL base", e);
231 }
232 this.context = service;
233 this.toneManager = service.getJingleConnectionManager().toneManager;
234 mainHandler.post(() -> {
235 appRTCAudioManager = AppRTCAudioManager.create(service, speakerPhonePreference);
236 toneManager.setAppRtcAudioManagerHasControl(true);
237 appRTCAudioManager.start(audioManagerEvents);
238 eventCallback.onAudioDeviceChanged(appRTCAudioManager.getSelectedAudioDevice(), appRTCAudioManager.getAudioDevices());
239 });
240 }
241
242 synchronized void initializePeerConnection(final Set<Media> media, final List<PeerConnection.IceServer> iceServers) throws InitializationException {
243 Preconditions.checkState(this.eglBase != null);
244 Preconditions.checkNotNull(media);
245 Preconditions.checkArgument(media.size() > 0, "media can not be empty when initializing peer connection");
246 final boolean setUseHardwareAcousticEchoCanceler = WebRtcAudioEffects.canUseAcousticEchoCanceler() && !HARDWARE_AEC_BLACKLIST.contains(Build.MODEL);
247 Log.d(Config.LOGTAG, String.format("setUseHardwareAcousticEchoCanceler(%s) model=%s", setUseHardwareAcousticEchoCanceler, Build.MODEL));
248 PeerConnectionFactory peerConnectionFactory = PeerConnectionFactory.builder()
249 .setVideoDecoderFactory(new DefaultVideoDecoderFactory(eglBase.getEglBaseContext()))
250 .setVideoEncoderFactory(new DefaultVideoEncoderFactory(eglBase.getEglBaseContext(), true, true))
251 .setAudioDeviceModule(JavaAudioDeviceModule.builder(context)
252 .setUseHardwareAcousticEchoCanceler(setUseHardwareAcousticEchoCanceler)
253 .createAudioDeviceModule()
254 )
255 .createPeerConnectionFactory();
256
257
258 final PeerConnection.RTCConfiguration rtcConfig = new PeerConnection.RTCConfiguration(iceServers);
259 rtcConfig.tcpCandidatePolicy = PeerConnection.TcpCandidatePolicy.DISABLED; //XEP-0176 doesn't support tcp
260 rtcConfig.continualGatheringPolicy = PeerConnection.ContinualGatheringPolicy.GATHER_CONTINUALLY;
261 rtcConfig.sdpSemantics = PeerConnection.SdpSemantics.UNIFIED_PLAN;
262 rtcConfig.rtcpMuxPolicy = PeerConnection.RtcpMuxPolicy.NEGOTIATE;
263 final PeerConnection peerConnection = peerConnectionFactory.createPeerConnection(rtcConfig, peerConnectionObserver);
264 if (peerConnection == null) {
265 throw new InitializationException("Unable to create PeerConnection");
266 }
267
268 final Optional<CapturerChoice> optionalCapturerChoice = media.contains(Media.VIDEO) ? getVideoCapturer() : Optional.absent();
269
270 if (optionalCapturerChoice.isPresent()) {
271 this.capturerChoice = optionalCapturerChoice.get();
272 final CameraVideoCapturer capturer = this.capturerChoice.cameraVideoCapturer;
273 final VideoSource videoSource = peerConnectionFactory.createVideoSource(false);
274 SurfaceTextureHelper surfaceTextureHelper = SurfaceTextureHelper.create("webrtc", eglBase.getEglBaseContext());
275 capturer.initialize(surfaceTextureHelper, requireContext(), videoSource.getCapturerObserver());
276 Log.d(Config.LOGTAG, String.format("start capturing at %dx%d@%d", capturerChoice.captureFormat.width, capturerChoice.captureFormat.height, capturerChoice.getFrameRate()));
277 capturer.startCapture(capturerChoice.captureFormat.width, capturerChoice.captureFormat.height, capturerChoice.getFrameRate());
278
279 this.localVideoTrack = peerConnectionFactory.createVideoTrack("my-video-track", videoSource);
280
281 peerConnection.addTrack(this.localVideoTrack);
282 }
283
284
285 if (media.contains(Media.AUDIO)) {
286 //set up audio track
287 final AudioSource audioSource = peerConnectionFactory.createAudioSource(new MediaConstraints());
288 this.localAudioTrack = peerConnectionFactory.createAudioTrack("my-audio-track", audioSource);
289 peerConnection.addTrack(this.localAudioTrack);
290 }
291 peerConnection.setAudioPlayout(true);
292 peerConnection.setAudioRecording(true);
293 this.peerConnection = peerConnection;
294 }
295
296 void restartIce() {
297 requirePeerConnection().restartIce();
298 }
299
300 synchronized void close() {
301 final PeerConnection peerConnection = this.peerConnection;
302 final CapturerChoice capturerChoice = this.capturerChoice;
303 final AppRTCAudioManager audioManager = this.appRTCAudioManager;
304 final EglBase eglBase = this.eglBase;
305 if (peerConnection != null) {
306 dispose(peerConnection);
307 this.peerConnection = null;
308 }
309 if (audioManager != null) {
310 toneManager.setAppRtcAudioManagerHasControl(false);
311 mainHandler.post(audioManager::stop);
312 }
313 this.localVideoTrack = null;
314 this.remoteVideoTrack = null;
315 if (capturerChoice != null) {
316 try {
317 capturerChoice.cameraVideoCapturer.stopCapture();
318 } catch (InterruptedException e) {
319 Log.e(Config.LOGTAG, "unable to stop capturing");
320 }
321 }
322 if (eglBase != null) {
323 eglBase.release();
324 this.eglBase = null;
325 }
326 }
327
328 synchronized void verifyClosed() {
329 if (this.peerConnection != null
330 || this.eglBase != null
331 || this.localVideoTrack != null
332 || this.remoteVideoTrack != null) {
333 final IllegalStateException e = new IllegalStateException("WebRTCWrapper hasn't been closed properly");
334 Log.e(Config.LOGTAG, "verifyClosed() failed. Going to throw", e);
335 throw e;
336 }
337 }
338
339 boolean isCameraSwitchable() {
340 final CapturerChoice capturerChoice = this.capturerChoice;
341 return capturerChoice != null && capturerChoice.availableCameras.size() > 1;
342 }
343
344 boolean isFrontCamera() {
345 final CapturerChoice capturerChoice = this.capturerChoice;
346 return capturerChoice == null || capturerChoice.isFrontCamera;
347 }
348
349 ListenableFuture<Boolean> switchCamera() {
350 final CapturerChoice capturerChoice = this.capturerChoice;
351 if (capturerChoice == null) {
352 return Futures.immediateFailedFuture(new IllegalStateException("CameraCapturer has not been initialized"));
353 }
354 final SettableFuture<Boolean> future = SettableFuture.create();
355 capturerChoice.cameraVideoCapturer.switchCamera(new CameraVideoCapturer.CameraSwitchHandler() {
356 @Override
357 public void onCameraSwitchDone(boolean isFrontCamera) {
358 capturerChoice.isFrontCamera = isFrontCamera;
359 future.set(isFrontCamera);
360 }
361
362 @Override
363 public void onCameraSwitchError(final String message) {
364 future.setException(new IllegalStateException(String.format("Unable to switch camera %s", message)));
365 }
366 });
367 return future;
368 }
369
370 boolean isMicrophoneEnabled() {
371 final AudioTrack audioTrack = this.localAudioTrack;
372 if (audioTrack == null) {
373 throw new IllegalStateException("Local audio track does not exist (yet)");
374 }
375 try {
376 return audioTrack.enabled();
377 } catch (final IllegalStateException e) {
378 //sometimes UI might still be rendering the buttons when a background thread has already ended the call
379 return false;
380 }
381 }
382
383 boolean setMicrophoneEnabled(final boolean enabled) {
384 final AudioTrack audioTrack = this.localAudioTrack;
385 if (audioTrack == null) {
386 throw new IllegalStateException("Local audio track does not exist (yet)");
387 }
388 try {
389 audioTrack.setEnabled(enabled);
390 return true;
391 } catch (final IllegalStateException e) {
392 Log.d(Config.LOGTAG, "unable to toggle microphone", e);
393 //ignoring race condition in case MediaStreamTrack has been disposed
394 return false;
395 }
396 }
397
398 boolean isVideoEnabled() {
399 final VideoTrack videoTrack = this.localVideoTrack;
400 if (videoTrack == null) {
401 return false;
402 }
403 return videoTrack.enabled();
404 }
405
406 void setVideoEnabled(final boolean enabled) {
407 final VideoTrack videoTrack = this.localVideoTrack;
408 if (videoTrack == null) {
409 throw new IllegalStateException("Local video track does not exist");
410 }
411 videoTrack.setEnabled(enabled);
412 }
413
414 ListenableFuture<SessionDescription> setLocalDescription() {
415 return Futures.transformAsync(getPeerConnectionFuture(), peerConnection -> {
416 final SettableFuture<SessionDescription> future = SettableFuture.create();
417 peerConnection.setLocalDescription(new SetSdpObserver() {
418 @Override
419 public void onSetSuccess() {
420 final SessionDescription description = peerConnection.getLocalDescription();
421 Log.d(EXTENDED_LOGGING_TAG, "set local description:");
422 logDescription(description);
423 future.set(description);
424 }
425
426 @Override
427 public void onSetFailure(final String message) {
428 future.setException(new FailureToSetDescriptionException(message));
429 }
430 });
431 return future;
432 }, MoreExecutors.directExecutor());
433 }
434
435 private static void logDescription(final SessionDescription sessionDescription) {
436 for (final String line : sessionDescription.description.split(eu.siacs.conversations.xmpp.jingle.SessionDescription.LINE_DIVIDER)) {
437 Log.d(EXTENDED_LOGGING_TAG, line);
438 }
439 }
440
441 ListenableFuture<Void> setRemoteDescription(final SessionDescription sessionDescription) {
442 Log.d(EXTENDED_LOGGING_TAG, "setting remote description:");
443 logDescription(sessionDescription);
444 return Futures.transformAsync(getPeerConnectionFuture(), peerConnection -> {
445 final SettableFuture<Void> future = SettableFuture.create();
446 peerConnection.setRemoteDescription(new SetSdpObserver() {
447 @Override
448 public void onSetSuccess() {
449 future.set(null);
450 }
451
452 @Override
453 public void onSetFailure(final String message) {
454 future.setException(new FailureToSetDescriptionException(message));
455 }
456 }, sessionDescription);
457 return future;
458 }, MoreExecutors.directExecutor());
459 }
460
461 @Nonnull
462 private ListenableFuture<PeerConnection> getPeerConnectionFuture() {
463 final PeerConnection peerConnection = this.peerConnection;
464 if (peerConnection == null) {
465 return Futures.immediateFailedFuture(new IllegalStateException("initialize PeerConnection first"));
466 } else {
467 return Futures.immediateFuture(peerConnection);
468 }
469 }
470
471 void addIceCandidate(IceCandidate iceCandidate) {
472 requirePeerConnection().addIceCandidate(iceCandidate);
473 }
474
475 private Optional<CapturerChoice> getVideoCapturer() {
476 final CameraEnumerator enumerator = new Camera2Enumerator(requireContext());
477 final Set<String> deviceNames = ImmutableSet.copyOf(enumerator.getDeviceNames());
478 for (final String deviceName : deviceNames) {
479 if (isFrontFacing(enumerator, deviceName)) {
480 final CapturerChoice capturerChoice = of(enumerator, deviceName, deviceNames);
481 if (capturerChoice == null) {
482 return Optional.absent();
483 }
484 capturerChoice.isFrontCamera = true;
485 return Optional.of(capturerChoice);
486 }
487 }
488 if (deviceNames.size() == 0) {
489 return Optional.absent();
490 } else {
491 return Optional.fromNullable(of(enumerator, Iterables.get(deviceNames, 0), deviceNames));
492 }
493 }
494
495 public PeerConnection.PeerConnectionState getState() {
496 return requirePeerConnection().connectionState();
497 }
498
499 EglBase.Context getEglBaseContext() {
500 return this.eglBase.getEglBaseContext();
501 }
502
503 Optional<VideoTrack> getLocalVideoTrack() {
504 return Optional.fromNullable(this.localVideoTrack);
505 }
506
507 Optional<VideoTrack> getRemoteVideoTrack() {
508 return Optional.fromNullable(this.remoteVideoTrack);
509 }
510
511 private PeerConnection requirePeerConnection() {
512 final PeerConnection peerConnection = this.peerConnection;
513 if (peerConnection == null) {
514 throw new PeerConnectionNotInitialized();
515 }
516 return peerConnection;
517 }
518
519 private Context requireContext() {
520 final Context context = this.context;
521 if (context == null) {
522 throw new IllegalStateException("call setup first");
523 }
524 return context;
525 }
526
527 AppRTCAudioManager getAudioManager() {
528 return appRTCAudioManager;
529 }
530
531 public interface EventCallback {
532 void onIceCandidate(IceCandidate iceCandidate);
533
534 void onConnectionChange(PeerConnection.PeerConnectionState newState);
535
536 void onAudioDeviceChanged(AppRTCAudioManager.AudioDevice selectedAudioDevice, Set<AppRTCAudioManager.AudioDevice> availableAudioDevices);
537
538 void onRenegotiationNeeded();
539 }
540
541 private static abstract class SetSdpObserver implements SdpObserver {
542
543 @Override
544 public void onCreateSuccess(org.webrtc.SessionDescription sessionDescription) {
545 throw new IllegalStateException("Not able to use SetSdpObserver");
546 }
547
548 @Override
549 public void onCreateFailure(String s) {
550 throw new IllegalStateException("Not able to use SetSdpObserver");
551 }
552
553 }
554
555 private static abstract class CreateSdpObserver implements SdpObserver {
556
557
558 @Override
559 public void onSetSuccess() {
560 throw new IllegalStateException("Not able to use CreateSdpObserver");
561 }
562
563
564 @Override
565 public void onSetFailure(String s) {
566 throw new IllegalStateException("Not able to use CreateSdpObserver");
567 }
568 }
569
570 static class InitializationException extends Exception {
571
572 private InitializationException(final String message, final Throwable throwable) {
573 super(message, throwable);
574 }
575
576 private InitializationException(final String message) {
577 super(message);
578 }
579 }
580
581 public static class PeerConnectionNotInitialized extends IllegalStateException {
582
583 private PeerConnectionNotInitialized() {
584 super("initialize PeerConnection first");
585 }
586
587 }
588
589 private static class FailureToSetDescriptionException extends IllegalArgumentException {
590 public FailureToSetDescriptionException(String message) {
591 super(message);
592 }
593 }
594
595 private static class CapturerChoice {
596 private final CameraVideoCapturer cameraVideoCapturer;
597 private final CameraEnumerationAndroid.CaptureFormat captureFormat;
598 private final Set<String> availableCameras;
599 private boolean isFrontCamera = false;
600
601 CapturerChoice(CameraVideoCapturer cameraVideoCapturer, CameraEnumerationAndroid.CaptureFormat captureFormat, Set<String> cameras) {
602 this.cameraVideoCapturer = cameraVideoCapturer;
603 this.captureFormat = captureFormat;
604 this.availableCameras = cameras;
605 }
606
607 int getFrameRate() {
608 return Math.max(captureFormat.framerate.min, Math.min(CAPTURING_MAX_FRAME_RATE, captureFormat.framerate.max));
609 }
610 }
611}