javascript - Send MediaStream object with Web Audio effects over PeerConnection -


I am trying to send the audio, received from getUserMedia () and the web Audio WebRTC has the ability to do this in API Web Audio API and WebRTC on peer connections but I am having trouble understanding how it can be done. Within the Web Audio API, there is a method in audiocontax object createMediaStreamSource () , which provides a way to connect to the mediastream received by getUserMedia (). Also, there is a createMediaStreamDestination () method, which returns an object with a stream attribute

I get both audio and video from the getUserMedia () method. What's the problem I'm having, how do I pass this stream object (both with audio and video) (such as: CreateMediaStreamSource ())? Do I need to remove it first, by any means, find a way to combine it back with audio (getAudioTracks) and video from the stream? Or do I pass this and leave this video unaffected? Can the audio be changed only once (before being added to a peercode)?

createMediaStreamSource () MediaStream takes an object, so that it takes AudioMediaStreamTrack before this object to use it as an audio object with the MediaStream object getUserMedia () Method, even if the object contains both audio and video, for example:

  var source = Context.createMediaStreamSource (local stream);  

The "reference" in the above code, a audiocontax object and "local stream" is a mediastream object that has been obtained from GetUserMedia (). The createMediaStreamDestination () method creates a destination node object in which there is a mediastream object within the "stream" attribute. This mediastream object contains only one audio mediastreamtrack (even if the source has both an audio stream and audio or multiple audio tracks in the input stream): the converted version of the track derived from the stream within the source. For example:

  var destination = reference .createMediaStreamDestination ();  

Now, before you can use the stream attribute of the newly created destination variable, you must create an audio graph by adding all the nodes at once. For this example, suppose we have a backdrop filter node named Filter:

  source.connect (filter); Filter.connect (destination);  

Then, we can derive the stream attribute from the destination variable. And it can be used to send a remote peer to the peaconction object:

  peerConnection.addstream (destination.stream);  

Note: The stream feature only includes MediaMstream object as well as converted audio mediastreamtracks. Therefore, if you want the video to be sent as well, then you need to add this track to a stream object that contains a video track:

var audiotecq = destination.stream. Ataudio Track (); Var track = audiotrack [0]; // Stream only has an audio track in localStream.addTrack (track); PeerConnection.addStream (localStream);

Keep in mind, if the ID is already in the MediaStream object in ID, then the addTrack method will not add the track. Therefore, you may have to remove the track you received in the source node for the first time.

The sound can be changed at any time by adjusting prices within the intermediate nodes (between source and destination). This is because the stream passes through the nodes before being sent to another coworker. Dynamically change the effect on the recorded sound (should be similar to a stream) Note: I have not tested this code yet. Although it works in principle, there may be some cross browser problems, because both Web Audio APIs and WebRTC are working in draft phases and are not yet standardized. I accept it to work in Mozilla Firefox and Google Chrome.

Context


Comments

Popular posts from this blog

winforms - C# Form - Property Change -

java - Messages from .properties file do not display UTF-8 characters -

javascript - amcharts makechart not working -