modified lib-jitsi-meet dev repo
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

BrowserCapabilities.js 5.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. import { getLogger } from 'jitsi-meet-logger';
  2. import { BrowserDetection } from 'js-utils';
  3. const logger = getLogger(__filename);
  4. // TODO: Move this code to js-utils.
  5. // NOTE: Now we are extending BrowserDetection in order to preserve
  6. // RTCBrowserType interface but maybe it worth exporting BrowserCapabilities
  7. // and BrowserDetection as separate objects in future.
  8. /**
  9. * Implements browser capabilities for lib-jitsi-meet.
  10. */
  11. export default class BrowserCapabilities extends BrowserDetection {
  12. /**
  13. * Creates new BrowserCapabilities instance.
  14. */
  15. constructor() {
  16. super();
  17. logger.info(
  18. `This appears to be ${this.getName()}, ver: ${this.getVersion()}`);
  19. }
  20. /**
  21. * Tells whether or not the <tt>MediaStream/tt> is removed from
  22. * the <tt>PeerConnection</tt> and disposed on video mute (in order to turn
  23. * off the camera device).
  24. * @return {boolean} <tt>true</tt> if the current browser supports this
  25. * strategy or <tt>false</tt> otherwise.
  26. */
  27. doesVideoMuteByStreamRemove() {
  28. return !(
  29. this.isFirefox()
  30. || this.isEdge()
  31. || this.isSafariWithWebrtc()
  32. );
  33. }
  34. /**
  35. * Check whether or not the current browser support peer to peer connections
  36. * @return {boolean} <tt>true</tt> if p2p is supported or <tt>false</tt>
  37. * otherwise.
  38. */
  39. supportsP2P() {
  40. return !this.isEdge();
  41. }
  42. /**
  43. * Checks if current browser is a Safari and a version of Safari that
  44. * supports native webrtc.
  45. *
  46. * @returns {boolean}
  47. */
  48. isSafariWithWebrtc() {
  49. return this.isSafari()
  50. && !this.isVersionLessThan('11');
  51. }
  52. /**
  53. * Checks if Temasys RTC plugin is used.
  54. * @returns {boolean}
  55. */
  56. isTemasysPluginUsed() {
  57. // Temasys do not support Microsoft Edge:
  58. // http://support.temasys.com.sg/support/solutions/articles/
  59. // 5000654345-can-the-temasys-webrtc-plugin-be-used-with-microsoft-edge-
  60. return (
  61. (this.isSafari()
  62. && !this.isSafariWithWebrtc())
  63. || (this.isIExplorer()
  64. && this.isVersionLessThan('12'))
  65. );
  66. }
  67. /**
  68. * Checks if the current browser triggers 'onmute'/'onunmute' events when
  69. * user's connection is interrupted and the video stops playback.
  70. * @returns {*|boolean} 'true' if the event is supported or 'false'
  71. * otherwise.
  72. */
  73. supportsVideoMuteOnConnInterrupted() {
  74. return this.isChrome() || this.isElectron();
  75. }
  76. /**
  77. * Checks if the current browser reports upload and download bandwidth
  78. * statistics.
  79. * @return {boolean}
  80. */
  81. supportsBandwidthStatistics() {
  82. // FIXME bandwidth stats are currently not implemented for FF on our
  83. // side, but not sure if not possible ?
  84. return !this.isFirefox() && !this.isEdge();
  85. }
  86. /**
  87. * Checks if the current browser supports WebRTC datachannels.
  88. * @return {boolean}
  89. */
  90. supportsDataChannels() {
  91. // NOTE: Edge does not yet implement DataChannel.
  92. return !this.isEdge();
  93. }
  94. /**
  95. * Checks if the current browser reports round trip time statistics for
  96. * the ICE candidate pair.
  97. * @return {boolean}
  98. */
  99. supportsRTTStatistics() {
  100. // Firefox does not seem to report RTT for ICE candidate pair:
  101. // eslint-disable-next-line max-len
  102. // https://www.w3.org/TR/webrtc-stats/#dom-rtcicecandidatepairstats-currentroundtriptime
  103. // It does report mozRTT for RTP streams, but at the time of this
  104. // writing it's value does not make sense most of the time
  105. // (is reported as 1):
  106. // https://bugzilla.mozilla.org/show_bug.cgi?id=1241066
  107. // For Chrome and others we rely on 'googRtt'.
  108. return !this.isFirefox() && !this.isEdge();
  109. }
  110. /**
  111. * Checks whether the browser supports RTPSender.
  112. *
  113. * @returns {boolean}
  114. */
  115. supportsRtpSender() {
  116. return this.isFirefox();
  117. }
  118. /**
  119. * Checks whether the browser supports RTX.
  120. *
  121. * @returns {boolean}
  122. */
  123. supportsRtx() {
  124. return !this.isFirefox();
  125. }
  126. /**
  127. * Whether jitsi-meet supports simulcast on the current browser.
  128. * @returns {boolean}
  129. */
  130. supportsSimulcast() {
  131. return this.isChrome()
  132. || this.isFirefox()
  133. || this.isElectron()
  134. || this.isNWJS()
  135. || this.isReactNative();
  136. }
  137. /**
  138. * Returns whether or not the current browser can support capturing video,
  139. * be it camera or desktop, and displaying received video.
  140. *
  141. * @returns {boolean}
  142. */
  143. supportsVideo() {
  144. // FIXME: Check if we can use supportsVideoOut and supportsVideoIn. I
  145. // leave the old implementation here in order not to brake something.
  146. // Currently Safari using webrtc/adapter does not support video due in
  147. // part to Safari only supporting H264 and the bridge sending VP8.
  148. return !this.isSafariWithWebrtc();
  149. }
  150. /**
  151. * Checks if the browser uses plan B.
  152. *
  153. * @returns {boolean}
  154. */
  155. usesPlanB() {
  156. return !this.usesUnifiedPlan();
  157. }
  158. /**
  159. * Checks if the browser uses unified plan.
  160. *
  161. * @returns {boolean}
  162. */
  163. usesUnifiedPlan() {
  164. return this.isFirefox();
  165. }
  166. /**
  167. * Returns whether or not the current browser should be using the new
  168. * getUserMedia flow, which utilizes the adapter shim. This method should
  169. * be temporary and used while migrating all browsers to use adapter and
  170. * the new getUserMedia.
  171. *
  172. * @returns {boolean}
  173. */
  174. usesNewGumFlow() {
  175. return (this.isChrome()
  176. && !this.isVersionLessThan('61'))
  177. || this.isFirefox()
  178. || this.isSafariWithWebrtc();
  179. }
  180. }