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

WebRTC PlanB: Allow renegotiation from clients

上级 cbf71235
...@@ -53,7 +53,7 @@ gulp.task('test:api', shell.task( ...@@ -53,7 +53,7 @@ gulp.task('test:api', shell.task(
], ],
{ {
verbose : true, verbose : true,
env : { DEBUG: '*ABORT*' } env : { DEBUG: '*ABORT* *WARN*' }
} }
)); ));
......
...@@ -236,7 +236,7 @@ class Server extends EventEmitter ...@@ -236,7 +236,7 @@ class Server extends EventEmitter
this.emit('newroom', room); this.emit('newroom', room);
return room; return room;
}) });
} }
_addWorker(worker) _addWorker(worker)
......
...@@ -339,7 +339,32 @@ class RTCPeerConnectionCommon extends EventEmitter ...@@ -339,7 +339,32 @@ class RTCPeerConnectionCommon extends EventEmitter
// Re-offer received from the client. // Re-offer received from the client.
else else
{ {
return this._handleRemoteReOffer(remoteDescription); // Set busy flag.
this._busy = true;
return this._handleRemoteReOffer(remoteDescription)
.then(() =>
{
this._logger.debug('setRemoteDescription() | succeed');
// Unset busy flag.
this._busy = false;
// Set remote description.
this._remoteDescription = remoteDescription;
// Update signaling state.
this._setSignalingState('have-remote-offer');
})
.catch((error) =>
{
this._logger.error('setRemoteDescription() | failed: %s', error);
// Unset busy flag.
this._busy = false;
throw error;
});
} }
} }
......
...@@ -61,7 +61,7 @@ module.exports = ...@@ -61,7 +61,7 @@ module.exports =
{ {
kind : 'audio', kind : 'audio',
name : 'audio/opus', name : 'audio/opus',
payloadType : 96, payloadType : 100,
clockRate : 48000, clockRate : 48000,
numChannels : 2 numChannels : 2
}, },
...@@ -74,23 +74,23 @@ module.exports = ...@@ -74,23 +74,23 @@ module.exports =
{ {
kind : 'video', kind : 'video',
name : 'video/VP8', name : 'video/VP8',
payloadType : 97, payloadType : 110,
clockRate : 90000 clockRate : 90000
}, },
{ {
kind : 'video', kind : 'video',
name : 'video/rtx', name : 'video/rtx',
payloadType : 100, payloadType : 97,
clockRate : 90000, clockRate : 90000,
parameters : parameters :
{ {
apt : 97 apt : 110
} }
}, },
{ {
kind : 'video', kind : 'video',
name : 'video/H264', name : 'video/H264',
payloadType : 98, payloadType : 111,
clockRate : 90000, clockRate : 90000,
parameters : parameters :
{ {
...@@ -100,17 +100,17 @@ module.exports = ...@@ -100,17 +100,17 @@ module.exports =
{ {
kind : 'video', kind : 'video',
name : 'video/rtx', name : 'video/rtx',
payloadType : 101, payloadType : 98,
clockRate : 90000, clockRate : 90000,
parameters : parameters :
{ {
apt : 98 apt : 111
} }
}, },
{ {
kind : 'video', kind : 'video',
name : 'video/H264', name : 'video/H264',
payloadType : 99, payloadType : 112,
clockRate : 90000, clockRate : 90000,
parameters : parameters :
{ {
...@@ -120,11 +120,11 @@ module.exports = ...@@ -120,11 +120,11 @@ module.exports =
{ {
kind : 'video', kind : 'video',
name : 'video/rtx', name : 'video/rtx',
payloadType : 102, payloadType : 99,
clockRate : 90000, clockRate : 90000,
parameters : parameters :
{ {
apt : 99 apt : 112
} }
} }
] ]
......
...@@ -280,6 +280,7 @@ namespace RTC ...@@ -280,6 +280,7 @@ namespace RTC
explicit RtpParameters(const RtpParameters* RtpParameters); explicit RtpParameters(const RtpParameters* RtpParameters);
Json::Value toJson(); Json::Value toJson();
void ReduceCodecsAndEncodings(RtpCapabilities& capabilities);
void ReduceHeaderExtensions(std::vector<RtpHeaderExtension>& supportedHeaderExtensions); void ReduceHeaderExtensions(std::vector<RtpHeaderExtension>& supportedHeaderExtensions);
uint32_t GetClockRateForEncoding(size_t encodingIdx); uint32_t GetClockRateForEncoding(size_t encodingIdx);
......
#define MS_CLASS "DepLibUV" #define MS_CLASS "DepLibUV"
// #define MS_LOG_DEV #define MS_LOG_DEV
#include "DepLibUV.h" #include "DepLibUV.h"
#include "Logger.h" #include "Logger.h"
...@@ -63,7 +63,7 @@ uint64_t DepLibUV::GetTime() ...@@ -63,7 +63,7 @@ uint64_t DepLibUV::GetTime()
static uint32_t maxTimeCounter = 32768; static uint32_t maxTimeCounter = 32768;
// TODO: Remove. // TODO: Remove.
if (DepLibUV::timeUpdateCounter == 0) if (DepLibUV::timeUpdateCounter == 0 && LAST_NOW != 0)
MS_DEBUG_DEV("now - LAST_NOW: %" PRIu64 "ms", uv_now(DepLibUV::loop) - LAST_NOW); MS_DEBUG_DEV("now - LAST_NOW: %" PRIu64 "ms", uv_now(DepLibUV::loop) - LAST_NOW);
// Update the libuv's concept of “now” every N usages. // Update the libuv's concept of “now” every N usages.
......
...@@ -684,29 +684,8 @@ namespace RTC ...@@ -684,29 +684,8 @@ namespace RTC
auto rtpParameters = rtpReceiver->GetParameters(); auto rtpParameters = rtpReceiver->GetParameters();
// Given codecs must be a subset of the capability codecs of the peer. // Remove unsupported codecs and their associated encodings.
for (auto& codec : rtpParameters->codecs) rtpParameters->ReduceCodecsAndEncodings(this->capabilities);
{
auto it = this->capabilities.codecs.begin();
for (; it != this->capabilities.codecs.end(); ++it)
{
auto& codecCapability = *it;
if (codecCapability.Matches(codec, true))
{
// Once matched, remove the unsupported RTCP feedback from the given codec.
codec.ReduceRtcpFeedback(codecCapability.rtcpFeedback);
break;
}
}
if (it == this->capabilities.codecs.end())
{
MS_THROW_ERROR("no matching peer codec capability found [payloadType:%" PRIu8 ", mime:%s]",
codec.payloadType, codec.mime.GetName().c_str());
}
}
// Remove unsupported header extensions. // Remove unsupported header extensions.
rtpParameters->ReduceHeaderExtensions(this->capabilities.headerExtensions); rtpParameters->ReduceHeaderExtensions(this->capabilities.headerExtensions);
......
...@@ -90,7 +90,6 @@ namespace RTC ...@@ -90,7 +90,6 @@ namespace RTC
this->userParameters = Json::objectValue; this->userParameters = Json::objectValue;
// Validate RTP parameters. // Validate RTP parameters.
ValidateCodecs(); ValidateCodecs();
ValidateEncodings(); ValidateEncodings();
} }
...@@ -158,6 +157,69 @@ namespace RTC ...@@ -158,6 +157,69 @@ namespace RTC
return json; return json;
} }
void RtpParameters::ReduceCodecsAndEncodings(RtpCapabilities& capabilities)
{
MS_TRACE();
std::vector<uint8_t> removedCodecPayloadTypes;
for (auto it = this->codecs.begin(); it != this->codecs.end();)
{
auto& codec = *it;
auto it2 = capabilities.codecs.begin();
for (; it2 != capabilities.codecs.end(); ++it2)
{
auto& codecCapability = *it2;
if (codecCapability.Matches(codec, true))
{
// Once matched, remove the unsupported RTCP feedback from the given codec.
codec.ReduceRtcpFeedback(codecCapability.rtcpFeedback);
++it;
break;
}
}
if (it2 == capabilities.codecs.end())
{
MS_WARN_DEV("no matching peer codec capability found [payloadType:%" PRIu8 ", mime:%s]",
codec.payloadType, codec.mime.GetName().c_str());
removedCodecPayloadTypes.push_back(codec.payloadType);
it = this->codecs.erase(it);
}
}
// Remove encodings if associated to removed codecs.
for (auto it = this->encodings.begin(); it != this->encodings.end();)
{
auto& encoding = *it;
auto it2 = removedCodecPayloadTypes.begin();
for (; it2 != removedCodecPayloadTypes.end(); ++it2)
{
auto removedCodecPayloadType = *it2;
if (encoding.codecPayloadType == removedCodecPayloadType)
{
MS_WARN_DEV("removing encoding without matching codec");
it = this->encodings.erase(it);
break;
}
}
if (it2 == removedCodecPayloadTypes.end())
{
++it;
}
}
// Finally validate codecs and encodings.
ValidateCodecs();
ValidateEncodings();
}
void RtpParameters::ReduceHeaderExtensions(std::vector<RtpHeaderExtension>& supportedHeaderExtensions) void RtpParameters::ReduceHeaderExtensions(std::vector<RtpHeaderExtension>& supportedHeaderExtensions)
{ {
MS_TRACE(); MS_TRACE();
......
Markdown 格式
0% 或
您添加了 0 人 到此讨论。请谨慎行事。
请先完成此评论的编辑!
请 注册 或者 后发表评论