admin管理员组文章数量:1318580
I can make the webrtc call between 2 parties with video and audio stream together. Is there any way to give user to stop sharing only video or audio during the call?
Assume
A and B are in a webrtc call
during the Call A just stop his video channel so b can only listen the A's voice/audio not video. When A resume video again B can see A face again.
Can anyone help?
I can make the webrtc call between 2 parties with video and audio stream together. Is there any way to give user to stop sharing only video or audio during the call?
Assume
A and B are in a webrtc call
during the Call A just stop his video channel so b can only listen the A's voice/audio not video. When A resume video again B can see A face again.
Can anyone help?
Share Improve this question asked Feb 2, 2014 at 6:24 new developernew developer 2051 gold badge5 silver badges12 bronze badges3 Answers
Reset to default 4I have already solved it in a efficient way. I have hanlded the local stream audio and video to pasue and resume. See my below way
To pause a local video steam to connected partner: mediastream.getVideoTracks()[0].enabled = false;
To resume a local video steam to connected partner: mediastream.getVideoTracks()[0].enabled = true;
for audio: pasue: mediastream.getAudioTracks()[0].enabled = false;
resume: mediastream.getAudioTracks()[0].enabled = true;
It is working perfectly in my project.
The Suman's answer kind of solves the problem but it's not efficient. You're still transmitting the data, just not displaying it. It's a pure waste, which may be problematic in case of devices with limited bandwidth. Please note that by default WebRTC will go as high as 2Mbps for video.
The proper solution to this problem would be to renegotiate offer/answer between the peers and mark particular media as sendonly/recvonly.
To do so, you need to store somewhere the SDP offer and when there is a need to stop sending media of particular type, you need to replace line
a=sendrecv with a=recvonly
like:
var localDescr = peerConnection.localDescription;
localDescr = makeRecvOnly(localDescr);
peerConnection.setLocalDescription(localDescr,function(){});
someWebSocketTransport.sendUpdateStreamingStatus(localDescr)
then the other end should handle this sendUpdateStreamingStatus and set the received description using
peerConnection.setRemoteDescription(receivedRemoteDescr, function() {})
Hope this helps.
Suppose when user(A) click on stop button for hide video. You will apply the css video {display:none
} to video(local/remote) element, and send that mand to server for other user(B), when other user get this mand, on his side video(local/remote) would be hidden with video{display:none}
.
As a result the video would be hidden, and you(A) and other(B) can hear each other voice, when you click on show button just do the video{display : block}
to video element on your and other's browser respectively.
But in this case if any user does video{display:block}
through the inspect element from browser then video would appear on his side.
本文标签: javascriptVideo and audio stream control duirng the webrtc callStack Overflow
版权声明:本文标题:javascript - Video and audio stream control duirng the webrtc call - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742047112a2417852.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论