Convert native handles to buffers before encoding.
Required to permit conversion of NV12 handles on iOS to I420 for VP8 software encoding, which blocks texture-based capture. This change enforces that all texture-based input provides a method for converting native handles to I420 if they are ever used with software encoders that do not understand the native handles. BUG=4081 R=emircan@chromium.org, glaznev@webrtc.org, hbos@webrtc.org, magjed@webrtc.org, mflodman@webrtc.org, stefan@webrtc.org, tkchin@webrtc.org Review URL: https://webrtc-codereview.appspot.com/50909005 Cr-Commit-Position: refs/heads/master@{#9347}
This commit is contained in:
@ -200,6 +200,10 @@ void VCMGenericEncoder::OnDroppedFrame() {
|
||||
encoder_->OnDroppedFrame();
|
||||
}
|
||||
|
||||
bool VCMGenericEncoder::SupportsNativeHandle() const {
|
||||
return encoder_->SupportsNativeHandle();
|
||||
}
|
||||
|
||||
/***************************
|
||||
* Callback Implementation
|
||||
***************************/
|
||||
|
||||
@ -138,6 +138,8 @@ public:
|
||||
|
||||
void OnDroppedFrame();
|
||||
|
||||
bool SupportsNativeHandle() const;
|
||||
|
||||
private:
|
||||
VideoEncoder* const encoder_;
|
||||
VideoEncoderRateObserver* const rate_observer_;
|
||||
|
||||
@ -321,8 +321,16 @@ int32_t VideoSender::AddVideoFrame(const VideoFrame& videoFrame,
|
||||
LOG(LS_ERROR) << "Incoming frame doesn't match set resolution. Dropping.";
|
||||
return VCM_PARAMETER_ERROR;
|
||||
}
|
||||
VideoFrame converted_frame = videoFrame;
|
||||
if (converted_frame.native_handle() && !_encoder->SupportsNativeHandle()) {
|
||||
// This module only supports software encoding.
|
||||
// TODO(pbos): Offload conversion from the encoder thread.
|
||||
converted_frame = converted_frame.ConvertNativeToI420Frame();
|
||||
CHECK(!converted_frame.IsZeroSize())
|
||||
<< "Frame conversion failed, won't be able to encode frame.";
|
||||
}
|
||||
int32_t ret =
|
||||
_encoder->Encode(videoFrame, codecSpecificInfo, _nextFrameTypes);
|
||||
_encoder->Encode(converted_frame, codecSpecificInfo, _nextFrameTypes);
|
||||
if (ret < 0) {
|
||||
LOG(LS_ERROR) << "Failed to encode frame. Error code: " << ret;
|
||||
return ret;
|
||||
|
||||
Reference in New Issue
Block a user