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

RtpPArameters: add kind (audio/video)

上级 4a0ab1dd
...@@ -20,63 +20,7 @@ tap.test('rtpReceiver.receive() with valid `rtpParameters` must succeed', { time ...@@ -20,63 +20,7 @@ tap.test('rtpReceiver.receive() with valid `rtpParameters` must succeed', { time
let rtpReceiver = peer.RtpReceiver(transport); let rtpReceiver = peer.RtpReceiver(transport);
let rtpParameters = let rtpParameters =
{ {
muxId : 'abcd', kind : 'audio',
codecs :
[
{
name : 'opus',
payloadType : 111,
clockRate : null,
numChannels : 2
},
{
name : 'PCMA',
payloadType : 8,
clockRate : 4800,
maxptime : 20
},
{
name : 'VP8',
payloadType : 103,
clockRate : 90000,
rtcpFeedback :
[
{ type: 'ccm', parameter: 'fir' },
{ type: 'nack' },
{ type: 'nack', parameter: 'pli' },
{ type: 'google-remb' }
]
}
],
encodings :
[
{
ssrc : 111222330,
codecPayloadType : 111,
fec :
{
mechanism : 'foo',
ssrc : 222222222
},
rtx :
{
payloadType : 201,
ssrc : 333333333
}
},
{
ssrc : 111222331
}
],
rtcp :
{
cname : 'a7sdihkj3sdsdflqwkejl98ujk',
ssrc : 88888888,
reducedSize : true
}
};
let expectedRtpParameters =
{
muxId : 'abcd', muxId : 'abcd',
codecs : codecs :
[ [
...@@ -121,7 +65,8 @@ tap.test('rtpReceiver.receive() with valid `rtpParameters` must succeed', { time ...@@ -121,7 +65,8 @@ tap.test('rtpReceiver.receive() with valid `rtpParameters` must succeed', { time
} }
}, },
{ {
ssrc : 111222331 ssrc : 111222331,
codecPayloadType : 8
} }
], ],
rtcp : rtcp :
...@@ -154,7 +99,7 @@ tap.test('rtpReceiver.receive() with valid `rtpParameters` must succeed', { time ...@@ -154,7 +99,7 @@ tap.test('rtpReceiver.receive() with valid `rtpParameters` must succeed', { time
.then((data) => .then((data) =>
{ {
t.pass('rtpReceiver.dump() succeeded'); t.pass('rtpReceiver.dump() succeeded');
t.same(data.rtpParameters, expectedRtpParameters, 'rtpReceiver.dump() must provide the expected `rtpParameters`'); t.same(data.rtpParameters, rtpParameters, 'rtpReceiver.dump() must provide the expected `rtpParameters`');
}) })
.catch((error) => t.fail(`rtpReceiver.dump() failed: ${error}`)) .catch((error) => t.fail(`rtpReceiver.dump() failed: ${error}`))
]) ])
......
...@@ -27,6 +27,7 @@ tap.test('alice, bob and carol create RtpReceivers and expect RtpSenders', { tim ...@@ -27,6 +27,7 @@ tap.test('alice, bob and carol create RtpReceivers and expect RtpSenders', { tim
let aliceAudioParameters = let aliceAudioParameters =
{ {
kind : 'audio',
muxId : 'alicemuxid1', muxId : 'alicemuxid1',
codecs : codecs :
[ [
...@@ -51,6 +52,7 @@ tap.test('alice, bob and carol create RtpReceivers and expect RtpSenders', { tim ...@@ -51,6 +52,7 @@ tap.test('alice, bob and carol create RtpReceivers and expect RtpSenders', { tim
}; };
let aliceVideoParameters = let aliceVideoParameters =
{ {
kind : 'video',
muxId : 'alicemuxid2', muxId : 'alicemuxid2',
codecs : codecs :
[ [
...@@ -75,6 +77,7 @@ tap.test('alice, bob and carol create RtpReceivers and expect RtpSenders', { tim ...@@ -75,6 +77,7 @@ tap.test('alice, bob and carol create RtpReceivers and expect RtpSenders', { tim
}; };
let bobVideoParameters = let bobVideoParameters =
{ {
kind : 'video',
muxId : 'bobmuxid2', muxId : 'bobmuxid2',
codecs : codecs :
[ [
...@@ -104,6 +107,7 @@ tap.test('alice, bob and carol create RtpReceivers and expect RtpSenders', { tim ...@@ -104,6 +107,7 @@ tap.test('alice, bob and carol create RtpReceivers and expect RtpSenders', { tim
}; };
let carolAudioParameters = let carolAudioParameters =
{ {
kind : 'audio',
muxId : 'carolmuxid1', muxId : 'carolmuxid1',
codecs : codecs :
[ [
...@@ -128,6 +132,7 @@ tap.test('alice, bob and carol create RtpReceivers and expect RtpSenders', { tim ...@@ -128,6 +132,7 @@ tap.test('alice, bob and carol create RtpReceivers and expect RtpSenders', { tim
}; };
let carolVideoParameters = let carolVideoParameters =
{ {
kind : 'video',
muxId : 'carolmuxid2', muxId : 'carolmuxid2',
codecs : codecs :
[ [
......
...@@ -101,6 +101,13 @@ namespace RTC ...@@ -101,6 +101,13 @@ namespace RTC
class RtpParameters class RtpParameters
{ {
public:
enum class Kind
{
AUDIO = 1,
VIDEO = 2
};
public: public:
RtpParameters(Json::Value& data); RtpParameters(Json::Value& data);
RtpParameters(const RtpParameters* RtpParameters); RtpParameters(const RtpParameters* RtpParameters);
...@@ -109,6 +116,7 @@ namespace RTC ...@@ -109,6 +116,7 @@ namespace RTC
Json::Value toJson(); Json::Value toJson();
public: public:
Kind kind;
// TODO: not sure if 1 or 2 bytes or what. // TODO: not sure if 1 or 2 bytes or what.
std::string muxId; std::string muxId;
std::vector<RtpCodecParameters> codecs; std::vector<RtpCodecParameters> codecs;
......
...@@ -12,11 +12,25 @@ namespace RTC ...@@ -12,11 +12,25 @@ namespace RTC
{ {
MS_TRACE(); MS_TRACE();
static const Json::StaticString k_kind("kind");
static const Json::StaticString k_muxId("muxId"); static const Json::StaticString k_muxId("muxId");
static const Json::StaticString k_codecs("codecs"); static const Json::StaticString k_codecs("codecs");
static const Json::StaticString k_encodings("encodings"); static const Json::StaticString k_encodings("encodings");
static const Json::StaticString k_rtcp("rtcp"); static const Json::StaticString k_rtcp("rtcp");
// `kind` is mandatory.
if (!data[k_kind].isString())
MS_THROW_ERROR("missing `kind`");
std::string kind = data[k_kind].asString();
if (kind == "audio")
this->kind = Kind::AUDIO;
else if (kind == "video")
this->kind = Kind::VIDEO;
else
MS_THROW_ERROR("unknown `kind`");
// `muxId` is optional. // `muxId` is optional.
if (data[k_muxId].isString()) if (data[k_muxId].isString())
{ {
...@@ -74,6 +88,7 @@ namespace RTC ...@@ -74,6 +88,7 @@ namespace RTC
{ {
MS_TRACE(); MS_TRACE();
this->kind = rtpParameters->kind;
this->muxId = rtpParameters->muxId; this->muxId = rtpParameters->muxId;
this->codecs = rtpParameters->codecs; this->codecs = rtpParameters->codecs;
this->encodings = rtpParameters->encodings; this->encodings = rtpParameters->encodings;
...@@ -89,6 +104,7 @@ namespace RTC ...@@ -89,6 +104,7 @@ namespace RTC
{ {
MS_TRACE(); MS_TRACE();
static const Json::StaticString k_kind("kind");
static const Json::StaticString k_muxId("muxId"); static const Json::StaticString k_muxId("muxId");
static const Json::StaticString k_codecs("codecs"); static const Json::StaticString k_codecs("codecs");
static const Json::StaticString k_encodings("encodings"); static const Json::StaticString k_encodings("encodings");
...@@ -96,6 +112,17 @@ namespace RTC ...@@ -96,6 +112,17 @@ namespace RTC
Json::Value json(Json::objectValue); Json::Value json(Json::objectValue);
// Add `kind`.
switch (this->kind)
{
case Kind::AUDIO:
json[k_kind] = "audio";
break;
case Kind::VIDEO:
json[k_kind] = "video";
break;
}
// Add `muxId`. // Add `muxId`.
json[k_muxId] = this->muxId; json[k_muxId] = this->muxId;
......
Markdown 格式
0% 或
您添加了 0 人 到此讨论。请谨慎行事。
请先完成此评论的编辑!
请 注册 或者 后发表评论