I've been googling a way to change codec in Chrome's implementation of WebRTC, but there doesn't seem to be a way.
How can I change the default codec used(audio or video) in a WebRTCpeer connection in Chrome?
I've been googling a way to change codec in Chrome's implementation of WebRTC, but there doesn't seem to be a way.
How can I change the default codec used(audio or video) in a WebRTCpeer connection in Chrome?
Yes, you can change the codec to be anything you want...as long as Chrome supports it. Right now, audio wise, the only supported codecs are PCMA, PCMU, ISAC, and OPUS(the default). For Video you have VP8(also H264 on some systems with FireFox).
To use any of these codecs as default, you must modify your SDP before setting it locally in your peerconnection and sending your offer/answer. I have tested successfully forcing Chrome to send PCMA instead of OPUS by default.
As an example:
Say you have your default audio SDP section that looks like the following(notes are in brackets are are not part of the sdp)
If you wanted to ONLY use PCMA, you would change the
m=audio
line to the following:m=audio 49353 RTP/SAVPF 8
this way only the PCMA payload is considered. Then you need to remove all the rtpmap lines that do not correspond with that payload, i.e. anya=rtpmap:
where the next character is NOT an 8. If you set that modified sdp locally and send it to your peer(and if they SUPPORT PCMA...does not have to be default for them as the negotiation will force PCMA if you only offer it), then PCMA will be your audio codec and not OPUS.Couple of asides:
createOffer
andcreateAnswer
functions of the peerconnectionfmtp
is needed for h264 as profiles are important and possiblysprop-parameter-sets
).