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.

BrowserCapabilities.js 6.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  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 supports the MediaStream constructor as
  96. * defined by https://www.w3.org/TR/mediacapture-streams/#constructors. In
  97. * cases where there is no support, it maybe be necessary to get audio
  98. * and video in two distinct GUM calls.
  99. * @return {boolean}
  100. */
  101. supportsMediaStreamConstructor() {
  102. return !this.isReactNative()
  103. && !this.isTemasysPluginUsed();
  104. }
  105. /**
  106. * Checks if the current browser reports round trip time statistics for
  107. * the ICE candidate pair.
  108. * @return {boolean}
  109. */
  110. supportsRTTStatistics() {
  111. // Firefox does not seem to report RTT for ICE candidate pair:
  112. // eslint-disable-next-line max-len
  113. // https://www.w3.org/TR/webrtc-stats/#dom-rtcicecandidatepairstats-currentroundtriptime
  114. // It does report mozRTT for RTP streams, but at the time of this
  115. // writing it's value does not make sense most of the time
  116. // (is reported as 1):
  117. // https://bugzilla.mozilla.org/show_bug.cgi?id=1241066
  118. // For Chrome and others we rely on 'googRtt'.
  119. return !this.isFirefox() && !this.isEdge();
  120. }
  121. /**
  122. * Checks whether the browser supports RTPSender.
  123. *
  124. * @returns {boolean}
  125. */
  126. supportsRtpSender() {
  127. return this.isFirefox();
  128. }
  129. /**
  130. * Checks whether the browser supports RTX.
  131. *
  132. * @returns {boolean}
  133. */
  134. supportsRtx() {
  135. return !this.isFirefox();
  136. }
  137. /**
  138. * Whether jitsi-meet supports simulcast on the current browser.
  139. * @returns {boolean}
  140. */
  141. supportsSimulcast() {
  142. return this.isChrome()
  143. || this.isFirefox()
  144. || this.isElectron()
  145. || this.isNWJS()
  146. || this.isReactNative();
  147. }
  148. /**
  149. * Returns whether or not the current browser can support capturing video,
  150. * be it camera or desktop, and displaying received video.
  151. *
  152. * @returns {boolean}
  153. */
  154. supportsVideo() {
  155. // FIXME: Check if we can use supportsVideoOut and supportsVideoIn. I
  156. // leave the old implementation here in order not to brake something.
  157. // Currently Safari using webrtc/adapter does not support video due in
  158. // part to Safari only supporting H264 and the bridge sending VP8.
  159. return !this.isSafariWithWebrtc();
  160. }
  161. /**
  162. * Checks if the browser uses plan B.
  163. *
  164. * @returns {boolean}
  165. */
  166. usesPlanB() {
  167. return !this.usesUnifiedPlan();
  168. }
  169. /**
  170. * Checks if the browser uses unified plan.
  171. *
  172. * @returns {boolean}
  173. */
  174. usesUnifiedPlan() {
  175. return this.isFirefox();
  176. }
  177. /**
  178. * Returns whether or not the current browser should be using the new
  179. * getUserMedia flow, which utilizes the adapter shim. This method should
  180. * be temporary and used while migrating all browsers to use adapter and
  181. * the new getUserMedia.
  182. *
  183. * @returns {boolean}
  184. */
  185. usesNewGumFlow() {
  186. return (this.isChrome()
  187. && !this.isVersionLessThan('61'))
  188. || this.isFirefox()
  189. || this.isSafariWithWebrtc();
  190. }
  191. }