Rename java VideoCodecType to VideoCodecMimeType
to avoid collission and confusion with VideoCodeType based on
c++ enum with the same name.
Bug: b/148146536
Change-Id: I049cce21d59f454c7ce507fdfc3a85d168f96223
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/170048
Reviewed-by: Sami Kalliomäki <sakal@webrtc.org>
Commit-Queue: Danil Chapovalov <danilchap@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#30728}
diff --git a/sdk/android/BUILD.gn b/sdk/android/BUILD.gn
index 278b0d9..1a5dc82 100644
--- a/sdk/android/BUILD.gn
+++ b/sdk/android/BUILD.gn
@@ -405,7 +405,7 @@
"src/java/org/webrtc/MediaCodecWrapperFactory.java",
"src/java/org/webrtc/MediaCodecWrapperFactoryImpl.java",
"src/java/org/webrtc/NV12Buffer.java",
- "src/java/org/webrtc/VideoCodecType.java",
+ "src/java/org/webrtc/VideoCodecMimeType.java",
]
deps = [
diff --git a/sdk/android/api/org/webrtc/HardwareVideoEncoderFactory.java b/sdk/android/api/org/webrtc/HardwareVideoEncoderFactory.java
index b6c397a..8fe8b36 100644
--- a/sdk/android/api/org/webrtc/HardwareVideoEncoderFactory.java
+++ b/sdk/android/api/org/webrtc/HardwareVideoEncoderFactory.java
@@ -94,7 +94,7 @@
return null;
}
- VideoCodecType type = VideoCodecType.valueOf(input.name);
+ VideoCodecMimeType type = VideoCodecMimeType.valueOf(input.name);
MediaCodecInfo info = findCodecForType(type);
if (info == null) {
@@ -108,7 +108,7 @@
Integer yuvColorFormat = MediaCodecUtils.selectColorFormat(
MediaCodecUtils.ENCODER_COLOR_FORMATS, info.getCapabilitiesForType(mime));
- if (type == VideoCodecType.H264) {
+ if (type == VideoCodecMimeType.H264) {
boolean isHighProfile = H264Utils.isSameH264Profile(
input.params, MediaCodecUtils.getCodecProperties(type, /* highProfile= */ true));
boolean isBaselineProfile = H264Utils.isSameH264Profile(
@@ -138,14 +138,14 @@
List<VideoCodecInfo> supportedCodecInfos = new ArrayList<VideoCodecInfo>();
// Generate a list of supported codecs in order of preference:
// VP8, VP9, H264 (high profile), and H264 (baseline profile).
- for (VideoCodecType type :
- new VideoCodecType[] {VideoCodecType.VP8, VideoCodecType.VP9, VideoCodecType.H264}) {
+ for (VideoCodecMimeType type : new VideoCodecMimeType[] {
+ VideoCodecMimeType.VP8, VideoCodecMimeType.VP9, VideoCodecMimeType.H264}) {
MediaCodecInfo codec = findCodecForType(type);
if (codec != null) {
String name = type.name();
// TODO(sakal): Always add H264 HP once WebRTC correctly removes codecs that are not
// supported by the decoder.
- if (type == VideoCodecType.H264 && isH264HighProfileSupported(codec)) {
+ if (type == VideoCodecMimeType.H264 && isH264HighProfileSupported(codec)) {
supportedCodecInfos.add(new VideoCodecInfo(
name, MediaCodecUtils.getCodecProperties(type, /* highProfile= */ true)));
}
@@ -158,7 +158,7 @@
return supportedCodecInfos.toArray(new VideoCodecInfo[supportedCodecInfos.size()]);
}
- private @Nullable MediaCodecInfo findCodecForType(VideoCodecType type) {
+ private @Nullable MediaCodecInfo findCodecForType(VideoCodecMimeType type) {
for (int i = 0; i < MediaCodecList.getCodecCount(); ++i) {
MediaCodecInfo info = null;
try {
@@ -179,7 +179,7 @@
}
// Returns true if the given MediaCodecInfo indicates a supported encoder for the given type.
- private boolean isSupportedCodec(MediaCodecInfo info, VideoCodecType type) {
+ private boolean isSupportedCodec(MediaCodecInfo info, VideoCodecMimeType type) {
if (!MediaCodecUtils.codecSupportsType(info, type)) {
return false;
}
@@ -194,7 +194,7 @@
// Returns true if the given MediaCodecInfo indicates a hardware module that is supported on the
// current SDK.
- private boolean isHardwareSupportedInCurrentSdk(MediaCodecInfo info, VideoCodecType type) {
+ private boolean isHardwareSupportedInCurrentSdk(MediaCodecInfo info, VideoCodecMimeType type) {
switch (type) {
case VP8:
return isHardwareSupportedInCurrentSdkVp8(info);
@@ -244,7 +244,7 @@
return codecAllowedPredicate.test(info);
}
- private int getKeyFrameIntervalSec(VideoCodecType type) {
+ private int getKeyFrameIntervalSec(VideoCodecMimeType type) {
switch (type) {
case VP8: // Fallthrough intended.
case VP9:
@@ -252,11 +252,11 @@
case H264:
return 20;
}
- throw new IllegalArgumentException("Unsupported VideoCodecType " + type);
+ throw new IllegalArgumentException("Unsupported VideoCodecMimeType " + type);
}
- private int getForcedKeyFrameIntervalMs(VideoCodecType type, String codecName) {
- if (type == VideoCodecType.VP8 && codecName.startsWith(QCOM_PREFIX)) {
+ private int getForcedKeyFrameIntervalMs(VideoCodecMimeType type, String codecName) {
+ if (type == VideoCodecMimeType.VP8 && codecName.startsWith(QCOM_PREFIX)) {
if (Build.VERSION.SDK_INT == Build.VERSION_CODES.LOLLIPOP
|| Build.VERSION.SDK_INT == Build.VERSION_CODES.LOLLIPOP_MR1) {
return QCOM_VP8_KEY_FRAME_INTERVAL_ANDROID_L_MS;
@@ -270,9 +270,9 @@
return 0;
}
- private BitrateAdjuster createBitrateAdjuster(VideoCodecType type, String codecName) {
+ private BitrateAdjuster createBitrateAdjuster(VideoCodecMimeType type, String codecName) {
if (codecName.startsWith(EXYNOS_PREFIX)) {
- if (type == VideoCodecType.VP8) {
+ if (type == VideoCodecMimeType.VP8) {
// Exynos VP8 encoders need dynamic bitrate adjustment.
return new DynamicBitrateAdjuster();
} else {
diff --git a/sdk/android/src/java/org/webrtc/AndroidVideoDecoder.java b/sdk/android/src/java/org/webrtc/AndroidVideoDecoder.java
index 5b6e030..b797e25 100644
--- a/sdk/android/src/java/org/webrtc/AndroidVideoDecoder.java
+++ b/sdk/android/src/java/org/webrtc/AndroidVideoDecoder.java
@@ -56,7 +56,7 @@
private final MediaCodecWrapperFactory mediaCodecWrapperFactory;
private final String codecName;
- private final VideoCodecType codecType;
+ private final VideoCodecMimeType codecType;
private static class FrameInfo {
final long decodeStartTimeMs;
@@ -129,7 +129,7 @@
@Nullable private MediaCodecWrapper codec;
AndroidVideoDecoder(MediaCodecWrapperFactory mediaCodecWrapperFactory, String codecName,
- VideoCodecType codecType, int colorFormat, @Nullable EglBase.Context sharedContext) {
+ VideoCodecMimeType codecType, int colorFormat, @Nullable EglBase.Context sharedContext) {
if (!isSupportedColorFormat(colorFormat)) {
throw new IllegalArgumentException("Unsupported color format: " + colorFormat);
}
diff --git a/sdk/android/src/java/org/webrtc/HardwareVideoEncoder.java b/sdk/android/src/java/org/webrtc/HardwareVideoEncoder.java
index 5cfd065..42800ae 100644
--- a/sdk/android/src/java/org/webrtc/HardwareVideoEncoder.java
+++ b/sdk/android/src/java/org/webrtc/HardwareVideoEncoder.java
@@ -103,7 +103,7 @@
// --- Initialized on construction.
private final MediaCodecWrapperFactory mediaCodecWrapperFactory;
private final String codecName;
- private final VideoCodecType codecType;
+ private final VideoCodecMimeType codecType;
private final Integer surfaceColorFormat;
private final Integer yuvColorFormat;
private final YuvFormat yuvFormat;
@@ -180,7 +180,7 @@
* @throws IllegalArgumentException if colorFormat is unsupported
*/
public HardwareVideoEncoder(MediaCodecWrapperFactory mediaCodecWrapperFactory, String codecName,
- VideoCodecType codecType, Integer surfaceColorFormat, Integer yuvColorFormat,
+ VideoCodecMimeType codecType, Integer surfaceColorFormat, Integer yuvColorFormat,
Map<String, String> params, int keyFrameIntervalSec, int forceKeyFrameIntervalMs,
BitrateAdjuster bitrateAdjuster, EglBase14.Context sharedContext) {
this.mediaCodecWrapperFactory = mediaCodecWrapperFactory;
@@ -240,7 +240,7 @@
format.setInteger(MediaFormat.KEY_COLOR_FORMAT, colorFormat);
format.setInteger(MediaFormat.KEY_FRAME_RATE, bitrateAdjuster.getCodecConfigFramerate());
format.setInteger(MediaFormat.KEY_I_FRAME_INTERVAL, keyFrameIntervalSec);
- if (codecType == VideoCodecType.H264) {
+ if (codecType == VideoCodecMimeType.H264) {
String profileLevelId = params.get(VideoCodecInfo.H264_FMTP_PROFILE_LEVEL_ID);
if (profileLevelId == null) {
profileLevelId = VideoCodecInfo.H264_CONSTRAINED_BASELINE_3_1;
@@ -465,11 +465,11 @@
public ScalingSettings getScalingSettings() {
encodeThreadChecker.checkIsOnValidThread();
if (automaticResizeOn) {
- if (codecType == VideoCodecType.VP8) {
+ if (codecType == VideoCodecMimeType.VP8) {
final int kLowVp8QpThreshold = 29;
final int kHighVp8QpThreshold = 95;
return new ScalingSettings(kLowVp8QpThreshold, kHighVp8QpThreshold);
- } else if (codecType == VideoCodecType.H264) {
+ } else if (codecType == VideoCodecMimeType.H264) {
final int kLowH264QpThreshold = 24;
final int kHighH264QpThreshold = 37;
return new ScalingSettings(kLowH264QpThreshold, kHighH264QpThreshold);
@@ -563,7 +563,7 @@
}
final ByteBuffer frameBuffer;
- if (isKeyFrame && codecType == VideoCodecType.H264) {
+ if (isKeyFrame && codecType == VideoCodecMimeType.H264) {
Logging.d(TAG,
"Prepending config frame of size " + configBuffer.capacity()
+ " to output buffer with offset " + info.offset + ", size " + info.size);
diff --git a/sdk/android/src/java/org/webrtc/MediaCodecUtils.java b/sdk/android/src/java/org/webrtc/MediaCodecUtils.java
index 8223317..9028cc3 100644
--- a/sdk/android/src/java/org/webrtc/MediaCodecUtils.java
+++ b/sdk/android/src/java/org/webrtc/MediaCodecUtils.java
@@ -76,7 +76,7 @@
return null;
}
- static boolean codecSupportsType(MediaCodecInfo info, VideoCodecType type) {
+ static boolean codecSupportsType(MediaCodecInfo info, VideoCodecMimeType type) {
for (String mimeType : info.getSupportedTypes()) {
if (type.mimeType().equals(mimeType)) {
return true;
@@ -85,7 +85,7 @@
return false;
}
- static Map<String, String> getCodecProperties(VideoCodecType type, boolean highProfile) {
+ static Map<String, String> getCodecProperties(VideoCodecMimeType type, boolean highProfile) {
switch (type) {
case VP8:
case VP9:
diff --git a/sdk/android/src/java/org/webrtc/MediaCodecVideoDecoderFactory.java b/sdk/android/src/java/org/webrtc/MediaCodecVideoDecoderFactory.java
index 4d18ca4..036aca5 100644
--- a/sdk/android/src/java/org/webrtc/MediaCodecVideoDecoderFactory.java
+++ b/sdk/android/src/java/org/webrtc/MediaCodecVideoDecoderFactory.java
@@ -46,7 +46,7 @@
@Nullable
@Override
public VideoDecoder createDecoder(VideoCodecInfo codecType) {
- VideoCodecType type = VideoCodecType.valueOf(codecType.getName());
+ VideoCodecMimeType type = VideoCodecMimeType.valueOf(codecType.getName());
MediaCodecInfo info = findCodecForType(type);
if (info == null) {
@@ -64,12 +64,12 @@
List<VideoCodecInfo> supportedCodecInfos = new ArrayList<VideoCodecInfo>();
// Generate a list of supported codecs in order of preference:
// VP8, VP9, H264 (high profile), and H264 (baseline profile).
- for (VideoCodecType type :
- new VideoCodecType[] {VideoCodecType.VP8, VideoCodecType.VP9, VideoCodecType.H264}) {
+ for (VideoCodecMimeType type : new VideoCodecMimeType[] {
+ VideoCodecMimeType.VP8, VideoCodecMimeType.VP9, VideoCodecMimeType.H264}) {
MediaCodecInfo codec = findCodecForType(type);
if (codec != null) {
String name = type.name();
- if (type == VideoCodecType.H264 && isH264HighProfileSupported(codec)) {
+ if (type == VideoCodecMimeType.H264 && isH264HighProfileSupported(codec)) {
supportedCodecInfos.add(new VideoCodecInfo(
name, MediaCodecUtils.getCodecProperties(type, /* highProfile= */ true)));
}
@@ -82,7 +82,7 @@
return supportedCodecInfos.toArray(new VideoCodecInfo[supportedCodecInfos.size()]);
}
- private @Nullable MediaCodecInfo findCodecForType(VideoCodecType type) {
+ private @Nullable MediaCodecInfo findCodecForType(VideoCodecMimeType type) {
// HW decoding is not supported on builds before KITKAT.
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {
return null;
@@ -109,7 +109,7 @@
}
// Returns true if the given MediaCodecInfo indicates a supported encoder for the given type.
- private boolean isSupportedCodec(MediaCodecInfo info, VideoCodecType type) {
+ private boolean isSupportedCodec(MediaCodecInfo info, VideoCodecMimeType type) {
String name = info.getName();
if (!MediaCodecUtils.codecSupportsType(info, type)) {
return false;
diff --git a/sdk/android/src/java/org/webrtc/VideoCodecType.java b/sdk/android/src/java/org/webrtc/VideoCodecMimeType.java
similarity index 89%
rename from sdk/android/src/java/org/webrtc/VideoCodecType.java
rename to sdk/android/src/java/org/webrtc/VideoCodecMimeType.java
index 2d4ef9a..f27a917 100644
--- a/sdk/android/src/java/org/webrtc/VideoCodecType.java
+++ b/sdk/android/src/java/org/webrtc/VideoCodecMimeType.java
@@ -11,14 +11,14 @@
package org.webrtc;
/** Enumeration of supported video codec types. */
-enum VideoCodecType {
+enum VideoCodecMimeType {
VP8("video/x-vnd.on2.vp8"),
VP9("video/x-vnd.on2.vp9"),
H264("video/avc");
private final String mimeType;
- private VideoCodecType(String mimeType) {
+ private VideoCodecMimeType(String mimeType) {
this.mimeType = mimeType;
}
diff --git a/sdk/android/tests/src/org/webrtc/AndroidVideoDecoderTest.java b/sdk/android/tests/src/org/webrtc/AndroidVideoDecoderTest.java
index fde99a1..c1e8f6c 100644
--- a/sdk/android/tests/src/org/webrtc/AndroidVideoDecoderTest.java
+++ b/sdk/android/tests/src/org/webrtc/AndroidVideoDecoderTest.java
@@ -62,7 +62,7 @@
private boolean deliverDecodedFrameDone = true;
public TestDecoder(MediaCodecWrapperFactory mediaCodecFactory, String codecName,
- VideoCodecType codecType, int colorFormat, EglBase.Context sharedContext) {
+ VideoCodecMimeType codecType, int colorFormat, EglBase.Context sharedContext) {
super(mediaCodecFactory, codecName, codecType, colorFormat, sharedContext);
}
@@ -143,10 +143,10 @@
}
private class TestDecoderBuilder {
- private VideoCodecType codecType = VideoCodecType.VP8;
+ private VideoCodecMimeType codecType = VideoCodecMimeType.VP8;
private boolean useSurface = true;
- public TestDecoderBuilder setCodecType(VideoCodecType codecType) {
+ public TestDecoderBuilder setCodecType(VideoCodecMimeType codecType) {
this.codecType = codecType;
return this;
}
@@ -216,7 +216,8 @@
@Test
public void testInit() {
// Set-up.
- AndroidVideoDecoder decoder = new TestDecoderBuilder().setCodecType(VideoCodecType.VP8).build();
+ AndroidVideoDecoder decoder =
+ new TestDecoderBuilder().setCodecType(VideoCodecMimeType.VP8).build();
// Test.
assertThat(decoder.initDecode(TEST_DECODER_SETTINGS, mockDecoderCallback))
@@ -232,7 +233,7 @@
assertThat(mediaFormat.getInteger(MediaFormat.KEY_HEIGHT))
.isEqualTo(TEST_DECODER_SETTINGS.height);
assertThat(mediaFormat.getString(MediaFormat.KEY_MIME))
- .isEqualTo(VideoCodecType.VP8.mimeType());
+ .isEqualTo(VideoCodecMimeType.VP8.mimeType());
}
@Test
diff --git a/sdk/android/tests/src/org/webrtc/HardwareVideoEncoderTest.java b/sdk/android/tests/src/org/webrtc/HardwareVideoEncoderTest.java
index 7de3a42..2eca89f 100644
--- a/sdk/android/tests/src/org/webrtc/HardwareVideoEncoderTest.java
+++ b/sdk/android/tests/src/org/webrtc/HardwareVideoEncoderTest.java
@@ -63,7 +63,7 @@
private boolean deliverEncodedImageDone = true;
TestEncoder(MediaCodecWrapperFactory mediaCodecWrapperFactory, String codecName,
- VideoCodecType codecType, Integer surfaceColorFormat, Integer yuvColorFormat,
+ VideoCodecMimeType codecType, Integer surfaceColorFormat, Integer yuvColorFormat,
Map<String, String> params, int keyFrameIntervalSec, int forceKeyFrameIntervalMs,
BitrateAdjuster bitrateAdjuster, EglBase14.Context sharedContext) {
super(mediaCodecWrapperFactory, codecName, codecType, surfaceColorFormat, yuvColorFormat,
@@ -113,9 +113,9 @@
}
private class TestEncoderBuilder {
- private VideoCodecType codecType = VideoCodecType.VP8;
+ private VideoCodecMimeType codecType = VideoCodecMimeType.VP8;
- public TestEncoderBuilder setCodecType(VideoCodecType codecType) {
+ public TestEncoderBuilder setCodecType(VideoCodecMimeType codecType) {
this.codecType = codecType;
return this;
}
@@ -149,7 +149,7 @@
public void testInit() {
// Set-up.
HardwareVideoEncoder encoder =
- new TestEncoderBuilder().setCodecType(VideoCodecType.VP8).build();
+ new TestEncoderBuilder().setCodecType(VideoCodecMimeType.VP8).build();
// Test.
assertThat(encoder.initEncode(TEST_ENCODER_SETTINGS, mockEncoderCallback))
@@ -165,7 +165,7 @@
assertThat(mediaFormat.getInteger(MediaFormat.KEY_HEIGHT))
.isEqualTo(TEST_ENCODER_SETTINGS.height);
assertThat(mediaFormat.getString(MediaFormat.KEY_MIME))
- .isEqualTo(VideoCodecType.VP8.mimeType());
+ .isEqualTo(VideoCodecMimeType.VP8.mimeType());
assertThat(fakeMediaCodecWrapper.getConfiguredFlags())
.isEqualTo(MediaCodec.CONFIGURE_FLAG_ENCODE);