Use RtcpPacket to send BYE in RtcpSender

BUG=webrtc:2450

Review URL: https://codereview.webrtc.org/1306893003

Cr-Commit-Position: refs/heads/master@{#9763}
This commit is contained in:
sprang
2015-08-24 03:25:19 -07:00
committed by Commit bot
parent 608c3cfe77
commit d8ee4f9915

View File

@ -885,26 +885,15 @@ RTCPSender::BuildResult RTCPSender::BuildNACK(RtcpContext* ctx) {
}
RTCPSender::BuildResult RTCPSender::BuildBYE(RtcpContext* ctx) {
// sanity
if (ctx->position + 8 >= IP_PACKET_SIZE)
rtcp::Bye bye;
bye.From(ssrc_);
for (uint32_t csrc : csrcs_)
bye.WithCsrc(csrc);
PacketBuiltCallback callback(ctx);
if (!callback.BuildPacket(bye))
return BuildResult::kTruncated;
// Add a bye packet
// Number of SSRC + CSRCs.
*ctx->AllocateData(1) = static_cast<uint8_t>(0x80 + 1 + csrcs_.size());
*ctx->AllocateData(1) = 203;
// length
*ctx->AllocateData(1) = 0;
*ctx->AllocateData(1) = static_cast<uint8_t>(1 + csrcs_.size());
// Add our own SSRC
ByteWriter<uint32_t>::WriteBigEndian(ctx->AllocateData(4), ssrc_);
// add CSRCs
for (size_t i = 0; i < csrcs_.size(); i++)
ByteWriter<uint32_t>::WriteBigEndian(ctx->AllocateData(4), csrcs_[i]);
return BuildResult::kSuccess;
}