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

Don't mandate codec.name's MIME type to match the RtpReceiver's kind.

上级 ffb0a1ec
......@@ -325,7 +325,45 @@ tap.test('rtpReceiver.receive() with wrong codecs must fail', { timeout: 2000 },
codecs :
[
{
name : 'chicken/FOO',
name : 'opus',
payloadType : 101
}
]
})
.then(() => t.fail('rtpReceiver.receive() succeeded'))
.catch((error) =>
{
t.pass(`rtpReceiver.receive() with an invalid codec.name failed: ${error}`);
});
});
funcs.push(function()
{
return rtpReceiver.receive(
{
codecs :
[
{
name : '/opus',
payloadType : 101
}
]
})
.then(() => t.fail('rtpReceiver.receive() succeeded'))
.catch((error) =>
{
t.pass(`rtpReceiver.receive() with an invalid codec.name failed: ${error}`);
});
});
funcs.push(function()
{
return rtpReceiver.receive(
{
codecs :
[
{
name : 'audio/',
payloadType : 101
}
]
......
......@@ -2,7 +2,6 @@
#define MS_RTC_RTP_DICTIONARIES_H
#include "common.h"
#include "RTC/RtpKind.h"
#include "RTC/CustomParameters.h"
#include <string>
#include <vector>
......@@ -42,7 +41,7 @@ namespace RTC
static std::unordered_map<std::string, RtpCodecParameters::Subtype> string2Subtype;
public:
RtpCodecParameters(RTC::RtpKind kind, Json::Value& data);
RtpCodecParameters(Json::Value& data);
virtual ~RtpCodecParameters();
Json::Value toJson();
......@@ -58,7 +57,6 @@ namespace RTC
RTC::CustomParameters parameters;
public:
RTC::RtpKind type;
Subtype subtype;
};
......@@ -149,7 +147,7 @@ namespace RTC
{
public:
// Constructor for receiver's parameters.
RtpParameters(RTC::RtpKind kind, Json::Value& data);
RtpParameters(Json::Value& data);
// Constructor for sender's parameters.
RtpParameters(const RtpParameters* RtpParameters);
virtual ~RtpParameters();
......@@ -168,10 +166,25 @@ namespace RTC
RtcpParameters rtcp;
bool hasRtcp = false;
Json::Value userParameters;
private:
RTC::RtpKind kind;
};
// class RtpCapabilities
// {
// public:
// RtpCapabilities() {};
// RtpCapabilities(Json::Value& data);
// virtual ~RtpCapabilities();
// Json::Value toJson();
// private:
// void ValidateCodecs();
// public:
// std::vector<RtpCodecCapability> codecs;
// std::vector<RtpHeaderExtensionCapability> headerExtensions;
// std::vector<std::string> fecMechanisms;
// };
}
#endif
......@@ -24,7 +24,7 @@ namespace RTC
/* Instance methods. */
RtpCodecParameters::RtpCodecParameters(RTC::RtpKind kind, Json::Value& data)
RtpCodecParameters::RtpCodecParameters(Json::Value& data)
{
MS_TRACE();
......@@ -46,16 +46,14 @@ namespace RTC
this->name = data[k_name].asString();
// Get and check name MIME type.
if (kind == RTC::RtpKind::AUDIO && this->name.compare(0, 6, "audio/") == 0)
this->type = RTC::RtpKind::AUDIO;
else if (kind == RTC::RtpKind::VIDEO && this->name.compare(0, 6, "video/") == 0)
this->type = RTC::RtpKind::VIDEO;
else
MS_THROW_ERROR("invalid RtpCodecParameters.name MIME type [name:%s]", this->name.c_str());
// Get name MIME subtype.
std::string subtype = this->name.substr(6);
auto slash_pos = this->name.find('/');
if (slash_pos == std::string::npos || slash_pos == 0 || slash_pos == this->name.length() - 1)
MS_THROW_ERROR("wrong RtpCodecParameters.name");
std::string subtype = this->name.substr(slash_pos + 1);
if (RtpCodecParameters::string2Subtype.find(subtype) == RtpCodecParameters::string2Subtype.end())
this->subtype = Subtype::MEDIA;
......
......@@ -9,8 +9,7 @@ namespace RTC
{
/* Instance methods. */
RtpParameters::RtpParameters(RTC::RtpKind kind, Json::Value& data) :
kind(kind)
RtpParameters::RtpParameters(Json::Value& data)
{
MS_TRACE();
......@@ -37,7 +36,7 @@ namespace RTC
for (Json::UInt i = 0; i < json_codecs.size(); i++)
{
RtpCodecParameters codec(this->kind, json_codecs[i]);
RtpCodecParameters codec(json_codecs[i]);
// Append to the codecs vector.
this->codecs.push_back(codec);
......@@ -99,7 +98,6 @@ namespace RTC
{
MS_TRACE();
this->kind = rtpParameters->kind;
this->muxId = rtpParameters->muxId;
this->codecs = rtpParameters->codecs;
this->encodings = rtpParameters->encodings;
......
......@@ -129,7 +129,7 @@ namespace RTC
try
{
this->rtpParameters = new RTC::RtpParameters(this->kind, request->data);
this->rtpParameters = new RTC::RtpParameters(request->data);
}
catch (const MediaSoupError &error)
{
......
......@@ -986,7 +986,7 @@ namespace RTC
MS_DEBUG("DTLS application data received [size:%zu]", len);
// TMP
// TODO: remove
MS_DEBUG("data: %s", std::string((char*)data, len).c_str());
}
}
......@@ -69,17 +69,17 @@ int main(int argc, char* argv[])
MS_DEBUG("starting " MS_PROCESS_NAME " [pid:%ld]", (long)getpid());
#if defined(MS_LITTLE_ENDIAN)
MS_DEBUG("detected Little-Endian CPU");
MS_DEBUG("Little-Endian CPU detected");
#elif defined(MS_BIG_ENDIAN)
MS_DEBUG("detected Big-Endian CPU");
MS_DEBUG("Big-Endian CPU detected");
#endif
#if defined(INTPTR_MAX) && defined(INT32_MAX) && (INTPTR_MAX == INT32_MAX)
MS_DEBUG("detected 32 bits architecture");
MS_DEBUG("32 bits architecture detected");
#elif defined(INTPTR_MAX) && defined(INT64_MAX) && (INTPTR_MAX == INT64_MAX)
MS_DEBUG("detected 64 bits architecture");
MS_DEBUG("64 bits architecture detected");
#else
MS_WARN("cannot determine whether the architecture is 32 or 64 bits");
MS_WARN("can not determine whether the architecture is 32 or 64 bits");
#endif
try
......@@ -145,7 +145,7 @@ void ignoreSignals()
for (auto it = ignored_signals.begin(); it != ignored_signals.end(); ++it)
{
std::string sig_name = it->first;
auto& sig_name = it->first;
int sig_id = it->second;
err = sigaction(sig_id, &act, nullptr);
......
Markdown 格式
0% 或
您添加了 0 人 到此讨论。请谨慎行事。
请先完成此评论的编辑!
请 注册 或者 后发表评论