Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(184)

Side by Side Diff: webrtc/examples/androidapp/src/org/appspot/apprtc/PeerConnectionClient.java

Issue 2117463002: Dispose audio source correctly in AppRTC Demo on Android. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
11 package org.appspot.apprtc; 11 package org.appspot.apprtc;
12 12
13 import org.appspot.apprtc.AppRTCClient.SignalingParameters;
14
13 import android.content.Context; 15 import android.content.Context;
16 import android.os.Environment;
14 import android.os.ParcelFileDescriptor; 17 import android.os.ParcelFileDescriptor;
15 import android.os.Environment;
16 import android.util.Log; 18 import android.util.Log;
17 19
18 import org.appspot.apprtc.AppRTCClient.SignalingParameters; 20 import org.webrtc.AudioSource;
19 import org.webrtc.AudioTrack; 21 import org.webrtc.AudioTrack;
20 import org.webrtc.CameraEnumerationAndroid; 22 import org.webrtc.CameraEnumerationAndroid;
21 import org.webrtc.DataChannel; 23 import org.webrtc.DataChannel;
22 import org.webrtc.EglBase; 24 import org.webrtc.EglBase;
23 import org.webrtc.IceCandidate; 25 import org.webrtc.IceCandidate;
24 import org.webrtc.Logging; 26 import org.webrtc.Logging;
25 import org.webrtc.MediaCodecVideoEncoder; 27 import org.webrtc.MediaCodecVideoEncoder;
26 import org.webrtc.MediaConstraints; 28 import org.webrtc.MediaConstraints;
27 import org.webrtc.MediaConstraints.KeyValuePair; 29 import org.webrtc.MediaConstraints.KeyValuePair;
28 import org.webrtc.MediaStream; 30 import org.webrtc.MediaStream;
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 private static final int MAX_VIDEO_FPS = 30; 91 private static final int MAX_VIDEO_FPS = 30;
90 92
91 private static final PeerConnectionClient instance = new PeerConnectionClient( ); 93 private static final PeerConnectionClient instance = new PeerConnectionClient( );
92 private final PCObserver pcObserver = new PCObserver(); 94 private final PCObserver pcObserver = new PCObserver();
93 private final SDPObserver sdpObserver = new SDPObserver(); 95 private final SDPObserver sdpObserver = new SDPObserver();
94 private final ScheduledExecutorService executor; 96 private final ScheduledExecutorService executor;
95 97
96 private PeerConnectionFactory factory; 98 private PeerConnectionFactory factory;
97 private PeerConnection peerConnection; 99 private PeerConnection peerConnection;
98 PeerConnectionFactory.Options options = null; 100 PeerConnectionFactory.Options options = null;
101 private AudioSource audioSource;
99 private VideoSource videoSource; 102 private VideoSource videoSource;
100 private boolean videoCallEnabled; 103 private boolean videoCallEnabled;
101 private boolean preferIsac; 104 private boolean preferIsac;
102 private String preferredVideoCodec; 105 private String preferredVideoCodec;
103 private boolean videoSourceStopped; 106 private boolean videoSourceStopped;
104 private boolean isError; 107 private boolean isError;
105 private Timer statsTimer; 108 private Timer statsTimer;
106 private VideoRenderer.Callbacks localRender; 109 private VideoRenderer.Callbacks localRender;
107 private VideoRenderer.Callbacks remoteRender; 110 private VideoRenderer.Callbacks remoteRender;
108 private SignalingParameters signalingParameters; 111 private SignalingParameters signalingParameters;
(...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after
535 private void closeInternal() { 538 private void closeInternal() {
536 if (factory != null && peerConnectionParameters.aecDump) { 539 if (factory != null && peerConnectionParameters.aecDump) {
537 factory.stopAecDump(); 540 factory.stopAecDump();
538 } 541 }
539 Log.d(TAG, "Closing peer connection."); 542 Log.d(TAG, "Closing peer connection.");
540 statsTimer.cancel(); 543 statsTimer.cancel();
541 if (peerConnection != null) { 544 if (peerConnection != null) {
542 peerConnection.dispose(); 545 peerConnection.dispose();
543 peerConnection = null; 546 peerConnection = null;
544 } 547 }
548 Log.d(TAG, "Closing audio source.");
549 if (audioSource != null) {
550 audioSource.dispose();
551 audioSource = null;
552 }
545 Log.d(TAG, "Closing video source."); 553 Log.d(TAG, "Closing video source.");
546 if (videoSource != null) { 554 if (videoSource != null) {
547 videoSource.dispose(); 555 videoSource.dispose();
548 videoSource = null; 556 videoSource = null;
549 } 557 }
550 Log.d(TAG, "Closing peer connection factory."); 558 Log.d(TAG, "Closing peer connection factory.");
551 if (factory != null) { 559 if (factory != null) {
552 factory.dispose(); 560 factory.dispose();
553 factory = null; 561 factory = null;
554 } 562 }
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
770 public void run() { 778 public void run() {
771 if (!isError) { 779 if (!isError) {
772 events.onPeerConnectionError(errorMessage); 780 events.onPeerConnectionError(errorMessage);
773 isError = true; 781 isError = true;
774 } 782 }
775 } 783 }
776 }); 784 });
777 } 785 }
778 786
779 private AudioTrack createAudioTrack() { 787 private AudioTrack createAudioTrack() {
780 localAudioTrack = factory.createAudioTrack( 788 audioSource = factory.createAudioSource(audioConstraints);
781 AUDIO_TRACK_ID, 789 localAudioTrack = factory.createAudioTrack(AUDIO_TRACK_ID, audioSource);
782 factory.createAudioSource(audioConstraints));
783 localAudioTrack.setEnabled(enableAudio); 790 localAudioTrack.setEnabled(enableAudio);
784 return localAudioTrack; 791 return localAudioTrack;
785 } 792 }
786 793
787 private VideoTrack createVideoTrack(VideoCapturerAndroid capturer) { 794 private VideoTrack createVideoTrack(VideoCapturerAndroid capturer) {
788 videoSource = factory.createVideoSource(capturer, videoConstraints); 795 videoSource = factory.createVideoSource(capturer, videoConstraints);
789 796
790 localVideoTrack = factory.createVideoTrack(VIDEO_TRACK_ID, videoSource); 797 localVideoTrack = factory.createVideoTrack(VIDEO_TRACK_ID, videoSource);
791 localVideoTrack.setEnabled(renderVideo); 798 localVideoTrack.setEnabled(renderVideo);
792 localVideoTrack.addRenderer(new VideoRenderer(localRender)); 799 localVideoTrack.addRenderer(new VideoRenderer(localRender));
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after
1142 public void onCreateFailure(final String error) { 1149 public void onCreateFailure(final String error) {
1143 reportError("createSDP error: " + error); 1150 reportError("createSDP error: " + error);
1144 } 1151 }
1145 1152
1146 @Override 1153 @Override
1147 public void onSetFailure(final String error) { 1154 public void onSetFailure(final String error) {
1148 reportError("setSDP error: " + error); 1155 reportError("setSDP error: " + error);
1149 } 1156 }
1150 } 1157 }
1151 } 1158 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698