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}
diff --git a/webrtc/api/sctputils.cc b/webrtc/api/sctputils.cc
index f2d1b0f..d6ea601 100644
--- a/webrtc/api/sctputils.cc
+++ b/webrtc/api/sctputils.cc
@@ -49,9 +49,7 @@
   // Format defined at
   // http://tools.ietf.org/html/draft-jesup-rtcweb-data-protocol-04
 
-  // TODO(jbauch): avoid copying the payload data into the ByteBuffer, see
-  // https://bugs.chromium.org/p/webrtc/issues/detail?id=5670
-  rtc::ByteBuffer buffer(payload.data<char>(), payload.size());
+  rtc::ByteBufferReader buffer(payload.data<char>(), payload.size());
   uint8_t message_type;
   if (!buffer.ReadUInt8(&message_type)) {
     LOG(LS_WARNING) << "Could not read OPEN message type.";
@@ -166,7 +164,7 @@
     }
   }
 
-  rtc::ByteBuffer buffer(
+  rtc::ByteBufferWriter buffer(
       NULL, 20 + label.length() + config.protocol.length(),
       rtc::ByteBuffer::ORDER_NETWORK);
   // TODO(tommi): Add error handling and check resulting length.