media: Fix crash when determining sample count of a frame during shutdown.

When shutting down Asterisk the codecs are cleaned up. As a result anything
attempting to get a codec based on ID or details will find that no codec
exists. This currently occurs when determining the sample count of a frame.
This code did not take this situation into account.

This change fixes this by getting the codec directly from the format and
eliminates the lookup. This is both faster and also provides a guarantee
that the codec will exist and will be valid.

ASTERISK-24604 #close
Reported by: Matt Jordan

Review: https://reviewboard.asterisk.org/r/4260/


git-svn-id: http://svn.asterisk.org/svn/asterisk/branches/13@429497 f38db490-d61c-443f-a65b-d21fe96a405b