Android: Cache implementation name in VideoDecoderWrapper.
This fixes a crash caused by access to already freed memory returned by VideoDecoderWrapper::ImplementationName method. Bug: webrtc:7760 Change-Id: Ia4b020d1dd861e6a45637abde35f12951b7c43ea Reviewed-on: https://webrtc-review.googlesource.com/9420 Reviewed-by: Magnus Jedvert <magjed@webrtc.org> Commit-Queue: Sami Kalliomäki <sakal@webrtc.org> Cr-Commit-Position: refs/heads/master@{#20290}
This commit is contained in:
committed by
Commit Bot
parent
ae012cf8b8
commit
cee3e53631
@ -76,6 +76,8 @@ VideoDecoderWrapper::VideoDecoderWrapper(JNIEnv* jni, jobject decoder)
|
||||
initialized_ = false;
|
||||
// QP parsing starts enabled and we disable it if the decoder provides frames.
|
||||
qp_parsing_enabled_ = true;
|
||||
|
||||
implementation_name_ = GetImplementationName(jni);
|
||||
}
|
||||
|
||||
int32_t VideoDecoderWrapper::InitDecode(const VideoCodec* codec_settings,
|
||||
@ -163,11 +165,7 @@ bool VideoDecoderWrapper::PrefersLateDecoding() const {
|
||||
}
|
||||
|
||||
const char* VideoDecoderWrapper::ImplementationName() const {
|
||||
JNIEnv* jni = AttachCurrentThreadIfNeeded();
|
||||
ScopedLocalRefFrame local_ref_frame(jni);
|
||||
jstring jname = reinterpret_cast<jstring>(
|
||||
jni->CallObjectMethod(*decoder_, get_implementation_name_method_));
|
||||
return JavaToStdString(jni, jname).c_str();
|
||||
return implementation_name_.c_str();
|
||||
}
|
||||
|
||||
void VideoDecoderWrapper::OnDecodedFrame(JNIEnv* jni,
|
||||
@ -298,6 +296,12 @@ rtc::Optional<uint8_t> VideoDecoderWrapper::ParseQP(
|
||||
return qp;
|
||||
}
|
||||
|
||||
std::string VideoDecoderWrapper::GetImplementationName(JNIEnv* jni) const {
|
||||
jstring jname = reinterpret_cast<jstring>(
|
||||
jni->CallObjectMethod(*decoder_, get_implementation_name_method_));
|
||||
return JavaToStdString(jni, jname);
|
||||
}
|
||||
|
||||
JNI_FUNCTION_DECLARATION(void,
|
||||
VideoDecoderWrapperCallback_nativeOnDecodedFrame,
|
||||
JNIEnv* jni,
|
||||
|
||||
@ -72,6 +72,8 @@ class VideoDecoderWrapper : public VideoDecoder {
|
||||
|
||||
rtc::Optional<uint8_t> ParseQP(const EncodedImage& input_image);
|
||||
|
||||
std::string GetImplementationName(JNIEnv* jni) const;
|
||||
|
||||
VideoCodec codec_settings_;
|
||||
int32_t number_of_cores_;
|
||||
|
||||
@ -80,6 +82,7 @@ class VideoDecoderWrapper : public VideoDecoder {
|
||||
std::deque<FrameExtraInfo> frame_extra_infos_;
|
||||
bool qp_parsing_enabled_;
|
||||
H264BitstreamParser h264_bitstream_parser_;
|
||||
std::string implementation_name_;
|
||||
|
||||
DecodedImageCallback* callback_;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user