Add spatial index to EncodedImage, not yet used.

This is a preparation for landing cl
https://webrtc-review.googlesource.com/c/src/+/83161, which needs to
be done in multiple steps:

1. Add the new spatial_index_ member and accessor methods to
   EncodedImage (this cl).

2. Update downstream encoders to assign spatial index and simulcast index
   in EncodedImage, in addition to the old members of
   CodecSpecificInfo.

3. Land main cl, converting webrtc code to use the spatial index from
   EncodedImage. Ignore the old fields in CodecSpecificInfo, but
   leave them in place in respective structs.

4. Delete downstream code accessing old fields.

5. Delete old fields in webrtc.

Bug: webrtc:9378
Change-Id: Ic132daf71f1cbbd57fb3b44f74ae94b921733f7a
Reviewed-on: https://webrtc-review.googlesource.com/90248
Reviewed-by: Erik Språng <sprang@webrtc.org>
Reviewed-by: Marco Paniconi <marpan@google.com>
Reviewed-by: Marco Paniconi <marpan@webrtc.org>
Commit-Queue: Niels Moller <nisse@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#24093}
diff --git a/common_video/include/video_frame.h b/common_video/include/video_frame.h
index 41c3919..2053ea4 100644
--- a/common_video/include/video_frame.h
+++ b/common_video/include/video_frame.h
@@ -16,6 +16,7 @@
 // to refactor and clean up related interfaces, at which point it
 // should be moved to somewhere under api/.
 
+#include "absl/types/optional.h"
 #include "api/video/video_content_type.h"
 #include "api/video/video_rotation.h"
 #include "api/video/video_timing.h"
@@ -39,6 +40,17 @@
 
   void SetEncodeTime(int64_t encode_start_ms, int64_t encode_finish_ms);
 
+  absl::optional<int> SpatialIndex() const {
+    if (spatial_index_ < 0)
+      return absl::nullopt;
+    return spatial_index_;
+  }
+  void SetSpatialIndex(absl::optional<int> spatial_index) {
+    RTC_DCHECK_GE(spatial_index.value_or(0), 0);
+    RTC_DCHECK_LT(spatial_index.value_or(0), kMaxSpatialLayers);
+    spatial_index_ = spatial_index.value_or(-1);
+  }
+
   uint32_t _encodedWidth = 0;
   uint32_t _encodedHeight = 0;
   uint32_t _timeStamp = 0;
@@ -70,6 +82,11 @@
     int64_t receive_start_ms = 0;
     int64_t receive_finish_ms = 0;
   } timing_;
+
+ private:
+  // -1 means not set. Use a plain int rather than optional, to keep this class
+  // copyable with memcpy.
+  int spatial_index_ = -1;
 };
 
 }  // namespace webrtc