Rename EncodedImage::_size to capacity_, make private.

Also adds a set_buffer method, as the only public setter for capacity_.

Bug: webrtc:9378
Change-Id: If0257c6d00bc8690f0428a3edc20b6da6dfa7119
Reviewed-on: https://webrtc-review.googlesource.com/c/112134
Commit-Queue: Niels Moller <nisse@webrtc.org>
Reviewed-by: Philip Eliasson <philipel@webrtc.org>
Reviewed-by: Erik Språng <sprang@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#25962}
diff --git a/api/video/encoded_image.cc b/api/video/encoded_image.cc
index e7c6fad..34d4813 100644
--- a/api/video/encoded_image.cc
+++ b/api/video/encoded_image.cc
@@ -31,8 +31,8 @@
 
 EncodedImage::EncodedImage(const EncodedImage&) = default;
 
-EncodedImage::EncodedImage(uint8_t* buffer, size_t length, size_t size)
-    : _buffer(buffer), _length(length), _size(size) {}
+EncodedImage::EncodedImage(uint8_t* buffer, size_t length, size_t capacity)
+    : _buffer(buffer), _length(length), capacity_(capacity) {}
 
 void EncodedImage::SetEncodeTime(int64_t encode_start_ms,
                                  int64_t encode_finish_ms) {
diff --git a/api/video/encoded_image.h b/api/video/encoded_image.h
index d7919ff..4497c8d 100644
--- a/api/video/encoded_image.h
+++ b/api/video/encoded_image.h
@@ -38,7 +38,7 @@
 
   EncodedImage();
   EncodedImage(const EncodedImage&);
-  EncodedImage(uint8_t* buffer, size_t length, size_t size);
+  EncodedImage(uint8_t* buffer, size_t length, size_t capacity);
 
   // TODO(nisse): Change style to timestamp(), set_timestamp(), for consistency
   // with the VideoFrame class.
@@ -69,14 +69,14 @@
 
   size_t size() const { return _length; }
   void set_size(size_t new_size) {
-    RTC_DCHECK_LE(new_size, _size);
+    RTC_DCHECK_LE(new_size, capacity_);
     _length = new_size;
   }
-  size_t capacity() const { return _size; }
+  size_t capacity() const { return capacity_; }
 
   void set_buffer(uint8_t* buffer, size_t capacity) {
     _buffer = buffer;
-    _size = capacity;
+    capacity_ = capacity;
   }
 
   uint32_t _encodedWidth = 0;
@@ -88,7 +88,6 @@
   uint8_t* _buffer;
   // TODO(bugs.webrtc.org/9378): Rename to size_, capacity_ and make private.
   size_t _length;
-  size_t _size;
   VideoRotation rotation_ = kVideoRotation_0;
   VideoContentType content_type_ = VideoContentType::UNSPECIFIED;
   bool _completeFrame = false;
@@ -112,6 +111,7 @@
   } timing_;
 
  private:
+  size_t capacity_;  // Allocated size of _buffer.
   uint32_t timestamp_rtp_ = 0;
   absl::optional<int> spatial_index_;
   absl::optional<webrtc::ColorSpace> color_space_;