As @sean-dubois said, MediaRecorder API is the way to go.
To add to that, I have made a project that utilizes MediaRecorder API to stream video calls over arbitrary data channels: https://github.com/WofWca/video-call-over-email.
Of course instead of endlessly streaming the data you can end it at any time, which would be the equivalent of an audio / video message.