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

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

Issue 2488643002: Add screenshare support to AppRTCMobile. (Closed)
Patch Set: Use correct capturing format. Created 4 years, 1 month 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
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
15 import android.content.Context; 13 import android.content.Context;
16 import android.os.Environment; 14 import android.os.Environment;
17 import android.os.ParcelFileDescriptor; 15 import android.os.ParcelFileDescriptor;
18 import android.util.Log; 16 import android.util.Log;
19 17 import java.io.File;
18 import java.io.IOException;
19 import java.util.Collections;
20 import java.util.EnumSet;
21 import java.util.LinkedList;
22 import java.util.List;
23 import java.util.Timer;
24 import java.util.TimerTask;
25 import java.util.concurrent.Executors;
26 import java.util.concurrent.ScheduledExecutorService;
27 import java.util.regex.Matcher;
28 import java.util.regex.Pattern;
29 import org.appspot.apprtc.AppRTCClient.SignalingParameters;
20 import org.webrtc.AudioSource; 30 import org.webrtc.AudioSource;
21 import org.webrtc.AudioTrack; 31 import org.webrtc.AudioTrack;
22 import org.webrtc.CameraVideoCapturer; 32 import org.webrtc.CameraVideoCapturer;
23 import org.webrtc.DataChannel; 33 import org.webrtc.DataChannel;
24 import org.webrtc.EglBase; 34 import org.webrtc.EglBase;
25 import org.webrtc.IceCandidate; 35 import org.webrtc.IceCandidate;
26 import org.webrtc.Logging; 36 import org.webrtc.Logging;
27 import org.webrtc.MediaConstraints; 37 import org.webrtc.MediaConstraints;
28 import org.webrtc.MediaStream; 38 import org.webrtc.MediaStream;
29 import org.webrtc.PeerConnection; 39 import org.webrtc.PeerConnection;
30 import org.webrtc.PeerConnection.IceConnectionState; 40 import org.webrtc.PeerConnection.IceConnectionState;
31 import org.webrtc.PeerConnectionFactory; 41 import org.webrtc.PeerConnectionFactory;
32 import org.webrtc.RtpParameters; 42 import org.webrtc.RtpParameters;
33 import org.webrtc.RtpSender; 43 import org.webrtc.RtpSender;
34 import org.webrtc.SdpObserver; 44 import org.webrtc.SdpObserver;
35 import org.webrtc.SessionDescription; 45 import org.webrtc.SessionDescription;
36 import org.webrtc.StatsObserver; 46 import org.webrtc.StatsObserver;
37 import org.webrtc.StatsReport; 47 import org.webrtc.StatsReport;
38 import org.webrtc.VideoCapturer; 48 import org.webrtc.VideoCapturer;
39 import org.webrtc.VideoRenderer; 49 import org.webrtc.VideoRenderer;
40 import org.webrtc.VideoSource; 50 import org.webrtc.VideoSource;
41 import org.webrtc.VideoTrack; 51 import org.webrtc.VideoTrack;
42 import org.webrtc.voiceengine.WebRtcAudioManager; 52 import org.webrtc.voiceengine.WebRtcAudioManager;
43 import org.webrtc.voiceengine.WebRtcAudioUtils; 53 import org.webrtc.voiceengine.WebRtcAudioUtils;
44 54
45 import java.io.File;
46 import java.io.IOException;
47 import java.util.Collections;
48 import java.util.EnumSet;
49 import java.util.LinkedList;
50 import java.util.List;
51 import java.util.Timer;
52 import java.util.TimerTask;
53 import java.util.concurrent.Executors;
54 import java.util.concurrent.ScheduledExecutorService;
55 import java.util.regex.Matcher;
56 import java.util.regex.Pattern;
57
58 /** 55 /**
59 * Peer connection client implementation. 56 * Peer connection client implementation.
60 * 57 *
61 * <p>All public methods are routed to local looper thread. 58 * <p>All public methods are routed to local looper thread.
62 * All PeerConnectionEvents callbacks are invoked from the same looper thread. 59 * All PeerConnectionEvents callbacks are invoked from the same looper thread.
63 * This class is a singleton. 60 * This class is a singleton.
64 */ 61 */
65 public class PeerConnectionClient { 62 public class PeerConnectionClient {
66 public static final String VIDEO_TRACK_ID = "ARDAMSv0"; 63 public static final String VIDEO_TRACK_ID = "ARDAMSv0";
67 public static final String AUDIO_TRACK_ID = "ARDAMSa0"; 64 public static final String AUDIO_TRACK_ID = "ARDAMSa0";
68 public static final String VIDEO_TRACK_TYPE = "video"; 65 public static final String VIDEO_TRACK_TYPE = "video";
69 private static final String TAG = "PCRTCClient"; 66 private static final String TAG = "PCRTCClient";
70 private static final String VIDEO_CODEC_VP8 = "VP8"; 67 private static final String VIDEO_CODEC_VP8 = "VP8";
71 private static final String VIDEO_CODEC_VP9 = "VP9"; 68 private static final String VIDEO_CODEC_VP9 = "VP9";
72 private static final String VIDEO_CODEC_H264 = "H264"; 69 private static final String VIDEO_CODEC_H264 = "H264";
73 private static final String AUDIO_CODEC_OPUS = "opus"; 70 private static final String AUDIO_CODEC_OPUS = "opus";
74 private static final String AUDIO_CODEC_ISAC = "ISAC"; 71 private static final String AUDIO_CODEC_ISAC = "ISAC";
75 private static final String VIDEO_CODEC_PARAM_START_BITRATE = "x-google-start- bitrate"; 72 private static final String VIDEO_CODEC_PARAM_START_BITRATE = "x-google-start- bitrate";
76 private static final String AUDIO_CODEC_PARAM_BITRATE = "maxaveragebitrate"; 73 private static final String AUDIO_CODEC_PARAM_BITRATE = "maxaveragebitrate";
77 private static final String AUDIO_ECHO_CANCELLATION_CONSTRAINT = "googEchoCanc ellation"; 74 private static final String AUDIO_ECHO_CANCELLATION_CONSTRAINT = "googEchoCanc ellation";
78 private static final String AUDIO_AUTO_GAIN_CONTROL_CONSTRAINT = "googAutoGain Control"; 75 private static final String AUDIO_AUTO_GAIN_CONTROL_CONSTRAINT = "googAutoGain Control";
79 private static final String AUDIO_HIGH_PASS_FILTER_CONSTRAINT = "googHighpassF ilter"; 76 private static final String AUDIO_HIGH_PASS_FILTER_CONSTRAINT = "googHighpassF ilter";
80 private static final String AUDIO_NOISE_SUPPRESSION_CONSTRAINT = "googNoiseSup pression"; 77 private static final String AUDIO_NOISE_SUPPRESSION_CONSTRAINT = "googNoiseSup pression";
81 private static final String AUDIO_LEVEL_CONTROL_CONSTRAINT = "levelControl"; 78 private static final String AUDIO_LEVEL_CONTROL_CONSTRAINT = "levelControl";
82 private static final String DTLS_SRTP_KEY_AGREEMENT_CONSTRAINT = "DtlsSrtpKeyA greement"; 79 private static final String DTLS_SRTP_KEY_AGREEMENT_CONSTRAINT = "DtlsSrtpKeyA greement";
83 private static final int HD_VIDEO_WIDTH = 1280; 80 private static final int HD_VIDEO_WIDTH = 1280;
84 private static final int HD_VIDEO_HEIGHT = 720; 81 private static final int HD_VIDEO_HEIGHT = 720;
85 private static final int MAX_VIDEO_WIDTH = 1280;
86 private static final int MAX_VIDEO_HEIGHT = 1280;
87 private static final int MAX_VIDEO_FPS = 30;
88 private static final int BPS_IN_KBPS = 1000; 82 private static final int BPS_IN_KBPS = 1000;
89 83
90 private static final PeerConnectionClient instance = new PeerConnectionClient( ); 84 private static final PeerConnectionClient instance = new PeerConnectionClient( );
91 private final PCObserver pcObserver = new PCObserver(); 85 private final PCObserver pcObserver = new PCObserver();
92 private final SDPObserver sdpObserver = new SDPObserver(); 86 private final SDPObserver sdpObserver = new SDPObserver();
93 private final ScheduledExecutorService executor; 87 private final ScheduledExecutorService executor;
94 88
95 private Context context; 89 private Context context;
96 private PeerConnectionFactory factory; 90 private PeerConnectionFactory factory;
97 private PeerConnection peerConnection; 91 private PeerConnection peerConnection;
(...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after
421 // If video resolution is not specified, default to HD. 415 // If video resolution is not specified, default to HD.
422 if (videoWidth == 0 || videoHeight == 0) { 416 if (videoWidth == 0 || videoHeight == 0) {
423 videoWidth = HD_VIDEO_WIDTH; 417 videoWidth = HD_VIDEO_WIDTH;
424 videoHeight = HD_VIDEO_HEIGHT; 418 videoHeight = HD_VIDEO_HEIGHT;
425 } 419 }
426 420
427 // If fps is not specified, default to 30. 421 // If fps is not specified, default to 30.
428 if (videoFps == 0) { 422 if (videoFps == 0) {
429 videoFps = 30; 423 videoFps = 30;
430 } 424 }
431 425 Logging.d(TAG, "Capturing format: " + videoWidth + "x" + videoHeight + "@" + videoFps);
432 videoWidth = Math.min(videoWidth, MAX_VIDEO_WIDTH);
433 videoHeight = Math.min(videoHeight, MAX_VIDEO_HEIGHT);
434 videoFps = Math.min(videoFps, MAX_VIDEO_FPS);
435 } 426 }
436 427
437 // Create audio constraints. 428 // Create audio constraints.
438 audioConstraints = new MediaConstraints(); 429 audioConstraints = new MediaConstraints();
439 // added for audio performance measurements 430 // added for audio performance measurements
440 if (peerConnectionParameters.noAudioProcessing) { 431 if (peerConnectionParameters.noAudioProcessing) {
441 Log.d(TAG, "Disabling audio processing"); 432 Log.d(TAG, "Disabling audio processing");
442 audioConstraints.mandatory.add( 433 audioConstraints.mandatory.add(
443 new MediaConstraints.KeyValuePair(AUDIO_ECHO_CANCELLATION_CONSTRAINT, "false")); 434 new MediaConstraints.KeyValuePair(AUDIO_ECHO_CANCELLATION_CONSTRAINT, "false"));
444 audioConstraints.mandatory.add( 435 audioConstraints.mandatory.add(
(...skipping 722 matching lines...) Expand 10 before | Expand all | Expand 10 after
1167 public void onCreateFailure(final String error) { 1158 public void onCreateFailure(final String error) {
1168 reportError("createSDP error: " + error); 1159 reportError("createSDP error: " + error);
1169 } 1160 }
1170 1161
1171 @Override 1162 @Override
1172 public void onSetFailure(final String error) { 1163 public void onSetFailure(final String error) {
1173 reportError("setSDP error: " + error); 1164 reportError("setSDP error: " + error);
1174 } 1165 }
1175 } 1166 }
1176 } 1167 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698