I would like to know the tracks presence in received stream onaddstream callback. Video calling is working well but I would like to make. audio only call, so I just passed audio:true,video:false
in getUserMedia constraints, now when I receive stream I cant figure out tracks presence in stream.
How to know tracks presence in stream?
To Know presence of Audio and Video use getAudioTracks
and getVideoTracks
.
function checkStream(stream){
var hasMedia={hasVideo:false,hasAudio:false};
if(stream.getAudioTracks().length)// checking audio presence
hasMedia.hasAudio=true;
if(stream.getVideoTracks().length)// checking video presence
hasMedia.hasVideo=true;
return hasMedia;
}
To stop passing Video in stream change offer and answer constrinats.
constraints = {
optional: [],
mandatory: {
OfferToReceiveAudio: true,
OfferToReceiveVideo: false
}
};
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With