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?
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?
Share Improve this question asked May 27, 2013 at 9:06 kongarajukongaraju 9,60611 gold badges58 silver badges78 bronze badges 5- 1 Did you try getAudioTracks().length? – Muaz Khan Commented May 27, 2013 at 12:04
- how would I know absence of VideoTracks? – kongaraju Commented May 27, 2013 at 12:07
- 2 getVideoTracks().length or "a=mid:video" presence in peer.remoteDescription.sdp – Muaz Khan Commented May 27, 2013 at 12:09
- Hope you're setting OfferToReceiveAudio:true and OfferToReceiveVideo:false --- like this: github./muaz-khan/WebRTC-Experiment/blob/master/RTCall/… – Muaz Khan Commented May 27, 2013 at 12:11
- 1 so if length is 0 that should be audio only – kongaraju Commented May 27, 2013 at 12:11
1 Answer
Reset to default 7To 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
}
};