Change mediaStream Stream while is recording

I am developing an application that allows you to record (both screen and by camera), my intention with this is to create a stream with another configuration (such as mute microphone or change place to record).

After that connect it to the MediaStream object so that the changes in the configuration are noticed without having to stop it completely in the stop () function since that would activate onLoadData ().