modified lib-jitsi-meet dev repo
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

JingleSession.js 4.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  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. import {getLogger} from "jitsi-meet-logger";
  7. const logger = getLogger(__filename);
  8. function JingleSession(me, sid, peerjid, connection,
  9. media_constraints, ice_config, service, eventEmitter) {
  10. /**
  11. * Our JID.
  12. */
  13. this.me = me;
  14. /**
  15. * The Jingle session identifier.
  16. */
  17. this.sid = sid;
  18. /**
  19. * the JID of the remote peer.
  20. */
  21. this.peerjid = peerjid;
  22. /**
  23. * The XMPP connection.
  24. */
  25. this.connection = connection;
  26. /**
  27. * The XMPP service.
  28. */
  29. this.service = service;
  30. /**
  31. * The event emitter.
  32. */
  33. this.eventEmitter = eventEmitter;
  34. /**
  35. * Whether to use dripping or not. Dripping is sending trickle candidates
  36. * not one-by-one.
  37. * Note: currently we do not support 'false'.
  38. */
  39. this.usedrip = true;
  40. /**
  41. * When dripping is used, stores ICE candidates which are to be sent.
  42. */
  43. this.drip_container = [];
  44. // Media constraints. Is this WebRTC only?
  45. this.media_constraints = media_constraints;
  46. // ICE servers config (RTCConfiguration?).
  47. this.ice_config = ice_config;
  48. // The chat room instance associated with the session.
  49. this.room = null;
  50. // Jingle session state - uninitialized until 'initialize' is called
  51. this.state = null;
  52. }
  53. /**
  54. * Prepares this object to initiate a session.
  55. * @param isInitiator whether we will be the Jingle initiator.
  56. * @param room <tt>ChatRoom<tt> for the conference associated with this session
  57. */
  58. JingleSession.prototype.initialize = function(isInitiator, room) {
  59. if (this.state !== null) {
  60. var errmsg
  61. = 'attempt to initiate on session ' + this.sid + 'in state '
  62. + this.state;
  63. logger.error(errmsg);
  64. throw new Error(errmsg);
  65. }
  66. this.room = room;
  67. this.state = 'pending';
  68. this.initiator = isInitiator ? this.me : this.peerjid;
  69. this.responder = !isInitiator ? this.me : this.peerjid;
  70. this.doInitialize();
  71. };
  72. /**
  73. * Finishes initialization.
  74. */
  75. JingleSession.prototype.doInitialize = function() {};
  76. /**
  77. * Adds the ICE candidates found in the 'contents' array as remote candidates?
  78. * Note: currently only used on transport-info
  79. */
  80. // eslint-disable-next-line no-unused-vars
  81. JingleSession.prototype.addIceCandidates = function(contents) {};
  82. /**
  83. * Checks if this JingleSession is in 'active' state which means that the call
  84. * is in progress.
  85. * @returns {boolean} <tt>true</tt> if this JingleSession is in 'active' state
  86. * or <tt>false</tt> otherwise.
  87. */
  88. JingleSession.prototype.active = function () {
  89. return this.state === 'active';
  90. };
  91. /**
  92. * Handles an 'add-source' event.
  93. *
  94. * @param contents an array of Jingle 'content' elements.
  95. */
  96. // eslint-disable-next-line no-unused-vars
  97. JingleSession.prototype.addSources = function(contents) {};
  98. /**
  99. * Handles a 'remove-source' event.
  100. *
  101. * @param contents an array of Jingle 'content' elements.
  102. */
  103. // eslint-disable-next-line no-unused-vars
  104. JingleSession.prototype.removeSources = function(contents) {};
  105. /**
  106. * Terminates this Jingle session by sending session-terminate
  107. * @param reason XMPP Jingle error condition
  108. * @param text some meaningful error message
  109. */
  110. // eslint-disable-next-line no-unused-vars
  111. JingleSession.prototype.terminate = function(reason, text) {};
  112. /**
  113. * Handles an offer from the remote peer (prepares to accept a session).
  114. * @param jingle the 'jingle' XML element.
  115. * @param success callback called when we the incoming session has been accepted
  116. * @param failure callback called when we fail for any reason, will supply error
  117. * object with details(which is meant more to be printed to the logger
  118. * than analysed in the code, as the error is unrecoverable anyway)
  119. */
  120. // eslint-disable-next-line no-unused-vars
  121. JingleSession.prototype.acceptOffer = function(jingle, success, failure) {};
  122. module.exports = JingleSession;