提交 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(
],
{
verbose : true,
env : { DEBUG: '*ABORT*' }
env : { DEBUG: '*ABORT* *WARN*' }
}
));
......
......@@ -236,7 +236,7 @@ class Server extends EventEmitter
this.emit('newroom', room);
return room;
})
});
}
_addWorker(worker)
......
......@@ -339,7 +339,32 @@ class RTCPeerConnectionCommon extends EventEmitter
// Re-offer received from the client.
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 =
{
kind : 'audio',
name : 'audio/opus',
payloadType : 96,
payloadType : 100,
clockRate : 48000,
numChannels : 2
},
......@@ -74,23 +74,23 @@ module.exports =
{
kind : 'video',
name : 'video/VP8',
payloadType : 97,
payloadType : 110,
clockRate : 90000
},
{
kind : 'video',
name : 'video/rtx',
payloadType : 100,
payloadType : 97,
clockRate : 90000,
parameters :
{
apt : 97
apt : 110
}
},
{
kind : 'video',
name : 'video/H264',
payloadType : 98,
payloadType : 111,
clockRate : 90000,
parameters :
{
......@@ -100,17 +100,17 @@ module.exports =
{
kind : 'video',
name : 'video/rtx',
payloadType : 101,
payloadType : 98,
clockRate : 90000,
parameters :
{
apt : 98
apt : 111
}
},
{
kind : 'video',
name : 'video/H264',
payloadType : 99,
payloadType : 112,
clockRate : 90000,
parameters :
{
......@@ -120,11 +120,11 @@ module.exports =
{
kind : 'video',
name : 'video/rtx',
payloadType : 102,
payloadType : 99,
clockRate : 90000,
parameters :
{
apt : 99
apt : 112
}
}
]
......
......@@ -280,6 +280,7 @@ namespace RTC
explicit RtpParameters(const RtpParameters* RtpParameters);
Json::Value toJson();
void ReduceCodecsAndEncodings(RtpCapabilities& capabilities);
void ReduceHeaderExtensions(std::vector<RtpHeaderExtension>& supportedHeaderExtensions);
uint32_t GetClockRateForEncoding(size_t encodingIdx);
......
#define MS_CLASS "DepLibUV"
// #define MS_LOG_DEV
#define MS_LOG_DEV
#include "DepLibUV.h"
#include "Logger.h"
......@@ -63,7 +63,7 @@ uint64_t DepLibUV::GetTime()
static uint32_t maxTimeCounter = 32768;
// 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);
// Update the libuv's concept of “now” every N usages.
......
......@@ -684,29 +684,8 @@ namespace RTC
auto rtpParameters = rtpReceiver->GetParameters();
// Given codecs must be a subset of the capability codecs of the peer.
for (auto& codec : rtpParameters->codecs)
{
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 codecs and their associated encodings.
rtpParameters->ReduceCodecsAndEncodings(this->capabilities);
// Remove unsupported header extensions.
rtpParameters->ReduceHeaderExtensions(this->capabilities.headerExtensions);
......
......@@ -90,7 +90,6 @@ namespace RTC
this->userParameters = Json::objectValue;
// Validate RTP parameters.
ValidateCodecs();
ValidateEncodings();
}
......@@ -158,6 +157,69 @@ namespace RTC
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)
{
MS_TRACE();
......
Markdown 格式
0% 或
您添加了 0 人 到此讨论。请谨慎行事。
请先完成此评论的编辑!
请 注册 或者 后发表评论