How does e.g. VLC detects the codec when opening a http stream?
Both AAC and MP3 has a very short sync mark which often appears in other streams.
http://www.flickr.com/photos/52807817@N00/4423485655/ (http://www.flickr.com/photos/52807817@N00/4423485655/)
http://www.mp3-tech.org/programmer/frame_header.html (http://www.mp3-tech.org/programmer/frame_header.html)
I guess VLC parses the frame length number and sees if it matches the next sync mark?
The first four bytes of an ADTS AAC frame header look exactly like an MPEG-1/2 "Layer 4" frame. So it's quite easy to detect the difference.