**//stream handling at incoming side
```
e.peerconnection.ontrack=function(ev){
console.log('ontrack',ev);
//fire onmute event when using camera off function or when track is unavailable
ev.track.onmute= function(ev1)
{
//when session is ended hide both local and remote video tag
if(session.isEnded())
{
$("#remoteUser").hide();
$("#localUser").hide();
}
else if(ev.track.kind=='video')
{
console.log('vineet',`${ev.transceiver.direction}+''+${ev.transceiver.currentDirection}`);
$("#remoteUser").hide();
}
};
//fire onunmute event when using camera on function or when track is available
ev.track.onunmute= (ev1)=>{
if(ev.track.kind=='audio')
{
let tracks=remoteAudio.srcObject.getTracks();
if(tracks.id!=ev.track.id)
remoteAudio.srcObject.addTrack(ev.track);
}
else if(ev.track.kind=='video')
{
let tracks=remoteVideo.srcObject.getTracks();
for(let i=0;i<tracks.length;i++)
{
if(tracks.id!=ev.track.id)
remoteVideo.srcObject.addTrack(ev.track);
}
$("#remoteUser").show();
if(ev.transceiver.sender.track!=null)
$("#localUser").show();
}
};
//for m=audio line in sdp
if(ev.transceiver.mid==0)
{
remoteAudio.srcObject=ev.streams[0];
console.log('vineet',session.connection.getTransceivers()[0].receiver);
}
//for m=video line in sdp
else if(ev.transceiver.mid==1)
{
if(ev.transceiver.sender.track!=null)
{
localVideo.srcObject=session.connection.getLocalStreams()[0];
remoteVideo.srcObject=ev.streams[0];
stream1=localVideo.srcObject;
}
//during audio call when caller on the camera and callee camera is off
else
{
remoteVideo.srcObject=ev.streams[0];
}
}
};
```
// stream handling at outgoing side
```
e.peerconnection.ontrack=function(ev){
console.log('ontrack',ev);
//fire onmute event when using camera off function or when track is unavailable
ev.track.onmute = function(ev1)
{
if(session.isEnded())
{
$("#remoteUser").hide();
$("#localUser").hide();
}
else if(ev.track.kind=='video')
$("#remoteUser").hide();
};
////fire onunmute event when using camera on function or when track is available
ev.track.onunmute= function(ev1){
if(ev.track.kind=='audio')
{
let tracks=remoteAudio.srcObject.getTracks();
if(tracks.id!=ev.track.id)
remoteAudio.srcObject.addTrack(ev.track);
}
else if(ev.track.kind=='video')
{
let tracks=remoteVideo.srcObject.getTracks();
for(let i=0;i<tracks.length;i++)
{
if(tracks.id!=ev.track.id)
remoteVideo.srcObject.addTrack(ev.track);
}
$("#remoteUser").show();
}
};
// for audio line in sdp
if(ev.transceiver.mid==0)
{
remoteAudio.srcObject=ev.streams[0];
}
// for video line in sdp
else if(ev.transceiver.mid==1)
{
remoteVideo.srcObject=ev.streams[0];
}
};
```
//media constraint at outgoing side
'mediaConstraints': {
'audio': {'autoGainControl':false,'channelCount':2,'echoCancellation':true,'noiseSuppression':true,'sampleRate':50000,'sampleSize':24},
'video': {'frameRate':{'exact':8}}
},
//media constraint at incoming side
'mediaConstraints': {
'audio': {'autoGainControl':false,'channelCount':2,'echoCancellation':true,'noiseSuppression':true,'sampleRate':50000,'sampleSize':24},
'video': videoValue&&{'frameRate':{'exact':8}}
},
当我进行视频通话时,视频开始在两侧闪烁。我还将帧频降低到8。但是chrome不尊重帧速率,而是按照自己的意愿增加和减少。当视频数据包丢失时,将触发静音事件。我也在使用相机开/关功能,这就是为什么在开/关功能期间隐藏远程视频的原因。我希望在视频数据包丢失时暂停远程视频。
操作系统= chrome到chrome **