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

C++: Add RtpHeaderExtensionUri

上级 c5af2d9d
...@@ -123,6 +123,26 @@ namespace RTC ...@@ -123,6 +123,26 @@ namespace RTC
std::string name; std::string name;
}; };
class RtpHeaderExtensionUri
{
public:
enum class Type : uint8_t
{
UNKNOWN = 0,
SSRC_AUDIO_LEVEL = 1,
TO_OFFSET = 2,
ABS_SEND_TIME = 3,
VIDEO_ORIENTATION = 4,
RTP_STREAM_ID = 5
};
private:
static std::unordered_map<std::string, Type> string2Type;
public:
static Type GetType(std::string& uri);
};
class RtcpFeedback class RtcpFeedback
{ {
public: public:
...@@ -174,6 +194,7 @@ namespace RTC ...@@ -174,6 +194,7 @@ namespace RTC
public: public:
Media::Kind kind = Media::Kind::ALL; Media::Kind kind = Media::Kind::ALL;
std::string uri; std::string uri;
RtpHeaderExtensionUri::Type type;
uint16_t preferredId = 0; uint16_t preferredId = 0;
bool preferredEncrypt = false; bool preferredEncrypt = false;
}; };
...@@ -255,6 +276,7 @@ namespace RTC ...@@ -255,6 +276,7 @@ namespace RTC
public: public:
std::string uri; std::string uri;
RtpHeaderExtensionUri::Type type;
uint16_t id = 0; uint16_t id = 0;
bool encrypt = false; bool encrypt = false;
RTC::Parameters parameters; RTC::Parameters parameters;
......
...@@ -30,6 +30,15 @@ namespace RTC ...@@ -30,6 +30,15 @@ namespace RTC
virtual void onRtpSenderClosed(RtpSender* rtpSender) = 0; virtual void onRtpSenderClosed(RtpSender* rtpSender) = 0;
}; };
private:
struct Data
{
std::string muxId;
RTC::RtpCodecMime mediaMime;
uint32_t mediaSsrc = 0;
// TODO: Add much more and move supportedPayloadTypes here.
};
private: private:
// Container of RTP packets to retransmit. // Container of RTP packets to retransmit.
static std::vector<RTC::RtpPacket*> rtpRetransmissionContainer; static std::vector<RTC::RtpPacket*> rtpRetransmissionContainer;
......
...@@ -52,6 +52,7 @@ ...@@ -52,6 +52,7 @@
'src/RTC/RtpDictionaries/RtpFecParameters.cpp', 'src/RTC/RtpDictionaries/RtpFecParameters.cpp',
'src/RTC/RtpDictionaries/RtpHeaderExtension.cpp', 'src/RTC/RtpDictionaries/RtpHeaderExtension.cpp',
'src/RTC/RtpDictionaries/RtpHeaderExtensionParameters.cpp', 'src/RTC/RtpDictionaries/RtpHeaderExtensionParameters.cpp',
'src/RTC/RtpDictionaries/RtpHeaderExtensionUri.cpp',
'src/RTC/RtpDictionaries/RtpParameters.cpp', 'src/RTC/RtpDictionaries/RtpParameters.cpp',
'src/RTC/RtpDictionaries/RtpRtxParameters.cpp', 'src/RTC/RtpDictionaries/RtpRtxParameters.cpp',
'src/RTC/RTCP/Packet.cpp', 'src/RTC/RTCP/Packet.cpp',
......
...@@ -41,7 +41,8 @@ namespace RTC ...@@ -41,7 +41,8 @@ namespace RTC
{ {
RtpHeaderExtension headerExtension(json_array[i]); RtpHeaderExtension headerExtension(json_array[i]);
// Append to the headerExtensions vector. // If a known header extension, append to the headerExtensions vector.
if (headerExtension.type != RtpHeaderExtensionUri::Type::UNKNOWN)
this->headerExtensions.push_back(headerExtension); this->headerExtensions.push_back(headerExtension);
} }
} }
...@@ -114,7 +115,7 @@ namespace RTC ...@@ -114,7 +115,7 @@ namespace RTC
for (auto& supportedHeaderExtension : supportedHeaderExtensions) for (auto& supportedHeaderExtension : supportedHeaderExtensions)
{ {
if ( if (
headerExtension.uri == supportedHeaderExtension.uri && headerExtension.type == supportedHeaderExtension.type &&
( (
headerExtension.kind == supportedHeaderExtension.kind || headerExtension.kind == supportedHeaderExtension.kind ||
supportedHeaderExtension.kind == RTC::Media::Kind::ALL supportedHeaderExtension.kind == RTC::Media::Kind::ALL
......
...@@ -38,6 +38,9 @@ namespace RTC ...@@ -38,6 +38,9 @@ namespace RTC
if (this->uri.empty()) if (this->uri.empty())
MS_THROW_ERROR("empty RtpHeaderExtension.uri"); MS_THROW_ERROR("empty RtpHeaderExtension.uri");
// Get the type.
this->type = RTC::RtpHeaderExtensionUri::GetType(this->uri);
// `preferredId` is mandatory. // `preferredId` is mandatory.
if (!data[k_preferredId].isUInt()) if (!data[k_preferredId].isUInt())
MS_THROW_ERROR("missing RtpHeaderExtension.preferredId"); MS_THROW_ERROR("missing RtpHeaderExtension.preferredId");
......
...@@ -29,6 +29,9 @@ namespace RTC ...@@ -29,6 +29,9 @@ namespace RTC
if (this->uri.empty()) if (this->uri.empty())
MS_THROW_ERROR("empty RtpHeaderExtensionParameters.uri"); MS_THROW_ERROR("empty RtpHeaderExtensionParameters.uri");
// Get the type.
this->type = RTC::RtpHeaderExtensionUri::GetType(this->uri);
// `id` is mandatory. // `id` is mandatory.
if (!data[k_id].isUInt()) if (!data[k_id].isUInt())
MS_THROW_ERROR("missing RtpHeaderExtensionParameters.id"); MS_THROW_ERROR("missing RtpHeaderExtensionParameters.id");
......
#define MS_CLASS "RTC::RtpHeaderExtensionUri"
// #define MS_LOG_DEV
#include "RTC/RtpDictionaries.hpp"
#include "Utils.hpp"
#include "Logger.hpp"
namespace RTC
{
/* Class variables. */
std::unordered_map<std::string, RtpHeaderExtensionUri::Type> RtpHeaderExtensionUri::string2Type =
{
{ "urn:ietf:params:rtp-hdrext:ssrc-audio-level", RtpHeaderExtensionUri::Type::SSRC_AUDIO_LEVEL },
{ "urn:ietf:params:rtp-hdrext:toffset", RtpHeaderExtensionUri::Type::TO_OFFSET },
{ "http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time", RtpHeaderExtensionUri::Type::ABS_SEND_TIME },
{ "urn:3gpp:video-orientation", RtpHeaderExtensionUri::Type::VIDEO_ORIENTATION },
{ "urn:ietf:params:rtp-hdrext:sdes:rtp-stream-id", RtpHeaderExtensionUri::Type::RTP_STREAM_ID }
};
/* Class methods. */
RtpHeaderExtensionUri::Type RtpHeaderExtensionUri::GetType(std::string& uri)
{
MS_TRACE();
// Force lowcase names.
Utils::String::ToLowerCase(uri);
auto it = RtpHeaderExtensionUri::string2Type.find(uri);
if (it != RtpHeaderExtensionUri::string2Type.end())
return it->second;
else
return RtpHeaderExtensionUri::Type::UNKNOWN;
}
}
...@@ -71,7 +71,8 @@ namespace RTC ...@@ -71,7 +71,8 @@ namespace RTC
{ {
RTC::RtpHeaderExtensionParameters headerExtension(json_array[i]); RTC::RtpHeaderExtensionParameters headerExtension(json_array[i]);
// Append to the headerExtensions vector. // If a known header extension, append to the headerExtensions vector.
if (headerExtension.type != RtpHeaderExtensionUri::Type::UNKNOWN)
this->headerExtensions.push_back(headerExtension); this->headerExtensions.push_back(headerExtension);
} }
} }
...@@ -230,7 +231,7 @@ namespace RTC ...@@ -230,7 +231,7 @@ namespace RTC
{ {
for (auto& supportedHeaderExtension : supportedHeaderExtensions) for (auto& supportedHeaderExtension : supportedHeaderExtensions)
{ {
if (headerExtension.uri == supportedHeaderExtension.uri) if (headerExtension.type == supportedHeaderExtension.type)
{ {
// Set the same id and other properties. // Set the same id and other properties.
headerExtension.id = supportedHeaderExtension.preferredId; headerExtension.id = supportedHeaderExtension.preferredId;
......
Markdown 格式
0% 或
您添加了 0 人 到此讨论。请谨慎行事。
请先完成此评论的编辑!
请 注册 或者 后发表评论