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

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

Issue 2077663003: Camera2 in AppRTC Android Demo. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@camera2_only
Patch Set: Create peer connection factory with the target context in the test 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
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 android.app.Activity; 13 import android.app.Activity;
14 import android.content.SharedPreferences; 14 import android.content.SharedPreferences;
15 import android.content.SharedPreferences.OnSharedPreferenceChangeListener; 15 import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
16 import android.os.Bundle; 16 import android.os.Bundle;
17 import android.preference.ListPreference;
17 import android.preference.Preference; 18 import android.preference.Preference;
18 19
20 import org.webrtc.Camera2Enumerator;
19 import org.webrtc.voiceengine.WebRtcAudioUtils; 21 import org.webrtc.voiceengine.WebRtcAudioUtils;
20 22
21 /** 23 /**
22 * Settings activity for AppRTC. 24 * Settings activity for AppRTC.
23 */ 25 */
24 public class SettingsActivity extends Activity 26 public class SettingsActivity extends Activity
25 implements OnSharedPreferenceChangeListener{ 27 implements OnSharedPreferenceChangeListener{
26 private SettingsFragment settingsFragment; 28 private SettingsFragment settingsFragment;
27 private String keyprefVideoCall; 29 private String keyprefVideoCall;
30 private String keyprefCamera2;
28 private String keyprefResolution; 31 private String keyprefResolution;
29 private String keyprefFps; 32 private String keyprefFps;
30 private String keyprefCaptureQualitySlider; 33 private String keyprefCaptureQualitySlider;
31 private String keyprefStartVideoBitrateType; 34 private String keyprefStartVideoBitrateType;
32 private String keyprefStartVideoBitrateValue; 35 private String keyprefStartVideoBitrateValue;
33 private String keyPrefVideoCodec; 36 private String keyPrefVideoCodec;
34 private String keyprefHwCodec; 37 private String keyprefHwCodec;
35 private String keyprefCaptureToTexture; 38 private String keyprefCaptureToTexture;
36 39
37 private String keyprefStartAudioBitrateType; 40 private String keyprefStartAudioBitrateType;
38 private String keyprefStartAudioBitrateValue; 41 private String keyprefStartAudioBitrateValue;
39 private String keyPrefAudioCodec; 42 private String keyPrefAudioCodec;
40 private String keyprefNoAudioProcessing; 43 private String keyprefNoAudioProcessing;
41 private String keyprefAecDump; 44 private String keyprefAecDump;
42 private String keyprefOpenSLES; 45 private String keyprefOpenSLES;
43 private String keyprefDisableBuiltInAEC; 46 private String keyprefDisableBuiltInAEC;
44 47
45 private String keyPrefRoomServerUrl; 48 private String keyPrefRoomServerUrl;
46 private String keyPrefDisplayHud; 49 private String keyPrefDisplayHud;
47 private String keyPrefTracing; 50 private String keyPrefTracing;
48 51
49 @Override 52 @Override
50 protected void onCreate(Bundle savedInstanceState) { 53 protected void onCreate(Bundle savedInstanceState) {
51 super.onCreate(savedInstanceState); 54 super.onCreate(savedInstanceState);
52 keyprefVideoCall = getString(R.string.pref_videocall_key); 55 keyprefVideoCall = getString(R.string.pref_videocall_key);
56 keyprefCamera2 = getString(R.string.pref_camera2_key);
53 keyprefResolution = getString(R.string.pref_resolution_key); 57 keyprefResolution = getString(R.string.pref_resolution_key);
54 keyprefFps = getString(R.string.pref_fps_key); 58 keyprefFps = getString(R.string.pref_fps_key);
55 keyprefCaptureQualitySlider = getString(R.string.pref_capturequalityslider_k ey); 59 keyprefCaptureQualitySlider = getString(R.string.pref_capturequalityslider_k ey);
56 keyprefStartVideoBitrateType = getString(R.string.pref_startvideobitrate_key ); 60 keyprefStartVideoBitrateType = getString(R.string.pref_startvideobitrate_key );
57 keyprefStartVideoBitrateValue = getString(R.string.pref_startvideobitrateval ue_key); 61 keyprefStartVideoBitrateValue = getString(R.string.pref_startvideobitrateval ue_key);
58 keyPrefVideoCodec = getString(R.string.pref_videocodec_key); 62 keyPrefVideoCodec = getString(R.string.pref_videocodec_key);
59 keyprefHwCodec = getString(R.string.pref_hwcodec_key); 63 keyprefHwCodec = getString(R.string.pref_hwcodec_key);
60 keyprefCaptureToTexture = getString(R.string.pref_capturetotexture_key); 64 keyprefCaptureToTexture = getString(R.string.pref_capturetotexture_key);
61 65
62 keyprefStartAudioBitrateType = getString(R.string.pref_startaudiobitrate_key ); 66 keyprefStartAudioBitrateType = getString(R.string.pref_startaudiobitrate_key );
(...skipping 16 matching lines...) Expand all
79 } 83 }
80 84
81 @Override 85 @Override
82 protected void onResume() { 86 protected void onResume() {
83 super.onResume(); 87 super.onResume();
84 // Set summary to be the user-description for the selected value 88 // Set summary to be the user-description for the selected value
85 SharedPreferences sharedPreferences = 89 SharedPreferences sharedPreferences =
86 settingsFragment.getPreferenceScreen().getSharedPreferences(); 90 settingsFragment.getPreferenceScreen().getSharedPreferences();
87 sharedPreferences.registerOnSharedPreferenceChangeListener(this); 91 sharedPreferences.registerOnSharedPreferenceChangeListener(this);
88 updateSummaryB(sharedPreferences, keyprefVideoCall); 92 updateSummaryB(sharedPreferences, keyprefVideoCall);
93 updateSummaryB(sharedPreferences, keyprefCamera2);
89 updateSummary(sharedPreferences, keyprefResolution); 94 updateSummary(sharedPreferences, keyprefResolution);
90 updateSummary(sharedPreferences, keyprefFps); 95 updateSummary(sharedPreferences, keyprefFps);
91 updateSummaryB(sharedPreferences, keyprefCaptureQualitySlider); 96 updateSummaryB(sharedPreferences, keyprefCaptureQualitySlider);
92 updateSummary(sharedPreferences, keyprefStartVideoBitrateType); 97 updateSummary(sharedPreferences, keyprefStartVideoBitrateType);
93 updateSummaryBitrate(sharedPreferences, keyprefStartVideoBitrateValue); 98 updateSummaryBitrate(sharedPreferences, keyprefStartVideoBitrateValue);
94 setVideoBitrateEnable(sharedPreferences); 99 setVideoBitrateEnable(sharedPreferences);
95 updateSummary(sharedPreferences, keyPrefVideoCodec); 100 updateSummary(sharedPreferences, keyPrefVideoCodec);
96 updateSummaryB(sharedPreferences, keyprefHwCodec); 101 updateSummaryB(sharedPreferences, keyprefHwCodec);
97 updateSummaryB(sharedPreferences, keyprefCaptureToTexture); 102 updateSummaryB(sharedPreferences, keyprefCaptureToTexture);
98 103
99 updateSummary(sharedPreferences, keyprefStartAudioBitrateType); 104 updateSummary(sharedPreferences, keyprefStartAudioBitrateType);
100 updateSummaryBitrate(sharedPreferences, keyprefStartAudioBitrateValue); 105 updateSummaryBitrate(sharedPreferences, keyprefStartAudioBitrateValue);
101 setAudioBitrateEnable(sharedPreferences); 106 setAudioBitrateEnable(sharedPreferences);
102 updateSummary(sharedPreferences, keyPrefAudioCodec); 107 updateSummary(sharedPreferences, keyPrefAudioCodec);
103 updateSummaryB(sharedPreferences, keyprefNoAudioProcessing); 108 updateSummaryB(sharedPreferences, keyprefNoAudioProcessing);
104 updateSummaryB(sharedPreferences, keyprefAecDump); 109 updateSummaryB(sharedPreferences, keyprefAecDump);
105 updateSummaryB(sharedPreferences, keyprefOpenSLES); 110 updateSummaryB(sharedPreferences, keyprefOpenSLES);
106 updateSummaryB(sharedPreferences, keyprefDisableBuiltInAEC); 111 updateSummaryB(sharedPreferences, keyprefDisableBuiltInAEC);
107 112
108 updateSummary(sharedPreferences, keyPrefRoomServerUrl); 113 updateSummary(sharedPreferences, keyPrefRoomServerUrl);
109 updateSummaryB(sharedPreferences, keyPrefDisplayHud); 114 updateSummaryB(sharedPreferences, keyPrefDisplayHud);
110 updateSummaryB(sharedPreferences, keyPrefTracing); 115 updateSummaryB(sharedPreferences, keyPrefTracing);
111 116
117 if (!Camera2Enumerator.isSupported()) {
118 Preference camera2Preference =
119 settingsFragment.findPreference(keyprefCamera2);
120
121 camera2Preference.setSummary(getString(R.string.pref_camera2_not_supported ));
122 camera2Preference.setEnabled(false);
123 }
124
112 // Disable forcing WebRTC based AEC so it won't affect our value. 125 // Disable forcing WebRTC based AEC so it won't affect our value.
113 // Otherwise, if it was enabled, isAcousticEchoCancelerSupported would alway s return false. 126 // Otherwise, if it was enabled, isAcousticEchoCancelerSupported would alway s return false.
114 WebRtcAudioUtils.setWebRtcBasedAcousticEchoCanceler(false); 127 WebRtcAudioUtils.setWebRtcBasedAcousticEchoCanceler(false);
115 if (!WebRtcAudioUtils.isAcousticEchoCancelerSupported()) { 128 if (!WebRtcAudioUtils.isAcousticEchoCancelerSupported()) {
116 Preference disableBuiltInAECPreference = 129 Preference disableBuiltInAECPreference =
117 settingsFragment.findPreference(keyprefDisableBuiltInAEC); 130 settingsFragment.findPreference(keyprefDisableBuiltInAEC);
118 131
119
120 disableBuiltInAECPreference.setSummary(getString(R.string.pref_built_in_ae c_not_available)); 132 disableBuiltInAECPreference.setSummary(getString(R.string.pref_built_in_ae c_not_available));
121 disableBuiltInAECPreference.setEnabled(false); 133 disableBuiltInAECPreference.setEnabled(false);
122 } 134 }
123 } 135 }
124 136
125 @Override 137 @Override
126 protected void onPause() { 138 protected void onPause() {
127 super.onPause(); 139 super.onPause();
128 SharedPreferences sharedPreferences = 140 SharedPreferences sharedPreferences =
129 settingsFragment.getPreferenceScreen().getSharedPreferences(); 141 settingsFragment.getPreferenceScreen().getSharedPreferences();
130 sharedPreferences.unregisterOnSharedPreferenceChangeListener(this); 142 sharedPreferences.unregisterOnSharedPreferenceChangeListener(this);
131 } 143 }
132 144
133 @Override 145 @Override
134 public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, 146 public void onSharedPreferenceChanged(SharedPreferences sharedPreferences,
135 String key) { 147 String key) {
136 if (key.equals(keyprefResolution) 148 if (key.equals(keyprefResolution)
137 || key.equals(keyprefFps) 149 || key.equals(keyprefFps)
138 || key.equals(keyprefStartVideoBitrateType) 150 || key.equals(keyprefStartVideoBitrateType)
139 || key.equals(keyPrefVideoCodec) 151 || key.equals(keyPrefVideoCodec)
140 || key.equals(keyprefStartAudioBitrateType) 152 || key.equals(keyprefStartAudioBitrateType)
141 || key.equals(keyPrefAudioCodec) 153 || key.equals(keyPrefAudioCodec)
142 || key.equals(keyPrefRoomServerUrl)) { 154 || key.equals(keyPrefRoomServerUrl)) {
143 updateSummary(sharedPreferences, key); 155 updateSummary(sharedPreferences, key);
144 } else if (key.equals(keyprefStartVideoBitrateValue) 156 } else if (key.equals(keyprefStartVideoBitrateValue)
145 || key.equals(keyprefStartAudioBitrateValue)) { 157 || key.equals(keyprefStartAudioBitrateValue)) {
146 updateSummaryBitrate(sharedPreferences, key); 158 updateSummaryBitrate(sharedPreferences, key);
147 } else if (key.equals(keyprefVideoCall) 159 } else if (key.equals(keyprefVideoCall)
160 || key.equals(keyprefCamera2)
148 || key.equals(keyPrefTracing) 161 || key.equals(keyPrefTracing)
149 || key.equals(keyprefCaptureQualitySlider) 162 || key.equals(keyprefCaptureQualitySlider)
150 || key.equals(keyprefHwCodec) 163 || key.equals(keyprefHwCodec)
151 || key.equals(keyprefCaptureToTexture) 164 || key.equals(keyprefCaptureToTexture)
152 || key.equals(keyprefNoAudioProcessing) 165 || key.equals(keyprefNoAudioProcessing)
153 || key.equals(keyprefAecDump) 166 || key.equals(keyprefAecDump)
154 || key.equals(keyprefOpenSLES) 167 || key.equals(keyprefOpenSLES)
155 || key.equals(keyprefDisableBuiltInAEC) 168 || key.equals(keyprefDisableBuiltInAEC)
156 || key.equals(keyPrefDisplayHud)) { 169 || key.equals(keyPrefDisplayHud)) {
157 updateSummaryB(sharedPreferences, key); 170 updateSummaryB(sharedPreferences, key);
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 String bitrateTypeDefault = getString(R.string.pref_startaudiobitrate_defaul t); 215 String bitrateTypeDefault = getString(R.string.pref_startaudiobitrate_defaul t);
203 String bitrateType = sharedPreferences.getString( 216 String bitrateType = sharedPreferences.getString(
204 keyprefStartAudioBitrateType, bitrateTypeDefault); 217 keyprefStartAudioBitrateType, bitrateTypeDefault);
205 if (bitrateType.equals(bitrateTypeDefault)) { 218 if (bitrateType.equals(bitrateTypeDefault)) {
206 bitratePreferenceValue.setEnabled(false); 219 bitratePreferenceValue.setEnabled(false);
207 } else { 220 } else {
208 bitratePreferenceValue.setEnabled(true); 221 bitratePreferenceValue.setEnabled(true);
209 } 222 }
210 } 223 }
211 } 224 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698