How can I detect WebRTC supported video and audio codecs in the browser using JavaScript?

Is there a way to check what WebRTC audio and video codecs are supported by the browser?

I have searched around but I can’t seem to find a solution.