how to remember the selected video source for setting as next default source while using Webcam?

If there are more than one camera with PC, some one will be selected as video source. How to get the source currently selected, so that its id can be stored in web stoarge, and be read for setting the default source for next use?