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}
This commit is contained in:
Danil Chapovalov
2020-03-09 15:39:39 +01:00
committed by Commit Bot
parent afa2e5f18c
commit 4e1d6ce384
9 changed files with 44 additions and 43 deletions

View File

@ -405,7 +405,7 @@ if (is_android) {
"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 = [

View File

@ -94,7 +94,7 @@ public class HardwareVideoEncoderFactory implements VideoEncoderFactory {
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 @@ public class HardwareVideoEncoderFactory implements VideoEncoderFactory {
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 @@ public class HardwareVideoEncoderFactory implements VideoEncoderFactory {
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 @@ public class HardwareVideoEncoderFactory implements VideoEncoderFactory {
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 @@ public class HardwareVideoEncoderFactory implements VideoEncoderFactory {
}
// 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 @@ public class HardwareVideoEncoderFactory implements VideoEncoderFactory {
// 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 @@ public class HardwareVideoEncoderFactory implements VideoEncoderFactory {
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 @@ public class HardwareVideoEncoderFactory implements VideoEncoderFactory {
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 @@ public class HardwareVideoEncoderFactory implements VideoEncoderFactory {
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 {

View File

@ -56,7 +56,7 @@ class AndroidVideoDecoder implements VideoDecoder, VideoSink {
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 @@ class AndroidVideoDecoder implements VideoDecoder, VideoSink {
@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);
}

View File

@ -103,7 +103,7 @@ class HardwareVideoEncoder implements VideoEncoder {
// --- 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 @@ class HardwareVideoEncoder implements VideoEncoder {
* @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 @@ class HardwareVideoEncoder implements VideoEncoder {
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 @@ class HardwareVideoEncoder implements VideoEncoder {
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 @@ class HardwareVideoEncoder implements VideoEncoder {
}
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);

View File

@ -76,7 +76,7 @@ class MediaCodecUtils {
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 @@ class MediaCodecUtils {
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:

View File

@ -46,7 +46,7 @@ class MediaCodecVideoDecoderFactory implements VideoDecoderFactory {
@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 @@ class MediaCodecVideoDecoderFactory implements VideoDecoderFactory {
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 @@ class MediaCodecVideoDecoderFactory implements VideoDecoderFactory {
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 @@ class MediaCodecVideoDecoderFactory implements VideoDecoderFactory {
}
// 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;

View File

@ -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;
}

View File

@ -62,7 +62,7 @@ public class AndroidVideoDecoderTest {
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 @@ public class AndroidVideoDecoderTest {
}
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 @@ public class AndroidVideoDecoderTest {
@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 @@ public class AndroidVideoDecoderTest {
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

View File

@ -63,7 +63,7 @@ public class HardwareVideoEncoderTest {
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 @@ public class HardwareVideoEncoderTest {
}
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 class HardwareVideoEncoderTest {
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 @@ public class HardwareVideoEncoderTest {
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);