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:
@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user