Update Android encoder to use GetEncoderInfo()
This method replaces GetScalingSettings(), SupportsNativeHandle() and GetImplementationName(). Bug: webrtc:9890 Change-Id: I755cd4c6b1f04853a35f1185a84bda7c8c8efb62 Reviewed-on: https://webrtc-review.googlesource.com/c/109440 Commit-Queue: Erik Språng <sprang@webrtc.org> Reviewed-by: Sami Kalliomäki <sakal@webrtc.org> Cr-Commit-Position: refs/heads/master@{#25527}
This commit is contained in:
@ -107,9 +107,7 @@ class MediaCodecVideoEncoder : public VideoEncoder {
|
||||
int32_t Release() override;
|
||||
int32_t SetRateAllocation(const VideoBitrateAllocation& rate_allocation,
|
||||
uint32_t frame_rate) override;
|
||||
|
||||
bool SupportsNativeHandle() const override { return has_egl_context_; }
|
||||
const char* ImplementationName() const override;
|
||||
EncoderInfo GetEncoderInfo() const override;
|
||||
|
||||
// Fills the input buffer with data from the buffers passed as parameters.
|
||||
bool FillInputBuffer(JNIEnv* jni,
|
||||
@ -178,7 +176,7 @@ class MediaCodecVideoEncoder : public VideoEncoder {
|
||||
// true on success.
|
||||
bool DeliverPendingOutputs(JNIEnv* jni);
|
||||
|
||||
VideoEncoder::ScalingSettings GetScalingSettings() const override;
|
||||
VideoEncoder::ScalingSettings GetScalingSettingsInternal() const;
|
||||
|
||||
// Displays encoder statistics.
|
||||
void LogStatistics(bool force_log);
|
||||
@ -923,6 +921,14 @@ int32_t MediaCodecVideoEncoder::SetRateAllocation(
|
||||
return WEBRTC_VIDEO_CODEC_OK;
|
||||
}
|
||||
|
||||
VideoEncoder::EncoderInfo MediaCodecVideoEncoder::GetEncoderInfo() const {
|
||||
EncoderInfo info;
|
||||
info.supports_native_handle = has_egl_context_;
|
||||
info.implementation_name = "MediaCodec";
|
||||
info.scaling_settings = GetScalingSettingsInternal();
|
||||
return info;
|
||||
}
|
||||
|
||||
bool MediaCodecVideoEncoder::DeliverPendingOutputs(JNIEnv* jni) {
|
||||
RTC_DCHECK_CALLED_SEQUENTIALLY(&encoder_queue_checker_);
|
||||
|
||||
@ -1141,8 +1147,8 @@ void MediaCodecVideoEncoder::LogStatistics(bool force_log) {
|
||||
}
|
||||
}
|
||||
|
||||
VideoEncoder::ScalingSettings MediaCodecVideoEncoder::GetScalingSettings()
|
||||
const {
|
||||
VideoEncoder::ScalingSettings
|
||||
MediaCodecVideoEncoder::GetScalingSettingsInternal() const {
|
||||
if (!scale_)
|
||||
return VideoEncoder::ScalingSettings::kOff;
|
||||
|
||||
@ -1199,10 +1205,6 @@ VideoEncoder::ScalingSettings MediaCodecVideoEncoder::GetScalingSettings()
|
||||
return VideoEncoder::ScalingSettings::kOff;
|
||||
}
|
||||
|
||||
const char* MediaCodecVideoEncoder::ImplementationName() const {
|
||||
return "MediaCodec";
|
||||
}
|
||||
|
||||
static void JNI_MediaCodecVideoEncoder_FillInputBuffer(
|
||||
JNIEnv* jni,
|
||||
const JavaParamRef<jclass>&,
|
||||
|
@ -148,8 +148,16 @@ int32_t VideoEncoderWrapper::SetRateAllocation(
|
||||
return HandleReturnCode(jni, ret, "setRateAllocation");
|
||||
}
|
||||
|
||||
VideoEncoderWrapper::ScalingSettings VideoEncoderWrapper::GetScalingSettings()
|
||||
const {
|
||||
VideoEncoder::EncoderInfo VideoEncoderWrapper::GetEncoderInfo() const {
|
||||
EncoderInfo info;
|
||||
info.supports_native_handle = true;
|
||||
info.implementation_name = implementation_name_;
|
||||
info.scaling_settings = GetScalingSettingsInternal();
|
||||
return info;
|
||||
}
|
||||
|
||||
VideoEncoderWrapper::ScalingSettings
|
||||
VideoEncoderWrapper::GetScalingSettingsInternal() const {
|
||||
JNIEnv* jni = AttachCurrentThreadIfNeeded();
|
||||
ScopedJavaLocalRef<jobject> j_scaling_settings =
|
||||
Java_VideoEncoder_getScalingSettings(jni, encoder_);
|
||||
@ -198,14 +206,6 @@ VideoEncoderWrapper::ScalingSettings VideoEncoderWrapper::GetScalingSettings()
|
||||
}
|
||||
}
|
||||
|
||||
bool VideoEncoderWrapper::SupportsNativeHandle() const {
|
||||
return true;
|
||||
}
|
||||
|
||||
const char* VideoEncoderWrapper::ImplementationName() const {
|
||||
return implementation_name_.c_str();
|
||||
}
|
||||
|
||||
void VideoEncoderWrapper::OnEncodedFrame(JNIEnv* jni,
|
||||
const JavaRef<jobject>& j_caller,
|
||||
const JavaRef<jobject>& j_buffer,
|
||||
|
@ -48,9 +48,7 @@ class VideoEncoderWrapper : public VideoEncoder {
|
||||
int32_t SetRateAllocation(const VideoBitrateAllocation& allocation,
|
||||
uint32_t framerate) override;
|
||||
|
||||
ScalingSettings GetScalingSettings() const override;
|
||||
|
||||
bool SupportsNativeHandle() const override;
|
||||
EncoderInfo GetEncoderInfo() const override;
|
||||
|
||||
// Should only be called by JNI.
|
||||
void OnEncodedFrame(JNIEnv* jni,
|
||||
@ -64,8 +62,6 @@ class VideoEncoderWrapper : public VideoEncoder {
|
||||
jboolean complete_frame,
|
||||
const JavaRef<jobject>& j_qp);
|
||||
|
||||
const char* ImplementationName() const override;
|
||||
|
||||
private:
|
||||
struct FrameExtraInfo {
|
||||
int64_t capture_time_ns; // Used as an identifier of the frame.
|
||||
@ -90,6 +86,8 @@ class VideoEncoderWrapper : public VideoEncoder {
|
||||
const VideoBitrateAllocation& allocation);
|
||||
std::string GetImplementationName(JNIEnv* jni) const;
|
||||
|
||||
ScalingSettings GetScalingSettingsInternal() const;
|
||||
|
||||
const ScopedJavaGlobalRef<jobject> encoder_;
|
||||
const ScopedJavaGlobalRef<jclass> int_array_class_;
|
||||
|
||||
|
Reference in New Issue
Block a user