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.

SDPDiffer.spec.js 2.8KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. import { $iq } from 'strophe.js';
  2. import FeatureFlags from '../flags/FeatureFlags';
  3. import SDP from './SDP';
  4. import SDPDiffer from './SDPDiffer';
  5. describe('SDPDiffer', () => {
  6. beforeEach(() => {
  7. FeatureFlags.init({ });
  8. });
  9. describe('toJingle', () => {
  10. /* eslint-disable max-len*/
  11. const testSdpOld = [
  12. 'v=0\r\n',
  13. 'o=thisisadapterortc 2719486166053431 0 IN IP4 127.0.0.1\r\n',
  14. 's=-\r\n',
  15. 't=0 0\r\n',
  16. 'a=group:BUNDLE audio video\r\n',
  17. 'm=audio 9 UDP/TLS/RTP/SAVPF 111 126\r\n',
  18. 'a=mid:audio\r\n',
  19. 'a=ssrc:2002 msid:26D16D51-503A-420B-8274-3DD1174E498F 8205D1FC-50B4-407C-87D5-9C45F1B779F0\r\n',
  20. 'a=ssrc:2002 cname:juejgy8a01\r\n',
  21. 'a=ssrc:2002 name:a8f7g30-a0\r\n',
  22. 'm=video 9 UDP/TLS/RTP/SAVPF 107 100 99 96\r\n',
  23. 'a=mid:video\r\n'
  24. ].join('');
  25. const testSdpNew = [
  26. 'm=audio 9 UDP/TLS/RTP/SAVPF 111 126\r\n',
  27. 'a=mid:audio\r\n',
  28. 'm=video 9 UDP/TLS/RTP/SAVPF 107 100 99 96\r\n',
  29. 'a=mid:video\r\n',
  30. 'a=ssrc:4004 msid:7C0035E5-2DA1-4AEA-804A-9E75BF9B3768 225E9CDA-0384-4C92-92DD-E74C1153EC68\r\n',
  31. 'a=ssrc:4005 msid:7C0035E5-2DA1-4AEA-804A-9E75BF9B3768 225E9CDA-0384-4C92-92DD-E74C1153EC68\r\n',
  32. 'a=ssrc:4004 cname:juejgy8a01\r\n',
  33. 'a=ssrc:4005 cname:juejgy8a01\r\n',
  34. 'a=ssrc:4004 name:a8f7g30-v0\r\n',
  35. 'a=ssrc:4005 name:a8f7g30-v0\r\n',
  36. 'a=ssrc-group:FID 4004 4005\r\n'
  37. ].join('');
  38. /* eslint-enable max-len*/
  39. it('should include source names in added/removed sources', () => {
  40. FeatureFlags.init({ });
  41. const newToOldDiff = new SDPDiffer(new SDP(testSdpNew), new SDP(testSdpOld));
  42. const sourceRemoveIq = $iq({})
  43. .c('jingle', { action: 'source-remove' });
  44. newToOldDiff.toJingle(sourceRemoveIq);
  45. const removedAudioSources = sourceRemoveIq.nodeTree
  46. .querySelectorAll('description[media=\'audio\']>source');
  47. expect(removedAudioSources[0].getAttribute('name')).toBe('a8f7g30-a0');
  48. const oldToNewDiff = new SDPDiffer(new SDP(testSdpOld), new SDP(testSdpNew));
  49. const sourceAddIq = $iq({})
  50. .c('jingle', { action: 'source-add' });
  51. oldToNewDiff.toJingle(sourceAddIq);
  52. const addedVideoSources = sourceAddIq.nodeTree
  53. .querySelectorAll('description[media=\'video\']>source');
  54. expect(addedVideoSources.length).toBe(2);
  55. expect(addedVideoSources[0].getAttribute('name')).toBe('a8f7g30-v0');
  56. expect(addedVideoSources[1].getAttribute('name')).toBe('a8f7g30-v0');
  57. });
  58. });
  59. });