Automate conversion from c++ VideoCodeType to java VideoCodecType
Bug: b/148146536 Change-Id: I030c7c6c2a1a9d002bcc60f45c8d6025bd0935b8 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/167301 Reviewed-by: Sami Kalliomäki <sakal@webrtc.org> Reviewed-by: Magnus Jedvert <magjed@webrtc.org> Commit-Queue: Danil Chapovalov <danilchap@webrtc.org> Cr-Commit-Position: refs/heads/master@{#30751}
This commit is contained in:
committed by
Commit Bot
parent
984dc32776
commit
59f3b71c04
@ -7,6 +7,10 @@
|
|||||||
# be found in the AUTHORS file in the root of the source tree.
|
# be found in the AUTHORS file in the root of the source tree.
|
||||||
|
|
||||||
import("../../webrtc.gni")
|
import("../../webrtc.gni")
|
||||||
|
if (is_android) {
|
||||||
|
import("//build/config/android/config.gni")
|
||||||
|
import("//build/config/android/rules.gni")
|
||||||
|
}
|
||||||
|
|
||||||
rtc_library("video_rtp_headers") {
|
rtc_library("video_rtp_headers") {
|
||||||
visibility = [ "*" ]
|
visibility = [ "*" ]
|
||||||
@ -56,6 +60,12 @@ rtc_library("video_frame") {
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (is_android) {
|
||||||
|
java_cpp_enum("video_frame_enums") {
|
||||||
|
sources = [ "video_codec_type.h" ]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
rtc_source_set("recordable_encoded_frame") {
|
rtc_source_set("recordable_encoded_frame") {
|
||||||
visibility = [ "*" ]
|
visibility = [ "*" ]
|
||||||
sources = [ "recordable_encoded_frame.h" ]
|
sources = [ "recordable_encoded_frame.h" ]
|
||||||
|
|||||||
@ -13,7 +13,7 @@
|
|||||||
|
|
||||||
namespace webrtc {
|
namespace webrtc {
|
||||||
|
|
||||||
// Video codec types
|
// GENERATED_JAVA_ENUM_PACKAGE: org.webrtc
|
||||||
enum VideoCodecType {
|
enum VideoCodecType {
|
||||||
// There are various memset(..., 0, ...) calls in the code that rely on
|
// There are various memset(..., 0, ...) calls in the code that rely on
|
||||||
// kVideoCodecGeneric being zero.
|
// kVideoCodecGeneric being zero.
|
||||||
|
|||||||
@ -327,6 +327,7 @@ if (is_android) {
|
|||||||
"//rtc_base:base_java",
|
"//rtc_base:base_java",
|
||||||
"//third_party/android_deps:com_android_support_support_annotations_java",
|
"//third_party/android_deps:com_android_support_support_annotations_java",
|
||||||
]
|
]
|
||||||
|
srcjar_deps = [ "//api/video:video_frame_enums" ]
|
||||||
}
|
}
|
||||||
|
|
||||||
# Modules, in alphabetical order.
|
# Modules, in alphabetical order.
|
||||||
|
|||||||
@ -134,20 +134,6 @@ public class MediaCodecVideoDecoder {
|
|||||||
private static final String FORMAT_KEY_CROP_TOP = "crop-top";
|
private static final String FORMAT_KEY_CROP_TOP = "crop-top";
|
||||||
private static final String FORMAT_KEY_CROP_BOTTOM = "crop-bottom";
|
private static final String FORMAT_KEY_CROP_BOTTOM = "crop-bottom";
|
||||||
|
|
||||||
// Tracks webrtc::VideoCodecType.
|
|
||||||
public enum VideoCodecType {
|
|
||||||
VIDEO_CODEC_UNKNOWN,
|
|
||||||
VIDEO_CODEC_VP8,
|
|
||||||
VIDEO_CODEC_VP9,
|
|
||||||
VIDEO_CODEC_AV1,
|
|
||||||
VIDEO_CODEC_H264;
|
|
||||||
|
|
||||||
@CalledByNative("VideoCodecType")
|
|
||||||
static VideoCodecType fromNativeIndex(int nativeIndex) {
|
|
||||||
return values()[nativeIndex];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Timeout for input buffer dequeue.
|
// Timeout for input buffer dequeue.
|
||||||
private static final int DEQUEUE_INPUT_TIMEOUT = 500000;
|
private static final int DEQUEUE_INPUT_TIMEOUT = 500000;
|
||||||
// Timeout for codec releasing.
|
// Timeout for codec releasing.
|
||||||
@ -423,7 +409,7 @@ public class MediaCodecVideoDecoder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@CalledByNativeUnchecked
|
@CalledByNativeUnchecked
|
||||||
private boolean initDecode(VideoCodecType type, int width, int height) {
|
private boolean initDecode(@VideoCodecType int type, int width, int height) {
|
||||||
if (mediaCodecThread != null) {
|
if (mediaCodecThread != null) {
|
||||||
throw new RuntimeException("initDecode: Forgot to release()?");
|
throw new RuntimeException("initDecode: Forgot to release()?");
|
||||||
}
|
}
|
||||||
|
|||||||
@ -135,20 +135,6 @@ public class MediaCodecVideoEncoder {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Tracks webrtc::VideoCodecType.
|
|
||||||
public enum VideoCodecType {
|
|
||||||
VIDEO_CODEC_UNKNOWN,
|
|
||||||
VIDEO_CODEC_VP8,
|
|
||||||
VIDEO_CODEC_VP9,
|
|
||||||
VIDEO_CODEC_AV1,
|
|
||||||
VIDEO_CODEC_H264;
|
|
||||||
|
|
||||||
@CalledByNative("VideoCodecType")
|
|
||||||
static VideoCodecType fromNativeIndex(int nativeIndex) {
|
|
||||||
return values()[nativeIndex];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static final int MEDIA_CODEC_RELEASE_TIMEOUT_MS = 5000; // Timeout for codec releasing.
|
private static final int MEDIA_CODEC_RELEASE_TIMEOUT_MS = 5000; // Timeout for codec releasing.
|
||||||
private static final int DEQUEUE_TIMEOUT = 0; // Non-blocking, no wait.
|
private static final int DEQUEUE_TIMEOUT = 0; // Non-blocking, no wait.
|
||||||
private static final int BITRATE_ADJUSTMENT_FPS = 30;
|
private static final int BITRATE_ADJUSTMENT_FPS = 30;
|
||||||
@ -331,7 +317,7 @@ public class MediaCodecVideoEncoder {
|
|||||||
CodecCapabilities.COLOR_QCOM_FormatYUV420SemiPlanar,
|
CodecCapabilities.COLOR_QCOM_FormatYUV420SemiPlanar,
|
||||||
COLOR_QCOM_FORMATYUV420PackedSemiPlanar32m};
|
COLOR_QCOM_FORMATYUV420PackedSemiPlanar32m};
|
||||||
private static final int[] supportedSurfaceColorList = {CodecCapabilities.COLOR_FormatSurface};
|
private static final int[] supportedSurfaceColorList = {CodecCapabilities.COLOR_FormatSurface};
|
||||||
private VideoCodecType type;
|
@VideoCodecType private int type;
|
||||||
private int colorFormat;
|
private int colorFormat;
|
||||||
|
|
||||||
// Variables used for dynamic bitrate adjustment.
|
// Variables used for dynamic bitrate adjustment.
|
||||||
@ -559,8 +545,8 @@ public class MediaCodecVideoEncoder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@CalledByNativeUnchecked
|
@CalledByNativeUnchecked
|
||||||
boolean initEncode(VideoCodecType type, int profile, int width, int height, int kbps, int fps,
|
boolean initEncode(@VideoCodecType int type, int profile, int width, int height, int kbps,
|
||||||
boolean useSurface) {
|
int fps, boolean useSurface) {
|
||||||
Logging.d(TAG,
|
Logging.d(TAG,
|
||||||
"Java initEncode: " + type + ". Profile: " + profile + " : " + width + " x " + height
|
"Java initEncode: " + type + ". Profile: " + profile + " : " + width + " x " + height
|
||||||
+ ". @ " + kbps + " kbps. Fps: " + fps + ". Encode from texture : " + useSurface);
|
+ ". @ " + kbps + " kbps. Fps: " + fps + ". Encode from texture : " + useSurface);
|
||||||
|
|||||||
@ -38,8 +38,8 @@ public class MediaCodecVideoEncoderTest {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
MediaCodecVideoEncoder encoder = new MediaCodecVideoEncoder();
|
MediaCodecVideoEncoder encoder = new MediaCodecVideoEncoder();
|
||||||
assertTrue(encoder.initEncode(MediaCodecVideoEncoder.VideoCodecType.VIDEO_CODEC_VP8, profile,
|
assertTrue(encoder.initEncode(
|
||||||
640, 480, 300, 30, /* useSurface= */ false));
|
VideoCodecType.VIDEO_CODEC_VP8, profile, 640, 480, 300, 30, /* useSurface= */ false));
|
||||||
encoder.release();
|
encoder.release();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -53,8 +53,8 @@ public class MediaCodecVideoEncoderTest {
|
|||||||
EglBase14 eglBase = EglBase.createEgl14(EglBase.CONFIG_PLAIN);
|
EglBase14 eglBase = EglBase.createEgl14(EglBase.CONFIG_PLAIN);
|
||||||
MediaCodecVideoEncoder.setEglContext(eglBase.getEglBaseContext());
|
MediaCodecVideoEncoder.setEglContext(eglBase.getEglBaseContext());
|
||||||
MediaCodecVideoEncoder encoder = new MediaCodecVideoEncoder();
|
MediaCodecVideoEncoder encoder = new MediaCodecVideoEncoder();
|
||||||
assertTrue(encoder.initEncode(MediaCodecVideoEncoder.VideoCodecType.VIDEO_CODEC_VP8, profile,
|
assertTrue(encoder.initEncode(
|
||||||
640, 480, 300, 30, /* useSurface= */ true));
|
VideoCodecType.VIDEO_CODEC_VP8, profile, 640, 480, 300, 30, /* useSurface= */ true));
|
||||||
encoder.release();
|
encoder.release();
|
||||||
MediaCodecVideoEncoder.disposeEglContext();
|
MediaCodecVideoEncoder.disposeEglContext();
|
||||||
eglBase.release();
|
eglBase.release();
|
||||||
@ -68,13 +68,13 @@ public class MediaCodecVideoEncoderTest {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
MediaCodecVideoEncoder encoder = new MediaCodecVideoEncoder();
|
MediaCodecVideoEncoder encoder = new MediaCodecVideoEncoder();
|
||||||
assertTrue(encoder.initEncode(MediaCodecVideoEncoder.VideoCodecType.VIDEO_CODEC_VP8, profile,
|
assertTrue(encoder.initEncode(
|
||||||
640, 480, 300, 30, /* useSurface= */ false));
|
VideoCodecType.VIDEO_CODEC_VP8, profile, 640, 480, 300, 30, /* useSurface= */ false));
|
||||||
encoder.release();
|
encoder.release();
|
||||||
EglBase14 eglBase = EglBase.createEgl14(EglBase.CONFIG_PLAIN);
|
EglBase14 eglBase = EglBase.createEgl14(EglBase.CONFIG_PLAIN);
|
||||||
MediaCodecVideoEncoder.setEglContext(eglBase.getEglBaseContext());
|
MediaCodecVideoEncoder.setEglContext(eglBase.getEglBaseContext());
|
||||||
assertTrue(encoder.initEncode(MediaCodecVideoEncoder.VideoCodecType.VIDEO_CODEC_VP8, profile,
|
assertTrue(encoder.initEncode(
|
||||||
640, 480, 300, 30, /* useSurface= */ true));
|
VideoCodecType.VIDEO_CODEC_VP8, profile, 640, 480, 300, 30, /* useSurface= */ true));
|
||||||
encoder.release();
|
encoder.release();
|
||||||
MediaCodecVideoEncoder.disposeEglContext();
|
MediaCodecVideoEncoder.disposeEglContext();
|
||||||
eglBase.release();
|
eglBase.release();
|
||||||
@ -95,8 +95,8 @@ public class MediaCodecVideoEncoderTest {
|
|||||||
|
|
||||||
MediaCodecVideoEncoder encoder = new MediaCodecVideoEncoder();
|
MediaCodecVideoEncoder encoder = new MediaCodecVideoEncoder();
|
||||||
|
|
||||||
assertTrue(encoder.initEncode(MediaCodecVideoEncoder.VideoCodecType.VIDEO_CODEC_VP8, profile,
|
assertTrue(encoder.initEncode(
|
||||||
width, height, 300, 30, /* useSurface= */ false));
|
VideoCodecType.VIDEO_CODEC_VP8, profile, width, height, 300, 30, /* useSurface= */ false));
|
||||||
ByteBuffer[] inputBuffers = encoder.getInputBuffers();
|
ByteBuffer[] inputBuffers = encoder.getInputBuffers();
|
||||||
assertNotNull(inputBuffers);
|
assertNotNull(inputBuffers);
|
||||||
assertTrue(min_size <= inputBuffers[0].capacity());
|
assertTrue(min_size <= inputBuffers[0].capacity());
|
||||||
|
|||||||
@ -213,10 +213,8 @@ int32_t MediaCodecVideoDecoder::InitDecodeOnCodecThread() {
|
|||||||
|
|
||||||
ResetVariables();
|
ResetVariables();
|
||||||
|
|
||||||
ScopedJavaLocalRef<jobject> j_video_codec_enum =
|
|
||||||
Java_VideoCodecType_fromNativeIndex(jni, codecType_);
|
|
||||||
bool success = Java_MediaCodecVideoDecoder_initDecode(
|
bool success = Java_MediaCodecVideoDecoder_initDecode(
|
||||||
jni, j_media_codec_video_decoder_, j_video_codec_enum, codec_.width,
|
jni, j_media_codec_video_decoder_, codecType_, codec_.width,
|
||||||
codec_.height);
|
codec_.height);
|
||||||
|
|
||||||
if (CheckException(jni) || !success) {
|
if (CheckException(jni) || !success) {
|
||||||
|
|||||||
@ -512,11 +512,9 @@ int32_t MediaCodecVideoEncoder::InitEncodeInternal(int width,
|
|||||||
frames_received_since_last_key_ = kMinKeyFrameInterval;
|
frames_received_since_last_key_ = kMinKeyFrameInterval;
|
||||||
|
|
||||||
// We enforce no extra stride/padding in the format creation step.
|
// We enforce no extra stride/padding in the format creation step.
|
||||||
ScopedJavaLocalRef<jobject> j_video_codec_enum =
|
|
||||||
Java_VideoCodecType_fromNativeIndex(jni, codec_type);
|
|
||||||
const bool encode_status = Java_MediaCodecVideoEncoder_initEncode(
|
const bool encode_status = Java_MediaCodecVideoEncoder_initEncode(
|
||||||
jni, j_media_codec_video_encoder_, j_video_codec_enum, profile_, width,
|
jni, j_media_codec_video_encoder_, codec_type, profile_, width, height,
|
||||||
height, kbps, fps, use_surface);
|
kbps, fps, use_surface);
|
||||||
|
|
||||||
if (!encode_status) {
|
if (!encode_status) {
|
||||||
ALOGE << "Failed to configure encoder.";
|
ALOGE << "Failed to configure encoder.";
|
||||||
|
|||||||
Reference in New Issue
Block a user