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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  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. function JingleSession(me, sid, connection, service, eventEmitter) {
  7. /**
  8. * Our JID.
  9. */
  10. this.me = me;
  11. /**
  12. * The Jingle session identifier.
  13. */
  14. this.sid = sid;
  15. /**
  16. * The XMPP connection.
  17. */
  18. this.connection = connection;
  19. /**
  20. * The XMPP service.
  21. */
  22. this.service = service;
  23. /**
  24. * The event emitter.
  25. */
  26. this.eventEmitter = eventEmitter;
  27. /**
  28. * Whether to use dripping or not. Dripping is sending trickle candidates
  29. * not one-by-one.
  30. * Note: currently we do not support 'false'.
  31. */
  32. this.usedrip = true;
  33. /**
  34. * When dripping is used, stores ICE candidates which are to be sent.
  35. */
  36. this.drip_container = [];
  37. // Media constraints. Is this WebRTC only?
  38. this.media_constraints = null;
  39. // ICE servers config (RTCConfiguration?).
  40. this.ice_config = {};
  41. }
  42. /**
  43. * Prepares this object to initiate a session.
  44. * @param peerjid the JID of the remote peer.
  45. * @param isInitiator whether we will be the Jingle initiator.
  46. * @param media_constraints
  47. * @param ice_config
  48. */
  49. JingleSession.prototype.initialize = function(peerjid, isInitiator,
  50. media_constraints, ice_config) {
  51. this.media_constraints = media_constraints;
  52. this.ice_config = ice_config;
  53. if (this.state !== null) {
  54. console.error('attempt to initiate on session ' + this.sid +
  55. 'in state ' + this.state);
  56. return;
  57. }
  58. this.state = 'pending';
  59. this.initiator = isInitiator ? this.me : peerjid;
  60. this.responder = !isInitiator ? this.me : peerjid;
  61. this.peerjid = peerjid;
  62. this.doInitialize();
  63. };
  64. /**
  65. * Finishes initialization.
  66. */
  67. JingleSession.prototype.doInitialize = function() {};
  68. /**
  69. * Adds the ICE candidates found in the 'contents' array as remote candidates?
  70. * Note: currently only used on transport-info
  71. */
  72. JingleSession.prototype.addIceCandidates = function(contents) {};
  73. /**
  74. * Handles an 'add-source' event.
  75. *
  76. * @param contents an array of Jingle 'content' elements.
  77. */
  78. JingleSession.prototype.addSources = function(contents) {};
  79. /**
  80. * Handles a 'remove-source' event.
  81. *
  82. * @param contents an array of Jingle 'content' elements.
  83. */
  84. JingleSession.prototype.removeSources = function(contents) {};
  85. /**
  86. * Terminates this Jingle session (stops sending media and closes the streams?)
  87. */
  88. JingleSession.prototype.terminate = function() {};
  89. /**
  90. * Sends a Jingle session-terminate message to the peer and terminates the
  91. * session.
  92. * @param reason
  93. * @param text
  94. */
  95. JingleSession.prototype.sendTerminate = function(reason, text) {};
  96. /**
  97. * Handles an offer from the remote peer (prepares to accept a session).
  98. * @param jingle the 'jingle' XML element.
  99. */
  100. JingleSession.prototype.setOffer = function(jingle) {};
  101. /**
  102. * Handles an answer from the remote peer (prepares to accept a session).
  103. * @param jingle the 'jingle' XML element.
  104. */
  105. JingleSession.prototype.setAnswer = function(jingle) {};
  106. module.exports = JingleSession;