提交 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 }, ...@@ -325,7 +325,45 @@ tap.test('rtpReceiver.receive() with wrong codecs must fail', { timeout: 2000 },
codecs : 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 payloadType : 101
} }
] ]
......
...@@ -2,7 +2,6 @@ ...@@ -2,7 +2,6 @@
#define MS_RTC_RTP_DICTIONARIES_H #define MS_RTC_RTP_DICTIONARIES_H
#include "common.h" #include "common.h"
#include "RTC/RtpKind.h"
#include "RTC/CustomParameters.h" #include "RTC/CustomParameters.h"
#include <string> #include <string>
#include <vector> #include <vector>
...@@ -42,7 +41,7 @@ namespace RTC ...@@ -42,7 +41,7 @@ namespace RTC
static std::unordered_map<std::string, RtpCodecParameters::Subtype> string2Subtype; static std::unordered_map<std::string, RtpCodecParameters::Subtype> string2Subtype;
public: public:
RtpCodecParameters(RTC::RtpKind kind, Json::Value& data); RtpCodecParameters(Json::Value& data);
virtual ~RtpCodecParameters(); virtual ~RtpCodecParameters();
Json::Value toJson(); Json::Value toJson();
...@@ -58,7 +57,6 @@ namespace RTC ...@@ -58,7 +57,6 @@ namespace RTC
RTC::CustomParameters parameters; RTC::CustomParameters parameters;
public: public:
RTC::RtpKind type;
Subtype subtype; Subtype subtype;
}; };
...@@ -149,7 +147,7 @@ namespace RTC ...@@ -149,7 +147,7 @@ namespace RTC
{ {
public: public:
// Constructor for receiver's parameters. // Constructor for receiver's parameters.
RtpParameters(RTC::RtpKind kind, Json::Value& data); RtpParameters(Json::Value& data);
// Constructor for sender's parameters. // Constructor for sender's parameters.
RtpParameters(const RtpParameters* RtpParameters); RtpParameters(const RtpParameters* RtpParameters);
virtual ~RtpParameters(); virtual ~RtpParameters();
...@@ -168,10 +166,25 @@ namespace RTC ...@@ -168,10 +166,25 @@ namespace RTC
RtcpParameters rtcp; RtcpParameters rtcp;
bool hasRtcp = false; bool hasRtcp = false;
Json::Value userParameters; 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 #endif
...@@ -24,7 +24,7 @@ namespace RTC ...@@ -24,7 +24,7 @@ namespace RTC
/* Instance methods. */ /* Instance methods. */
RtpCodecParameters::RtpCodecParameters(RTC::RtpKind kind, Json::Value& data) RtpCodecParameters::RtpCodecParameters(Json::Value& data)
{ {
MS_TRACE(); MS_TRACE();
...@@ -46,16 +46,14 @@ namespace RTC ...@@ -46,16 +46,14 @@ namespace RTC
this->name = data[k_name].asString(); 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. // 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()) if (RtpCodecParameters::string2Subtype.find(subtype) == RtpCodecParameters::string2Subtype.end())
this->subtype = Subtype::MEDIA; this->subtype = Subtype::MEDIA;
......
...@@ -9,8 +9,7 @@ namespace RTC ...@@ -9,8 +9,7 @@ namespace RTC
{ {
/* Instance methods. */ /* Instance methods. */
RtpParameters::RtpParameters(RTC::RtpKind kind, Json::Value& data) : RtpParameters::RtpParameters(Json::Value& data)
kind(kind)
{ {
MS_TRACE(); MS_TRACE();
...@@ -37,7 +36,7 @@ namespace RTC ...@@ -37,7 +36,7 @@ namespace RTC
for (Json::UInt i = 0; i < json_codecs.size(); i++) 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. // Append to the codecs vector.
this->codecs.push_back(codec); this->codecs.push_back(codec);
...@@ -99,7 +98,6 @@ namespace RTC ...@@ -99,7 +98,6 @@ 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;
......
...@@ -129,7 +129,7 @@ namespace RTC ...@@ -129,7 +129,7 @@ namespace RTC
try try
{ {
this->rtpParameters = new RTC::RtpParameters(this->kind, request->data); this->rtpParameters = new RTC::RtpParameters(request->data);
} }
catch (const MediaSoupError &error) catch (const MediaSoupError &error)
{ {
......
...@@ -986,7 +986,7 @@ namespace RTC ...@@ -986,7 +986,7 @@ namespace RTC
MS_DEBUG("DTLS application data received [size:%zu]", len); MS_DEBUG("DTLS application data received [size:%zu]", len);
// TMP // TODO: remove
MS_DEBUG("data: %s", std::string((char*)data, len).c_str()); MS_DEBUG("data: %s", std::string((char*)data, len).c_str());
} }
} }
...@@ -69,17 +69,17 @@ int main(int argc, char* argv[]) ...@@ -69,17 +69,17 @@ int main(int argc, char* argv[])
MS_DEBUG("starting " MS_PROCESS_NAME " [pid:%ld]", (long)getpid()); MS_DEBUG("starting " MS_PROCESS_NAME " [pid:%ld]", (long)getpid());
#if defined(MS_LITTLE_ENDIAN) #if defined(MS_LITTLE_ENDIAN)
MS_DEBUG("detected Little-Endian CPU"); MS_DEBUG("Little-Endian CPU detected");
#elif defined(MS_BIG_ENDIAN) #elif defined(MS_BIG_ENDIAN)
MS_DEBUG("detected Big-Endian CPU"); MS_DEBUG("Big-Endian CPU detected");
#endif #endif
#if defined(INTPTR_MAX) && defined(INT32_MAX) && (INTPTR_MAX == INT32_MAX) #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) #elif defined(INTPTR_MAX) && defined(INT64_MAX) && (INTPTR_MAX == INT64_MAX)
MS_DEBUG("detected 64 bits architecture"); MS_DEBUG("64 bits architecture detected");
#else #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 #endif
try try
...@@ -145,7 +145,7 @@ void ignoreSignals() ...@@ -145,7 +145,7 @@ void ignoreSignals()
for (auto it = ignored_signals.begin(); it != ignored_signals.end(); ++it) 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; int sig_id = it->second;
err = sigaction(sig_id, &act, nullptr); err = sigaction(sig_id, &act, nullptr);
......
Markdown 格式
0% 或
您添加了 0 人 到此讨论。请谨慎行事。
请先完成此评论的编辑!
请 注册 或者 后发表评论