How to use addHeaderExtensionToSdp method in wpt

Best JavaScript code snippet using wpt

RTCRtpSynchronizationSource-helper.js

Source:RTCRtpSynchronizationSource-helper.js Github

copy

Full Screen

2// This file depends on `webrtc/RTCPeerConnection-helper.js`3// which should be loaded from the main HTML file.4var kAbsCaptureTime =5 'http://www.webrtc.org/experiments/rtp-hdrext/abs-capture-time';6function addHeaderExtensionToSdp(sdp, uri) {7 const extmap = new RegExp('a=extmap:(\\d+)');8 let sdpLines = sdp.split('\r\n');9 // This assumes at most one audio m= section and one video m= section.10 // If more are present, only the first section of each kind is munged.11 for (const section of ['audio', 'video']) {12 let found_section = false;13 let maxId = undefined;14 let maxIdLine = undefined;15 let extmapAllowMixed = false;16 // find the largest header extension id for section.17 for (let i = 0; i < sdpLines.length; ++i) {18 if (!found_section) {19 if (sdpLines[i].startsWith('m=' + section)) {20 found_section = true;21 }22 continue;23 } else {24 if (sdpLines[i].startsWith('m=')) {25 // end of section26 break;27 }28 }29 if (sdpLines[i] === 'a=extmap-allow-mixed') {30 extmapAllowMixed = true;31 }32 let result = sdpLines[i].match(extmap);33 if (result && result.length === 2) {34 if (maxId == undefined || result[1] > maxId) {35 maxId = parseInt(result[1]);36 maxIdLine = i;37 }38 }39 }40 if (maxId == 14 && !extmapAllowMixed) {41 // Reaching the limit of one byte header extension. Adding two byte header42 // extension support.43 sdpLines.splice(maxIdLine + 1, 0, 'a=extmap-allow-mixed');44 }45 if (maxIdLine !== undefined) {46 sdpLines.splice(maxIdLine + 1, 0,47 'a=extmap:' + (maxId + 1).toString() + ' ' + uri);48 }49 }50 return sdpLines.join('\r\n');51}52// TODO(crbug.com/1051821): Use RTP header extension API instead of munging53// when the RTP header extension API is implemented.54async function addAbsCaptureTimeAndExchangeOffer(caller, callee) {55 let offer = await caller.createOffer();56 // Absolute capture time header extension may not be offered by default,57 // in such case, munge the SDP.58 offer.sdp = addHeaderExtensionToSdp(offer.sdp, kAbsCaptureTime);59 await caller.setLocalDescription(offer);60 return callee.setRemoteDescription(offer);61}62// TODO(crbug.com/1051821): Use RTP header extension API instead of munging63// when the RTP header extension API is implemented.64async function checkAbsCaptureTimeAndExchangeAnswer(caller, callee,65 absCaptureTimeAnswered) {66 let answer = await callee.createAnswer();67 const extmap = new RegExp('a=extmap:\\d+ ' + kAbsCaptureTime + '\r\n', 'g');68 if (answer.sdp.match(extmap) == null) {69 // We expect that absolute capture time RTP header extension is answered.70 // But if not, there is no need to proceed with the test.71 assert_false(absCaptureTimeAnswered, 'Absolute capture time RTP ' +72 'header extension is not answered');...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1addHeaderExtensionToSdp(sdp, 'urn:ietf:params:rtp-hdrext:ssrc-audio-level', 1, function(sdp) {2 console.log('sdp after adding header extension: ' + sdp);3});4removeHeaderExtensionFromSdp(sdp, 'urn:ietf:params:rtp-hdrext:ssrc-audio-level', function(sdp) {5 console.log('sdp after removing header extension: ' + sdp);6});7This project is licensed under the Apache License - see the [LICENSE](LICENSE) file for details

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run wpt automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful