How to use rtpParameters method in wpt

Best JavaScript code snippet using wpt

simulcast.js

Source:simulcast.js Github

copy

Full Screen

1'use strict';2/* Helper functions to munge SDP and split the sending track into3 * separate tracks on the receiving end. This can be done in a number4 * of ways, the one used here uses the fact that the MID and RID header5 * extensions which are used for packet routing share the same wire6 * format. The receiver interprets the rids from the sender as mids7 * which allows receiving the different spatial resolutions on separate8 * m-lines and tracks.9 */10const extensionsToFilter = [11 'urn:ietf:params:rtp-hdrext:sdes:mid',12 'urn:ietf:params:rtp-hdrext:sdes:rtp-stream-id',13 'urn:ietf:params:rtp-hdrext:sdes:repaired-rtp-stream-id',14];15function swapRidAndMidExtensionsInSimulcastOffer(offer, rids) {16 const sections = SDPUtils.splitSections(offer.sdp);17 const dtls = SDPUtils.getDtlsParameters(sections[1], sections[0]);18 const ice = SDPUtils.getIceParameters(sections[1], sections[0]);19 const rtpParameters = SDPUtils.parseRtpParameters(sections[1]);20 // The gist of this hack is that rid and mid have the same wire format.21 const rid = rtpParameters.headerExtensions.find(ext => ext.uri === 'urn:ietf:params:rtp-hdrext:sdes:rtp-stream-id');22 rtpParameters.headerExtensions = rtpParameters.headerExtensions.filter(ext => {23 return !extensionsToFilter.includes(ext.uri);24 });25 // This tells the other side that the RID packets are actually mids.26 rtpParameters.headerExtensions.push({id: rid.id, uri: 'urn:ietf:params:rtp-hdrext:sdes:mid', direction: 'sendrecv'});27 // Filter rtx as we have no way to (re)interpret rrid.28 // Not doing this makes probing use RTX, it's not understood and ramp-up is slower.29 rtpParameters.codecs = rtpParameters.codecs.filter(c => c.name.toUpperCase() !== 'RTX');30 let sdp = SDPUtils.writeSessionBoilerplate() +31 SDPUtils.writeDtlsParameters(dtls, 'actpass') +32 SDPUtils.writeIceParameters(ice) +33 'a=group:BUNDLE ' + rids.join(' ') + '\r\n';34 const baseRtpDescription = SDPUtils.writeRtpDescription('video', rtpParameters);35 rids.forEach(rid => {36 sdp += baseRtpDescription +37 'a=mid:' + rid + '\r\n' +38 'a=msid:rid-' + rid + ' rid-' + rid + '\r\n';39 });40 return sdp;41}42function swapRidAndMidExtensionsInSimulcastAnswer(answer, localDescription, rids) {43 const sections = SDPUtils.splitSections(answer.sdp);44 const dtls = SDPUtils.getDtlsParameters(sections[1], sections[0]);45 const ice = SDPUtils.getIceParameters(sections[1], sections[0]);46 const rtpParameters = SDPUtils.parseRtpParameters(sections[1]);47 rtpParameters.headerExtensions = rtpParameters.headerExtensions.filter(ext => {48 return !extensionsToFilter.includes(ext.uri);49 });50 const localMid = SDPUtils.getMid(SDPUtils.splitSections(localDescription.sdp)[1]);51 let sdp = SDPUtils.writeSessionBoilerplate() +52 SDPUtils.writeDtlsParameters(dtls, 'active') +53 SDPUtils.writeIceParameters(ice) +54 'a=group:BUNDLE ' + localMid + '\r\n';55 sdp += SDPUtils.writeRtpDescription('video', rtpParameters);56 sdp += 'a=mid:' + localMid + '\r\n';57 rids.forEach(rid => {58 sdp += 'a=rid:' + rid + ' recv\r\n';59 });60 sdp += 'a=simulcast:recv ' + rids.join(';') + '\r\n';61 // Re-add headerextensions we filtered.62 const headerExtensions = SDPUtils.parseRtpParameters(SDPUtils.splitSections(localDescription.sdp)[1]).headerExtensions;63 headerExtensions.forEach(ext => {64 if (extensionsToFilter.includes(ext.uri)) {65 sdp += 'a=extmap:' + ext.id + ' ' + ext.uri + '\r\n';66 }67 });68 return sdp;69}70async function negotiateSimulcastAndWaitForVideo(t, rids, pc1, pc2, codec) {71 exchangeIceCandidates(pc1, pc2);72 const metadataToBeLoaded = [];73 pc2.ontrack = (e) => {74 const stream = e.streams[0];75 const v = document.createElement('video');76 v.autoplay = true;77 v.srcObject = stream;78 v.id = stream.id79 metadataToBeLoaded.push(new Promise((resolve) => {80 v.addEventListener('loadedmetadata', () => {81 resolve();82 });83 }));84 };85 // Use getUserMedia as getNoiseStream does not have enough entropy to ramp-up.86 await setMediaPermission();87 const stream = await navigator.mediaDevices.getUserMedia({video: {width: 1280, height: 720}});88 t.add_cleanup(() => stream.getTracks().forEach(track => track.stop()));89 const transceiver = pc1.addTransceiver(stream.getVideoTracks()[0], {90 streams: [stream],91 sendEncodings: rids.map(rid => ({rid})),92 });93 if (codec) {94 preferCodec(transceiver, codec.mimeType, codec.sdpFmtpLine);95 }96 const offer = await pc1.createOffer();97 await pc1.setLocalDescription(offer),98 await pc2.setRemoteDescription({99 type: 'offer',100 sdp: swapRidAndMidExtensionsInSimulcastOffer(offer, rids),101 });102 const answer = await pc2.createAnswer();103 await pc2.setLocalDescription(answer);104 await pc1.setRemoteDescription({105 type: 'answer',106 sdp: swapRidAndMidExtensionsInSimulcastAnswer(answer, pc1.localDescription, rids),107 });108 assert_equals(metadataToBeLoaded.length, rids.length);109 return Promise.all(metadataToBeLoaded);...

Full Screen

Full Screen

sdp.ts

Source:sdp.ts Github

copy

Full Screen

1import { Consumer } from 'mediasoup/lib/Consumer';2import { PlainTransport } from 'mediasoup/lib/PlainTransport';3import { Producer } from 'mediasoup/lib/Producer';4import { MediaKind, RtpParameters } from 'mediasoup/lib/RtpParameters';5import config from './config';6const parseParams = (obj: any) => {7 if (!obj) return;8 const keys = Object.keys(obj);9 if (!keys.length) return;10 const params = [];11 // level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=42e01f12 keys.forEach((key) => {13 params.push(`${key}=${obj[key]}`);14 });15 return params.join(';');16};17export const getCodecInfoFromRtpParameters = (18 kind: MediaKind,19 rtpParameters: RtpParameters20) => {21 const codec = rtpParameters.codecs[0];22 const encoding = rtpParameters.encodings[0];23 return {24 payloadType: codec.payloadType,25 codecName: codec.mimeType.replace(`${kind}/`, '').toLowerCase(),26 clockRate: codec.clockRate,27 parameters: parseParams(codec.parameters),28 channels: kind === 'audio' ? codec.channels : undefined,29 ssrc: encoding.ssrc30 };31};32export const getSdpText = (33 transport: PlainTransport,34 producer: Producer,35 consumer: Consumer36) => {37 let sdpText = '';38 const streamIp = config.mediasoup.plainTransportOptions.listenIp.ip;39 sdpText += 'v=0\n';40 sdpText += `o=- 0 0 IN IP4 ${streamIp}\n`;41 sdpText += 's=FFmpeg\n';42 sdpText += `c=IN IP4 ${streamIp}\n`;43 sdpText += 't=0 0\n';44 const remoteRtpPort = transport.tuple.remotePort;45 const remoteRtcpPort = transport.rtcpTuple.remotePort;46 const rtpParameters = consumer.rtpParameters;47 const codec = getCodecInfoFromRtpParameters(producer.kind, rtpParameters);48 if (producer.kind === 'video') {49 sdpText += `m=video ${remoteRtpPort} RTP/AVPF ${codec.payloadType}\n`;50 sdpText += `a=ssrc:${codec.ssrc}\n`;51 sdpText += `a=rtcp:${remoteRtcpPort}\n`;52 sdpText += `a=rtpmap:${codec.payloadType} ${codec.codecName}/${codec.clockRate}\n`;53 if (codec.parameters) {54 sdpText += `a=fmtp:${codec.payloadType} ${codec.parameters}\n`;55 }56 }57 if (producer.kind === 'audio') {58 sdpText += `m=audio ${remoteRtpPort} RTP/AVPF ${codec.payloadType}\n`;59 sdpText += `a=ssrc:${codec.ssrc}\n`;60 sdpText += `a=rtcp:${remoteRtcpPort}\n`;61 sdpText += `a=rtpmap:${codec.payloadType} ${codec.codecName}/${codec.clockRate}/${codec.channels}\n`;62 if (codec.parameters) {63 sdpText += `a=fmtp:${codec.payloadType} ${codec.parameters}\n`;64 }65 }66 return sdpText;...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('../lib/webpagetest.js');2var wpt = new wpt('www.webpagetest.org');3wpt.getLocations(function (err, data) {4 if (err) return console.error(err);5 console.log(data);6});7wpt.getTesters(function (err, data) {8 if (err) return console.error(err);9 console.log(data);10});11wpt.runTest('www.google.com', {location: 'Dulles:Chrome'}, function (err, data) {12 if (err) return console.error(err);13 console.log(data);14});15wpt.getTestStatus('140714_9S_1f8', function (err, data) {16 if (err) return console.error(err);17 console.log(data);18});19wpt.getTestResults('140714_9S_1f8', function (err, data) {20 if (err) return console.error(err);21 console.log(data);22});23wpt.getTestResults('140714_9S_1f8', {breakdown: true}, function (err, data) {24 if (err) return console.error(err);25 console.log(data);26});27wpt.getTestResults('140714_9S_1f8', {requests: true}, function (err, data) {28 if (err) return console.error(err);29 console.log(data);30});31wpt.getTestResults('140714_9S_1f8', {pagespeed: true}, function (err, data) {32 if (err) return console.error(err);33 console.log(data);34});35wpt.getTestResults('140714_9S_1f8', {pagespeed: true, requests: true}, function (err, data) {36 if (err) return console.error(err);37 console.log(data);38});39wpt.getTestResults('140714_9S_1f8', {pagespeed: true, requests: true, breakdown: true}, function (err, data) {40 if (err) return console.error(err);41 console.log(data);42});43wpt.getTestResults('140714_9S_1f8', {pagespeed: true, requests: true, breakdown: true, medianMetric: 'loadTime'}, function (err, data) {44 if (err) return

Full Screen

Using AI Code Generation

copy

Full Screen

1var wptool = require('./wptool.js');2var fs = require('fs');3var path = require('path');4var test = function (url) {5 var options = {6 output: path.join(__dirname, 'output'),

Full Screen

Using AI Code Generation

copy

Full Screen

1const wptool = require('wptool');2var rtpParameters = wptool.rtpParameters();3console.log(rtpParameters);4{ audio: 5 { codecs: 6 [ { name: 'opus',7 parameters: [Object] },8 { name: 'ISAC',9 parameters: [Object] },10 { name: 'ISAC',11 parameters: [Object] },12 { name: 'G722',13 parameters: [Object] },14 { name: 'PCMU',15 parameters: [Object] },16 { name: 'PCMA',17 parameters: [Object] },18 { name: 'CN',19 parameters: [Object] },20 { name: 'CN',21 parameters: [Object] },22 { name: 'CN',23 parameters: [Object] },24 { name: 'telephone-event',25 parameters: [Object] },26 { name: 'telephone-event',27 parameters: [Object] },28 { name: 'telephone-event',29 parameters: [Object] } ],30 [ { uri: 'urn:ietf:params:rtp-hdrext:ssrc-audio-level',31 parameters: [Object] },32 parameters: [Object] },33 { uri: 'urn:ietf:params:rtp-hdrext:toffset',

Full Screen

Using AI Code Generation

copy

Full Screen

1const wptool = require('wptool');2const path = require('path');3const wp = new wptool({4 path: path.resolve(__dirname, '../wordpress')5});6wp.rtpParameters().then((data) => {7 console.log(data);8}).catch((err) => {9 console.log(err);10});

Full Screen

Using AI Code Generation

copy

Full Screen

1var wptools = require('./index.js');2wptools.page(url).then(function(page) {3 return page.rtpParameters();4}).then(function(rtpParameters) {5 console.log(rtpParameters);6}).catch(function(err) {7 console.log(err);8});

Full Screen

Using AI Code Generation

copy

Full Screen

1const wptool = require('wptool');2const rtpParameters = wptool.rtpParameters;3console.log(rtp);4### wptool.searchVideo(query, maxResults, callback)5const wptool = require('wptool');6const query = "youtube";7const maxResults = 5;8wptool.searchVideo(query, maxResults, function(videos) {9 console.log(videos);10});11### wptool.rtpParameters(url, callback)12const wptool = require('wptool');13wptool.rtpParameters(url, function(rtp) {14 console.log(rtp);15});16### wptool.download(url, callback)17const wptool = require('wptool');

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