OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2014 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2014 The WebRTC Project Authors. All rights reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 private static final String DTLS_SRTP_KEY_AGREEMENT_CONSTRAINT = "DtlsSrtpKeyA
greement"; | 85 private static final String DTLS_SRTP_KEY_AGREEMENT_CONSTRAINT = "DtlsSrtpKeyA
greement"; |
86 private static final int HD_VIDEO_WIDTH = 1280; | 86 private static final int HD_VIDEO_WIDTH = 1280; |
87 private static final int HD_VIDEO_HEIGHT = 720; | 87 private static final int HD_VIDEO_HEIGHT = 720; |
88 private static final int BPS_IN_KBPS = 1000; | 88 private static final int BPS_IN_KBPS = 1000; |
89 | 89 |
90 private static final PeerConnectionClient instance = new PeerConnectionClient(
); | 90 private static final PeerConnectionClient instance = new PeerConnectionClient(
); |
91 private final PCObserver pcObserver = new PCObserver(); | 91 private final PCObserver pcObserver = new PCObserver(); |
92 private final SDPObserver sdpObserver = new SDPObserver(); | 92 private final SDPObserver sdpObserver = new SDPObserver(); |
93 private final ScheduledExecutorService executor; | 93 private final ScheduledExecutorService executor; |
94 | 94 |
95 private Context context; | |
96 private PeerConnectionFactory factory; | 95 private PeerConnectionFactory factory; |
97 private PeerConnection peerConnection; | 96 private PeerConnection peerConnection; |
98 PeerConnectionFactory.Options options = null; | 97 PeerConnectionFactory.Options options = null; |
99 private AudioSource audioSource; | 98 private AudioSource audioSource; |
100 private VideoSource videoSource; | 99 private VideoSource videoSource; |
101 private boolean videoCallEnabled; | 100 private boolean videoCallEnabled; |
102 private boolean preferIsac; | 101 private boolean preferIsac; |
103 private String preferredVideoCodec; | 102 private String preferredVideoCodec; |
104 private boolean videoCapturerStopped; | 103 private boolean videoCapturerStopped; |
105 private boolean isError; | 104 private boolean isError; |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
285 this.options = options; | 284 this.options = options; |
286 } | 285 } |
287 | 286 |
288 public void createPeerConnectionFactory(final Context context, | 287 public void createPeerConnectionFactory(final Context context, |
289 final PeerConnectionParameters peerConnectionParameters, final PeerConnect
ionEvents events) { | 288 final PeerConnectionParameters peerConnectionParameters, final PeerConnect
ionEvents events) { |
290 this.peerConnectionParameters = peerConnectionParameters; | 289 this.peerConnectionParameters = peerConnectionParameters; |
291 this.events = events; | 290 this.events = events; |
292 videoCallEnabled = peerConnectionParameters.videoCallEnabled; | 291 videoCallEnabled = peerConnectionParameters.videoCallEnabled; |
293 dataChannelEnabled = peerConnectionParameters.dataChannelParameters != null; | 292 dataChannelEnabled = peerConnectionParameters.dataChannelParameters != null; |
294 // Reset variables to initial states. | 293 // Reset variables to initial states. |
295 this.context = null; | |
296 factory = null; | 294 factory = null; |
297 peerConnection = null; | 295 peerConnection = null; |
298 preferIsac = false; | 296 preferIsac = false; |
299 videoCapturerStopped = false; | 297 videoCapturerStopped = false; |
300 isError = false; | 298 isError = false; |
301 queuedRemoteCandidates = null; | 299 queuedRemoteCandidates = null; |
302 localSdp = null; // either offer or answer SDP | 300 localSdp = null; // either offer or answer SDP |
303 mediaStream = null; | 301 mediaStream = null; |
304 videoCapturer = null; | 302 videoCapturer = null; |
305 renderVideo = true; | 303 renderVideo = true; |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
452 }); | 450 }); |
453 | 451 |
454 // Create peer connection factory. | 452 // Create peer connection factory. |
455 if (!PeerConnectionFactory.initializeAndroidGlobals( | 453 if (!PeerConnectionFactory.initializeAndroidGlobals( |
456 context, true, true, peerConnectionParameters.videoCodecHwAccelerati
on)) { | 454 context, true, true, peerConnectionParameters.videoCodecHwAccelerati
on)) { |
457 events.onPeerConnectionError("Failed to initializeAndroidGlobals"); | 455 events.onPeerConnectionError("Failed to initializeAndroidGlobals"); |
458 } | 456 } |
459 if (options != null) { | 457 if (options != null) { |
460 Log.d(TAG, "Factory networkIgnoreMask option: " + options.networkIgnoreMas
k); | 458 Log.d(TAG, "Factory networkIgnoreMask option: " + options.networkIgnoreMas
k); |
461 } | 459 } |
462 this.context = context; | |
463 factory = new PeerConnectionFactory(options); | 460 factory = new PeerConnectionFactory(options); |
464 Log.d(TAG, "Peer connection factory created."); | 461 Log.d(TAG, "Peer connection factory created."); |
465 } | 462 } |
466 | 463 |
467 private void createMediaConstraintsInternal() { | 464 private void createMediaConstraintsInternal() { |
468 // Create peer connection constraints. | 465 // Create peer connection constraints. |
469 pcConstraints = new MediaConstraints(); | 466 pcConstraints = new MediaConstraints(); |
470 // Enable DTLS for normal calls and disable for loopback calls. | 467 // Enable DTLS for normal calls and disable for loopback calls. |
471 if (peerConnectionParameters.loopback) { | 468 if (peerConnectionParameters.loopback) { |
472 pcConstraints.optional.add( | 469 pcConstraints.optional.add( |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
632 } | 629 } |
633 videoCapturerStopped = true; | 630 videoCapturerStopped = true; |
634 videoCapturer.dispose(); | 631 videoCapturer.dispose(); |
635 videoCapturer = null; | 632 videoCapturer = null; |
636 } | 633 } |
637 Log.d(TAG, "Closing video source."); | 634 Log.d(TAG, "Closing video source."); |
638 if (videoSource != null) { | 635 if (videoSource != null) { |
639 videoSource.dispose(); | 636 videoSource.dispose(); |
640 videoSource = null; | 637 videoSource = null; |
641 } | 638 } |
| 639 localRender = null; |
| 640 remoteRenders = null; |
642 Log.d(TAG, "Closing peer connection factory."); | 641 Log.d(TAG, "Closing peer connection factory."); |
643 if (factory != null) { | 642 if (factory != null) { |
644 factory.dispose(); | 643 factory.dispose(); |
645 factory = null; | 644 factory = null; |
646 } | 645 } |
647 options = null; | 646 options = null; |
648 Log.d(TAG, "Closing peer connection done."); | 647 Log.d(TAG, "Closing peer connection done."); |
649 events.onPeerConnectionClosed(); | 648 events.onPeerConnectionClosed(); |
650 PeerConnectionFactory.stopInternalTracingCapture(); | 649 PeerConnectionFactory.stopInternalTracingCapture(); |
651 PeerConnectionFactory.shutdownInternalTracer(); | 650 PeerConnectionFactory.shutdownInternalTracer(); |
| 651 events = null; |
652 } | 652 } |
653 | 653 |
654 public boolean isHDVideo() { | 654 public boolean isHDVideo() { |
655 if (!videoCallEnabled) { | 655 if (!videoCallEnabled) { |
656 return false; | 656 return false; |
657 } | 657 } |
658 | 658 |
659 return videoWidth * videoHeight >= 1280 * 720; | 659 return videoWidth * videoHeight >= 1280 * 720; |
660 } | 660 } |
661 | 661 |
(...skipping 617 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1279 public void onCreateFailure(final String error) { | 1279 public void onCreateFailure(final String error) { |
1280 reportError("createSDP error: " + error); | 1280 reportError("createSDP error: " + error); |
1281 } | 1281 } |
1282 | 1282 |
1283 @Override | 1283 @Override |
1284 public void onSetFailure(final String error) { | 1284 public void onSetFailure(final String error) { |
1285 reportError("setSDP error: " + error); | 1285 reportError("setSDP error: " + error); |
1286 } | 1286 } |
1287 } | 1287 } |
1288 } | 1288 } |
OLD | NEW |