diff --git a/README.md b/README.md index 239bcc7..dc25d55 100644 --- a/README.md +++ b/README.md @@ -34,6 +34,8 @@ Options: --turn-password TURN password [string] [required] --turn-username TURN username [string] [required] -u, --uri MQTT broker URI [string] [required] + --vc, --video-codec Codec name for video (SDP) + [string] [choices: "H264", "VP8", "VP9"] [default: "H264"] --help Show help [boolean] ``` diff --git a/cli.js b/cli.js index 12f39a3..5b8e1a0 100755 --- a/cli.js +++ b/cli.js @@ -66,6 +66,13 @@ const { argv } = require('yargs') demandOption: true, description: 'MQTT broker URI', type: 'string' + }, + 'vc': { + alias: 'video-codec', + choices: ['H264', 'VP8', 'VP9'], + default: 'H264', + description: 'Codec name for video (SDP)', + type: 'string' } }) .help() @@ -88,7 +95,8 @@ const { turn, turnPassword, turnUsername, - uri + uri, + videoCodec } = argv const iceServers = [ @@ -182,7 +190,7 @@ function startListening (client, mqttClient, activeRtcStream) { return peer.createOffer(listenerOptions) }) .then(offer => { - const newOffer = transformOffer(offer) + const newOffer = transformOffer(offer, { videoCodec }) return client.createRtcSignal(handleId, newOffer) .then((response) => ({ response, offer: newOffer })) diff --git a/lib/peer.js b/lib/peer.js index 3e77b82..84baf38 100644 --- a/lib/peer.js +++ b/lib/peer.js @@ -113,10 +113,10 @@ class Peer { } } -function transformOffer (offer) { +function transformOffer (offer, options) { return { type: 'offer', - sdp: transformOfferSDP(offer.sdp) + sdp: transformOfferSDP(offer.sdp, options) } } diff --git a/lib/sdp.js b/lib/sdp.js index 21ee8e3..ee3c552 100644 --- a/lib/sdp.js +++ b/lib/sdp.js @@ -30,7 +30,7 @@ function mapByPayload (payload) { } } -function transformOfferSDP (sdp) { +function transformOfferSDP (sdp, options) { const sdpParsed = parse(sdp) const config = { audio: { @@ -38,14 +38,11 @@ function transformOfferSDP (sdp) { modifiedPayload: 109, }, video: { - codecName: 'H264', + codecName: options.videoCodec, modifiedPayload: 126, } } - // console.debug('[sdp] opts', opts) - // console.debug('[sdp] original', sdpParsed) - sdpParsed.media.forEach(m => { if (m.type === 'audio' || m.type === 'video') { const originalPayload = getPayloadByCodec(config[m.type].codecName, m.rtp) diff --git a/package-lock.json b/package-lock.json index 4ed3267..64c3963 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "@ulms/wrtc-agent", - "version": "0.2.1", + "version": "0.2.2", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index fe2ca67..3002f34 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@ulms/wrtc-agent", - "version": "0.2.1", + "version": "0.2.2", "description": "WebRTC agent for load testing", "main": "cli.js", "bin": {