Migrate android video decoder wrapper from InitDecode to Configure
Bug: webrtc:13045 Change-Id: Idb6d83d5cde659876ea3a106a85f177191f8074c Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/228941 Reviewed-by: Sergey Silkin <ssilkin@webrtc.org> Commit-Queue: Danil Chapovalov <danilchap@webrtc.org> Cr-Commit-Position: refs/heads/master@{#34769}
This commit is contained in:
committed by
WebRTC LUCI CQ
parent
600bb8c79f
commit
ffce8e3ea0
@ -657,6 +657,7 @@ if (current_os == "linux" || is_android) {
|
||||
"../../api:media_stream_interface",
|
||||
"../../api/task_queue",
|
||||
"../../api/video:encoded_image",
|
||||
"../../api/video:render_resolution",
|
||||
"../../api/video:video_frame",
|
||||
"../../api/video:video_frame_type",
|
||||
"../../api/video:video_rtp_headers",
|
||||
|
||||
@ -10,7 +10,9 @@
|
||||
|
||||
#include "sdk/android/src/jni/video_decoder_wrapper.h"
|
||||
|
||||
#include "api/video/render_resolution.h"
|
||||
#include "api/video/video_frame.h"
|
||||
#include "api/video_codecs/video_decoder.h"
|
||||
#include "modules/video_coding/include/video_codec_interface.h"
|
||||
#include "modules/video_coding/utility/vp8_header_parser.h"
|
||||
#include "modules/video_coding/utility/vp9_uncompressed_header_parser.h"
|
||||
@ -54,18 +56,18 @@ VideoDecoderWrapper::VideoDecoderWrapper(JNIEnv* jni,
|
||||
|
||||
VideoDecoderWrapper::~VideoDecoderWrapper() = default;
|
||||
|
||||
int32_t VideoDecoderWrapper::InitDecode(const VideoCodec* codec_settings,
|
||||
int32_t number_of_cores) {
|
||||
bool VideoDecoderWrapper::Configure(const Settings& settings) {
|
||||
RTC_DCHECK_RUN_ON(&decoder_thread_checker_);
|
||||
JNIEnv* jni = AttachCurrentThreadIfNeeded();
|
||||
codec_settings_ = *codec_settings;
|
||||
number_of_cores_ = number_of_cores;
|
||||
return InitDecodeInternal(jni);
|
||||
decoder_settings_ = settings;
|
||||
return ConfigureInternal(jni);
|
||||
}
|
||||
|
||||
int32_t VideoDecoderWrapper::InitDecodeInternal(JNIEnv* jni) {
|
||||
ScopedJavaLocalRef<jobject> settings = Java_Settings_Constructor(
|
||||
jni, number_of_cores_, codec_settings_.width, codec_settings_.height);
|
||||
bool VideoDecoderWrapper::ConfigureInternal(JNIEnv* jni) {
|
||||
RenderResolution resolution = decoder_settings_.max_render_resolution();
|
||||
ScopedJavaLocalRef<jobject> settings =
|
||||
Java_Settings_Constructor(jni, decoder_settings_.number_of_cores(),
|
||||
resolution.Width(), resolution.Height());
|
||||
|
||||
ScopedJavaLocalRef<jobject> callback =
|
||||
Java_VideoDecoderWrapper_createDecoderCallback(jni,
|
||||
@ -82,7 +84,7 @@ int32_t VideoDecoderWrapper::InitDecodeInternal(JNIEnv* jni) {
|
||||
// providing QP values.
|
||||
qp_parsing_enabled_ = true;
|
||||
|
||||
return status;
|
||||
return status == WEBRTC_VIDEO_CODEC_OK;
|
||||
}
|
||||
|
||||
int32_t VideoDecoderWrapper::Decode(
|
||||
@ -211,8 +213,7 @@ int32_t VideoDecoderWrapper::HandleReturnCode(JNIEnv* jni,
|
||||
}
|
||||
|
||||
// Try resetting the codec.
|
||||
if (Release() == WEBRTC_VIDEO_CODEC_OK &&
|
||||
InitDecodeInternal(jni) == WEBRTC_VIDEO_CODEC_OK) {
|
||||
if (Release() == WEBRTC_VIDEO_CODEC_OK && ConfigureInternal(jni)) {
|
||||
RTC_LOG(LS_WARNING) << "Reset Java decoder.";
|
||||
return WEBRTC_VIDEO_CODEC_ERROR;
|
||||
}
|
||||
@ -228,7 +229,7 @@ absl::optional<uint8_t> VideoDecoderWrapper::ParseQP(
|
||||
}
|
||||
|
||||
absl::optional<uint8_t> qp;
|
||||
switch (codec_settings_.codecType) {
|
||||
switch (decoder_settings_.codec_type()) {
|
||||
case kVideoCodecVP8: {
|
||||
int qp_int;
|
||||
if (vp8::GetQp(input_image.data(), input_image.size(), &qp_int)) {
|
||||
|
||||
@ -32,8 +32,7 @@ class VideoDecoderWrapper : public VideoDecoder {
|
||||
VideoDecoderWrapper(JNIEnv* jni, const JavaRef<jobject>& decoder);
|
||||
~VideoDecoderWrapper() override;
|
||||
|
||||
int32_t InitDecode(const VideoCodec* codec_settings,
|
||||
int32_t number_of_cores) override;
|
||||
bool Configure(const Settings& settings) override;
|
||||
|
||||
int32_t Decode(const EncodedImage& input_image,
|
||||
bool missing_frames,
|
||||
@ -68,7 +67,7 @@ class VideoDecoderWrapper : public VideoDecoder {
|
||||
~FrameExtraInfo();
|
||||
};
|
||||
|
||||
int32_t InitDecodeInternal(JNIEnv* jni) RTC_RUN_ON(decoder_thread_checker_);
|
||||
bool ConfigureInternal(JNIEnv* jni) RTC_RUN_ON(decoder_thread_checker_);
|
||||
|
||||
// Takes Java VideoCodecStatus, handles it and returns WEBRTC_VIDEO_CODEC_*
|
||||
// status code.
|
||||
@ -88,9 +87,9 @@ class VideoDecoderWrapper : public VideoDecoder {
|
||||
// own this thread so a thread checker cannot be used.
|
||||
rtc::RaceChecker callback_race_checker_;
|
||||
|
||||
// Initialized on InitDecode and immutable after that.
|
||||
VideoCodec codec_settings_ RTC_GUARDED_BY(decoder_thread_checker_);
|
||||
int32_t number_of_cores_ RTC_GUARDED_BY(decoder_thread_checker_);
|
||||
// Initialized on Configure and immutable after that.
|
||||
VideoDecoder::Settings decoder_settings_
|
||||
RTC_GUARDED_BY(decoder_thread_checker_);
|
||||
|
||||
bool initialized_ RTC_GUARDED_BY(decoder_thread_checker_);
|
||||
H264BitstreamParser h264_bitstream_parser_
|
||||
|
||||
Reference in New Issue
Block a user