提交 d687f935 authored 作者: Iñaki Baz Castillo's avatar Iñaki Baz Castillo

- Add custom userParameters into RtpParameters

- Allow float/double parameter values in Dictionaries
上级 8847e9ac
......@@ -94,6 +94,14 @@ tap.test('rtpReceiver.receive() with valid `rtpParameters` must succeed', { time
cname : 'a7sdihkj3sdsdflqwkejl98ujk',
ssrc : 88888888,
reducedSize : true
},
userParameters :
{
foo : 123,
bar : 'BAR',
baz : true,
cas : -123.123,
arr : [ 1, '2', 3.3, { qwe: 'QWE', asd: 123, zxc: null } ]
}
};
......
......@@ -48,6 +48,10 @@ tap.test('alice, bob and carol create RtpReceivers and expect RtpSenders', { tim
cname : 'ALICEAUDIO',
ssrc : 51000011,
reducedSize : false
},
userParameters :
{
msid : 'alice-msid'
}
};
let aliceVideoParameters =
......@@ -83,6 +87,10 @@ tap.test('alice, bob and carol create RtpReceivers and expect RtpSenders', { tim
cname : 'ALICEVIDEO',
ssrc : 51000021,
reducedSize : true
},
userParameters :
{
msid : 'alice-msid'
}
};
let bobVideoParameters =
......@@ -118,6 +126,10 @@ tap.test('alice, bob and carol create RtpReceivers and expect RtpSenders', { tim
cname : 'BOBVIDEO',
ssrc : 52000021,
reducedSize : true
},
userParameters :
{
msid : 'bob-msid'
}
};
let carolAudioParameters =
......@@ -143,6 +155,10 @@ tap.test('alice, bob and carol create RtpReceivers and expect RtpSenders', { tim
cname : 'CAROLAUDIO',
ssrc : 53000011,
reducedSize : true
},
userParameters :
{
msid : 'carol-msid'
}
};
let carolVideoParameters =
......@@ -177,6 +193,10 @@ tap.test('alice, bob and carol create RtpReceivers and expect RtpSenders', { tim
cname : 'CAROLVIDEO',
ssrc : 53000021,
reducedSize : true
},
userParameters :
{
msid : 'carol-msid'
}
};
......@@ -187,9 +207,9 @@ tap.test('alice, bob and carol create RtpReceivers and expect RtpSenders', { tim
{ kind: 'audio', rtpParameters: aliceAudioParameters },
{ kind: 'video', rtpParameters: aliceVideoParameters }
])
// Once transport is created let's check the already existing RtpSenders
// and listen for 'newrtpsender' if all the expected ones are not yet
// present
// Once transport and rtpReceivers are created let's check the already
// existing RtpSenders and listen for 'newrtpsender' if all the expected
// ones are not yet present
.then(() =>
{
const EXPECTED_RTPSENDERS = 1;
......
......@@ -15,14 +15,16 @@ namespace RTC
enum class Type
{
BOOLEAN = 1,
STRING,
INTEGER
INTEGER,
DOUBLE,
STRING
};
public:
CustomParameterValue() {};
CustomParameterValue(bool booleanValue);
CustomParameterValue(uint32_t integerValue);
CustomParameterValue(double doubleValue);
CustomParameterValue(std::string& stringValue);
virtual ~CustomParameterValue();
......@@ -32,6 +34,7 @@ namespace RTC
Type type;
bool booleanValue = false;
uint32_t integerValue = 0;
double doubleValue = 0.0;
std::string stringValue;
};
......@@ -167,6 +170,7 @@ namespace RTC
std::vector<RtpHeaderExtensionParameters> headerExtensions;
RtcpParameters rtcp;
bool hasRtcp = false;
Json::Value userParameters;
};
}
......
......@@ -20,6 +20,13 @@ namespace RTC
MS_TRACE();
}
CustomParameterValue::CustomParameterValue(double doubleValue) :
type(Type::DOUBLE),
doubleValue(doubleValue)
{
MS_TRACE();
}
CustomParameterValue::CustomParameterValue(std::string& stringValue) :
type(Type::STRING),
stringValue(stringValue)
......
......@@ -71,9 +71,9 @@ namespace RTC
// `parameters` is optional.
if (data[k_parameters].isObject())
{
auto& parameters = data[k_parameters];
auto& json_parameters = data[k_parameters];
for (Json::Value::iterator it = parameters.begin(); it != parameters.end(); ++it)
for (Json::Value::iterator it = json_parameters.begin(); it != json_parameters.end(); ++it)
{
std::string key = it.key().asString();
Json::Value value = (*it);
......@@ -99,6 +99,15 @@ namespace RTC
break;
}
case Json::realValue:
{
double doubleValue = value.asDouble();
this->parameters[key] = RTC::CustomParameterValue(doubleValue);
break;
}
case Json::stringValue:
{
std::string stringValue = value.asString();
......@@ -188,6 +197,10 @@ namespace RTC
json_parameters[key] = (Json::UInt)parameterValue.integerValue;
break;
case RTC::CustomParameterValue::Type::DOUBLE:
json_parameters[key] = parameterValue.doubleValue;
break;
case RTC::CustomParameterValue::Type::STRING:
json_parameters[key] = parameterValue.stringValue;
break;
......
......@@ -41,9 +41,9 @@ namespace RTC
// `parameters` is optional.
if (data[k_parameters].isObject())
{
auto& parameters = data[k_parameters];
auto& json_parameters = data[k_parameters];
for (Json::Value::iterator it = parameters.begin(); it != parameters.end(); ++it)
for (Json::Value::iterator it = json_parameters.begin(); it != json_parameters.end(); ++it)
{
std::string key = it.key().asString();
Json::Value value = (*it);
......@@ -69,6 +69,15 @@ namespace RTC
break;
}
case Json::realValue:
{
double doubleValue = value.asDouble();
this->parameters[key] = RTC::CustomParameterValue(doubleValue);
break;
}
case Json::stringValue:
{
std::string stringValue = value.asString();
......@@ -130,6 +139,10 @@ namespace RTC
json_parameters[key] = (Json::UInt)parameterValue.integerValue;
break;
case RTC::CustomParameterValue::Type::DOUBLE:
json_parameters[key] = parameterValue.doubleValue;
break;
case RTC::CustomParameterValue::Type::STRING:
json_parameters[key] = parameterValue.stringValue;
break;
......
......@@ -17,6 +17,7 @@ namespace RTC
static const Json::StaticString k_encodings("encodings");
static const Json::StaticString k_headerExtensions("headerExtensions");
static const Json::StaticString k_rtcp("rtcp");
static const Json::StaticString k_userParameters("userParameters");
// `muxId` is optional.
if (data[k_muxId].isString())
......@@ -77,6 +78,12 @@ namespace RTC
this->rtcp = RtcpParameters(data[k_rtcp]);
this->hasRtcp = true;
}
// `userParameters` is optional.
if (data[k_userParameters].isObject())
this->userParameters = data[k_userParameters];
else
this->userParameters = Json::objectValue;
}
RtpParameters::RtpParameters(const RtpParameters* rtpParameters)
......@@ -89,6 +96,7 @@ namespace RTC
this->headerExtensions = rtpParameters->headerExtensions;
this->rtcp = rtpParameters->rtcp;
this->hasRtcp = rtpParameters->hasRtcp;
this->userParameters = rtpParameters->userParameters;
}
RtpParameters::~RtpParameters()
......@@ -105,6 +113,7 @@ namespace RTC
static const Json::StaticString k_encodings("encodings");
static const Json::StaticString k_headerExtensions("headerExtensions");
static const Json::StaticString k_rtcp("rtcp");
static const Json::StaticString k_userParameters("userParameters");
Json::Value json(Json::objectValue);
......@@ -149,6 +158,9 @@ namespace RTC
if (this->hasRtcp)
json[k_rtcp] = this->rtcp.toJson();
// Add `userParameters`.
json[k_userParameters] = this->userParameters;
return json;
}
}
Markdown 格式
0% 或
您添加了 0 人 到此讨论。请谨慎行事。
请先完成此评论的编辑!
请 注册 或者 后发表评论