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 Release() override;
|
||||||
int32_t SetRateAllocation(const VideoBitrateAllocation& rate_allocation,
|
int32_t SetRateAllocation(const VideoBitrateAllocation& rate_allocation,
|
||||||
uint32_t frame_rate) override;
|
uint32_t frame_rate) override;
|
||||||
|
EncoderInfo GetEncoderInfo() const override;
|
||||||
bool SupportsNativeHandle() const override { return has_egl_context_; }
|
|
||||||
const char* ImplementationName() const override;
|
|
||||||
|
|
||||||
// Fills the input buffer with data from the buffers passed as parameters.
|
// Fills the input buffer with data from the buffers passed as parameters.
|
||||||
bool FillInputBuffer(JNIEnv* jni,
|
bool FillInputBuffer(JNIEnv* jni,
|
||||||
@ -178,7 +176,7 @@ class MediaCodecVideoEncoder : public VideoEncoder {
|
|||||||
// true on success.
|
// true on success.
|
||||||
bool DeliverPendingOutputs(JNIEnv* jni);
|
bool DeliverPendingOutputs(JNIEnv* jni);
|
||||||
|
|
||||||
VideoEncoder::ScalingSettings GetScalingSettings() const override;
|
VideoEncoder::ScalingSettings GetScalingSettingsInternal() const;
|
||||||
|
|
||||||
// Displays encoder statistics.
|
// Displays encoder statistics.
|
||||||
void LogStatistics(bool force_log);
|
void LogStatistics(bool force_log);
|
||||||
@ -923,6 +921,14 @@ int32_t MediaCodecVideoEncoder::SetRateAllocation(
|
|||||||
return WEBRTC_VIDEO_CODEC_OK;
|
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) {
|
bool MediaCodecVideoEncoder::DeliverPendingOutputs(JNIEnv* jni) {
|
||||||
RTC_DCHECK_CALLED_SEQUENTIALLY(&encoder_queue_checker_);
|
RTC_DCHECK_CALLED_SEQUENTIALLY(&encoder_queue_checker_);
|
||||||
|
|
||||||
@ -1141,8 +1147,8 @@ void MediaCodecVideoEncoder::LogStatistics(bool force_log) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
VideoEncoder::ScalingSettings MediaCodecVideoEncoder::GetScalingSettings()
|
VideoEncoder::ScalingSettings
|
||||||
const {
|
MediaCodecVideoEncoder::GetScalingSettingsInternal() const {
|
||||||
if (!scale_)
|
if (!scale_)
|
||||||
return VideoEncoder::ScalingSettings::kOff;
|
return VideoEncoder::ScalingSettings::kOff;
|
||||||
|
|
||||||
@ -1199,10 +1205,6 @@ VideoEncoder::ScalingSettings MediaCodecVideoEncoder::GetScalingSettings()
|
|||||||
return VideoEncoder::ScalingSettings::kOff;
|
return VideoEncoder::ScalingSettings::kOff;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* MediaCodecVideoEncoder::ImplementationName() const {
|
|
||||||
return "MediaCodec";
|
|
||||||
}
|
|
||||||
|
|
||||||
static void JNI_MediaCodecVideoEncoder_FillInputBuffer(
|
static void JNI_MediaCodecVideoEncoder_FillInputBuffer(
|
||||||
JNIEnv* jni,
|
JNIEnv* jni,
|
||||||
const JavaParamRef<jclass>&,
|
const JavaParamRef<jclass>&,
|
||||||
|
@ -148,8 +148,16 @@ int32_t VideoEncoderWrapper::SetRateAllocation(
|
|||||||
return HandleReturnCode(jni, ret, "setRateAllocation");
|
return HandleReturnCode(jni, ret, "setRateAllocation");
|
||||||
}
|
}
|
||||||
|
|
||||||
VideoEncoderWrapper::ScalingSettings VideoEncoderWrapper::GetScalingSettings()
|
VideoEncoder::EncoderInfo VideoEncoderWrapper::GetEncoderInfo() const {
|
||||||
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();
|
JNIEnv* jni = AttachCurrentThreadIfNeeded();
|
||||||
ScopedJavaLocalRef<jobject> j_scaling_settings =
|
ScopedJavaLocalRef<jobject> j_scaling_settings =
|
||||||
Java_VideoEncoder_getScalingSettings(jni, encoder_);
|
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,
|
void VideoEncoderWrapper::OnEncodedFrame(JNIEnv* jni,
|
||||||
const JavaRef<jobject>& j_caller,
|
const JavaRef<jobject>& j_caller,
|
||||||
const JavaRef<jobject>& j_buffer,
|
const JavaRef<jobject>& j_buffer,
|
||||||
|
@ -48,9 +48,7 @@ class VideoEncoderWrapper : public VideoEncoder {
|
|||||||
int32_t SetRateAllocation(const VideoBitrateAllocation& allocation,
|
int32_t SetRateAllocation(const VideoBitrateAllocation& allocation,
|
||||||
uint32_t framerate) override;
|
uint32_t framerate) override;
|
||||||
|
|
||||||
ScalingSettings GetScalingSettings() const override;
|
EncoderInfo GetEncoderInfo() const override;
|
||||||
|
|
||||||
bool SupportsNativeHandle() const override;
|
|
||||||
|
|
||||||
// Should only be called by JNI.
|
// Should only be called by JNI.
|
||||||
void OnEncodedFrame(JNIEnv* jni,
|
void OnEncodedFrame(JNIEnv* jni,
|
||||||
@ -64,8 +62,6 @@ class VideoEncoderWrapper : public VideoEncoder {
|
|||||||
jboolean complete_frame,
|
jboolean complete_frame,
|
||||||
const JavaRef<jobject>& j_qp);
|
const JavaRef<jobject>& j_qp);
|
||||||
|
|
||||||
const char* ImplementationName() const override;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct FrameExtraInfo {
|
struct FrameExtraInfo {
|
||||||
int64_t capture_time_ns; // Used as an identifier of the frame.
|
int64_t capture_time_ns; // Used as an identifier of the frame.
|
||||||
@ -90,6 +86,8 @@ class VideoEncoderWrapper : public VideoEncoder {
|
|||||||
const VideoBitrateAllocation& allocation);
|
const VideoBitrateAllocation& allocation);
|
||||||
std::string GetImplementationName(JNIEnv* jni) const;
|
std::string GetImplementationName(JNIEnv* jni) const;
|
||||||
|
|
||||||
|
ScalingSettings GetScalingSettingsInternal() const;
|
||||||
|
|
||||||
const ScopedJavaGlobalRef<jobject> encoder_;
|
const ScopedJavaGlobalRef<jobject> encoder_;
|
||||||
const ScopedJavaGlobalRef<jclass> int_array_class_;
|
const ScopedJavaGlobalRef<jclass> int_array_class_;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user