How to use the @twilio/webrtc.RTCSessionDescription function in @twilio/webrtc

To help you get started, we’ve selected a few @twilio/webrtc examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github twilio / twilio-video.js / test / unit / spec / util / sdp / issue8329.js View on Github external
it('still works', () => {
      const input = new RTCSessionDescription({ type: 'offer', sdp: validSdp2 });
      const output = workaround(input).sdp;
      assert(!output.match(/\r\n\r\n/));
    });
  });
github twilio / twilio-video.js / test / integration / spec / util / simulcast.js View on Github external
before(async () => {
        const constraints = { audio: true, video: true };
        stream = await makeStream(constraints);
        pc1 = new RTCPeerConnection({ iceServers: [] });
        pc1.addStream(stream);
        pc2 = new RTCPeerConnection({ iceServers: [] });
        pc2.addStream(stream);
        trackIdsToAttributes = new Map();

        const offerOptions = { offerToReceiveAudio: true, offerToReceiveVideo: true };
        const offer = await pc1.createOffer(offerOptions);

        offer1 = createSdp === 'createOffer' ? new RTCSessionDescription({
          type: offer.type,
          sdp: setSimulcast(offer.sdp, sdpFormat, trackIdsToAttributes)
        }) : offer;

        await pc1.setLocalDescription(offer1);
        await pc2.setRemoteDescription(offer1);
        const answer = await pc2.createAnswer();

        answer1 = createSdp === 'createAnswer' ? new RTCSessionDescription({
          type: answer.type,
          sdp: setSimulcast(answer.sdp, sdpFormat, trackIdsToAttributes)
        }) : answer;

        await pc2.setLocalDescription(answer1);
        await pc1.setRemoteDescription(answer1);
        const _offer = await pc1.createOffer(offerOptions);
github twilio / twilio-video.js / test / integration / spec / util / simulcast.js View on Github external
pc1.addStream(stream);
      trackIdsToAttributes = new Map();

      const offerOptions = { offerToReceiveAudio: true, offerToReceiveVideo: true };
      const offer = await pc1.createOffer(offerOptions);

      offer1 = new RTCSessionDescription({
        type: offer.type,
        sdp: setSimulcast(offer.sdp, sdpFormat, trackIdsToAttributes)
      });

      await pc1.setLocalDescription(offer1);
      assert.equal(pc1.signalingState, 'have-local-offer');
      const _offer = await pc1.createOffer(offerOptions);

      offer2 = new RTCSessionDescription({
        type: _offer.type,
        sdp: setSimulcast(_offer.sdp, sdpFormat, trackIdsToAttributes)
      });
    });
github twilio / twilio-video.js / test / integration / spec / util / simulcast.js View on Github external
before(async () => {
      const constraints = { audio: true, video: true };
      stream = await makeStream(constraints);
      pc1 = new RTCPeerConnection({ iceServers: [] });
      pc1.addStream(stream);
      trackIdsToAttributes = new Map();

      const offerOptions = { offerToReceiveAudio: true, offerToReceiveVideo: true };
      const offer = await pc1.createOffer(offerOptions);

      offer1 = new RTCSessionDescription({
        type: offer.type,
        sdp: setSimulcast(offer.sdp, sdpFormat, trackIdsToAttributes)
      });

      await pc1.setLocalDescription(offer1);
      assert.equal(pc1.signalingState, 'have-local-offer');
      const _offer = await pc1.createOffer(offerOptions);

      offer2 = new RTCSessionDescription({
        type: _offer.type,
        sdp: setSimulcast(_offer.sdp, sdpFormat, trackIdsToAttributes)
      });
    });
github twilio / twilio-video.js / test / integration / spec / util / simulcast.js View on Github external
}) : offer;

        await pc1.setLocalDescription(offer1);
        await pc2.setRemoteDescription(offer1);
        const answer = await pc2.createAnswer();

        answer1 = createSdp === 'createAnswer' ? new RTCSessionDescription({
          type: answer.type,
          sdp: setSimulcast(answer.sdp, sdpFormat, trackIdsToAttributes)
        }) : answer;

        await pc2.setLocalDescription(answer1);
        await pc1.setRemoteDescription(answer1);
        const _offer = await pc1.createOffer(offerOptions);

        offer2 = createSdp === 'createOffer' ? new RTCSessionDescription({
          type: _offer.type,
          sdp: setSimulcast(_offer.sdp, sdpFormat, trackIdsToAttributes)
        }) : _offer;

        await pc2.setRemoteDescription(offer2);
        answer2 = await pc2.createAnswer();
      });
github twilio / twilio-video.js / test / integration / spec / util / simulcast.js View on Github external
pc2.addStream(stream);
        trackIdsToAttributes = new Map();

        const offerOptions = { offerToReceiveAudio: true, offerToReceiveVideo: true };
        const offer = await pc1.createOffer(offerOptions);

        offer1 = createSdp === 'createOffer' ? new RTCSessionDescription({
          type: offer.type,
          sdp: setSimulcast(offer.sdp, sdpFormat, trackIdsToAttributes)
        }) : offer;

        await pc1.setLocalDescription(offer1);
        await pc2.setRemoteDescription(offer1);
        const answer = await pc2.createAnswer();

        answer1 = createSdp === 'createAnswer' ? new RTCSessionDescription({
          type: answer.type,
          sdp: setSimulcast(answer.sdp, sdpFormat, trackIdsToAttributes)
        }) : answer;

        await pc2.setLocalDescription(answer1);
        await pc1.setRemoteDescription(answer1);
        const _offer = await pc1.createOffer(offerOptions);

        offer2 = createSdp === 'createOffer' ? new RTCSessionDescription({
          type: _offer.type,
          sdp: setSimulcast(_offer.sdp, sdpFormat, trackIdsToAttributes)
        }) : _offer;

        await pc2.setRemoteDescription(offer2);
        answer2 = await pc2.createAnswer();
      });
github twilio / twilio-video.js / test / unit / spec / util / sdp / issue8329.js View on Github external
    ['RTCSessionDescription', descriptionInit => new RTCSessionDescription(descriptionInit)],
    ['RTCSessionDescriptionInit', descriptionInit => descriptionInit]
github twilio / twilio-video.js / lib / util / sdp / issue8329.js View on Github external
function workaround(description) {
  const descriptionInit = { type: description.type };
  if (description.type !== 'rollback') {
    descriptionInit.sdp = sdpWorkaround(description.sdp);
  }
  return new RTCSessionDescription(descriptionInit);
}