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

More work on removing JSON arguments in C++ methods.

上级 8f73fcb5
......@@ -60,6 +60,8 @@ namespace RTC
void UpdateRtpParameters(RTC::RtpParameters& rtpParameters);
void Pause();
void Resume();
void SetRtpRawEvent(bool enabled);
void SetRtpObjectEvent(bool enabled);
const RTC::RtpParameters& GetParameters() const;
bool IsPaused() const;
void ReceiveRtpPacket(RTC::RtpPacket* packet);
......
......@@ -135,50 +135,6 @@ namespace RTC
break;
}
case Channel::Request::MethodId::PRODUCER_SET_RTP_RAW_EVENT:
{
static const Json::StaticString JsonStringEnabled{ "enabled" };
if (!request->data[JsonStringEnabled].isBool())
{
request->Reject("Request has invalid data.enabled");
return;
}
this->rtpRawEventEnabled = request->data[JsonStringEnabled].asBool();
request->Accept();
// If set, require a full frame.
if (this->rtpRawEventEnabled)
RequestFullFrame(true);
break;
}
case Channel::Request::MethodId::PRODUCER_SET_RTP_OBJECT_EVENT:
{
static const Json::StaticString JsonStringEnabled{ "enabled" };
if (!request->data[JsonStringEnabled].isBool())
{
request->Reject("Request has invalid data.enabled");
return;
}
this->rtpObjectEventEnabled = request->data[JsonStringEnabled].asBool();
request->Accept();
// If set, require a full frame.
if (this->rtpObjectEventEnabled)
RequestFullFrame(true);
break;
}
default:
{
MS_ERROR("unknown method");
......@@ -276,6 +232,28 @@ namespace RTC
RequestFullFrame(true);
}
void Producer::SetRtpRawEvent(bool enabled)
{
MS_TRACE();
this->rtpRawEventEnabled = enabled;
// If set (and not paused), require a full frame.
if (this->rtpRawEventEnabled && !this->paused)
RequestFullFrame(true);
}
void Producer::SetRtpObjectEvent(bool enabled)
{
MS_TRACE();
this->rtpObjectEventEnabled = enabled;
// If set (and not paused), require a full frame.
if (this->rtpObjectEventEnabled && !this->paused)
RequestFullFrame(true);
}
void Producer::ReceiveRtpPacket(RTC::RtpPacket* packet)
{
MS_TRACE();
......
......@@ -920,8 +920,49 @@ namespace RTC
}
case Channel::Request::MethodId::PRODUCER_SET_RTP_RAW_EVENT:
{
static const Json::StaticString JsonStringEnabled{ "enabled" };
RTC::Producer* producer;
try
{
producer = GetProducerFromRequest(request);
}
catch (const MediaSoupError& error)
{
request->Reject(error.what());
return;
}
if (producer == nullptr)
{
request->Reject("Producer does not exist");
return;
}
if (!request->data[JsonStringEnabled].isBool())
{
request->Reject("Request has invalid data.enabled");
return;
}
bool enabled = request->data[JsonStringEnabled].asBool();
producer->SetRtpRawEvent(enabled);
request->Accept();
break;
}
case Channel::Request::MethodId::PRODUCER_SET_RTP_OBJECT_EVENT:
{
static const Json::StaticString JsonStringEnabled{ "enabled" };
RTC::Producer* producer;
try
......@@ -942,7 +983,18 @@ namespace RTC
return;
}
producer->HandleRequest(request);
if (!request->data[JsonStringEnabled].isBool())
{
request->Reject("Request has invalid data.enabled");
return;
}
bool enabled = request->data[JsonStringEnabled].asBool();
producer->SetRtpObjectEvent(enabled);
request->Accept();
break;
}
......
Markdown 格式
0% 或
您添加了 0 人 到此讨论。请谨慎行事。
请先完成此评论的编辑!
请 注册 或者 后发表评论