OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2015 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2015 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.app.Fragment; | 14 import android.app.Fragment; |
15 import android.os.Bundle; | 15 import android.os.Bundle; |
16 import android.view.LayoutInflater; | 16 import android.view.LayoutInflater; |
17 import android.view.View; | 17 import android.view.View; |
18 import android.view.ViewGroup; | 18 import android.view.ViewGroup; |
19 import android.widget.ImageButton; | 19 import android.widget.ImageButton; |
| 20 import android.widget.SeekBar; |
20 import android.widget.TextView; | 21 import android.widget.TextView; |
21 | 22 |
22 import org.webrtc.RendererCommon.ScalingType; | 23 import org.webrtc.RendererCommon.ScalingType; |
23 | 24 |
24 /** | 25 /** |
25 * Fragment for call control. | 26 * Fragment for call control. |
26 */ | 27 */ |
27 public class CallFragment extends Fragment { | 28 public class CallFragment extends Fragment { |
28 private View controlView; | 29 private View controlView; |
29 private TextView contactView; | 30 private TextView contactView; |
30 private ImageButton disconnectButton; | 31 private ImageButton disconnectButton; |
31 private ImageButton cameraSwitchButton; | 32 private ImageButton cameraSwitchButton; |
32 private ImageButton videoScalingButton; | 33 private ImageButton videoScalingButton; |
| 34 private TextView captureFormatText; |
| 35 private SeekBar captureFormatSlider; |
33 private OnCallEvents callEvents; | 36 private OnCallEvents callEvents; |
34 private ScalingType scalingType; | 37 private ScalingType scalingType; |
35 private boolean videoCallEnabled = true; | 38 private boolean videoCallEnabled = true; |
36 | 39 |
37 /** | 40 /** |
38 * Call control interface for container activity. | 41 * Call control interface for container activity. |
39 */ | 42 */ |
40 public interface OnCallEvents { | 43 public interface OnCallEvents { |
41 public void onCallHangUp(); | 44 public void onCallHangUp(); |
42 public void onCameraSwitch(); | 45 public void onCameraSwitch(); |
43 public void onVideoScalingSwitch(ScalingType scalingType); | 46 public void onVideoScalingSwitch(ScalingType scalingType); |
| 47 public void onCaptureFormatChange(int width, int height, int framerate); |
44 } | 48 } |
45 | 49 |
46 @Override | 50 @Override |
47 public View onCreateView(LayoutInflater inflater, ViewGroup container, | 51 public View onCreateView(LayoutInflater inflater, ViewGroup container, |
48 Bundle savedInstanceState) { | 52 Bundle savedInstanceState) { |
49 controlView = | 53 controlView = |
50 inflater.inflate(R.layout.fragment_call, container, false); | 54 inflater.inflate(R.layout.fragment_call, container, false); |
51 | 55 |
52 // Create UI controls. | 56 // Create UI controls. |
53 contactView = | 57 contactView = |
54 (TextView) controlView.findViewById(R.id.contact_name_call); | 58 (TextView) controlView.findViewById(R.id.contact_name_call); |
55 disconnectButton = | 59 disconnectButton = |
56 (ImageButton) controlView.findViewById(R.id.button_call_disconnect); | 60 (ImageButton) controlView.findViewById(R.id.button_call_disconnect); |
57 cameraSwitchButton = | 61 cameraSwitchButton = |
58 (ImageButton) controlView.findViewById(R.id.button_call_switch_camera); | 62 (ImageButton) controlView.findViewById(R.id.button_call_switch_camera); |
59 videoScalingButton = | 63 videoScalingButton = |
60 (ImageButton) controlView.findViewById(R.id.button_call_scaling_mode); | 64 (ImageButton) controlView.findViewById(R.id.button_call_scaling_mode); |
| 65 captureFormatText = |
| 66 (TextView) controlView.findViewById(R.id.capture_format_text_call); |
| 67 captureFormatSlider = |
| 68 (SeekBar) controlView.findViewById(R.id.capture_format_slider_call); |
61 | 69 |
62 // Add buttons click events. | 70 // Add buttons click events. |
63 disconnectButton.setOnClickListener(new View.OnClickListener() { | 71 disconnectButton.setOnClickListener(new View.OnClickListener() { |
64 @Override | 72 @Override |
65 public void onClick(View view) { | 73 public void onClick(View view) { |
66 callEvents.onCallHangUp(); | 74 callEvents.onCallHangUp(); |
67 } | 75 } |
68 }); | 76 }); |
69 | 77 |
70 cameraSwitchButton.setOnClickListener(new View.OnClickListener() { | 78 cameraSwitchButton.setOnClickListener(new View.OnClickListener() { |
(...skipping 20 matching lines...) Expand all Loading... |
91 }); | 99 }); |
92 scalingType = ScalingType.SCALE_ASPECT_FILL; | 100 scalingType = ScalingType.SCALE_ASPECT_FILL; |
93 | 101 |
94 return controlView; | 102 return controlView; |
95 } | 103 } |
96 | 104 |
97 @Override | 105 @Override |
98 public void onStart() { | 106 public void onStart() { |
99 super.onStart(); | 107 super.onStart(); |
100 | 108 |
| 109 boolean captureSliderEnabled = false; |
101 Bundle args = getArguments(); | 110 Bundle args = getArguments(); |
102 if (args != null) { | 111 if (args != null) { |
103 String contactName = args.getString(CallActivity.EXTRA_ROOMID); | 112 String contactName = args.getString(CallActivity.EXTRA_ROOMID); |
104 contactView.setText(contactName); | 113 contactView.setText(contactName); |
105 videoCallEnabled = args.getBoolean(CallActivity.EXTRA_VIDEO_CALL, true); | 114 videoCallEnabled = args.getBoolean(CallActivity.EXTRA_VIDEO_CALL, true); |
| 115 captureSliderEnabled = videoCallEnabled |
| 116 && args.getBoolean(CallActivity.EXTRA_VIDEO_CAPTUREQUALITYSLIDER_ENABL
ED, false); |
106 } | 117 } |
107 if (!videoCallEnabled) { | 118 if (!videoCallEnabled) { |
108 cameraSwitchButton.setVisibility(View.INVISIBLE); | 119 cameraSwitchButton.setVisibility(View.INVISIBLE); |
109 } | 120 } |
| 121 if (captureSliderEnabled) { |
| 122 captureFormatSlider.setOnSeekBarChangeListener( |
| 123 new CaptureQualityController(captureFormatText, callEvents)); |
| 124 } else { |
| 125 captureFormatText.setVisibility(View.GONE); |
| 126 captureFormatSlider.setVisibility(View.GONE); |
| 127 } |
110 } | 128 } |
111 | 129 |
112 @Override | 130 @Override |
113 public void onAttach(Activity activity) { | 131 public void onAttach(Activity activity) { |
114 super.onAttach(activity); | 132 super.onAttach(activity); |
115 callEvents = (OnCallEvents) activity; | 133 callEvents = (OnCallEvents) activity; |
116 } | 134 } |
117 | 135 |
118 } | 136 } |
OLD | NEW |