Is it possible to detect the codec used in an RTP stream by analyzing the RTP stream alone? I know about the payload type (PT) field in the RTP header -- that can be used to identify codecs that have statically assigned PT numbers. What about the other codecs that use the dynamic PT number range? Are there any heuristics to detect the type of the payload? I'm interested in all kinds of solutions, even if the detection works for one codec only.
Sure, you can sniff around the packet to see if it appears to be RFC XXX, or YYY, etc. Length checks (for fixed-length codecs, though watch out for multiple frames per packet); timestamp rate (tells you narrow/wide/ultra-wide band audio or video); and then you can see if the first N bytes matches the valid pattern for one of the possible matches.
Not a small amount of work unless you're only interested in a subset.