diff --git a/common_video/include/video_frame.h b/common_video/include/video_frame.h index 41c391941e..2053ea488e 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 @@ class EncodedImage { void SetEncodeTime(int64_t encode_start_ms, int64_t encode_finish_ms); + absl::optional SpatialIndex() const { + if (spatial_index_ < 0) + return absl::nullopt; + return spatial_index_; + } + void SetSpatialIndex(absl::optional 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 @@ class EncodedImage { 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