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.

TraceablePeerConnection.spec.js 1.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. import transform from 'sdp-transform';
  2. import { multiCodecVideoSdp, plainVideoSdp } from '../xmpp/SampleSdpStrings';
  3. import TraceablePeerConnection from './TraceablePeerConnection';
  4. describe('TraceablePeerConnection', () => {
  5. describe('_injectH264IfNotPresent', () => {
  6. // Store the method-in-test in a convenience variable.
  7. const injectFunction
  8. = TraceablePeerConnection.prototype._injectH264IfNotPresent;
  9. const MockSessionDescription = function({ sdp }) {
  10. this.sdp = sdp;
  11. };
  12. const originalSessionDescription = window.originalSessionDescription;
  13. beforeEach(() => {
  14. window.RTCSessionDescription = MockSessionDescription;
  15. });
  16. afterEach(() => {
  17. window.RTCSessionDescription = originalSessionDescription;
  18. });
  19. it('adds h264', () => {
  20. const sessionDescription = new MockSessionDescription({
  21. sdp: transform.write(plainVideoSdp)
  22. });
  23. const { sdp } = injectFunction(sessionDescription);
  24. const expectedH264Payload = [
  25. 'm=video 9 RTP/SAVPF 100 127',
  26. 'a=rtpmap:127 H264/90000',
  27. 'a=fmtp:127 level-asymmetry-allowed=1;'
  28. + 'packetization-mode=1;'
  29. + 'profile-level-id=42e01f'
  30. ];
  31. expectedH264Payload.forEach(h264Description =>
  32. expect(sdp.indexOf(h264Description) > -1).toBe(true));
  33. });
  34. it('does not modify the description if H264 is present', () => {
  35. const sessionDescription = new MockSessionDescription({
  36. sdp: transform.write(multiCodecVideoSdp)
  37. });
  38. const result = injectFunction(sessionDescription);
  39. expect(result).toEqual(sessionDescription);
  40. });
  41. });
  42. });