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

Refactor: avoid passing JSON data to Transport/Producer/Consumer instance…

Refactor: avoid passing JSON data to Transport/Producer/Consumer instance methods (work in progress).
上级 5347ea26
# BUGS in mediasoup v2 (server-side)
* PeerA is joined. Later PeerB joins with audio+video. PeerA does not render the video from PeerB (note: we are not relaying PLI yet, but it should work).
- To reproduce it,: Have to peers in the room (sending video) and restart the server.
- Suspecting logs:
```
mediasoup:WARN:mediasoup-worker [id:bnicjuxw#1] RTC::Transport::HandleConsumer() | requesting fullframe for new Consumer since Transport already connected +20s
mediasoup-demo-server:INFO:Room mediaPeer "newconsumer" event [id:50465828] +31ms
mediasoup-demo-server:INFO:Room mediaPeer "newproducer" event [id:91290656] +0ms
mediasoup-demo-server:INFO:Room mediaPeer "newconsumer" event [id:13942695] +179ms
mediasoup-demo-server:INFO:Room mediaPeer "newproducer" event [id:24688710] +1ms
mediasoup:WARN:mediasoup-worker [id:bnicjuxw#1] RTC::Transport::HandleConsumer() | requesting fullframe for new Consumer since Transport already connected +365ms
mediasoup:WARN:mediasoup-worker [id:bnicjuxw#1] RTC::RtpStreamSend::StorePacket() | ignoring packet older than anything in the buffer [ssrc:1815865740, seq:18175] +7ms
mediasoup:WARN:mediasoup-worker [id:bnicjuxw#1] RTC::RtpStreamSend::StorePacket() | ignoring packet older than anything in the buffer [ssrc:1815865740, seq:18175] +10ms
```
# TODO in mediasoup v2 (server-side) # TODO in mediasoup v2 (server-side)
* Must avoid passing JSON data to Transport/Producer/Consumer instance methods. Instead, create API methods that receive "nice" C++ params and do all the JSON decode work in `Router::HandleRequest()`.
* Must mangle RTP sequence numbers in Consumers: * Must mangle RTP sequence numbers in Consumers:
- After paused. - After paused.
- After the Producer gets `updateRtpParameters()` called (so a `OnProducerRtpParametersUpdated` listener is required in Producer for the Router to call `SourceRtpParametersUpdated()` on all its Concumers). - After the Producer gets `updateRtpParameters()` called (so a `OnProducerRtpParametersUpdated` listener is required in Producer for the Router to call `SourceRtpParametersUpdated()` on all its Concumers).
- NOTE: We may also need to mangle RTP timestamps!
* After `updateProducer` (which changes receiving SSRCs), should we do something in Transport between `producer->ReceiveRtpPacket(packet)` and `this->remoteBitrateEstimator->IncomingPacket`? * After `updateProducer` (which changes receiving SSRCs), should we do something in Transport between `producer->ReceiveRtpPacket(packet)` and `this->remoteBitrateEstimator->IncomingPacket`?
......
...@@ -49,7 +49,7 @@ namespace RTC ...@@ -49,7 +49,7 @@ namespace RTC
public: public:
struct Fingerprint struct Fingerprint
{ {
FingerprintAlgorithm algorithm; FingerprintAlgorithm algorithm{ FingerprintAlgorithm::NONE };
std::string value; std::string value;
}; };
...@@ -166,7 +166,7 @@ namespace RTC ...@@ -166,7 +166,7 @@ namespace RTC
// Others. // Others.
DtlsState state{ DtlsState::NEW }; DtlsState state{ DtlsState::NEW };
Role localRole{ Role::NONE }; Role localRole{ Role::NONE };
Fingerprint remoteFingerprint{ FingerprintAlgorithm::NONE, "" }; Fingerprint remoteFingerprint;
bool handshakeDone{ false }; bool handshakeDone{ false };
bool handshakeDoneNow{ false }; bool handshakeDoneNow{ false };
std::string remoteCert; std::string remoteCert;
......
...@@ -50,7 +50,18 @@ namespace RTC ...@@ -50,7 +50,18 @@ namespace RTC
}; };
public: public:
Transport(Listener* listener, Channel::Notifier* notifier, uint32_t transportId, Json::Value& data); struct TransportOptions
{
bool udp{ true };
bool tcp{ true };
bool preferIPv4{ true };
bool preferIPv6{ true };
bool preferUdp{ true };
bool preferTcp{ true };
};
public:
Transport(Listener* listener, Channel::Notifier* notifier, uint32_t transportId, TransportOptions& options);
private: private:
~Transport() override; ~Transport() override;
...@@ -61,6 +72,10 @@ namespace RTC ...@@ -61,6 +72,10 @@ namespace RTC
void HandleRequest(Channel::Request* request); void HandleRequest(Channel::Request* request);
void HandleProducer(RTC::Producer* producer); void HandleProducer(RTC::Producer* producer);
void HandleConsumer(RTC::Consumer* consumer); void HandleConsumer(RTC::Consumer* consumer);
RTC::DtlsTransport::Role setRemoteDtlsParameters(
RTC::DtlsTransport::Fingerprint& fingerprint, RTC::DtlsTransport::Role role);
void SetMaxBitrate(uint32_t bitrate);
void ChangeUfragPwd(std::string& usernameFragment, std::string& password);
void SendRtpPacket(RTC::RtpPacket* packet); void SendRtpPacket(RTC::RtpPacket* packet);
void SendRtcpPacket(RTC::RTCP::Packet* packet); void SendRtcpPacket(RTC::RTCP::Packet* packet);
void SendRtcpCompoundPacket(RTC::RTCP::CompoundPacket* packet); void SendRtcpCompoundPacket(RTC::RTCP::CompoundPacket* packet);
......
...@@ -173,6 +173,13 @@ namespace RTC ...@@ -173,6 +173,13 @@ namespace RTC
case Channel::Request::MethodId::ROUTER_CREATE_TRANSPORT: case Channel::Request::MethodId::ROUTER_CREATE_TRANSPORT:
{ {
static const Json::StaticString JsonStringUdp{ "udp" };
static const Json::StaticString JsonStringTcp{ "tcp" };
static const Json::StaticString JsonStringPreferIPv4{ "preferIPv4" };
static const Json::StaticString JsonStringPreferIPv6{ "preferIPv6" };
static const Json::StaticString JsonStringPreferUdp{ "preferUdp" };
static const Json::StaticString JsonStringPreferTcp{ "preferTcp" };
RTC::Transport* transport; RTC::Transport* transport;
uint32_t transportId; uint32_t transportId;
...@@ -194,9 +201,24 @@ namespace RTC ...@@ -194,9 +201,24 @@ namespace RTC
return; return;
} }
RTC::Transport::TransportOptions options;
if (request->data[JsonStringUdp].isBool())
options.udp = request->data[JsonStringUdp].asBool();
if (request->data[JsonStringTcp].isBool())
options.tcp = request->data[JsonStringTcp].asBool();
if (request->data[JsonStringPreferIPv4].isBool())
options.preferIPv4 = request->data[JsonStringPreferIPv4].asBool();
if (request->data[JsonStringPreferIPv6].isBool())
options.preferIPv6 = request->data[JsonStringPreferIPv6].asBool();
if (request->data[JsonStringPreferUdp].isBool())
options.preferUdp = request->data[JsonStringPreferUdp].asBool();
if (request->data[JsonStringPreferTcp].isBool())
options.preferTcp = request->data[JsonStringPreferTcp].asBool();
try try
{ {
transport = new RTC::Transport(this, this->notifier, transportId, request->data); transport = new RTC::Transport(this, this->notifier, transportId, options);
} }
catch (const MediaSoupError& error) catch (const MediaSoupError& error)
{ {
...@@ -538,9 +560,164 @@ namespace RTC ...@@ -538,9 +560,164 @@ namespace RTC
case Channel::Request::MethodId::TRANSPORT_DUMP: case Channel::Request::MethodId::TRANSPORT_DUMP:
case Channel::Request::MethodId::TRANSPORT_SET_REMOTE_DTLS_PARAMETERS: case Channel::Request::MethodId::TRANSPORT_SET_REMOTE_DTLS_PARAMETERS:
{
static const Json::StaticString JsonStringRole{ "role" };
static const Json::StaticString JsonStringClient{ "client" };
static const Json::StaticString JsonStringServer{ "server" };
static const Json::StaticString JsonStringFingerprints{ "fingerprints" };
static const Json::StaticString JsonStringAlgorithm{ "algorithm" };
static const Json::StaticString JsonStringValue{ "value" };
RTC::Transport* transport;
try
{
transport = GetTransportFromRequest(request);
}
catch (const MediaSoupError& error)
{
request->Reject(error.what());
return;
}
if (transport == nullptr)
{
request->Reject("Transport does not exist");
return;
}
if (!request->data[JsonStringFingerprints].isArray())
{
request->Reject("missing data.fingerprints");
return;
}
RTC::DtlsTransport::Fingerprint remoteFingerprint;
// Default value if missing.
RTC::DtlsTransport::Role remoteRole{ RTC::DtlsTransport::Role::AUTO };
auto& jsonArray = request->data[JsonStringFingerprints];
for (Json::Value::ArrayIndex i = jsonArray.size() - 1; static_cast<int32_t>(i) >= 0; --i)
{
auto& jsonFingerprint = jsonArray[i];
if (!jsonFingerprint.isObject())
{
request->Reject("wrong fingerprint");
return;
}
if (!jsonFingerprint[JsonStringAlgorithm].isString() || !jsonFingerprint[JsonStringValue].isString())
{
request->Reject("missing data.fingerprint.algorithm and/or data.fingerprint.value");
return;
}
remoteFingerprint.algorithm = RTC::DtlsTransport::GetFingerprintAlgorithm(jsonFingerprint[JsonStringAlgorithm].asString());
if (remoteFingerprint.algorithm != RTC::DtlsTransport::FingerprintAlgorithm::NONE)
{
remoteFingerprint.value = jsonFingerprint[JsonStringValue].asString();
break;
}
}
if (request->data[JsonStringRole].isString())
remoteRole = RTC::DtlsTransport::StringToRole(request->data[JsonStringRole].asString());
RTC::DtlsTransport::Role localRole;
try
{
// This may throw.
localRole = transport->setRemoteDtlsParameters(
remoteFingerprint, remoteRole);
}
catch (const MediaSoupError& error)
{
request->Reject(error.what());
return;
}
Json::Value data(Json::objectValue);
switch (localRole)
{
case RTC::DtlsTransport::Role::CLIENT:
{
data[JsonStringRole] = JsonStringClient;
break;
}
case RTC::DtlsTransport::Role::SERVER:
{
data[JsonStringRole] = JsonStringServer;
break;
}
default:
{
MS_ABORT("invalid local DTLS role");
}
}
request->Accept(data);
break;
}
case Channel::Request::MethodId::TRANSPORT_SET_MAX_BITRATE: case Channel::Request::MethodId::TRANSPORT_SET_MAX_BITRATE:
{
static const Json::StaticString JsonStringBitrate{ "bitrate" };
RTC::Transport* transport;
try
{
transport = GetTransportFromRequest(request);
}
catch (const MediaSoupError& error)
{
request->Reject(error.what());
return;
}
if (transport == nullptr)
{
request->Reject("Transport does not exist");
return;
}
if (!request->data[JsonStringBitrate].isUInt())
{
request->Reject("missing data.bitrate");
return;
}
auto bitrate = uint32_t{ request->data[JsonStringBitrate].asUInt() };
transport->SetMaxBitrate(bitrate);
request->Accept();
break;
}
case Channel::Request::MethodId::TRANSPORT_CHANGE_UFRAG_PWD: case Channel::Request::MethodId::TRANSPORT_CHANGE_UFRAG_PWD:
{ {
static const Json::StaticString JsonStringUsernameFragment{ "usernameFragment" };
static const Json::StaticString JsonStringPassword{ "password" };
RTC::Transport* transport; RTC::Transport* transport;
try try
...@@ -561,7 +738,17 @@ namespace RTC ...@@ -561,7 +738,17 @@ namespace RTC
return; return;
} }
transport->HandleRequest(request); std::string usernameFragment = Utils::Crypto::GetRandomString(16);
std::string password = Utils::Crypto::GetRandomString(32);
transport->ChangeUfragPwd(usernameFragment, password);
Json::Value data(Json::objectValue);
data[JsonStringUsernameFragment] = usernameFragment;
data[JsonStringPassword] = password;
request->Accept(data);
break; break;
} }
......
...@@ -44,42 +44,15 @@ namespace RTC ...@@ -44,42 +44,15 @@ namespace RTC
/* Instance methods. */ /* Instance methods. */
Transport::Transport( Transport::Transport(
Listener* listener, Channel::Notifier* notifier, uint32_t transportId, Json::Value& data) Listener* listener, Channel::Notifier* notifier, uint32_t transportId, TransportOptions& options)
: transportId(transportId), listener(listener), notifier(notifier) : transportId(transportId), listener(listener), notifier(notifier)
{ {
MS_TRACE(); MS_TRACE();
static const Json::StaticString JsonStringUdp{ "udp" }; bool tryIPv4udp{ options.udp };
static const Json::StaticString JsonStringTcp{ "tcp" }; bool tryIPv6udp{ options.udp };
static const Json::StaticString JsonStringPreferIPv4{ "preferIPv4" }; bool tryIPv4tcp{ options.tcp };
static const Json::StaticString JsonStringPreferIPv6{ "preferIPv6" }; bool tryIPv6tcp{ options.tcp };
static const Json::StaticString JsonStringPreferUdp{ "preferUdp" };
static const Json::StaticString JsonStringPreferTcp{ "preferTcp" };
bool tryIPv4udp{ true };
bool tryIPv6udp{ true };
bool tryIPv4tcp{ true };
bool tryIPv6tcp{ true };
bool preferIPv4{ false };
bool preferIPv6{ false };
bool preferUdp{ false };
bool preferTcp{ false };
if (data[JsonStringUdp].isBool())
tryIPv4udp = tryIPv6udp = data[JsonStringUdp].asBool();
if (data[JsonStringTcp].isBool())
tryIPv4tcp = tryIPv6tcp = data[JsonStringTcp].asBool();
if (data[JsonStringPreferIPv4].isBool())
preferIPv4 = data[JsonStringPreferIPv4].asBool();
if (data[JsonStringPreferIPv6].isBool())
preferIPv6 = data[JsonStringPreferIPv6].asBool();
if (data[JsonStringPreferUdp].isBool())
preferUdp = data[JsonStringPreferUdp].asBool();
if (data[JsonStringPreferTcp].isBool())
preferTcp = data[JsonStringPreferTcp].asBool();
// Create a ICE server. // Create a ICE server.
this->iceServer = new RTC::IceServer( this->iceServer = new RTC::IceServer(
...@@ -90,9 +63,9 @@ namespace RTC ...@@ -90,9 +63,9 @@ namespace RTC
{ {
uint16_t localPreference = IceCandidateDefaultLocalPriority; uint16_t localPreference = IceCandidateDefaultLocalPriority;
if (preferIPv4) if (options.preferIPv4)
localPreference += IceCandidateLocalPriorityPreferFamilyIncrement; localPreference += IceCandidateLocalPriorityPreferFamilyIncrement;
if (preferUdp) if (options.preferUdp)
localPreference += IceCandidateLocalPriorityPreferProtocolIncrement; localPreference += IceCandidateLocalPriorityPreferProtocolIncrement;
uint32_t priority = generateIceCandidatePriority(localPreference); uint32_t priority = generateIceCandidatePriority(localPreference);
...@@ -116,9 +89,9 @@ namespace RTC ...@@ -116,9 +89,9 @@ namespace RTC
{ {
uint16_t localPreference = IceCandidateDefaultLocalPriority; uint16_t localPreference = IceCandidateDefaultLocalPriority;
if (preferIPv6) if (options.preferIPv6)
localPreference += IceCandidateLocalPriorityPreferFamilyIncrement; localPreference += IceCandidateLocalPriorityPreferFamilyIncrement;
if (preferUdp) if (options.preferUdp)
localPreference += IceCandidateLocalPriorityPreferProtocolIncrement; localPreference += IceCandidateLocalPriorityPreferProtocolIncrement;
uint32_t priority = generateIceCandidatePriority(localPreference); uint32_t priority = generateIceCandidatePriority(localPreference);
...@@ -142,9 +115,9 @@ namespace RTC ...@@ -142,9 +115,9 @@ namespace RTC
{ {
uint16_t localPreference = IceCandidateDefaultLocalPriority; uint16_t localPreference = IceCandidateDefaultLocalPriority;
if (preferIPv4) if (options.preferIPv4)
localPreference += IceCandidateLocalPriorityPreferFamilyIncrement; localPreference += IceCandidateLocalPriorityPreferFamilyIncrement;
if (preferTcp) if (options.preferTcp)
localPreference += IceCandidateLocalPriorityPreferProtocolIncrement; localPreference += IceCandidateLocalPriorityPreferProtocolIncrement;
uint32_t priority = generateIceCandidatePriority(localPreference); uint32_t priority = generateIceCandidatePriority(localPreference);
...@@ -168,9 +141,9 @@ namespace RTC ...@@ -168,9 +141,9 @@ namespace RTC
{ {
uint16_t localPreference = IceCandidateDefaultLocalPriority; uint16_t localPreference = IceCandidateDefaultLocalPriority;
if (preferIPv6) if (options.preferIPv6)
localPreference += IceCandidateLocalPriorityPreferFamilyIncrement; localPreference += IceCandidateLocalPriorityPreferFamilyIncrement;
if (preferTcp) if (options.preferTcp)
localPreference += IceCandidateLocalPriorityPreferProtocolIncrement; localPreference += IceCandidateLocalPriorityPreferProtocolIncrement;
uint32_t priority = generateIceCandidatePriority(localPreference); uint32_t priority = generateIceCandidatePriority(localPreference);
...@@ -417,138 +390,108 @@ namespace RTC ...@@ -417,138 +390,108 @@ namespace RTC
break; break;
} }
case Channel::Request::MethodId::TRANSPORT_SET_REMOTE_DTLS_PARAMETERS: default:
{
static const Json::StaticString JsonStringRole{ "role" };
static const Json::StaticString JsonStringClient{ "client" };
static const Json::StaticString JsonStringServer{ "server" };
static const Json::StaticString JsonStringFingerprints{ "fingerprints" };
static const Json::StaticString JsonStringAlgorithm{ "algorithm" };
static const Json::StaticString JsonStringValue{ "value" };
RTC::DtlsTransport::Fingerprint remoteFingerprint;
RTC::DtlsTransport::Role remoteRole =
RTC::DtlsTransport::Role::AUTO; // Default value if missing.
// Just in case.
remoteFingerprint.algorithm = RTC::DtlsTransport::FingerprintAlgorithm::NONE;
// Ensure this method is not called twice.
if (this->hasRemoteDtlsParameters)
{ {
request->Reject("Transport already has remote DTLS parameters"); MS_ERROR("unknown method");
return; request->Reject("unknown method");
}
} }
this->hasRemoteDtlsParameters = true;
if (!request->data[JsonStringFingerprints].isArray())
{
request->Reject("missing data.fingerprints");
return;
} }
auto& jsonArray = request->data[JsonStringFingerprints]; void Transport::HandleProducer(RTC::Producer* producer)
for (Json::Value::ArrayIndex i = jsonArray.size() - 1; static_cast<int32_t>(i) >= 0; --i)
{ {
auto& jsonFingerprint = jsonArray[i]; MS_TRACE();
if (!jsonFingerprint.isObject()) // Add to the map.
{ this->producers.insert(producer);
request->Reject("wrong fingerprint");
return; // Pass it to the RtpListener.
} this->rtpListener.AddProducer(producer);
if (!jsonFingerprint[JsonStringAlgorithm].isString() || !jsonFingerprint[JsonStringValue].isString())
{
request->Reject("missing data.fingerprint.algorithm and/or data.fingerprint.value");
return; // Add us as listener.
producer->AddListener(this);
} }
auto algorithm = jsonFingerprint[JsonStringAlgorithm].asString(); void Transport::HandleConsumer(RTC::Consumer* consumer)
{
MS_TRACE();
// Add to the map.
this->consumers.insert(consumer);
remoteFingerprint.algorithm = RTC::DtlsTransport::GetFingerprintAlgorithm(algorithm); // Add us as listener.
consumer->AddListener(this);
if (remoteFingerprint.algorithm != RTC::DtlsTransport::FingerprintAlgorithm::NONE) // If we are connected, ask a fullrequest for this enabled Consumer.
if (IsConnected())
{
if (consumer->kind == RTC::Media::Kind::VIDEO)
{ {
remoteFingerprint.value = jsonFingerprint[JsonStringValue].asString(); MS_DEBUG_TAG(
rtcp, "requesting full frame for new Consumer since Transport already connected");
}
break; consumer->RequestFullFrame();
} }
} }
if (remoteFingerprint.algorithm == RTC::DtlsTransport::FingerprintAlgorithm::NONE) RTC::DtlsTransport::Role Transport::setRemoteDtlsParameters(
RTC::DtlsTransport::Fingerprint& fingerprint, RTC::DtlsTransport::Role role)
{ {
request->Reject("unsupported data.fingerprint.algorithm"); MS_TRACE();
return; // Ensure this method is not called twice.
} if (this->hasRemoteDtlsParameters)
MS_THROW_ERROR("Transport already has remote DTLS parameters");
if (request->data[JsonStringRole].isString()) if (fingerprint.algorithm == RTC::DtlsTransport::FingerprintAlgorithm::NONE)
remoteRole = RTC::DtlsTransport::StringToRole(request->data[JsonStringRole].asString()); MS_THROW_ERROR("unsupported remote fingerprint algorithm");
// Set local DTLS role. // Set local DTLS role.
switch (remoteRole) switch (role)
{ {
case RTC::DtlsTransport::Role::CLIENT: case RTC::DtlsTransport::Role::CLIENT:
{
this->dtlsLocalRole = RTC::DtlsTransport::Role::SERVER; this->dtlsLocalRole = RTC::DtlsTransport::Role::SERVER;
break; break;
}
case RTC::DtlsTransport::Role::SERVER: case RTC::DtlsTransport::Role::SERVER:
{
this->dtlsLocalRole = RTC::DtlsTransport::Role::CLIENT; this->dtlsLocalRole = RTC::DtlsTransport::Role::CLIENT;
break; break;
}
// If the peer has "auto" we become "client" since we are ICE controlled. // If the peer has "auto" we become "client" since we are ICE controlled.
case RTC::DtlsTransport::Role::AUTO: case RTC::DtlsTransport::Role::AUTO:
{
this->dtlsLocalRole = RTC::DtlsTransport::Role::CLIENT; this->dtlsLocalRole = RTC::DtlsTransport::Role::CLIENT;
break; break;
case RTC::DtlsTransport::Role::NONE:
request->Reject("invalid data.role");
return;
} }
case RTC::DtlsTransport::Role::NONE:
Json::Value data(Json::objectValue);
switch (this->dtlsLocalRole)
{ {
case RTC::DtlsTransport::Role::CLIENT: MS_THROW_ERROR("invalid remote role");
data[JsonStringRole] = JsonStringClient; }
break;
case RTC::DtlsTransport::Role::SERVER:
data[JsonStringRole] = JsonStringServer;
break;
default:
MS_ABORT("invalid local DTLS role");
} }
request->Accept(data); this->hasRemoteDtlsParameters = true;
// Pass the remote fingerprint to the DTLS transport. // Pass the remote fingerprint to the DTLS transport.
this->dtlsTransport->SetRemoteFingerprint(remoteFingerprint); this->dtlsTransport->SetRemoteFingerprint(fingerprint);
// Run the DTLS transport if ready. // Run the DTLS transport if ready.
MayRunDtlsTransport(); MayRunDtlsTransport();
break; return this->dtlsLocalRole;
} }
case Channel::Request::MethodId::TRANSPORT_SET_MAX_BITRATE: void Transport::SetMaxBitrate(uint32_t bitrate)
{
static const Json::StaticString JsonStringBitrate{ "bitrate" };
static constexpr uint32_t MinBitrate{ 10000 };
// Validate request data.
if (!request->data[JsonStringBitrate].isUInt())
{ {
request->Reject("missing data.bitrate"); MS_TRACE();
return;
}
auto bitrate = uint32_t{ request->data[JsonStringBitrate].asUInt() }; static constexpr uint32_t MinBitrate{ 10000 };
if (bitrate < MinBitrate) if (bitrate < MinBitrate)
bitrate = MinBitrate; bitrate = MinBitrate;
...@@ -556,77 +499,14 @@ namespace RTC ...@@ -556,77 +499,14 @@ namespace RTC
this->maxBitrate = bitrate; this->maxBitrate = bitrate;
MS_DEBUG_TAG(rbe, "transport max bitrate set to %" PRIu32 "bps", this->maxBitrate); MS_DEBUG_TAG(rbe, "transport max bitrate set to %" PRIu32 "bps", this->maxBitrate);
request->Accept();
break;
} }
case Channel::Request::MethodId::TRANSPORT_CHANGE_UFRAG_PWD: void Transport::ChangeUfragPwd(std::string& usernameFragment, std::string& password)
{ {
static const Json::StaticString JsonStringUsernameFragment{ "usernameFragment" }; MS_TRACE();
static const Json::StaticString JsonStringPassword{ "password" };
std::string usernameFragment = Utils::Crypto::GetRandomString(16);
std::string password = Utils::Crypto::GetRandomString(32);
this->iceServer->SetUsernameFragment(usernameFragment); this->iceServer->SetUsernameFragment(usernameFragment);
this->iceServer->SetPassword(password); this->iceServer->SetPassword(password);
Json::Value data(Json::objectValue);
data[JsonStringUsernameFragment] = this->iceServer->GetUsernameFragment();
data[JsonStringPassword] = this->iceServer->GetPassword();
request->Accept(data);
break;
}
default:
{
MS_ERROR("unknown method");
request->Reject("unknown method");
}
}
}
void Transport::HandleProducer(RTC::Producer* producer)
{
MS_TRACE();
// Add to the map.
this->producers.insert(producer);
// Pass it to the RtpListener.
this->rtpListener.AddProducer(producer);
// Add us as listener.
producer->AddListener(this);
}
void Transport::HandleConsumer(RTC::Consumer* consumer)
{
MS_TRACE();
// Add to the map.
this->consumers.insert(consumer);
// Add us as listener.
consumer->AddListener(this);
// If we are connected, ask a fullrequest for this enabled Consumer.
if (IsConnected())
{
if (consumer->kind == RTC::Media::Kind::VIDEO)
{
MS_DEBUG_TAG(
rtcp, "requesting full frame for new Consumer since Transport already connected");
}
consumer->RequestFullFrame();
}
} }
void Transport::SendRtpPacket(RTC::RtpPacket* packet) void Transport::SendRtpPacket(RTC::RtpPacket* packet)
......
Markdown 格式
0% 或
您添加了 0 人 到此讨论。请谨慎行事。
请先完成此评论的编辑!
请 注册 或者 后发表评论