Move some video codec constants to separate file.

kMaxSimulcastStreams, kMaxSpatialLayers and kMaxTemporalStreams don't
really beling on VideoBitrateAllocation.
common_types.h is going away and it feels dubious to requrie include
of the full VideoEncoder api to use them. Therefore moving them into a
seprate file/target.

Also includes some remaining cleanup of includes.

Bug: webrtc:9271
Change-Id: I7ded3d97a9a835ac756159700774445a2b93a697
Reviewed-on: https://webrtc-review.googlesource.com/c/117305
Reviewed-by: Stefan Holmer <stefan@webrtc.org>
Reviewed-by: Niels Moller <nisse@webrtc.org>
Commit-Queue: Erik Språng <sprang@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#26299}
diff --git a/api/video/BUILD.gn b/api/video/BUILD.gn
index 22aebd3..356597c 100644
--- a/api/video/BUILD.gn
+++ b/api/video/BUILD.gn
@@ -102,6 +102,14 @@
   ]
 }
 
+rtc_source_set("video_codec_constants") {
+  visibility = [ "*" ]
+  sources = [
+    "video_codec_constants.h",
+  ]
+  deps = []
+}
+
 rtc_source_set("video_bitrate_allocation") {
   visibility = [ "*" ]
   sources = [
@@ -109,6 +117,7 @@
     "video_bitrate_allocation.h",
   ]
   deps = [
+    ":video_codec_constants",
     "../../rtc_base:checks",
     "../../rtc_base:safe_conversions",
     "../../rtc_base:stringutils",
diff --git a/api/video/video_bitrate_allocation.h b/api/video/video_bitrate_allocation.h
index d1771b4..ef64226 100644
--- a/api/video/video_bitrate_allocation.h
+++ b/api/video/video_bitrate_allocation.h
@@ -18,14 +18,10 @@
 #include <vector>
 
 #include "absl/types/optional.h"
+#include "api/video/video_codec_constants.h"
 
 namespace webrtc {
 
-// TODO(sprang): Move back to common_types when include of this is removed.
-enum : int { kMaxSimulcastStreams = 4 };
-enum : int { kMaxSpatialLayers = 5 };
-enum : int { kMaxTemporalStreams = 4 };
-
 // Class that describes how video bitrate, in bps, is allocated across temporal
 // and spatial layers. Not that bitrates are NOT cumulative. Depending on if
 // layers are dependent or not, it is up to the user to aggregate.
diff --git a/api/video/video_codec_constants.h b/api/video/video_codec_constants.h
new file mode 100644
index 0000000..a3f7cd2
--- /dev/null
+++ b/api/video/video_codec_constants.h
@@ -0,0 +1,22 @@
+/*
+ *  Copyright (c) 2019 The WebRTC project authors. All Rights Reserved.
+ *
+ *  Use of this source code is governed by a BSD-style license
+ *  that can be found in the LICENSE file in the root of the source
+ *  tree. An additional intellectual property rights grant can be found
+ *  in the file PATENTS.  All contributing project authors may
+ *  be found in the AUTHORS file in the root of the source tree.
+ */
+
+#ifndef API_VIDEO_VIDEO_CODEC_CONSTANTS_H_
+#define API_VIDEO_VIDEO_CODEC_CONSTANTS_H_
+
+namespace webrtc {
+
+enum : int { kMaxSimulcastStreams = 4 };
+enum : int { kMaxSpatialLayers = 5 };
+enum : int { kMaxTemporalStreams = 4 };
+
+}  // namespace webrtc
+
+#endif  // API_VIDEO_VIDEO_CODEC_CONSTANTS_H_
diff --git a/api/video_codecs/BUILD.gn b/api/video_codecs/BUILD.gn
index bafe17f..af13271 100644
--- a/api/video_codecs/BUILD.gn
+++ b/api/video_codecs/BUILD.gn
@@ -38,6 +38,7 @@
     "../../rtc_base/system:rtc_export",
     "../video:encoded_image",
     "../video:video_bitrate_allocation",
+    "../video:video_codec_constants",
     "../video:video_frame",
     "//third_party/abseil-cpp/absl/strings",
     "//third_party/abseil-cpp/absl/types:optional",
diff --git a/api/video_codecs/video_encoder.h b/api/video_codecs/video_encoder.h
index cce2dbd..2856b1c 100644
--- a/api/video_codecs/video_encoder.h
+++ b/api/video_codecs/video_encoder.h
@@ -18,6 +18,7 @@
 #include "absl/types/optional.h"
 #include "api/video/encoded_image.h"
 #include "api/video/video_bitrate_allocation.h"
+#include "api/video/video_codec_constants.h"
 #include "api/video/video_frame.h"
 #include "api/video_codecs/video_codec.h"
 #include "rtc_base/checks.h"
diff --git a/common_types.h b/common_types.h
index c6d4c94..2422ce0 100644
--- a/common_types.h
+++ b/common_types.h
@@ -14,8 +14,6 @@
 #include <stddef.h>  // For size_t
 #include <cstdint>
 
-// TODO(sprang): Remove this include when all usage includes it directly.
-#include "api/video/video_bitrate_allocation.h"
 // TODO(bugs.webrtc.org/7660): Delete include once downstream code is updated.
 #include "api/video/video_codec_type.h"
 
diff --git a/media/BUILD.gn b/media/BUILD.gn
index 4801e89..40c843d 100644
--- a/media/BUILD.gn
+++ b/media/BUILD.gn
@@ -190,7 +190,7 @@
     "engine/simulcast_encoder_adapter.h",
   ]
   deps = [
-    "../api/video:video_bitrate_allocation",
+    "../api/video:video_codec_constants",
     "../api/video:video_frame",
     "../api/video:video_frame_i420",
     "../api/video_codecs:video_codecs_api",
@@ -374,6 +374,7 @@
     "../api:transport_api",
     "../api/audio_codecs:audio_codecs_api",
     "../api/video:builtin_video_bitrate_allocator_factory",
+    "../api/video:video_codec_constants",
     "../api/video:video_frame",
     "../api/video:video_frame_i420",
     "../api/video_codecs:rtc_software_fallback_wrappers",
diff --git a/media/engine/simulcast.cc b/media/engine/simulcast.cc
index ac49b57..f093675 100644
--- a/media/engine/simulcast.cc
+++ b/media/engine/simulcast.cc
@@ -14,7 +14,7 @@
 #include <string>
 
 #include "absl/types/optional.h"
-#include "api/video/video_bitrate_allocation.h"
+#include "api/video/video_codec_constants.h"
 #include "media/base/media_constants.h"
 #include "media/engine/constants.h"
 #include "media/engine/simulcast.h"
diff --git a/media/engine/simulcast_encoder_adapter.cc b/media/engine/simulcast_encoder_adapter.cc
index 7acb726..0365ce2 100644
--- a/media/engine/simulcast_encoder_adapter.cc
+++ b/media/engine/simulcast_encoder_adapter.cc
@@ -18,7 +18,7 @@
 #include <utility>
 
 #include "api/video/i420_buffer.h"
-#include "api/video/video_bitrate_allocation.h"
+#include "api/video/video_codec_constants.h"
 #include "api/video/video_frame_buffer.h"
 #include "api/video/video_rotation.h"
 #include "api/video_codecs/video_encoder_factory.h"
diff --git a/media/engine/webrtc_video_engine.cc b/media/engine/webrtc_video_engine.cc
index a0dc049..7c7eab2 100644
--- a/media/engine/webrtc_video_engine.cc
+++ b/media/engine/webrtc_video_engine.cc
@@ -17,6 +17,7 @@
 #include <utility>
 
 #include "absl/strings/match.h"
+#include "api/video/video_codec_constants.h"
 #include "api/video_codecs/sdp_video_format.h"
 #include "api/video_codecs/video_decoder_factory.h"
 #include "api/video_codecs/video_encoder.h"
@@ -246,8 +247,8 @@
              num_temporal_layers) != 2) {
     return false;
   }
-  const size_t kMaxSpatialLayers = 3;
-  if (*num_spatial_layers > kMaxSpatialLayers || *num_spatial_layers < 1)
+  if (*num_spatial_layers > webrtc::kMaxSpatialLayers ||
+      *num_spatial_layers < 1)
     return false;
 
   const size_t kMaxTemporalLayers = 3;
diff --git a/modules/include/module_common_types.h b/modules/include/module_common_types.h
index e058cc8..b189c43 100644
--- a/modules/include/module_common_types.h
+++ b/modules/include/module_common_types.h
@@ -13,6 +13,7 @@
 
 #include <stddef.h>
 #include <stdint.h>
+#include <vector>
 
 #include "api/rtp_headers.h"
 #include "common_types.h"  // NOLINT(build/include)
diff --git a/modules/rtp_rtcp/BUILD.gn b/modules/rtp_rtcp/BUILD.gn
index d416d44..3524b44 100644
--- a/modules/rtp_rtcp/BUILD.gn
+++ b/modules/rtp_rtcp/BUILD.gn
@@ -426,6 +426,7 @@
       "../../api:transport_api",
       "../../api/video:video_bitrate_allocation",
       "../../api/video:video_bitrate_allocator",
+      "../../api/video:video_codec_constants",
       "../../api/video:video_frame",
       "../../api/video_codecs:video_codecs_api",
       "../../call:rtp_receiver",
diff --git a/modules/rtp_rtcp/source/rtp_sender_unittest.cc b/modules/rtp_rtcp/source/rtp_sender_unittest.cc
index acb542e..89bad12 100644
--- a/modules/rtp_rtcp/source/rtp_sender_unittest.cc
+++ b/modules/rtp_rtcp/source/rtp_sender_unittest.cc
@@ -12,6 +12,7 @@
 #include <vector>
 
 #include "absl/memory/memory.h"
+#include "api/video/video_codec_constants.h"
 #include "api/video/video_timing.h"
 #include "logging/rtc_event_log/events/rtc_event.h"
 #include "logging/rtc_event_log/mock/mock_rtc_event_log.h"
diff --git a/sdk/android/src/jni/encoded_image.h b/sdk/android/src/jni/encoded_image.h
index 02047aa..148ba03 100644
--- a/sdk/android/src/jni/encoded_image.h
+++ b/sdk/android/src/jni/encoded_image.h
@@ -12,6 +12,8 @@
 #define SDK_ANDROID_SRC_JNI_ENCODED_IMAGE_H_
 
 #include <jni.h>
+#include <vector>
+
 #include "common_types.h"  // NOLINT(build/include)
 
 #include "sdk/android/native_api/jni/scoped_java_ref.h"
diff --git a/video/BUILD.gn b/video/BUILD.gn
index 50a106c..f82668a 100644
--- a/video/BUILD.gn
+++ b/video/BUILD.gn
@@ -499,6 +499,7 @@
       "../api/test/video:function_video_factory",
       "../api/video:builtin_video_bitrate_allocator_factory",
       "../api/video:encoded_image",
+      "../api/video:video_bitrate_allocation",
       "../api/video:video_frame",
       "../api/video:video_frame_i420",
       "../api/video_codecs:create_vp8_temporal_layers",
diff --git a/video/end_to_end_tests/bandwidth_tests.cc b/video/end_to_end_tests/bandwidth_tests.cc
index cbbffa6..15327a9 100644
--- a/video/end_to_end_tests/bandwidth_tests.cc
+++ b/video/end_to_end_tests/bandwidth_tests.cc
@@ -11,6 +11,7 @@
 #include "absl/memory/memory.h"
 #include "api/test/simulated_network.h"
 #include "api/video/builtin_video_bitrate_allocator_factory.h"
+#include "api/video/video_bitrate_allocation.h"
 #include "call/fake_network_pipe.h"
 #include "call/simulated_network.h"
 #include "modules/rtp_rtcp/include/rtp_rtcp.h"
diff --git a/video/video_send_stream_tests.cc b/video/video_send_stream_tests.cc
index 821db3a..4b7550b 100644
--- a/video/video_send_stream_tests.cc
+++ b/video/video_send_stream_tests.cc
@@ -14,6 +14,7 @@
 #include "absl/memory/memory.h"
 #include "api/test/simulated_network.h"
 #include "api/video/encoded_image.h"
+#include "api/video/video_bitrate_allocation.h"
 #include "call/call.h"
 #include "call/fake_network_pipe.h"
 #include "call/rtp_transport_controller_send.h"
diff --git a/video/video_stream_encoder_unittest.cc b/video/video_stream_encoder_unittest.cc
index 28e06c7..9d275ad 100644
--- a/video/video_stream_encoder_unittest.cc
+++ b/video/video_stream_encoder_unittest.cc
@@ -16,6 +16,7 @@
 
 #include "api/video/builtin_video_bitrate_allocator_factory.h"
 #include "api/video/i420_buffer.h"
+#include "api/video/video_bitrate_allocation.h"
 #include "api/video_codecs/create_vp8_temporal_layers.h"
 #include "api/video_codecs/vp8_temporal_layers.h"
 #include "media/base/video_adapter.h"