提交 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
let rtpReceiver = peer.RtpReceiver(transport);
let rtpParameters =
{
muxId : 'abcd',
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 =
{
kind : 'audio',
muxId : 'abcd',
codecs :
[
......@@ -121,7 +65,8 @@ tap.test('rtpReceiver.receive() with valid `rtpParameters` must succeed', { time
}
},
{
ssrc : 111222331
ssrc : 111222331,
codecPayloadType : 8
}
],
rtcp :
......@@ -154,7 +99,7 @@ tap.test('rtpReceiver.receive() with valid `rtpParameters` must succeed', { time
.then((data) =>
{
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}`))
])
......
......@@ -27,6 +27,7 @@ tap.test('alice, bob and carol create RtpReceivers and expect RtpSenders', { tim
let aliceAudioParameters =
{
kind : 'audio',
muxId : 'alicemuxid1',
codecs :
[
......@@ -51,6 +52,7 @@ tap.test('alice, bob and carol create RtpReceivers and expect RtpSenders', { tim
};
let aliceVideoParameters =
{
kind : 'video',
muxId : 'alicemuxid2',
codecs :
[
......@@ -75,6 +77,7 @@ tap.test('alice, bob and carol create RtpReceivers and expect RtpSenders', { tim
};
let bobVideoParameters =
{
kind : 'video',
muxId : 'bobmuxid2',
codecs :
[
......@@ -104,6 +107,7 @@ tap.test('alice, bob and carol create RtpReceivers and expect RtpSenders', { tim
};
let carolAudioParameters =
{
kind : 'audio',
muxId : 'carolmuxid1',
codecs :
[
......@@ -128,6 +132,7 @@ tap.test('alice, bob and carol create RtpReceivers and expect RtpSenders', { tim
};
let carolVideoParameters =
{
kind : 'video',
muxId : 'carolmuxid2',
codecs :
[
......
......@@ -101,6 +101,13 @@ namespace RTC
class RtpParameters
{
public:
enum class Kind
{
AUDIO = 1,
VIDEO = 2
};
public:
RtpParameters(Json::Value& data);
RtpParameters(const RtpParameters* RtpParameters);
......@@ -109,6 +116,7 @@ namespace RTC
Json::Value toJson();
public:
Kind kind;
// TODO: not sure if 1 or 2 bytes or what.
std::string muxId;
std::vector<RtpCodecParameters> codecs;
......
......@@ -12,11 +12,25 @@ namespace RTC
{
MS_TRACE();
static const Json::StaticString k_kind("kind");
static const Json::StaticString k_muxId("muxId");
static const Json::StaticString k_codecs("codecs");
static const Json::StaticString k_encodings("encodings");
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.
if (data[k_muxId].isString())
{
......@@ -74,6 +88,7 @@ namespace RTC
{
MS_TRACE();
this->kind = rtpParameters->kind;
this->muxId = rtpParameters->muxId;
this->codecs = rtpParameters->codecs;
this->encodings = rtpParameters->encodings;
......@@ -89,6 +104,7 @@ namespace RTC
{
MS_TRACE();
static const Json::StaticString k_kind("kind");
static const Json::StaticString k_muxId("muxId");
static const Json::StaticString k_codecs("codecs");
static const Json::StaticString k_encodings("encodings");
......@@ -96,6 +112,17 @@ namespace RTC
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`.
json[k_muxId] = this->muxId;
......
Markdown 格式
0% 或
您添加了 0 人 到此讨论。请谨慎行事。
请先完成此评论的编辑!
请 注册 或者 后发表评论