New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Problems, DataChannel and renegotiate #225
Comments
if broadcaster - Mozilla Firefox, and viewer - Google Chrome - dataChannel not crashed you way of revision it - recreateOffer and recreateAnswer i.e. /// offer
this.connection.createOffer(function (sessionDescription) {
self.connection.setLocalDescription(sessionDescription);
self.onSessionDescription(sessionDescription, self.streaminfo); // send to answerer
}, this.onSdpError, this.constraints);
/// answer
this.setRemoteDescription(this.offerDescription);
this.connection.createAnswer(function (sessionDescription) {
self.connection.setLocalDescription(sessionDescription);
self.onSessionDescription(sessionDescription, self.streaminfo); // send to offerer
}, this.onSdpError, this.constraints);
/// offerer
setRemoteDescription(answerDescription); it work only chrome, firefox not create new works SDP /// offer
this.connection = new RTCPeerConnection(this.iceServers, this.optionalArgument); // new
/// ... createDataChannel
/// ... onaddstream
/// ... etc ...
this.connection.createOffer(function (sessionDescription) {
self.connection.setLocalDescription(sessionDescription);
self.onSessionDescription(sessionDescription, self.streaminfo); // send to answerer
}, this.onSdpError, this.constraints);
/// answer
this.connection = new RTCPeerConnection(this.iceServers, this.optionalArgument); // new
/// ... createDataChannel
/// ... onaddstream
/// ... etc ...
this.setRemoteDescription(this.offerDescription);
this.connection.createAnswer(function (sessionDescription) {
self.connection.setLocalDescription(sessionDescription);
self.onSessionDescription(sessionDescription, self.streaminfo); // send to offerer
}, this.onSdpError, this.constraints);
/// offerer
setRemoteDescription(answerDescription); it work in chrome and firefox =) firefox has only one problem, break the old connection dataChannel |
If caller or callee is Firefox; RTCMultiConnection recreates "peer-connection" instead of merely recreating "session-descriptions". The next remaining part in v1.8 is to make sure that "session" object has all "renegotiation" values when we are recreating peer connection. We simply need to store all "sessions" from "addStream" invocations in a RTCMultiSession-level object which is a private object accessible among all RTCMultiConnection APIs. E.g. // on constructor initialization
rtcMultiSession.allSessions = connection.session;
// when user invokes "addStream" method
connection.addStream = function (session) {
rtcMultiSession.allSessions = merge(rtcMultiSession.allSessions, session);
// ---
};
// now, when recreating peer connection
connection.session = rtcMultiSession.allSessions;
connection.peers['target-userid'].redial(); |
Another question is to remove the old Stream necessary to cause removal PEER.removeStream(); |
First of all, as far as I know,
|
@muaz-khan Thanks. |
hi @muaz-khan . if (isData(this.session) && isFirefox) {
navigator.mozGetUserMedia({
audio: true,
fake: true
}, function (stream) {
self.connection.addStream(stream);
if (type == 'offer') {
self.createDataChannel();
}
self.getLocalDescription(type);
if (type == 'answer') {
self.createDataChannel();
}
}, this.onMediaError);
} Why in the data channel include fake user media data? without this code dataChannel good work. |
Ah, yes, I'm still using old dirty workaround; though it is fixed since a while (I think since mozilla24). I'll update v1.8 very soon. |
@muaz-khan it very good=) i will be waiting =) Error: removeStream not yet implemented
peer.removeStream(connection.streams[label].stream); is there a way in Firefox to remove old and add a new stream? |
@muaz-khan Hi. connection._getStream = function (e) {
return {
.....
stop: function (forceToStopRemoteStream) {
this.sockets.forEach(function (socket) {
// this.type == undifened need to add 'self' connection._getStream = function (e) {
return {
.....
stop: function (forceToStopRemoteStream) {
var self =this; // new this
this.sockets.forEach(function (socket) {
// self.type == local or remote - good=) |
remove impossible ? #225 (comment) |
For Firefox, until |
@muaz-khan hi. ie essentially rebuilding connections to the original view, without media streams ? |
@muaz-khan Hi again =) not work offerer stream.onended function captureUserMedia(callback, _session) {
...
function _captureUserMedia(forcedConstraints, forcedCallback, isRemoveVideoTracks, dontPreventSSLAutoAllowed) {
...
var mediaConfig = {
onsuccess: function (stream, returnBack, idInstance, streamid) {
...
stream.onended = function () { //////////// NOT WORK IN MOZILLA
}
}
}
}
} Solution of the problem. function connection._getStream method stop, add new if connection._getStream = function (e) {
return {
.....
stop: function (forceToStopRemoteStream) {
var self =this;
if(isFirefox)self.stream.onended(self.streamObject); |
Thanks @serhanters. Now I'm manually invoking function stopTracks(mediaStream) {
if (!mediaStream) throw 'MediaStream argument is mandatory.';
if (typeof mediaStream.getAudioTracks == 'undefined') {
if (mediaStream.stop) {
mediaStream.stop();
}
return;
}
if (mediaStream.getAudioTracks().length && mediaStream.getAudioTracks()[0].stop) {
mediaStream.getAudioTracks()[0].stop();
}
if (mediaStream.getVideoTracks().length && mediaStream.getVideoTracks()[0].stop) {
mediaStream.getVideoTracks()[0].stop();
}
//--------------------------------- here:
if (isFirefox) {
// todo-verify: this may cause multiple-invocation of "onstreamended"
if (mediaStream.onended) mediaStream.onended();
}
} I also updated stop: function (forceToStopRemoteStream) {
var self = this;
// .............
var stream = self.stream;
if (stream) stopTracks(stream); //---------------- this line
} |
@muaz-khan if (isFirefox && session.data) { you forgot to add 'this' or 'self' (line 2363) |
@muaz-khan idea. // renegotiate new stream
this.addStream = function (e) {
.....
function addStream(_peer) {
var socket = _peer.socket;
if (!socket) {
warn(_peer, 'doesn\'t has socket.');
return;
}
socket.send({newSession:session});
}
}
// function SocketResponce
function socketResponse(response) {
if (response.userid == connection.userid)return;
if(response.newSession){
connection.session=response.newSession;
log(connection.session);
}
................
} it for Firefox (prepare answerer to receive stream) |
@muaz-khan . I have question. if i add stream (with video ) and stop stream (connection.streams.stop()) and then add stream (with video ) everything works fine. but if i add stream (with video ) and stop stream (connection.streams.stop()) and then add stream (with AUDIO) nothing does not work. see:
answerer not receiving stream if switch the audio to video or video to audio. why ? =( |
Simply set // you must set it before calling "open" or "join" method
connection.sdpConstraints.mandatory = {
OfferToReceiveAudio: true,
OfferToReceiveVideo: true
}; |
@muaz-khan yes, it work, but works only in Chrome. ie. example stream (only audio) - set OfferToReceiveAudio in true IF set OfferToReceiveAudio&&OfferToReceiveVideo in true stream not work. if use your method works only Chrome. |
Hi Muaz Khan.
I decided to improve you code.
I have one one question.
Two Users, connect with DataChannel.
without audio or video, only for transmitting messages =)
Next I try to add a video here so.
my new methods
Result connection - http://clip2net.com/s/ij4Wch
step 2. I turn on video. - http://clip2net.com/s/ij5dN0
After 5-7 sec dataChannel connection Crashed and viewer remove from conection.channels object
variant 2 recreateOffer and recreateAnswer
this variant not work, (offerer recreate SDP wrong) the viewer gets Old SDP.
Is it possible to solve the problem of disconnection or realize dataChannel normal revision?
PS. my first option allows you to make renegotiate, can be used as a temporary solution for Mozilla =)
The text was updated successfully, but these errors were encountered: