Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

SDP.spec.js 4.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. import { $iq } from 'strophe.js';
  2. import SDP from './SDP';
  3. describe('SDP', () => {
  4. describe('toJingle', () => {
  5. /* eslint-disable max-len*/
  6. const testSdp = [
  7. 'v=0\r\n',
  8. 'o=thisisadapterortc 2719486166053431 0 IN IP4 127.0.0.1\r\n',
  9. 's=-\r\n',
  10. 't=0 0\r\n',
  11. 'a=group:BUNDLE audio video\r\n',
  12. 'm=audio 9 UDP/TLS/RTP/SAVPF 111 126\r\n',
  13. 'c=IN IP4 0.0.0.0\r\n',
  14. 'a=rtpmap:111 opus/48000/2\r\n',
  15. 'a=rtpmap:126 telephone-event/8000\r\n',
  16. 'a=fmtp:111 minptime=10;useinbandfec=1\r\n',
  17. 'a=rtcp:9 IN IP4 0.0.0.0\r\n',
  18. 'a=setup:active\r\n',
  19. 'a=mid:audio\r\n',
  20. 'a=msid:26D16D51-503A-420B-8274-3DD1174E498F 8205D1FC-50B4-407C-87D5-9C45F1B779F0\r\n',
  21. 'a=sendrecv\r\n',
  22. 'a=ice-ufrag:tOQd\r\n',
  23. 'a=ice-pwd:3sAozs7hw6+2O6DBp2pt9fvY\r\n',
  24. 'a=fingerprint:sha-256 A9:00:CC:F9:81:33:EA:E9:E3:B4:01:E9:9E:18:B3:9B:F8:49:25:A0:5D:12:20:70:D5:6F:34:5A:2A:39:19:0A\r\n',
  25. 'a=ssrc:2002 msid:26D16D51-503A-420B-8274-3DD1174E498F 8205D1FC-50B4-407C-87D5-9C45F1B779F0\r\n',
  26. 'a=ssrc:2002 cname:juejgy8a01\r\n',
  27. 'a=rtcp-mux\r\n',
  28. 'm=video 9 UDP/TLS/RTP/SAVPF 107 100 99 96\r\n',
  29. 'c=IN IP4 0.0.0.0\r\n',
  30. 'a=rtpmap:107 h264/90000\r\n',
  31. 'a=rtpmap:100 VP8/90000\r\n',
  32. 'a=rtpmap:99 rtx/90000\r\n',
  33. 'a=rtpmap:96 rtx/90000\r\n',
  34. 'a=fmtp:107 x-google-start-bitrate=800\r\n',
  35. 'a=fmtp:100 x-google-start-bitrate=800\r\n',
  36. 'a=fmtp:99 apt=107\r\n',
  37. 'a=fmtp:96 apt=100\r\n',
  38. 'a=rtcp:9 IN IP4 0.0.0.0\r\n',
  39. 'a=rtcp-fb:107 nack\r\n',
  40. 'a=rtcp-fb:107 nack pli\r\n',
  41. 'a=rtcp-fb:107 goog-remb\r\n',
  42. 'a=rtcp-fb:100 nack\r\n',
  43. 'a=rtcp-fb:100 nack pli\r\n',
  44. 'a=rtcp-fb:100 goog-remb\r\n',
  45. 'a=extmap:3 http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time\r\n',
  46. 'a=setup:active\r\n',
  47. 'a=mid:video\r\n',
  48. 'a=msid:7C0035E5-2DA1-4AEA-804A-9E75BF9B3768 225E9CDA-0384-4C92-92DD-E74C1153EC68\r\n',
  49. 'a=sendrecv\r\n',
  50. 'a=ice-ufrag:tOQd\r\n',
  51. 'a=ice-pwd:3sAozs7hw6+2O6DBp2pt9fvY\r\n',
  52. 'a=fingerprint:sha-256 A9:00:CC:F9:81:33:EA:E9:E3:B4:01:E9:9E:18:B3:9B:F8:49:25:A0:5D:12:20:70:D5:6F:34:5A:2A:39:19:0A\r\n',
  53. 'a=ssrc:4004 msid:7C0035E5-2DA1-4AEA-804A-9E75BF9B3768 225E9CDA-0384-4C92-92DD-E74C1153EC68\r\n',
  54. 'a=ssrc:4005 msid:7C0035E5-2DA1-4AEA-804A-9E75BF9B3768 225E9CDA-0384-4C92-92DD-E74C1153EC68\r\n',
  55. 'a=ssrc:4004 cname:juejgy8a01\r\n',
  56. 'a=ssrc:4005 cname:juejgy8a01\r\n',
  57. 'a=ssrc-group:FID 4004 4005\r\n',
  58. 'a=rtcp-mux\r\n'
  59. ].join('');
  60. /* eslint-enable max-len*/
  61. it('correctly groups ssrcs lines that are not in order', () => {
  62. const sdp = new SDP(testSdp);
  63. const accept = $iq({
  64. to: 'peerjid',
  65. type: 'set'
  66. })
  67. .c('jingle', {
  68. xmlns: 'urn:xmpp:jingle:1',
  69. action: 'session-accept',
  70. initiator: false,
  71. responder: true,
  72. sid: 'temp-sid'
  73. });
  74. sdp.toJingle(accept, false);
  75. const { nodeTree } = accept;
  76. const descriptions
  77. = Array.from(nodeTree.getElementsByTagName('description'));
  78. const videoDescriptions = descriptions.filter(description =>
  79. description.getAttribute('media') === 'video');
  80. const count = videoDescriptions.reduce((iterator, description) => {
  81. const childNodes = Array.from(description.childNodes);
  82. const childNodesSources = childNodes.filter(child =>
  83. child.nodeName === 'source');
  84. return iterator + childNodesSources.length;
  85. }, 0);
  86. expect(count).toBe(2);
  87. });
  88. });
  89. });