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.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  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. }
  45. /**
  46. * Prepares this object to initiate a session.
  47. * @param peerjid the JID of the remote peer.
  48. * @param isInitiator whether we will be the Jingle initiator.
  49. * @param media_constraints
  50. * @param ice_config
  51. */
  52. JingleSession.prototype.initialize = function(peerjid, isInitiator,
  53. media_constraints, ice_config) {
  54. this.media_constraints = media_constraints;
  55. this.ice_config = ice_config;
  56. if (this.state !== null) {
  57. logger.error('attempt to initiate on session ' + this.sid +
  58. 'in state ' + this.state);
  59. return;
  60. }
  61. this.state = 'pending';
  62. this.initiator = isInitiator ? this.me : peerjid;
  63. this.responder = !isInitiator ? this.me : peerjid;
  64. this.peerjid = peerjid;
  65. this.doInitialize();
  66. };
  67. /**
  68. * Finishes initialization.
  69. */
  70. JingleSession.prototype.doInitialize = function() {};
  71. /**
  72. * Adds the ICE candidates found in the 'contents' array as remote candidates?
  73. * Note: currently only used on transport-info
  74. */
  75. JingleSession.prototype.addIceCandidates = function(contents) {};
  76. /**
  77. * Handles an 'add-source' event.
  78. *
  79. * @param contents an array of Jingle 'content' elements.
  80. */
  81. JingleSession.prototype.addSources = function(contents) {};
  82. /**
  83. * Handles a 'remove-source' event.
  84. *
  85. * @param contents an array of Jingle 'content' elements.
  86. */
  87. JingleSession.prototype.removeSources = function(contents) {};
  88. /**
  89. * Terminates this Jingle session (stops sending media and closes the streams?)
  90. */
  91. JingleSession.prototype.terminate = function() {};
  92. /**
  93. * Sends a Jingle session-terminate message to the peer and terminates the
  94. * session.
  95. * @param reason
  96. * @param text
  97. */
  98. JingleSession.prototype.sendTerminate = function(reason, text) {};
  99. /**
  100. * Handles an offer from the remote peer (prepares to accept a session).
  101. * @param jingle the 'jingle' XML element.
  102. */
  103. JingleSession.prototype.setOffer = function(jingle) {};
  104. /**
  105. * Handles an answer from the remote peer (prepares to accept a session).
  106. * @param jingle the 'jingle' XML element.
  107. */
  108. JingleSession.prototype.setAnswer = function(jingle) {};
  109. module.exports = JingleSession;