Texture Movie Encoder2
Encode a movie from frames rendered from an external texture image.
The object wraps an encoder running partly on two different threads. An external thread is sending data to the encoder's input surface, and we (the encoder thread) are pulling the encoded data out and feeding it into a MediaMuxer.
We could block forever waiting for the encoder, but because of the thread decomposition that turns out to be a little awkward (we want to call signalEndOfInputStream() from the encoder thread to avoid thread-safety issues, but we can't do that if we're blocked on the encoder). If we don't pull from the encoder often enough, the producer side can back up.
The solution is to have the producer trigger drainEncoder() on every frame, before it submits the new frame. drainEncoder() might run before or after the frame is submitted, but it doesn't matter -- either it runs early and prevents blockage, or it runs late and un-blocks the encoder.
TODO: reconcile this with TextureMovieEncoder.