i tried to share local video file's stream in webrtc. it was successful in tomcat localhost but fails on running in website. just when i share navigator.mediaDevices's stream it works every where but sharing video file's stream works only in localhost.
var video = document.getElementById('myVideo');
var stream;
var rTCPeerConnection;
/*
stream = await navigator.mediaDevices.getUserMedia({
audio: true,
video: true
});
*/
video.onloadeddata = function(){
if ($.browser.mozilla){
stream = this.mozCaptureStream();
}else{
stream = this.captureStream();
}
}
video.src= "./myfile.webm";
function share_stream_to_peerConnection(){
stream.getTracks().forEach(track => rTCPeerConnection.addTrack(track, stream) );
}
this is a simple example i made to share file through webRTC, here you can see how webRTC data flow works. I used a websocket to handle the message between 2 users. Maybe can be helpfull.
https://bit.cloud/intershare/galacfetch/hooks/web-rtc-local-share/~code/src/web-rtc-local-share.ts