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 |
11 package org.appspot.apprtc; | 11 package org.appspot.apprtc; |
12 | 12 |
13 import android.content.Context; | 13 import android.content.Context; |
14 import android.os.Environment; | 14 import android.os.Environment; |
15 import android.os.ParcelFileDescriptor; | 15 import android.os.ParcelFileDescriptor; |
16 import android.util.Log; | 16 import android.util.Log; |
17 import java.io.File; | 17 import java.io.File; |
18 import java.io.IOException; | 18 import java.io.IOException; |
19 import java.nio.ByteBuffer; | 19 import java.nio.ByteBuffer; |
20 import java.util.ArrayList; | 20 import java.util.ArrayList; |
21 import java.util.Arrays; | 21 import java.util.Arrays; |
22 import java.util.Collections; | 22 import java.util.Collections; |
23 import java.util.EnumSet; | 23 import java.util.EnumSet; |
24 import java.util.Iterator; | 24 import java.util.Iterator; |
25 import java.util.LinkedList; | 25 import java.util.LinkedList; |
26 import java.util.List; | 26 import java.util.List; |
27 import java.util.Timer; | 27 import java.util.Timer; |
28 import java.util.TimerTask; | 28 import java.util.TimerTask; |
| 29 import java.util.concurrent.ExecutorService; |
29 import java.util.concurrent.Executors; | 30 import java.util.concurrent.Executors; |
30 import java.util.concurrent.ExecutorService; | |
31 import java.util.regex.Matcher; | 31 import java.util.regex.Matcher; |
32 import java.util.regex.Pattern; | 32 import java.util.regex.Pattern; |
33 import org.appspot.apprtc.AppRTCClient.SignalingParameters; | 33 import org.appspot.apprtc.AppRTCClient.SignalingParameters; |
34 import org.webrtc.AudioSource; | 34 import org.webrtc.AudioSource; |
35 import org.webrtc.AudioTrack; | 35 import org.webrtc.AudioTrack; |
36 import org.webrtc.CameraVideoCapturer; | 36 import org.webrtc.CameraVideoCapturer; |
37 import org.webrtc.DataChannel; | 37 import org.webrtc.DataChannel; |
38 import org.webrtc.EglBase; | 38 import org.webrtc.EglBase; |
39 import org.webrtc.IceCandidate; | 39 import org.webrtc.IceCandidate; |
40 import org.webrtc.Logging; | 40 import org.webrtc.Logging; |
41 import org.webrtc.MediaConstraints; | 41 import org.webrtc.MediaConstraints; |
42 import org.webrtc.MediaStream; | 42 import org.webrtc.MediaStream; |
43 import org.webrtc.PeerConnection; | 43 import org.webrtc.PeerConnection; |
44 import org.webrtc.PeerConnection.IceConnectionState; | 44 import org.webrtc.PeerConnection.IceConnectionState; |
45 import org.webrtc.PeerConnectionFactory; | 45 import org.webrtc.PeerConnectionFactory; |
46 import org.webrtc.RtpParameters; | 46 import org.webrtc.RtpParameters; |
47 import org.webrtc.RtpReceiver; | 47 import org.webrtc.RtpReceiver; |
48 import org.webrtc.RtpSender; | 48 import org.webrtc.RtpSender; |
49 import org.webrtc.SdpObserver; | 49 import org.webrtc.SdpObserver; |
50 import org.webrtc.SessionDescription; | 50 import org.webrtc.SessionDescription; |
51 import org.webrtc.StatsObserver; | 51 import org.webrtc.StatsObserver; |
52 import org.webrtc.StatsReport; | 52 import org.webrtc.StatsReport; |
53 import org.webrtc.VideoCapturer; | 53 import org.webrtc.VideoCapturer; |
54 import org.webrtc.VideoRenderer; | 54 import org.webrtc.VideoRenderer; |
55 import org.webrtc.VideoSource; | 55 import org.webrtc.VideoSource; |
56 import org.webrtc.VideoTrack; | 56 import org.webrtc.VideoTrack; |
57 import org.webrtc.voiceengine.WebRtcAudioManager; | 57 import org.webrtc.voiceengine.WebRtcAudioManager; |
58 import org.webrtc.voiceengine.WebRtcAudioRecord; | 58 import org.webrtc.voiceengine.WebRtcAudioRecord; |
59 import org.webrtc.voiceengine.WebRtcAudioTrack; | |
60 import org.webrtc.voiceengine.WebRtcAudioRecord.AudioRecordStartErrorCode; | 59 import org.webrtc.voiceengine.WebRtcAudioRecord.AudioRecordStartErrorCode; |
61 import org.webrtc.voiceengine.WebRtcAudioRecord.WebRtcAudioRecordErrorCallback; | 60 import org.webrtc.voiceengine.WebRtcAudioRecord.WebRtcAudioRecordErrorCallback; |
| 61 import org.webrtc.voiceengine.WebRtcAudioTrack; |
62 import org.webrtc.voiceengine.WebRtcAudioTrack.WebRtcAudioTrackErrorCallback; | 62 import org.webrtc.voiceengine.WebRtcAudioTrack.WebRtcAudioTrackErrorCallback; |
63 import org.webrtc.voiceengine.WebRtcAudioUtils; | 63 import org.webrtc.voiceengine.WebRtcAudioUtils; |
64 | 64 |
65 /** | 65 /** |
66 * Peer connection client implementation. | 66 * Peer connection client implementation. |
67 * | 67 * |
68 * <p>All public methods are routed to local looper thread. | 68 * <p>All public methods are routed to local looper thread. |
69 * All PeerConnectionEvents callbacks are invoked from the same looper thread. | 69 * All PeerConnectionEvents callbacks are invoked from the same looper thread. |
70 * This class is a singleton. | 70 * This class is a singleton. |
71 */ | 71 */ |
(...skipping 10 matching lines...) Expand all Loading... |
82 private static final String AUDIO_CODEC_OPUS = "opus"; | 82 private static final String AUDIO_CODEC_OPUS = "opus"; |
83 private static final String AUDIO_CODEC_ISAC = "ISAC"; | 83 private static final String AUDIO_CODEC_ISAC = "ISAC"; |
84 private static final String VIDEO_CODEC_PARAM_START_BITRATE = "x-google-start-
bitrate"; | 84 private static final String VIDEO_CODEC_PARAM_START_BITRATE = "x-google-start-
bitrate"; |
85 private static final String VIDEO_FLEXFEC_FIELDTRIAL = | 85 private static final String VIDEO_FLEXFEC_FIELDTRIAL = |
86 "WebRTC-FlexFEC-03-Advertised/Enabled/WebRTC-FlexFEC-03/Enabled/"; | 86 "WebRTC-FlexFEC-03-Advertised/Enabled/WebRTC-FlexFEC-03/Enabled/"; |
87 private static final String VIDEO_VP8_INTEL_HW_ENCODER_FIELDTRIAL = "WebRTC-In
telVP8/Enabled/"; | 87 private static final String VIDEO_VP8_INTEL_HW_ENCODER_FIELDTRIAL = "WebRTC-In
telVP8/Enabled/"; |
88 private static final String VIDEO_H264_HIGH_PROFILE_FIELDTRIAL = | 88 private static final String VIDEO_H264_HIGH_PROFILE_FIELDTRIAL = |
89 "WebRTC-H264HighProfile/Enabled/"; | 89 "WebRTC-H264HighProfile/Enabled/"; |
90 private static final String DISABLE_WEBRTC_AGC_FIELDTRIAL = | 90 private static final String DISABLE_WEBRTC_AGC_FIELDTRIAL = |
91 "WebRTC-Audio-MinimizeResamplingOnMobile/Enabled/"; | 91 "WebRTC-Audio-MinimizeResamplingOnMobile/Enabled/"; |
| 92 private static final String VIDEO_FRAME_EMIT_FIELDTRIAL = |
| 93 PeerConnectionFactory.VIDEO_FRAME_EMIT_TRIAL + "/" + PeerConnectionFactory
.TRIAL_ENABLED |
| 94 + "/"; |
92 private static final String AUDIO_CODEC_PARAM_BITRATE = "maxaveragebitrate"; | 95 private static final String AUDIO_CODEC_PARAM_BITRATE = "maxaveragebitrate"; |
93 private static final String AUDIO_ECHO_CANCELLATION_CONSTRAINT = "googEchoCanc
ellation"; | 96 private static final String AUDIO_ECHO_CANCELLATION_CONSTRAINT = "googEchoCanc
ellation"; |
94 private static final String AUDIO_AUTO_GAIN_CONTROL_CONSTRAINT = "googAutoGain
Control"; | 97 private static final String AUDIO_AUTO_GAIN_CONTROL_CONSTRAINT = "googAutoGain
Control"; |
95 private static final String AUDIO_HIGH_PASS_FILTER_CONSTRAINT = "googHighpassF
ilter"; | 98 private static final String AUDIO_HIGH_PASS_FILTER_CONSTRAINT = "googHighpassF
ilter"; |
96 private static final String AUDIO_NOISE_SUPPRESSION_CONSTRAINT = "googNoiseSup
pression"; | 99 private static final String AUDIO_NOISE_SUPPRESSION_CONSTRAINT = "googNoiseSup
pression"; |
97 private static final String AUDIO_LEVEL_CONTROL_CONSTRAINT = "levelControl"; | 100 private static final String AUDIO_LEVEL_CONTROL_CONSTRAINT = "levelControl"; |
98 private static final String DTLS_SRTP_KEY_AGREEMENT_CONSTRAINT = "DtlsSrtpKeyA
greement"; | 101 private static final String DTLS_SRTP_KEY_AGREEMENT_CONSTRAINT = "DtlsSrtpKeyA
greement"; |
99 private static final int HD_VIDEO_WIDTH = 1280; | 102 private static final int HD_VIDEO_WIDTH = 1280; |
100 private static final int HD_VIDEO_HEIGHT = 720; | 103 private static final int HD_VIDEO_HEIGHT = 720; |
101 private static final int BPS_IN_KBPS = 1000; | 104 private static final int BPS_IN_KBPS = 1000; |
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
391 String fieldTrials = ""; | 394 String fieldTrials = ""; |
392 if (peerConnectionParameters.videoFlexfecEnabled) { | 395 if (peerConnectionParameters.videoFlexfecEnabled) { |
393 fieldTrials += VIDEO_FLEXFEC_FIELDTRIAL; | 396 fieldTrials += VIDEO_FLEXFEC_FIELDTRIAL; |
394 Log.d(TAG, "Enable FlexFEC field trial."); | 397 Log.d(TAG, "Enable FlexFEC field trial."); |
395 } | 398 } |
396 fieldTrials += VIDEO_VP8_INTEL_HW_ENCODER_FIELDTRIAL; | 399 fieldTrials += VIDEO_VP8_INTEL_HW_ENCODER_FIELDTRIAL; |
397 if (peerConnectionParameters.disableWebRtcAGCAndHPF) { | 400 if (peerConnectionParameters.disableWebRtcAGCAndHPF) { |
398 fieldTrials += DISABLE_WEBRTC_AGC_FIELDTRIAL; | 401 fieldTrials += DISABLE_WEBRTC_AGC_FIELDTRIAL; |
399 Log.d(TAG, "Disable WebRTC AGC field trial."); | 402 Log.d(TAG, "Disable WebRTC AGC field trial."); |
400 } | 403 } |
| 404 fieldTrials += VIDEO_FRAME_EMIT_FIELDTRIAL; |
401 | 405 |
402 // Check preferred video codec. | 406 // Check preferred video codec. |
403 preferredVideoCodec = VIDEO_CODEC_VP8; | 407 preferredVideoCodec = VIDEO_CODEC_VP8; |
404 if (videoCallEnabled && peerConnectionParameters.videoCodec != null) { | 408 if (videoCallEnabled && peerConnectionParameters.videoCodec != null) { |
405 switch (peerConnectionParameters.videoCodec) { | 409 switch (peerConnectionParameters.videoCodec) { |
406 case VIDEO_CODEC_VP8: | 410 case VIDEO_CODEC_VP8: |
407 preferredVideoCodec = VIDEO_CODEC_VP8; | 411 preferredVideoCodec = VIDEO_CODEC_VP8; |
408 break; | 412 break; |
409 case VIDEO_CODEC_VP9: | 413 case VIDEO_CODEC_VP9: |
410 preferredVideoCodec = VIDEO_CODEC_VP9; | 414 preferredVideoCodec = VIDEO_CODEC_VP9; |
(...skipping 941 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1352 public void onCreateFailure(final String error) { | 1356 public void onCreateFailure(final String error) { |
1353 reportError("createSDP error: " + error); | 1357 reportError("createSDP error: " + error); |
1354 } | 1358 } |
1355 | 1359 |
1356 @Override | 1360 @Override |
1357 public void onSetFailure(final String error) { | 1361 public void onSetFailure(final String error) { |
1358 reportError("setSDP error: " + error); | 1362 reportError("setSDP error: " + error); |
1359 } | 1363 } |
1360 } | 1364 } |
1361 } | 1365 } |
OLD | NEW |