Thursday, 15 September 2011

webrtc - Using getUserMedia to get audio from the microphone as it is being recorded? -



webrtc - Using getUserMedia to get audio from the microphone as it is being recorded? -

i'm trying write meteor.js app uses peer peer "radio" communication. when user presses button broadcasts microphone output people.

i have code gets permission record audio, , gets mediastream object, can't figure out how info mediastream object beingness recorded.

i see there method defined somewhere getting of tracks of recorded audio. i'm sure find way write kind of loop notifies me when sound has been added, seems there should native, event-driven way retrieve sound getusermedia. missing something? thanks

what want access stream through audioapi(for recording part). after assigning var stream grabbed through getusermedia (i phone call localstream). so, can create many mediastreamsource nodes want 1 stream, can record while sending numerous people through different rtcpeerconnections.

var audiocontext = new webkitaudiocontext() || audiocontext(); var source = audiocontext.createmediastreamsource(localstream); var audiorecorder = function (source) { var recording = false; var worker = new worker(worker_path); var config = {}; var bufferlen = 4096; this.context = source.context; this.node = (this.context.createscriptprocessor || this.context.createjavascriptnode).call(this.context, bufferlen, 2, 2); this.node.onaudioprocess = function (e) { var sample = e.inputbuffer.getchanneldata(0); //do want sound sample, force blob or send on websocket } source.connect(this.node); this.node.connect(this.context.destination); };

here version wrote/modified send sound on websockets recording on server.

for sending sound when available, utilize websockets or webrtc peerconnection. grab stream through getusermedia success object(you should have global variable stream connection). , when becomes available, can utilize signalling server forwards requesting sdps sound supplier. can set requesting sdps receive , connection.

peerconnection illustration 1 peerconnection illustration 2

audio webrtc

No comments:

Post a Comment