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.

JingleSessionPC.spec.js 4.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. import $ from 'jquery';
  2. import { MockRTC } from '../RTC/MockClasses';
  3. import FeatureFlags from '../flags/FeatureFlags';
  4. import JingleSessionPC from './JingleSessionPC';
  5. import * as JingleSessionState from './JingleSessionState';
  6. import MediaSessionEvents from './MediaSessionEvents';
  7. import { MockChatRoom, MockStropheConnection } from './MockClasses';
  8. /**
  9. * Creates 'content-modify' Jingle IQ.
  10. * @returns {jQuery}
  11. */
  12. function createContentModifyForSourceNames() {
  13. const modifyContentsIq = $.parseXML(
  14. '<jingle action="content-modify" initiator="peer2" sid="sid12345" xmlns="urn:xmpp:jingle:1">'
  15. + '<content name="video" senders="both">'
  16. + '<source-frame-height maxHeight="180" sourceName="8d519815-v0" xmlns="http://jitsi.org/jitmeet/video"/>'
  17. + '<source-frame-height maxHeight="2160" sourceName="8d519815-v1" xmlns="http://jitsi.org/jitmeet/video"/>'
  18. + '</content>'
  19. + '</jingle>');
  20. return $(modifyContentsIq).find('>jingle');
  21. }
  22. describe('JingleSessionPC', () => {
  23. let jingleSession;
  24. let connection;
  25. let rtc;
  26. const offerIQ = {
  27. find: () => {
  28. return {
  29. // eslint-disable-next-line no-empty-function
  30. each: () => { }
  31. };
  32. }
  33. };
  34. const SID = 'sid12345';
  35. beforeEach(() => {
  36. connection = new MockStropheConnection();
  37. jingleSession = new JingleSessionPC(
  38. SID,
  39. 'peer1',
  40. 'peer2',
  41. connection,
  42. { },
  43. { },
  44. true,
  45. false);
  46. rtc = new MockRTC();
  47. jingleSession.initialize(
  48. /* ChatRoom */ new MockChatRoom(),
  49. /* RTC */ rtc,
  50. /* Signaling layer */ { },
  51. /* options */ { });
  52. // eslint-disable-next-line no-empty-function
  53. // connection.connect('jid', undefined, () => { }); */
  54. });
  55. describe('send/receive video constraints w/ source-name', () => {
  56. beforeEach(() => {
  57. FeatureFlags.init({ });
  58. });
  59. it('sends content-modify with recv frame size', () => {
  60. const sendIQSpy = spyOn(connection, 'sendIQ').and.callThrough();
  61. const sourceConstraints = new Map();
  62. sourceConstraints.set('8d519815-v0', 180);
  63. sourceConstraints.set('8d519815-v1', 2160);
  64. jingleSession.setReceiverVideoConstraint(sourceConstraints);
  65. expect(jingleSession.getState()).toBe(JingleSessionState.PENDING);
  66. return new Promise((resolve, reject) => {
  67. jingleSession.acceptOffer(
  68. offerIQ,
  69. resolve,
  70. reject,
  71. /* local tracks */ []);
  72. }).then(() => {
  73. expect(jingleSession.getState()).toBe(JingleSessionState.ACTIVE);
  74. // FIXME content-modify is sent before session-accept
  75. expect(sendIQSpy.calls.count()).toBe(2);
  76. expect(sendIQSpy.calls.first().args[0].toString()).toBe(
  77. '<iq to="peer2" type="set" xmlns="jabber:client">'
  78. + '<jingle action="content-modify" initiator="peer2" sid="sid12345" xmlns="urn:xmpp:jingle:1">'
  79. + '<content name="video" senders="both">'
  80. + '<source-frame-height maxHeight="180" sourceName="8d519815-v0"'
  81. + ' xmlns="http://jitsi.org/jitmeet/video"/>'
  82. + '<source-frame-height maxHeight="2160" sourceName="8d519815-v1"'
  83. + ' xmlns="http://jitsi.org/jitmeet/video"/>'
  84. + '</content>'
  85. + '</jingle>'
  86. + '</iq>');
  87. });
  88. });
  89. it('fires an event when remote peer sends content-modify', () => {
  90. let remoteSourcesRecvMaxFrameHeight;
  91. const remoteVideoConstraintsListener = () => {
  92. remoteSourcesRecvMaxFrameHeight = jingleSession.getRemoteSourcesRecvMaxFrameHeight();
  93. };
  94. jingleSession.addListener(
  95. MediaSessionEvents.REMOTE_SOURCE_CONSTRAINTS_CHANGED,
  96. remoteVideoConstraintsListener);
  97. return new Promise((resolve, reject) => {
  98. jingleSession.acceptOffer(
  99. offerIQ,
  100. resolve,
  101. reject,
  102. /* local tracks */ []);
  103. }).then(() => {
  104. jingleSession.modifyContents(createContentModifyForSourceNames());
  105. const v0Height = remoteSourcesRecvMaxFrameHeight[0].maxHeight;
  106. const v1Height = remoteSourcesRecvMaxFrameHeight[1].maxHeight;
  107. expect(v0Height).toBe('180');
  108. expect(v1Height).toBe('2160');
  109. });
  110. });
  111. });
  112. });