aboutsummaryrefslogtreecommitdiff
path: root/webrtc/examples/android/media_demo/src/org/webrtc/webrtcdemo/SettingsMenuFragment.java
diff options
context:
space:
mode:
authorChih-hung Hsieh <chh@google.com>2015-12-01 17:07:48 +0000
committerandroid-build-merger <android-build-merger@google.com>2015-12-01 17:07:48 +0000
commita4acd9d6bc9b3b033d7d274316e75ee067df8d20 (patch)
tree672a185b294789cf991f385c3e395dd63bea9063 /webrtc/examples/android/media_demo/src/org/webrtc/webrtcdemo/SettingsMenuFragment.java
parent3681b90ba4fe7a27232dd3e27897d5d7ed9d651c (diff)
parentfe8b4a657979b49e1701bd92f6d5814a99e0b2be (diff)
downloadwebrtc-a4acd9d6bc9b3b033d7d274316e75ee067df8d20.tar.gz
Merge changes I7bbf776e,I1b827825
am: fe8b4a6579 * commit 'fe8b4a657979b49e1701bd92f6d5814a99e0b2be': (7237 commits) WIP: Changes after merge commit 'cb3f9bd' Make the nonlinear beamformer steerable Utilize bitrate above codec max to protect video. Enable VP9 internal resize by default. Filter overlapping RTP header extensions. Make VCMEncodedFrameCallback const. MediaCodecVideoEncoder: Add number of quality resolution downscales to Encoded callback. Remove redudant encoder rate calls. Create isolate files for nonparallel tests. Register header extensions in RtpRtcpObserver to avoid log spam. Make an enum class out of NetEqDecoder, and hide the neteq_decoders_ table ACM: Move NACK functionality inside NetEq Fix chromium-style warnings in webrtc/sound/. Create a 'webrtc_nonparallel_tests' target. Update scalability structure data according to updates in the RTP payload profile. audio_coding: rename interface -> include Rewrote perform_action_on_all_files to be parallell. Update reference indices according to updates in the RTP payload profile. Disable P2PTransport...TestFailoverControlledSide on Memcheck pass clangcl compile options to ignore warnings in gflags.cc ...
Diffstat (limited to 'webrtc/examples/android/media_demo/src/org/webrtc/webrtcdemo/SettingsMenuFragment.java')
-rw-r--r--webrtc/examples/android/media_demo/src/org/webrtc/webrtcdemo/SettingsMenuFragment.java129
1 files changed, 129 insertions, 0 deletions
diff --git a/webrtc/examples/android/media_demo/src/org/webrtc/webrtcdemo/SettingsMenuFragment.java b/webrtc/examples/android/media_demo/src/org/webrtc/webrtcdemo/SettingsMenuFragment.java
new file mode 100644
index 0000000000..761f96ce29
--- /dev/null
+++ b/webrtc/examples/android/media_demo/src/org/webrtc/webrtcdemo/SettingsMenuFragment.java
@@ -0,0 +1,129 @@
+/*
+ * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved.
+ *
+ * Use of this source code is governed by a BSD-style license
+ * that can be found in the LICENSE file in the root of the source
+ * tree. An additional intellectual property rights grant can be found
+ * in the file PATENTS. All contributing project authors may
+ * be found in the AUTHORS file in the root of the source tree.
+ */
+
+package org.webrtc.webrtcdemo;
+
+import android.app.Activity;
+import android.app.Fragment;
+import android.os.Bundle;
+import android.util.Log;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.CheckBox;
+import android.widget.EditText;
+import android.widget.RadioGroup;
+import android.widget.TextView;
+import java.net.InetAddress;
+import java.net.NetworkInterface;
+import java.net.SocketException;
+import java.util.Enumeration;
+
+public class SettingsMenuFragment extends Fragment
+ implements RadioGroup.OnCheckedChangeListener {
+
+ private String TAG;
+ private MenuStateProvider stateProvider;
+
+ EditText etRemoteIp;
+
+ @Override
+ public View onCreateView(LayoutInflater inflater, ViewGroup container,
+ Bundle savedInstanceState) {
+ View v = inflater.inflate(R.layout.settingsmenu, container, false);
+
+ TAG = getResources().getString(R.string.tag);
+
+ CheckBox cbAudio = (CheckBox) v.findViewById(R.id.cbAudio);
+ cbAudio.setChecked(getEngine().audioEnabled());
+ cbAudio.setOnClickListener(new View.OnClickListener() {
+ public void onClick(View checkBox) {
+ CheckBox cbAudio = (CheckBox) checkBox;
+ getEngine().setAudio(cbAudio.isChecked());
+ cbAudio.setChecked(getEngine().audioEnabled());
+ }
+ });
+ boolean loopback =
+ getResources().getBoolean(R.bool.loopback_enabled_default);
+ CheckBox cbLoopback = (CheckBox) v.findViewById(R.id.cbLoopback);
+ cbLoopback.setChecked(loopback);
+ cbLoopback.setOnClickListener(new View.OnClickListener() {
+ public void onClick(View checkBox) {
+ loopbackChanged((CheckBox) checkBox);
+ }
+ });
+ etRemoteIp = (EditText) v.findViewById(R.id.etRemoteIp);
+ etRemoteIp.setOnFocusChangeListener(new View.OnFocusChangeListener() {
+ public void onFocusChange(View editText, boolean hasFocus) {
+ if (!hasFocus) {
+ getEngine().setRemoteIp(etRemoteIp.getText().toString());
+ }
+ }
+ });
+ // Has to be after remote IP as loopback changes it.
+ loopbackChanged(cbLoopback);
+ return v;
+ }
+
+ @Override
+ public void onAttach(Activity activity) {
+ super.onAttach(activity);
+
+ // This makes sure that the container activity has implemented
+ // the callback interface. If not, it throws an exception.
+ try {
+ stateProvider = (MenuStateProvider) activity;
+ } catch (ClassCastException e) {
+ throw new ClassCastException(activity +
+ " must implement MenuStateProvider");
+ }
+ }
+
+ private void loopbackChanged(CheckBox cbLoopback) {
+ boolean loopback = cbLoopback.isChecked();
+ etRemoteIp.setText(loopback ? getLoopbackIPString() : getLocalIpAddress());
+ getEngine().setRemoteIp(etRemoteIp.getText().toString());
+ }
+
+ private String getLoopbackIPString() {
+ return getResources().getString(R.string.loopbackIp);
+ }
+
+ private String getLocalIpAddress() {
+ String localIp = "";
+ try {
+ for (Enumeration<NetworkInterface> en = NetworkInterface
+ .getNetworkInterfaces(); en.hasMoreElements();) {
+ NetworkInterface intf = en.nextElement();
+ for (Enumeration<InetAddress> enumIpAddr =
+ intf.getInetAddresses();
+ enumIpAddr.hasMoreElements(); ) {
+ InetAddress inetAddress = enumIpAddr.nextElement();
+ if (!inetAddress.isLoopbackAddress()) {
+ // Set the remote ip address the same as
+ // the local ip address of the last netif
+ localIp = inetAddress.getHostAddress().toString();
+ }
+ }
+ }
+ } catch (SocketException e) {
+ Log.e(TAG, "Unable to get local IP address. Not the end of the world", e);
+ }
+ return localIp;
+ }
+
+ private MediaEngine getEngine() {
+ return stateProvider.getEngine();
+ }
+
+ @Override
+ public void onCheckedChanged(RadioGroup group, int checkedId) {
+ }
+} \ No newline at end of file