Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

BrowserCapabilities.js 6.3KB

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