I'm newbie in this website and I really don't know where exactly should I ask this question ;-;
But since the code is related to OPUS, I think this channel may be a good place to start.
The scenario I'm actually interested in is the following.
Image two users (A and B) are talking with each other in a voip applicaiton. If user A has a very bad internet connection and user B has a really good internet connection I want to change their configuration so they can have a better user experience. User A should have a small sample rate and a small bit rate. And user B should have a high sample rate and bit rate. But a friend of mine told me that you should never alter sample rate. You should leave it to highest value as possible and just alter bit rate. But I really don't know if this is accurate.
Additionally, the code available at https://github.com/pjsip/pjproject/blob/master/pjmedia/include/pjmedia-codec/config.h (PJSIP) explicit says that bit rate value should be left to default value specified by Opus - ZERO(0), which will take into account factors such as media content (speech/music), sample rate, channel count, etc. In other words, in the voip scenario, you should only alter sample rate.
Finally, here is the question. In an application that dynamically changes OPUS configurations for a better user experience should alter only bit rate, only sample rate or both?
Opus has a fixed sample rate of 48 kHz. It can encode from factors of this sample rate as a shortcut to reducing the encoding complexity, which also reduces the bitrate. It will still decode to 48 kHz, regardless.
Applications which alter the experience based on available bandwidth, should try to target the available upstream bandwidth for the audio, with room for anything else the user may be doing. Sample rate can't explicitly target a given bitrate as easily.
Technically, their software should be utilizing a maximum bitrate cap, as an optional feature. At best, it could detect when the stream is falling behind and reduce its send bitrate.
In an application that dynamically changes OPUS configurations for a better user experience should alter only bit rate, only sample rate or both?
In most cases, including VoIP, you should only change the bit rate.
The sample rate should be set according to the sample rate of your source audio. If you're switching between different sources with different sample rates, then you can change the sample rate. Otherwise, you should set the sample rate once and never change it.