Huge refactoring (part 1).

* Capturing and recording code are now factored into their corresponding
mode, this should help reducing bugs and ease adding new modes.
* MediaRecorder is now prepared when switching to video mode, so hitting
the record button should start recording as soon as possible.