How pass audiostream to createOffer in legacy 0.x janus version

I need to put an audio processor behind the microphone similar to the webaudio.js 1.x demo in a legacy 0.x version.

I have the stream obtained with
peer = audioContext.createMediaStreamDestination();
connected to processor.

But I don’t know how to put it in the createOffer.
I tested :

        media: {
  			stream: peer.stream.getAudioTracks()[0],
     		replaceAudio: true,	
  	     	video: {            
            .......

and

        media: {
         	audio: peer.stream.getAudioTracks()[0],
  	    	replaceAudio: true,	
  		    video: {
         .......

or

        media: {
  		    audio: {
  			    deviceId: {
  				   exact:  peer.stream.id
  			    }
  		     },
             video: {
         ........

But nothing has worked.
What should the equivalent of setupWebAudioDemo() fucnton on webadio.js for janus 0.x version?

Thanks,

It’s peer.stream, I think, not the single track. In 0.x you need to pass the whole stream.

Thanks,
but not work for me.

if I put outside media I have only audio and ignore media contents. The log says “MediaStream provided by the application”.


sfutest.createOffer(
{
      stream: peer.stream,
      media: {
 		audioRecv: false,
		videoRecv: false,
		audioSend: useAudio,
		videoSend: true,
		     video: {
		         deviceId: {
						exact: videoDeviceId
					},
                 }
     ...............

Inside media don’t work and sound the default audio device.

sfutest.createOffer(
{
       media: {
                stream: peer.stream,
                audioRecv: false,
   ...................

Check the canvas.js and multiopus.js demos: they will give you a practical example of how that works, since they both take a stream from a canvas and use it in createOffer.

1 Like

Hello Lorenzo,
in canvas.js , you capture canvas stream and add an audio track, and pass the canvas stream to createOffer.
In videoroom.js (0.x), we don’t have the video stream, only the deviceID. And getting the video stream supposes a new asynchronous call to getUserMedia using in constraints the videoDeviceId.
The aplication combines videoroom demo with device selection demo.

I don’t know if there would be another way to combine the video with its videDeviceId with the audio track obtained from the new stream.

Using 1.x, seems that you can combine tracks by their deviceId with tracks with their stream. (I’m not sure about it). But migrating the application to 1.x is too much work for me. There are various applications using janus 0.x on the same server and I would have to modify all of them.

My final solution has been to use getUserMedia with selected devices in constraints and with the returned stream replace the audio with processed audio and pass it to createOffer.
It seems to work well.

Thanks,