You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

JingleSession.js 3.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  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, peerjid, connection,
  8. media_constraints, ice_config, service, eventEmitter) {
  9. /**
  10. * Our JID.
  11. */
  12. this.me = me;
  13. /**
  14. * The Jingle session identifier.
  15. */
  16. this.sid = sid;
  17. /**
  18. * the JID of the remote peer.
  19. */
  20. this.peerjid = peerjid;
  21. /**
  22. * The XMPP connection.
  23. */
  24. this.connection = connection;
  25. /**
  26. * The XMPP service.
  27. */
  28. this.service = service;
  29. /**
  30. * The event emitter.
  31. */
  32. this.eventEmitter = eventEmitter;
  33. /**
  34. * Whether to use dripping or not. Dripping is sending trickle candidates
  35. * not one-by-one.
  36. * Note: currently we do not support 'false'.
  37. */
  38. this.usedrip = true;
  39. /**
  40. * When dripping is used, stores ICE candidates which are to be sent.
  41. */
  42. this.drip_container = [];
  43. // Media constraints. Is this WebRTC only?
  44. this.media_constraints = media_constraints;
  45. // ICE servers config (RTCConfiguration?).
  46. this.ice_config = ice_config;
  47. // The chat room instance associated with the session.
  48. this.room = null;
  49. // Jingle session state - uninitialized until 'initialize' is called
  50. this.state = null;
  51. }
  52. /**
  53. * Prepares this object to initiate a session.
  54. * @param isInitiator whether we will be the Jingle initiator.
  55. * @param room <tt>ChatRoom<tt> for the conference associated with this session
  56. */
  57. JingleSession.prototype.initialize = function(isInitiator, room) {
  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.room = room;
  64. this.state = 'pending';
  65. this.initiator = isInitiator ? this.me : this.peerjid;
  66. this.responder = !isInitiator ? this.me : this.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 by sending session-terminate
  101. * @param reason XMPP Jingle error condition
  102. * @param text some meaningful error message
  103. */
  104. JingleSession.prototype.terminate = function(reason, text) {};
  105. /**
  106. * Handles an offer from the remote peer (prepares to accept a session).
  107. * @param jingle the 'jingle' XML element.
  108. * @param success callback called when we the incoming session has been accepted
  109. * @param failure callback called when we fail for any reason, will supply error
  110. * object with details(which is meant more to be printed to the logger
  111. * than analysed in the code, as the error is unrecoverable anyway)
  112. */
  113. JingleSession.prototype.acceptOffer = function(jingle, success, failure) {};
  114. module.exports = JingleSession;