syweb-jitsi-conference.patch 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  1. diff --git a/syweb/webclient/app/components/matrix/matrix-call.js b/syweb/webclient/app/components/matrix/matrix-call.js
  2. index 9fbfff0..dc68077 100644
  3. --- a/syweb/webclient/app/components/matrix/matrix-call.js
  4. +++ b/syweb/webclient/app/components/matrix/matrix-call.js
  5. @@ -16,6 +16,45 @@ limitations under the License.
  6. 'use strict';
  7. +
  8. +function sendKeyframe(pc) {
  9. + console.log('sendkeyframe', pc.iceConnectionState);
  10. + if (pc.iceConnectionState !== 'connected') return; // safe...
  11. + pc.setRemoteDescription(
  12. + pc.remoteDescription,
  13. + function () {
  14. + pc.createAnswer(
  15. + function (modifiedAnswer) {
  16. + pc.setLocalDescription(
  17. + modifiedAnswer,
  18. + function () {
  19. + // noop
  20. + },
  21. + function (error) {
  22. + console.log('triggerKeyframe setLocalDescription failed', error);
  23. + messageHandler.showError();
  24. + }
  25. + );
  26. + },
  27. + function (error) {
  28. + console.log('triggerKeyframe createAnswer failed', error);
  29. + messageHandler.showError();
  30. + }
  31. + );
  32. + },
  33. + function (error) {
  34. + console.log('triggerKeyframe setRemoteDescription failed', error);
  35. + messageHandler.showError();
  36. + }
  37. + );
  38. +}
  39. +
  40. +
  41. +
  42. +
  43. +
  44. +
  45. +
  46. var forAllVideoTracksOnStream = function(s, f) {
  47. var tracks = s.getVideoTracks();
  48. for (var i = 0; i < tracks.length; i++) {
  49. @@ -83,7 +122,7 @@ angular.module('MatrixCall', [])
  50. }
  51. // FIXME: we should prevent any calls from being placed or accepted before this has finished
  52. - MatrixCall.getTurnServer();
  53. + //MatrixCall.getTurnServer();
  54. MatrixCall.CALL_TIMEOUT = 60000;
  55. MatrixCall.FALLBACK_STUN_SERVER = 'stun:stun.l.google.com:19302';
  56. @@ -132,6 +171,22 @@ angular.module('MatrixCall', [])
  57. pc.onsignalingstatechange = function() { self.onSignallingStateChanged(); };
  58. pc.onicecandidate = function(c) { self.gotLocalIceCandidate(c); };
  59. pc.onaddstream = function(s) { self.onAddStream(s); };
  60. +
  61. + var datachan = pc.createDataChannel('RTCDataChannel', {
  62. + reliable: false
  63. + });
  64. + console.log("data chan: "+datachan);
  65. + datachan.onopen = function() {
  66. + console.log("data channel open");
  67. + };
  68. + datachan.onmessage = function() {
  69. + console.log("data channel message");
  70. + };
  71. + pc.ondatachannel = function(event) {
  72. + console.log("have data channel");
  73. + event.channel.binaryType = 'blob';
  74. + };
  75. +
  76. return pc;
  77. }
  78. @@ -200,6 +255,12 @@ angular.module('MatrixCall', [])
  79. }, this.msg.lifetime - event.age);
  80. };
  81. + MatrixCall.prototype.receivedInvite = function(event) {
  82. + console.log("Got second invite for call "+this.call_id);
  83. + this.peerConn.setRemoteDescription(new RTCSessionDescription(this.msg.offer), this.onSetRemoteDescriptionSuccess, this.onSetRemoteDescriptionError);
  84. + };
  85. +
  86. +
  87. // perverse as it may seem, sometimes we want to instantiate a call with a hangup message
  88. // (because when getting the state of the room on load, events come in reverse order and
  89. // we want to remember that a call has been hung up)
  90. @@ -349,7 +410,7 @@ angular.module('MatrixCall', [])
  91. 'mandatory': {
  92. 'OfferToReceiveAudio': true,
  93. 'OfferToReceiveVideo': this.type == 'video'
  94. - },
  95. + }
  96. };
  97. this.peerConn.createAnswer(function(d) { self.createdAnswer(d); }, function(e) {}, constraints);
  98. // This can't be in an apply() because it's called by a predecessor call under glare conditions :(
  99. @@ -359,8 +420,20 @@ angular.module('MatrixCall', [])
  100. MatrixCall.prototype.gotLocalIceCandidate = function(event) {
  101. if (event.candidate) {
  102. console.log("Got local ICE "+event.candidate.sdpMid+" candidate: "+event.candidate.candidate);
  103. - this.sendCandidate(event.candidate);
  104. - }
  105. + //this.sendCandidate(event.candidate);
  106. + } else {
  107. + console.log("have all candidates, sending answer");
  108. + var content = {
  109. + version: 0,
  110. + call_id: this.call_id,
  111. + answer: this.peerConn.localDescription
  112. + };
  113. + this.sendEventWithRetry('m.call.answer', content);
  114. + var self = this;
  115. + $rootScope.$apply(function() {
  116. + self.state = 'connecting';
  117. + });
  118. + }
  119. }
  120. MatrixCall.prototype.gotRemoteIceCandidate = function(cand) {
  121. @@ -418,15 +491,6 @@ angular.module('MatrixCall', [])
  122. console.log("Created answer: "+description);
  123. var self = this;
  124. this.peerConn.setLocalDescription(description, function() {
  125. - var content = {
  126. - version: 0,
  127. - call_id: self.call_id,
  128. - answer: self.peerConn.localDescription
  129. - };
  130. - self.sendEventWithRetry('m.call.answer', content);
  131. - $rootScope.$apply(function() {
  132. - self.state = 'connecting';
  133. - });
  134. }, function() { console.log("Error setting local description!"); } );
  135. };
  136. @@ -448,6 +512,9 @@ angular.module('MatrixCall', [])
  137. $rootScope.$apply(function() {
  138. self.state = 'connected';
  139. self.didConnect = true;
  140. + /*$timeout(function() {
  141. + sendKeyframe(self.peerConn);
  142. + }, 1000);*/
  143. });
  144. } else if (this.peerConn.iceConnectionState == 'failed') {
  145. this.hangup('ice_failed');
  146. @@ -518,6 +585,7 @@ angular.module('MatrixCall', [])
  147. MatrixCall.prototype.onRemoteStreamEnded = function(event) {
  148. console.log("Remote stream ended");
  149. + return;
  150. var self = this;
  151. $rootScope.$apply(function() {
  152. self.state = 'ended';
  153. diff --git a/syweb/webclient/app/components/matrix/matrix-phone-service.js b/syweb/webclient/app/components/matrix/matrix-phone-service.js
  154. index 55dbbf5..272fa27 100644
  155. --- a/syweb/webclient/app/components/matrix/matrix-phone-service.js
  156. +++ b/syweb/webclient/app/components/matrix/matrix-phone-service.js
  157. @@ -48,6 +48,13 @@ angular.module('matrixPhoneService', [])
  158. return;
  159. }
  160. + // do we already have an entry for this call ID?
  161. + var existingEntry = matrixPhoneService.allCalls[msg.call_id];
  162. + if (existingEntry) {
  163. + existingEntry.receivedInvite(msg);
  164. + return;
  165. + }
  166. +
  167. var call = undefined;
  168. if (!isLive) {
  169. // if this event wasn't live then this call may already be over
  170. @@ -108,7 +115,7 @@ angular.module('matrixPhoneService', [])
  171. call.hangup();
  172. }
  173. } else {
  174. - $rootScope.$broadcast(matrixPhoneService.INCOMING_CALL_EVENT, call);
  175. + $rootScope.$broadcast(matrixPhoneService.INCOMING_CALL_EVENT, call);
  176. }
  177. } else if (event.type == 'm.call.answer') {
  178. var call = matrixPhoneService.allCalls[msg.call_id];