You might have a look at the source code for the Procam extension for ideas.
I am not sure if it is possible to duplicate the live feed from the camera, though.