//
// 'localStream' is stream obtained via gUM() ;
//
var track = localStream.getAudioTracks()[0] ;options.pc.getStats(track,
function(stats) { stats.forEach(function(entry) { console.log("Entry : id = " + entry.id + ", type = " + entry.type) ; }) ; },
function(error) {...}) ;
Entry : id = outbound_rtcp_audio_0, type = inboundrtpEntry : id = inbound_rtp_audio_1, type = inboundrtp
Doesn't work:
+-------+ +-------------+ +----+
| gUM() |--->| AnalyseNode |--->| PC |
+-------+ +-------------+ +----+
Works:
+-------+ +----+
| gUM() |--->| PC |
+-------+ +----+
|
|
V
+-------------+
| AnalyseNode |
+-------------+
Code (outline):
// // localStream will be stream from gUM() // pc will be created RTCPeerConnection // // This example leaves out all the boilerplate for obtaining these // pc.addStream(localStream) ; var audioContext = new AudioContext() ; var analyser = audioContext.createAnalyser() ; var fftSize = 128 ; // Must be power of 2 var fftBins = new Uint8Array(fftSize); analyser.fftSize = fftSize; var sourceNode = audioContext.createMediaStreamSource(localStream);
// // Do something like this periodically // function monitorAudio() { analyser.getByteFrequencyData(fftBins); // Get average of spectrum // Can restrict this to a specific range of frequency bins // depending on application (e.g. voice is typically 300-3000Hz) var total=0 ; for(var i=0;i<fftSize; ++i) { total+=fftBins[i] ; } var avg = total/fftSize ; if(avg==0) {...} // No audio if.... // Some other case }
--
---
You received this message because you are subscribed to the Google Groups "discuss-webrtc" group.
To unsubscribe from this group and stop receiving emails from it, send an email to discuss-webrt...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.