[cast] Handle frame size changes directly in the VideoToolbox encoder.
commit89a288bd741c318d11085c4b6fdbbfa32f746335
authorjfroy <jfroy@chromium.org>
Fri, 24 Apr 2015 22:30:05 +0000 (24 15:30 -0700)
committerCommit bot <commit-bot@chromium.org>
Fri, 24 Apr 2015 22:30:01 +0000 (24 22:30 +0000)
treeadf302dec2a25c5122471a0d1adf0b5412a9b172
parent65d478a3b4402351e4103e69b3b37108213202c3
[cast] Handle frame size changes directly in the VideoToolbox encoder.

To implement various kinds of re-initialization conditions more easily,
this CL subsumes responsibility for handling frame size changes directly
in the VideoToolbox encoder.

The design is very similar to the previous one with a proxy encoder.
Instead of proxying the entire encoder, only the video frame factory is
proxied. Both the encoder and the proxy own a ref-counted reference to
the factory, which in turn owns a weak back-reference to the encoder and
a ref-counted reference to the current pixel buffer pool.

When a frame size change is detected either by the encoder or by the
video frame factory, the internal compression session is reset. This is
done synchronously when executing on the Cast main thread, and by
posting a task to the cast main thread when not.

The code to re-initialize the compression session will be re-used in
upcoming work where additional conditions, such as backgrounding, need
to be monitored for session reinitialization.

This new CL fixes the cast unit tests by modifying the tests to handle
encoders that do not have a frame delay when changing the video size.

R=dcaiafa@chromium.org, miu@chromium.org
BUG=477895

Review URL: https://codereview.chromium.org/1100643002

Cr-Commit-Position: refs/heads/master@{#326907}
media/cast/sender/h264_vt_encoder.cc
media/cast/sender/h264_vt_encoder.h
media/cast/sender/h264_vt_encoder_unittest.cc
media/cast/sender/video_encoder.cc
media/cast/sender/video_encoder_unittest.cc
media/cast/sender/video_frame_factory.h