Split ByteBuffer into writer/reader objects.

This allows the reader to reference data, thus avoiding unnecessary
allocations and memory copies.

BUG=webrtc:5155,webrtc:5670

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

Cr-Commit-Position: refs/heads/master@{#12160}
This commit is contained in:
jbauch
2016-03-30 06:43:37 -07:00
committed by Commit bot
parent 0d05da7ee6
commit f1f87203d7
33 changed files with 488 additions and 454 deletions

View File

@ -138,7 +138,7 @@ bool StunRequestManager::CheckResponse(const char* data, size_t size) {
// Parse the STUN message and continue processing as usual.
rtc::ByteBuffer buf(data, size);
rtc::ByteBufferReader buf(data, size);
rtc::scoped_ptr<StunMessage> response(iter->second->msg_->CreateNew());
if (!response->Read(&buf)) {
LOG(LS_WARNING) << "Failed to read STUN response " << rtc::hex_encode(id);
@ -213,7 +213,7 @@ void StunRequest::OnMessage(rtc::Message* pmsg) {
tstamp_ = rtc::Time64();
rtc::ByteBuffer buf;
rtc::ByteBufferWriter buf;
msg_->Write(&buf);
manager_->SignalSendPacket(buf.Data(), buf.Length(), this);