summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBodam Nam <bodamnam@google.com>2023-03-28 10:57:57 +0000
committerAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2023-03-28 10:57:57 +0000
commit43f8768787f9e5385b0e29b7185b4f9bea026c87 (patch)
tree6d8c9f5b55d76c8172efda3fd9515f193237e060
parentea31b65fe4320d710701c2eb4cb62323db8297db (diff)
parent079ac227d80cbfe1ab72f4f03abf2a91ac283c3b (diff)
downloadImsMedia-43f8768787f9e5385b0e29b7185b4f9bea026c87.tar.gz
Merge "Add video resolution selection for testing" into udc-dev am: 079ac227d8
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/modules/ImsMedia/+/22248242 Change-Id: I6d4f11f4a28a6800e9709c4095b22863b17dd395 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
-rw-r--r--test/app/ImsMediaTestingApp/app/src/main/java/com/example/imsmediatestingapp/MainActivity.java68
-rw-r--r--test/app/ImsMediaTestingApp/app/src/main/res/layout/settings_video.xml20
-rw-r--r--test/app/ImsMediaTestingApp/app/src/main/res/values/strings.xml1
3 files changed, 76 insertions, 13 deletions
diff --git a/test/app/ImsMediaTestingApp/app/src/main/java/com/example/imsmediatestingapp/MainActivity.java b/test/app/ImsMediaTestingApp/app/src/main/java/com/example/imsmediatestingapp/MainActivity.java
index 0a0a6257..51e981fa 100644
--- a/test/app/ImsMediaTestingApp/app/src/main/java/com/example/imsmediatestingapp/MainActivity.java
+++ b/test/app/ImsMediaTestingApp/app/src/main/java/com/example/imsmediatestingapp/MainActivity.java
@@ -102,8 +102,8 @@ public class MainActivity extends AppCompatActivity {
private static final int DTMF_SAMPLING_RATE_KHZ = 16;
private static final int DTMF_DURATION = 140;
private static final int IDR_INTERVAL = 1;
- private static final int RESOLUTION_WIDTH = 640;
- private static final int RESOLUTION_HEIGHT = 480;
+ private static final int RESOLUTION_WIDTH = 480;
+ private static final int RESOLUTION_HEIGHT = 640;
private static final String IMAGE = "data/user_de/0/com.android.telephony.imsmedia/test.jpg";
private static final float DISABLED_ALPHA = 0.3f;
private static final float ENABLED_ALPHA = 1.0f;
@@ -134,6 +134,7 @@ public class MainActivity extends AppCompatActivity {
private int mSelectedCameraZoom = CAMERA_ZOOM;
private int mSelectedDeviceOrientationDegree = 0;
private int mSelectedCvoValue = -1;
+ private String mSelectedVideoResolution = "VGA_PR";
private Set<Integer> mSelectedRtcpFbTypes = new HashSet<>();
// The order of these values determines the priority in which they would be
@@ -569,6 +570,34 @@ public class MainActivity extends AppCompatActivity {
}
}
+ public String[] mVideoResolutionStrings = new String[] {
+ "HD_PR", "HD_LS", "VGA_PR", "VGA_LS", "QVGA_PR", "QVGA_LS", "SIF_PR", "SIF_LS", "CIF_PR",
+ "CIF_LS", "QCIF_PR", "QCIF_LS",
+ };
+
+ public int[][] mVideoResolution = {
+ {720, 1280}, {1280, 720}, {480, 640}, {640, 480}, {240, 320}, {320, 240}, {240, 352},
+ {352, 240}, {288, 352}, {352, 288}, {176, 144}, {144, 176},
+ };
+
+ public int getResolutionWidth(String resolution) {
+ for (int i = 0; i < mVideoResolutionStrings.length; i++) {
+ if (mVideoResolutionStrings[i].equals(resolution)) {
+ return mVideoResolution[i][0];
+ }
+ }
+ return RESOLUTION_WIDTH;
+ }
+
+ public int getResolutionHeight(String resolution) {
+ for (int i = 0; i < mVideoResolutionStrings.length; i++) {
+ if (mVideoResolutionStrings[i].equals(resolution)) {
+ return mVideoResolution[i][1];
+ }
+ }
+ return RESOLUTION_HEIGHT;
+ }
+
/**
* Enum of the different states the application can be in. Mainly used to decide
* how
@@ -1425,7 +1454,7 @@ public class MainActivity extends AppCompatActivity {
private VideoConfig createVideoConfig(InetSocketAddress remoteRtpAddress,
RtcpConfig rtcpConfig, int codecType, int videoMode, int framerate, int bitrate,
int profile, int level, int cameraId, int cameraZoom, int deviceOrientation, int cvo,
- int rtcpFbTypes) {
+ int rtcpFbTypes, int width, int height) {
VideoConfig config = new VideoConfig.Builder()
.setMediaDirection(RtpConfig.MEDIA_DIRECTION_SEND_RECEIVE)
.setAccessNetwork(AccessNetworkType.EUTRAN)
@@ -1446,8 +1475,8 @@ public class MainActivity extends AppCompatActivity {
.setPacketizationMode(VideoConfig.MODE_NON_INTERLEAVED)
.setCameraId(cameraId)
.setCameraZoom(cameraZoom)
- .setResolutionWidth(RESOLUTION_WIDTH)
- .setResolutionHeight(RESOLUTION_HEIGHT)
+ .setResolutionWidth(width)
+ .setResolutionHeight(height)
.setPauseImagePath(IMAGE)
.setDeviceOrientationDegree(deviceOrientation)
.setCvoValue(cvo)
@@ -1641,7 +1670,7 @@ public class MainActivity extends AppCompatActivity {
*/
private VideoConfig createVideoConfig(int codecType, int videoMode, int framerate, int bitrate,
int profile, int level, int cameraId, int cameraZoom, int deviceOrientation, int cvo,
- int rtcpFbTypes) {
+ int rtcpFbTypes, int width, int height) {
VideoConfig videoConfig = null;
switch (codecType) {
@@ -1649,7 +1678,8 @@ public class MainActivity extends AppCompatActivity {
case VideoConfig.VIDEO_CODEC_HEVC:
videoConfig = createVideoConfig(getRemoteVideoSocketAddress(),
getRemoteVideoRtcpConfig(), codecType, videoMode, framerate, bitrate,
- profile, level, cameraId, cameraZoom, deviceOrientation, cvo, rtcpFbTypes);
+ profile, level, cameraId, cameraZoom, deviceOrientation, cvo, rtcpFbTypes,
+ width, height);
break;
}
@@ -1844,7 +1874,9 @@ public class MainActivity extends AppCompatActivity {
mSelectedFramerate, mSelectedBitrate, mSelectedCodecProfile,
mSelectedCodecLevel, mSelectedCameraId, mSelectedCameraZoom,
mSelectedDeviceOrientationDegree,
- mSelectedCvoValue, rtcpfbTypes);
+ mSelectedCvoValue, rtcpfbTypes,
+ getResolutionWidth(mSelectedVideoResolution),
+ getResolutionHeight(mSelectedVideoResolution));
Log.d(TAG, "VideoConfig: " + mVideoConfig.toString());
RtpVideoSessionCallback sessionVideoCallback = new RtpVideoSessionCallback();
@@ -1906,6 +1938,7 @@ public class MainActivity extends AppCompatActivity {
Spinner videoBitrateSpinner = findViewById(R.id.spinnerVideoBitrates);
Spinner videoDeviceOrientationSpinner = findViewById(R.id.spinnerVideoDeviceOrientations);
Spinner videoCvoValueSpinner = findViewById(R.id.spinnerVideoCvoValues);
+ Spinner videoResolutionSpinner = (Spinner) findViewById(R.id.spinnerVideoResolution);
mSelectedVideoCodec =
((VideoCodecEnum) videoCodecSpinner.getSelectedItem()).getValue();
@@ -1929,6 +1962,7 @@ public class MainActivity extends AppCompatActivity {
.getValue();
mSelectedCvoValue = ((VideoCvoValueEnum) videoCvoValueSpinner.getSelectedItem())
.getValue();
+ mSelectedVideoResolution = (String) videoResolutionSpinner.getSelectedItem();
Toast.makeText(getApplicationContext(), R.string.save_button_action_toast,
Toast.LENGTH_SHORT).show();
}
@@ -2084,7 +2118,7 @@ public class MainActivity extends AppCompatActivity {
setupCodecSelectionOnClickListeners();
}
- private int getSpinnerIndex(Spinner spinner, int value) {
+ private int getSpinnerIndex(Spinner spinner, Object value) {
int index = 0;
for (int i = 0; i < spinner.getCount(); i++) {
if (spinner.getItemAtPosition(i).equals(value)) {
@@ -2107,8 +2141,7 @@ public class MainActivity extends AppCompatActivity {
}
/**
- * Gets the saved user selections for the audio codec settings and updates the
- * UI's lists to
+ * Gets the saved user selections for the audio codec settings and updates the UI's lists to
* match.
*/
private void setupAudioCodecSelectionLists() {
@@ -2236,6 +2269,15 @@ public class MainActivity extends AppCompatActivity {
videoCvoValueSpinner.setAdapter(videoCvoValueAdaptor);
videoCvoValueSpinner.setSelection(getSpinnerIndex(videoCvoValueSpinner,
mSelectedCvoValue));
+
+ Spinner videoResolutionSpinner = (Spinner) findViewById(R.id.spinnerVideoResolution);
+ ArrayAdapter<String> videoResolutionAdapter = new ArrayAdapter<String>(this,
+ android.R.layout.simple_spinner_item, mVideoResolutionStrings);
+ videoResolutionAdapter.setDropDownViewResource(
+ android.R.layout.simple_spinner_dropdown_item);
+ videoResolutionSpinner.setAdapter(videoResolutionAdapter);
+ videoResolutionSpinner.setSelection(getSpinnerIndex(videoResolutionSpinner,
+ mSelectedVideoResolution));
}
/**
@@ -2631,8 +2673,8 @@ public class MainActivity extends AppCompatActivity {
.setFramerate(10)
.setIntraFrameIntervalSec(1)
.setPacketizationMode(VideoConfig.MODE_NON_INTERLEAVED)
- .setResolutionWidth(480)
- .setResolutionHeight(640)
+ .setResolutionWidth(RESOLUTION_WIDTH)
+ .setResolutionHeight(RESOLUTION_HEIGHT)
.setVideoMode(VideoConfig.VIDEO_MODE_RECORDING)
.setMaxMtuBytes(1500);
diff --git a/test/app/ImsMediaTestingApp/app/src/main/res/layout/settings_video.xml b/test/app/ImsMediaTestingApp/app/src/main/res/layout/settings_video.xml
index 89f103ae..ec502bec 100644
--- a/test/app/ImsMediaTestingApp/app/src/main/res/layout/settings_video.xml
+++ b/test/app/ImsMediaTestingApp/app/src/main/res/layout/settings_video.xml
@@ -254,6 +254,26 @@
android:layout_toEndOf="@id/videoCvoValueTitle"
android:layout_below="@id/videoPauseImagePathTitle" />
+ <TextView
+ android:id="@+id/videoResolutionTitle"
+ android:textStyle="bold"
+ android:layout_width="150dp"
+ android:layout_height="wrap_content"
+ android:layout_marginTop="30dp"
+ android:layout_below="@id/videoCvoValueTitle"
+ android:layout_alignStart="@id/videoCodecTitle"
+ android:text="@string/video_resolution"
+ android:textAlignment="textStart" />
+
+ <Spinner
+ android:id="@+id/spinnerVideoResolution"
+ android:layout_width="200dp"
+ android:layout_height="wrap_content"
+ android:layout_marginTop="30dp"
+ android:layout_marginStart="15dp"
+ android:layout_toEndOf="@id/videoResolutionTitle"
+ android:layout_below="@id/videoCvoValueTitle" />
+
<Button
android:id="@+id/saveVideoSettingsButton"
android:layout_width="wrap_content"
diff --git a/test/app/ImsMediaTestingApp/app/src/main/res/values/strings.xml b/test/app/ImsMediaTestingApp/app/src/main/res/values/strings.xml
index 37d6b5a7..7dd2cf86 100644
--- a/test/app/ImsMediaTestingApp/app/src/main/res/values/strings.xml
+++ b/test/app/ImsMediaTestingApp/app/src/main/res/values/strings.xml
@@ -64,6 +64,7 @@
<string name="video_device_orientation">Device Orientation</string>
<string name="video_pause_image_path">Pause Image Path</string>
<string name="video_cvo_value">CVO Value</string>
+ <string name="video_resolution">Resolution</string>
<!-- Save button text -->
<string name="save">SAVE</string>