AndroidVideoCapturer getSupportedFormats(): Change interface from JSON string to List/vector
This CL simplifies the VideoCapturer interface from 'String getSupportedFormatsAsJson() throws JSONException' to 'List<CaptureFormat> getSupportedFormats()'. The intermediate conversion to/from a JSON string is removed, and AndroidVideoCapturerJni converts the Java list to a C++ vector directly instead. BUG=webrtc:5519 R=perkj@webrtc.org Review URL: https://codereview.webrtc.org/1702603002 . Cr-Commit-Position: refs/heads/master@{#11669}
This commit is contained in:
@ -14,10 +14,6 @@ import static java.lang.Math.abs;
|
||||
import static java.lang.Math.ceil;
|
||||
import android.graphics.ImageFormat;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import org.webrtc.Logging;
|
||||
|
||||
import java.util.Collections;
|
||||
@ -42,7 +38,9 @@ public class CameraEnumerationAndroid {
|
||||
}
|
||||
|
||||
public static synchronized List<CaptureFormat> getSupportedFormats(int cameraId) {
|
||||
return enumerator.getSupportedFormats(cameraId);
|
||||
final List<CaptureFormat> formats = enumerator.getSupportedFormats(cameraId);
|
||||
Logging.d(TAG, "Supported formats for camera " + cameraId + ": " + formats);
|
||||
return formats;
|
||||
}
|
||||
|
||||
public static class CaptureFormat {
|
||||
@ -137,21 +135,6 @@ public class CameraEnumerationAndroid {
|
||||
return getNameOfDevice(android.hardware.Camera.CameraInfo.CAMERA_FACING_BACK);
|
||||
}
|
||||
|
||||
public static String getSupportedFormatsAsJson(int id) throws JSONException {
|
||||
List<CaptureFormat> formats = getSupportedFormats(id);
|
||||
JSONArray json_formats = new JSONArray();
|
||||
for (CaptureFormat format : formats) {
|
||||
JSONObject json_format = new JSONObject();
|
||||
json_format.put("width", format.width);
|
||||
json_format.put("height", format.height);
|
||||
json_format.put("framerate", (format.maxFramerate + 999) / 1000);
|
||||
json_formats.put(json_format);
|
||||
}
|
||||
Logging.d(TAG, "Supported formats for camera " + id + ": "
|
||||
+ json_formats.toString(2));
|
||||
return json_formats.toString();
|
||||
}
|
||||
|
||||
// Helper class for finding the closest supported format for the two functions below.
|
||||
private static abstract class ClosestComparator<T> implements Comparator<T> {
|
||||
// Difference between supported and requested parameter.
|
||||
|
||||
@ -17,7 +17,6 @@ import android.os.SystemClock;
|
||||
import android.view.Surface;
|
||||
import android.view.WindowManager;
|
||||
|
||||
import org.json.JSONException;
|
||||
import org.webrtc.CameraEnumerationAndroid.CaptureFormat;
|
||||
import org.webrtc.Logging;
|
||||
|
||||
@ -284,6 +283,7 @@ public class VideoCapturerAndroid implements
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CaptureFormat> getSupportedFormats() {
|
||||
return CameraEnumerationAndroid.getSupportedFormats(getCurrentCameraId());
|
||||
}
|
||||
@ -293,11 +293,6 @@ public class VideoCapturerAndroid implements
|
||||
return isCapturingToTexture;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSupportedFormatsAsJson() throws JSONException {
|
||||
return CameraEnumerationAndroid.getSupportedFormatsAsJson(getCurrentCameraId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public SurfaceTextureHelper getSurfaceTextureHelper() {
|
||||
return surfaceHelper;
|
||||
|
||||
Reference in New Issue
Block a user