kclyu / rpi-webrtc-streamer

This repo's objective is providing something like Web Cam server on the most popular Raspberry PI hardware. By integrating [WebRTC](https://webrtc.org/native-code/) and Raspberry PI, we can stream the Raspberry camera feed to browser or native client which talks WebRTC.
Other
617 stars 108 forks source link

Changing fixed bitrate at runtime #131

Open ArosPrince opened 2 years ago

ArosPrince commented 2 years ago

Hi, I noticed max_bitrate param in config_media_params in config_media.mjs is commented out. I tried putting it back in and bind it with a UI component. So far so good...

But I am not sure what to do in the c++ code to get it working. I tried replacing this call:

if (webrtc::MMALWrapper::Instance()->ReinitEncoderInternal() == true) {

in app_ws_config.cc - apply command hadler (line 612) with this:

if (webrtc::MMALWrapper::Instance()->ReinitEncoderWithBitrate(config_media_->GetMaxBitrate()) == true) {

And defined that function in mmal_wrapper.cc. It just first sets the bitrate and then call ReinitEncoderInternal - nothing special...

It seems to work, but only for a second or so. There seems to be something else running that set's it back to the initial value again.

I was able to figure out that MMALEncoderWrapper::SetRate() is getting called periodically always with the same values, which could be what sets it back. This function gets called from RaspiEncoderImpl::SetRates() but I wasn't able to dig any further. I tried to print the callstack but no matter what I do and with which flags I try to compile, I always only get function addresses but not the symbols.

Any idea what is calling those functions and why?