Thank you Mirko, Thank you Lorenzo.
I understood that I can only publish one stream one track, but I was able to solve this, I will post the solution if someone interested.
1- I made some modifications to janus js library, in StreamsDone function before addstream, i added a callback function called hookstream, this allowed me to modify the stream before being published by janus and return another stream, as I failed to removestream/addstream this approach was complicated as need to re-create offer etc... so now I do in StreamsDone before config.pc.addStream (with some minor changes in callback class)
if(callbacks.hookstream){
var newstream = callbacks.hookstream(stream)
stream = newstream;
}
2- In attach audiobridge plugin I added callback function hookstream, now I used audioapi to get the stream form audio element, then mixed with mic stream coming from janus, and returned the new stream, this worked!!
Users now able to select a background music file and played together with his mic voice!
My only problem is we need to activate enable-experimental-web-platform-features in chrome flags, but can not blame janus for that, it worked with firefox directly.
here is the code to mix the streams:
I think the hook is useful because now I can do some webapi works to janus stream like controlling the gain or anything ... I do not know if I can modify the stream before being published without touching janus js library, but it is good for me now.
Thank you again !