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 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 this.audioCodec = audioCodec; | 167 this.audioCodec = audioCodec; |
168 this.noAudioProcessing = noAudioProcessing; | 168 this.noAudioProcessing = noAudioProcessing; |
169 this.aecDump = aecDump; | 169 this.aecDump = aecDump; |
170 this.useOpenSLES = useOpenSLES; | 170 this.useOpenSLES = useOpenSLES; |
171 } | 171 } |
172 } | 172 } |
173 | 173 |
174 /** | 174 /** |
175 * Peer connection events. | 175 * Peer connection events. |
176 */ | 176 */ |
177 public static interface PeerConnectionEvents { | 177 public interface PeerConnectionEvents { |
178 /** | 178 /** |
179 * Callback fired once local SDP is created and set. | 179 * Callback fired once local SDP is created and set. |
180 */ | 180 */ |
181 public void onLocalDescription(final SessionDescription sdp); | 181 void onLocalDescription(final SessionDescription sdp); |
182 | 182 |
183 /** | 183 /** |
184 * Callback fired once local Ice candidate is generated. | 184 * Callback fired once local Ice candidate is generated. |
185 */ | 185 */ |
186 public void onIceCandidate(final IceCandidate candidate); | 186 void onIceCandidate(final IceCandidate candidate); |
187 | 187 |
188 /** | 188 /** |
189 * Callback fired once local ICE candidates are removed. | 189 * Callback fired once local ICE candidates are removed. |
190 */ | 190 */ |
191 public void onIceCandidatesRemoved(final IceCandidate[] candidates); | 191 void onIceCandidatesRemoved(final IceCandidate[] candidates); |
192 | 192 |
193 /** | 193 /** |
194 * Callback fired once connection is established (IceConnectionState is | 194 * Callback fired once connection is established (IceConnectionState is |
195 * CONNECTED). | 195 * CONNECTED). |
196 */ | 196 */ |
197 public void onIceConnected(); | 197 void onIceConnected(); |
198 | 198 |
199 /** | 199 /** |
200 * Callback fired once connection is closed (IceConnectionState is | 200 * Callback fired once connection is closed (IceConnectionState is |
201 * DISCONNECTED). | 201 * DISCONNECTED). |
202 */ | 202 */ |
203 public void onIceDisconnected(); | 203 void onIceDisconnected(); |
204 | 204 |
205 /** | 205 /** |
206 * Callback fired once peer connection is closed. | 206 * Callback fired once peer connection is closed. |
207 */ | 207 */ |
208 public void onPeerConnectionClosed(); | 208 void onPeerConnectionClosed(); |
209 | 209 |
210 /** | 210 /** |
211 * Callback fired once peer connection statistics is ready. | 211 * Callback fired once peer connection statistics is ready. |
212 */ | 212 */ |
213 public void onPeerConnectionStatsReady(final StatsReport[] reports); | 213 void onPeerConnectionStatsReady(final StatsReport[] reports); |
214 | 214 |
215 /** | 215 /** |
216 * Callback fired once peer connection error happened. | 216 * Callback fired once peer connection error happened. |
217 */ | 217 */ |
218 public void onPeerConnectionError(final String description); | 218 void onPeerConnectionError(final String description); |
219 } | 219 } |
220 | 220 |
221 private PeerConnectionClient() { | 221 private PeerConnectionClient() { |
222 executor = new LooperExecutor(); | 222 executor = new LooperExecutor(); |
223 // Looper thread is started once in private ctor and is used for all | 223 // Looper thread is started once in private ctor and is used for all |
224 // peer connection API calls to ensure new peer connection factory is | 224 // peer connection API calls to ensure new peer connection factory is |
225 // created on the same thread as previously destroyed factory. | 225 // created on the same thread as previously destroyed factory. |
226 executor.requestStart(); | 226 executor.requestStart(); |
227 } | 227 } |
228 | 228 |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
319 if (videoCallEnabled && peerConnectionParameters.videoCodec != null) { | 319 if (videoCallEnabled && peerConnectionParameters.videoCodec != null) { |
320 if (peerConnectionParameters.videoCodec.equals(VIDEO_CODEC_VP9)) { | 320 if (peerConnectionParameters.videoCodec.equals(VIDEO_CODEC_VP9)) { |
321 preferredVideoCodec = VIDEO_CODEC_VP9; | 321 preferredVideoCodec = VIDEO_CODEC_VP9; |
322 } else if (peerConnectionParameters.videoCodec.equals(VIDEO_CODEC_H264)) { | 322 } else if (peerConnectionParameters.videoCodec.equals(VIDEO_CODEC_H264)) { |
323 preferredVideoCodec = VIDEO_CODEC_H264; | 323 preferredVideoCodec = VIDEO_CODEC_H264; |
324 } | 324 } |
325 } | 325 } |
326 Log.d(TAG, "Pereferred video codec: " + preferredVideoCodec); | 326 Log.d(TAG, "Pereferred video codec: " + preferredVideoCodec); |
327 | 327 |
328 // Check if ISAC is used by default. | 328 // Check if ISAC is used by default. |
329 preferIsac = false; | 329 preferIsac = peerConnectionParameters.audioCodec != null |
330 if (peerConnectionParameters.audioCodec != null | 330 && peerConnectionParameters.audioCodec.equals(AUDIO_CODEC_ISAC); |
331 && peerConnectionParameters.audioCodec.equals(AUDIO_CODEC_ISAC)) { | |
332 preferIsac = true; | |
333 } | |
334 | 331 |
335 // Enable/disable OpenSL ES playback. | 332 // Enable/disable OpenSL ES playback. |
336 if (!peerConnectionParameters.useOpenSLES) { | 333 if (!peerConnectionParameters.useOpenSLES) { |
337 Log.d(TAG, "Disable OpenSL ES audio even if device supports it"); | 334 Log.d(TAG, "Disable OpenSL ES audio even if device supports it"); |
338 WebRtcAudioManager.setBlacklistDeviceForOpenSLESUsage(true /* enable */); | 335 WebRtcAudioManager.setBlacklistDeviceForOpenSLESUsage(true /* enable */); |
339 } else { | 336 } else { |
340 Log.d(TAG, "Allow OpenSL ES audio if device supports it"); | 337 Log.d(TAG, "Allow OpenSL ES audio if device supports it"); |
341 WebRtcAudioManager.setBlacklistDeviceForOpenSLESUsage(false); | 338 WebRtcAudioManager.setBlacklistDeviceForOpenSLESUsage(false); |
342 } | 339 } |
343 | 340 |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
495 } | 492 } |
496 mediaStream.addTrack(createVideoTrack(videoCapturer)); | 493 mediaStream.addTrack(createVideoTrack(videoCapturer)); |
497 } | 494 } |
498 | 495 |
499 mediaStream.addTrack(createAudioTrack()); | 496 mediaStream.addTrack(createAudioTrack()); |
500 peerConnection.addStream(mediaStream); | 497 peerConnection.addStream(mediaStream); |
501 | 498 |
502 if (peerConnectionParameters.aecDump) { | 499 if (peerConnectionParameters.aecDump) { |
503 try { | 500 try { |
504 aecDumpFileDescriptor = ParcelFileDescriptor.open( | 501 aecDumpFileDescriptor = ParcelFileDescriptor.open( |
505 new File("/sdcard/Download/audio.aecdump"), | 502 new File(Environment.getExternalStorageDirectory().getPath() |
| 503 + "Download/audio.aecdump"), |
506 ParcelFileDescriptor.MODE_READ_WRITE | | 504 ParcelFileDescriptor.MODE_READ_WRITE | |
507 ParcelFileDescriptor.MODE_CREATE | | 505 ParcelFileDescriptor.MODE_CREATE | |
508 ParcelFileDescriptor.MODE_TRUNCATE); | 506 ParcelFileDescriptor.MODE_TRUNCATE); |
509 factory.startAecDump(aecDumpFileDescriptor.getFd(), -1); | 507 factory.startAecDump(aecDumpFileDescriptor.getFd(), -1); |
510 } catch(IOException e) { | 508 } catch(IOException e) { |
511 Log.e(TAG, "Can not open aecdump file", e); | 509 Log.e(TAG, "Can not open aecdump file", e); |
512 } | 510 } |
513 } | 511 } |
514 | 512 |
515 Log.d(TAG, "Peer connection created."); | 513 Log.d(TAG, "Peer connection created."); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
556 Log.e(TAG, "Can not parse video width from video constraints"); | 554 Log.e(TAG, "Can not parse video width from video constraints"); |
557 } | 555 } |
558 } else if (keyValuePair.getKey().equals("minHeight")) { | 556 } else if (keyValuePair.getKey().equals("minHeight")) { |
559 try { | 557 try { |
560 minHeight = Integer.parseInt(keyValuePair.getValue()); | 558 minHeight = Integer.parseInt(keyValuePair.getValue()); |
561 } catch (NumberFormatException e) { | 559 } catch (NumberFormatException e) { |
562 Log.e(TAG, "Can not parse video height from video constraints"); | 560 Log.e(TAG, "Can not parse video height from video constraints"); |
563 } | 561 } |
564 } | 562 } |
565 } | 563 } |
566 if (minWidth * minHeight >= 1280 * 720) { | 564 return minWidth * minHeight >= 1280 * 720; |
567 return true; | |
568 } else { | |
569 return false; | |
570 } | |
571 } | 565 } |
572 | 566 |
573 private void getStats() { | 567 private void getStats() { |
574 if (peerConnection == null || isError) { | 568 if (peerConnection == null || isError) { |
575 return; | 569 return; |
576 } | 570 } |
577 boolean success = peerConnection.getStats(new StatsObserver() { | 571 boolean success = peerConnection.getStats(new StatsObserver() { |
578 @Override | 572 @Override |
579 public void onComplete(final StatsReport[] reports) { | 573 public void onComplete(final StatsReport[] reports) { |
580 events.onPeerConnectionStatsReady(reports); | 574 events.onPeerConnectionStatsReady(reports); |
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
861 } | 855 } |
862 for (int i = 0; (i < lines.length) | 856 for (int i = 0; (i < lines.length) |
863 && (mLineIndex == -1 || codecRtpMap == null); i++) { | 857 && (mLineIndex == -1 || codecRtpMap == null); i++) { |
864 if (lines[i].startsWith(mediaDescription)) { | 858 if (lines[i].startsWith(mediaDescription)) { |
865 mLineIndex = i; | 859 mLineIndex = i; |
866 continue; | 860 continue; |
867 } | 861 } |
868 Matcher codecMatcher = codecPattern.matcher(lines[i]); | 862 Matcher codecMatcher = codecPattern.matcher(lines[i]); |
869 if (codecMatcher.matches()) { | 863 if (codecMatcher.matches()) { |
870 codecRtpMap = codecMatcher.group(1); | 864 codecRtpMap = codecMatcher.group(1); |
871 continue; | |
872 } | 865 } |
873 } | 866 } |
874 if (mLineIndex == -1) { | 867 if (mLineIndex == -1) { |
875 Log.w(TAG, "No " + mediaDescription + " line, so can't prefer " + codec); | 868 Log.w(TAG, "No " + mediaDescription + " line, so can't prefer " + codec); |
876 return sdpDescription; | 869 return sdpDescription; |
877 } | 870 } |
878 if (codecRtpMap == null) { | 871 if (codecRtpMap == null) { |
879 Log.w(TAG, "No rtpmap for " + codec); | 872 Log.w(TAG, "No rtpmap for " + codec); |
880 return sdpDescription; | 873 return sdpDescription; |
881 } | 874 } |
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1130 public void onCreateFailure(final String error) { | 1123 public void onCreateFailure(final String error) { |
1131 reportError("createSDP error: " + error); | 1124 reportError("createSDP error: " + error); |
1132 } | 1125 } |
1133 | 1126 |
1134 @Override | 1127 @Override |
1135 public void onSetFailure(final String error) { | 1128 public void onSetFailure(final String error) { |
1136 reportError("setSDP error: " + error); | 1129 reportError("setSDP error: " + error); |
1137 } | 1130 } |
1138 } | 1131 } |
1139 } | 1132 } |
OLD | NEW |