Fix regression for h264 VideoToolbox entering background.

We need to check the pool to make sure that the encoder session is valid. Otherwise, it appears as if the encoder just does not output frames.

NOTRY=True
BUG=

Review-Url: https://codereview.webrtc.org/2226383002
Cr-Commit-Position: refs/heads/master@{#13698}
This commit is contained in:
tkchin
2016-08-09 13:02:00 -07:00
committed by Commit bot
parent 3cb0c573dd
commit 4c45234b81

View File

@ -307,11 +307,6 @@ int H264VideoToolboxEncoder::Encode(
return ret;
}
CVPixelBufferRef pixel_buffer =
static_cast<CVPixelBufferRef>(input_image->native_handle());
if (pixel_buffer) {
CVBufferRetain(pixel_buffer);
} else {
// Get a pixel buffer from the pool and copy frame data over.
CVPixelBufferPoolRef pixel_buffer_pool =
VTCompressionSessionGetPixelBufferPool(compression_session_);
@ -326,8 +321,16 @@ int H264VideoToolboxEncoder::Encode(
pixel_buffer_pool =
VTCompressionSessionGetPixelBufferPool(compression_session_);
is_keyframe_required = true;
LOG(LS_INFO) << "Resetting compression session due to invalid pool.";
}
#endif
CVPixelBufferRef pixel_buffer =
static_cast<CVPixelBufferRef>(input_image->native_handle());
if (pixel_buffer) {
CVBufferRetain(pixel_buffer);
pixel_buffer_pool = nullptr;
} else {
if (!pixel_buffer_pool) {
LOG(LS_ERROR) << "Failed to get pixel buffer pool.";
return WEBRTC_VIDEO_CODEC_ERROR;