Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(19)

Unified Diff: webrtc/modules/video_coding/codecs/h264/h264_video_toolbox_encoder.mm

Issue 2226383002: Fix regression for h264 VideoToolbox entering background. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/modules/video_coding/codecs/h264/h264_video_toolbox_encoder.mm
diff --git a/webrtc/modules/video_coding/codecs/h264/h264_video_toolbox_encoder.mm b/webrtc/modules/video_coding/codecs/h264/h264_video_toolbox_encoder.mm
index 5a1fe845f78226c5313effdd81a4a4821010db0a..43c3fe575bdc1e9886a2de1966e529bbe1aeeb38 100644
--- a/webrtc/modules/video_coding/codecs/h264/h264_video_toolbox_encoder.mm
+++ b/webrtc/modules/video_coding/codecs/h264/h264_video_toolbox_encoder.mm
@@ -307,27 +307,30 @@ int H264VideoToolboxEncoder::Encode(
return ret;
}
+ // Get a pixel buffer from the pool and copy frame data over.
+ CVPixelBufferPoolRef pixel_buffer_pool =
+ VTCompressionSessionGetPixelBufferPool(compression_session_);
+#if defined(WEBRTC_IOS)
+ if (!pixel_buffer_pool) {
+ // Kind of a hack. On backgrounding, the compression session seems to get
+ // invalidated, which causes this pool call to fail when the application
+ // is foregrounded and frames are being sent for encoding again.
+ // Resetting the session when this happens fixes the issue.
+ // In addition we request a keyframe so video can recover quickly.
+ ResetCompressionSession();
+ 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 {
- // Get a pixel buffer from the pool and copy frame data over.
- CVPixelBufferPoolRef pixel_buffer_pool =
- VTCompressionSessionGetPixelBufferPool(compression_session_);
-#if defined(WEBRTC_IOS)
- if (!pixel_buffer_pool) {
- // Kind of a hack. On backgrounding, the compression session seems to get
- // invalidated, which causes this pool call to fail when the application
- // is foregrounded and frames are being sent for encoding again.
- // Resetting the session when this happens fixes the issue.
- // In addition we request a keyframe so video can recover quickly.
- ResetCompressionSession();
- pixel_buffer_pool =
- VTCompressionSessionGetPixelBufferPool(compression_session_);
- is_keyframe_required = true;
- }
-#endif
if (!pixel_buffer_pool) {
LOG(LS_ERROR) << "Failed to get pixel buffer pool.";
return WEBRTC_VIDEO_CODEC_ERROR;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698