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