Skip to content
This repository has been archived by the owner on Jul 16, 2024. It is now read-only.

Commit

Permalink
Added -vc option (video codec name)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexkonst committed Jun 22, 2020
1 parent 48975d5 commit 471ee23
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 11 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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]
```

Expand Down
12 changes: 10 additions & 2 deletions cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -88,7 +95,8 @@ const {
turn,
turnPassword,
turnUsername,
uri
uri,
videoCodec
} = argv

const iceServers = [
Expand Down Expand Up @@ -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 }))
Expand Down
4 changes: 2 additions & 2 deletions lib/peer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}

Expand Down
7 changes: 2 additions & 5 deletions lib/sdp.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,22 +30,19 @@ function mapByPayload (payload) {
}
}

function transformOfferSDP (sdp) {
function transformOfferSDP (sdp, options) {
const sdpParsed = parse(sdp)
const config = {
audio: {
codecName: 'opus',
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)
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down

0 comments on commit 471ee23

Please sign in to comment.