Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

JingleSession.js 3.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. /*
  2. * JingleSession provides an API to manage a single Jingle session. We will
  3. * have different implementations depending on the underlying interface used
  4. * (i.e. WebRTC and ORTC) and here we hold the code common to all of them.
  5. */
  6. var logger = require("jitsi-meet-logger").getLogger(__filename);
  7. function JingleSession(me, sid, connection, service, eventEmitter) {
  8. /**
  9. * Our JID.
  10. */
  11. this.me = me;
  12. /**
  13. * The Jingle session identifier.
  14. */
  15. this.sid = sid;
  16. /**
  17. * The XMPP connection.
  18. */
  19. this.connection = connection;
  20. /**
  21. * The XMPP service.
  22. */
  23. this.service = service;
  24. /**
  25. * The event emitter.
  26. */
  27. this.eventEmitter = eventEmitter;
  28. /**
  29. * Whether to use dripping or not. Dripping is sending trickle candidates
  30. * not one-by-one.
  31. * Note: currently we do not support 'false'.
  32. */
  33. this.usedrip = true;
  34. /**
  35. * When dripping is used, stores ICE candidates which are to be sent.
  36. */
  37. this.drip_container = [];
  38. // Media constraints. Is this WebRTC only?
  39. this.media_constraints = null;
  40. // ICE servers config (RTCConfiguration?).
  41. this.ice_config = {};
  42. // The chat room instance associated with the session.
  43. this.room = null;
  44. // Jingle session state - uninitialized until 'initialize' is called
  45. this.state = null;
  46. }
  47. /**
  48. * Prepares this object to initiate a session.
  49. * @param peerjid the JID of the remote peer.
  50. * @param isInitiator whether we will be the Jingle initiator.
  51. * @param media_constraints
  52. * @param ice_config
  53. */
  54. JingleSession.prototype.initialize = function(peerjid, isInitiator,
  55. media_constraints, ice_config) {
  56. this.media_constraints = media_constraints;
  57. this.ice_config = ice_config;
  58. if (this.state !== null) {
  59. logger.error('attempt to initiate on session ' + this.sid +
  60. 'in state ' + this.state);
  61. return;
  62. }
  63. this.state = 'pending';
  64. this.initiator = isInitiator ? this.me : peerjid;
  65. this.responder = !isInitiator ? this.me : peerjid;
  66. this.peerjid = peerjid;
  67. this.doInitialize();
  68. };
  69. /**
  70. * Finishes initialization.
  71. */
  72. JingleSession.prototype.doInitialize = function() {};
  73. /**
  74. * Adds the ICE candidates found in the 'contents' array as remote candidates?
  75. * Note: currently only used on transport-info
  76. */
  77. JingleSession.prototype.addIceCandidates = function(contents) {};
  78. /**
  79. * Checks if this JingleSession is in 'active' state which means that the call
  80. * is in progress.
  81. * @returns {boolean} <tt>true</tt> if this JingleSession is in 'active' state
  82. * or <tt>false</tt> otherwise.
  83. */
  84. JingleSession.prototype.active = function () {
  85. return this.state === 'active';
  86. };
  87. /**
  88. * Handles an 'add-source' event.
  89. *
  90. * @param contents an array of Jingle 'content' elements.
  91. */
  92. JingleSession.prototype.addSources = function(contents) {};
  93. /**
  94. * Handles a 'remove-source' event.
  95. *
  96. * @param contents an array of Jingle 'content' elements.
  97. */
  98. JingleSession.prototype.removeSources = function(contents) {};
  99. /**
  100. * Terminates this Jingle session (stops sending media and closes the streams?)
  101. */
  102. JingleSession.prototype.terminate = function() {};
  103. /**
  104. * Sends a Jingle session-terminate message to the peer and terminates the
  105. * session.
  106. * @param reason
  107. * @param text
  108. */
  109. JingleSession.prototype.sendTerminate = function(reason, text) {};
  110. /**
  111. * Handles an offer from the remote peer (prepares to accept a session).
  112. * @param jingle the 'jingle' XML element.
  113. */
  114. JingleSession.prototype.setOffer = function(jingle) {};
  115. /**
  116. * Handles an answer from the remote peer (prepares to accept a session).
  117. * @param jingle the 'jingle' XML element.
  118. */
  119. JingleSession.prototype.setAnswer = function(jingle) {};
  120. module.exports = JingleSession;