最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - webRTC: How to detect audiovideo presence in Stream? - Stack Overflow

programmeradmin0浏览0评论

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
Add a ment  | 

1 Answer 1

Reset to default 7

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
            }
        };
发布评论

评论列表(0)

  1. 暂无评论