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

RtpSender: allow disable()/enable() without forcing SDP renegotiation (fixes #113)

上级 4d248a7d
......@@ -211,15 +211,21 @@ class RtpSender extends EventEmitter
*
* @return {Promise} Resolves to this.
*/
enable()
enable(options)
{
logger.debug('enable()');
logger.debug('enable() [options:%o]', options);
if (this._closed)
return Promise.reject(new errors.InvalidStateError('RtpSender closed'));
options = options || {};
// Send Channel request.
return this._channel.request('rtpSender.disable', this._internal, { disabled: false })
return this._channel.request('rtpSender.disable', this._internal,
{
disabled : false,
emit : !!options.emit
})
.then(() =>
{
logger.debug('"rtpSender.disable" request succeeded');
......@@ -239,15 +245,21 @@ class RtpSender extends EventEmitter
*
* @return {Promise} Resolves to this.
*/
disable()
disable(options)
{
logger.debug('disable()');
logger.debug('disable() [options:%o]', options);
if (this._closed)
return Promise.reject(new errors.InvalidStateError('RtpSender closed'));
options = options || {};
// Send Channel request.
return this._channel.request('rtpSender.disable', this._internal, { disabled: true })
return this._channel.request('rtpSender.disable', this._internal,
{
disabled : true,
emit : !!options.emit
})
.then(() =>
{
logger.debug('"rtpSender.disable" request succeeded');
......
......@@ -97,6 +97,7 @@ namespace RTC
/* Pure virtual methods inherited from RTC::RtpSender::Listener. */
public:
void OnRtpSenderClosed(RTC::RtpSender* rtpSender) override;
void OnRtpSenderFullFrameRequired(RTC::RtpSender* rtpSender) override;
/* Pure virtual methods inherited from Timer::Listener. */
public:
......
......@@ -27,7 +27,8 @@ namespace RTC
class Listener
{
public:
virtual void OnRtpSenderClosed(RtpSender* rtpSender) = 0;
virtual void OnRtpSenderClosed(RtpSender* rtpSender) = 0;
virtual void OnRtpSenderFullFrameRequired(RtpSender* rtpSender) = 0;
};
public:
......
......@@ -950,6 +950,10 @@ namespace RTC
if (rtpSender != nullptr)
{
// If the RtpSender is not active, drop the packet.
if (!rtpSender->GetActive())
break;
if (feedback->GetMessageType() == RTCP::FeedbackPs::MessageType::PLI)
{
MS_DEBUG_TAG(rtx, "PLI received [media ssrc:%" PRIu32 "]", feedback->GetMediaSsrc());
......@@ -1150,6 +1154,13 @@ namespace RTC
this->listener->OnPeerRtpSenderClosed(this, rtpSender);
}
void Peer::OnRtpSenderFullFrameRequired(RTC::RtpSender* rtpSender)
{
MS_TRACE();
this->listener->OnFullFrameRequired(this, rtpSender);
}
void Peer::OnTimer(Timer* /*timer*/)
{
uint64_t interval = RTC::RTCP::MaxVideoIntervalMs;
......
......@@ -112,6 +112,7 @@ namespace RTC
case Channel::Request::MethodId::RTP_SENDER_DISABLE:
{
static const Json::StaticString JsonStringDisabled{ "disabled" };
static const Json::StaticString JsonStringEmit{ "emit" };
if (!request->data[JsonStringDisabled].isBool())
{
......@@ -121,6 +122,10 @@ namespace RTC
}
bool disabled = request->data[JsonStringDisabled].asBool();
bool emit = true;
if (request->data[JsonStringEmit].isBool())
emit = request->data[JsonStringEmit].asBool();
// Nothing changed.
if (this->disabled == disabled)
......@@ -135,7 +140,13 @@ namespace RTC
this->disabled = disabled;
if (wasActive != this->GetActive())
EmitActiveChange();
{
if (emit)
EmitActiveChange();
if (this->GetActive())
this->listener->OnRtpSenderFullFrameRequired(this);
}
request->Accept();
......
Markdown 格式
0% 或
您添加了 0 人 到此讨论。请谨慎行事。
请先完成此评论的编辑!
请 注册 或者 后发表评论