You mean a hardware CD/DVD reader?
How it can detect the difference?
I guess the laser reads the inner parts of the CV/DVD
to identify if it is a DVD or CD. That is not that difficult to
do I guess. The readers can read out from the CD/DVD the
manufacturer and I guess there's some info about type as well.