From f93eda17051990ab431947c46c533313e1bbe5e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Erik=20Spr=C3=A5ng?= Date: Wed, 16 Jan 2019 17:10:57 +0100 Subject: [PATCH] Move some video codec constants to separate file. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Reviewed-by: Niels Moller Commit-Queue: Erik Språng Cr-Commit-Position: refs/heads/master@{#26299} --- api/video/BUILD.gn | 9 ++++++++ api/video/video_bitrate_allocation.h | 6 +---- api/video/video_codec_constants.h | 22 +++++++++++++++++++ api/video_codecs/BUILD.gn | 1 + api/video_codecs/video_encoder.h | 1 + common_types.h | 2 -- media/BUILD.gn | 3 ++- media/engine/simulcast.cc | 2 +- media/engine/simulcast_encoder_adapter.cc | 2 +- media/engine/webrtc_video_engine.cc | 5 +++-- modules/include/module_common_types.h | 1 + modules/rtp_rtcp/BUILD.gn | 1 + .../rtp_rtcp/source/rtp_sender_unittest.cc | 1 + sdk/android/src/jni/encoded_image.h | 2 ++ video/BUILD.gn | 1 + video/end_to_end_tests/bandwidth_tests.cc | 1 + video/video_send_stream_tests.cc | 1 + video/video_stream_encoder_unittest.cc | 1 + 18 files changed, 50 insertions(+), 12 deletions(-) create mode 100644 api/video/video_codec_constants.h diff --git a/api/video/BUILD.gn b/api/video/BUILD.gn index 22aebd3851..356597c7aa 100644 --- a/api/video/BUILD.gn +++ b/api/video/BUILD.gn @@ -102,6 +102,14 @@ rtc_source_set("encoded_frame") { ] } +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 @@ rtc_source_set("video_bitrate_allocation") { "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 d1771b44a4..ef64226058 100644 --- a/api/video/video_bitrate_allocation.h +++ b/api/video/video_bitrate_allocation.h @@ -18,14 +18,10 @@ #include #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 0000000000..a3f7cd2997 --- /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 bafe17f10c..af132717df 100644 --- a/api/video_codecs/BUILD.gn +++ b/api/video_codecs/BUILD.gn @@ -38,6 +38,7 @@ rtc_source_set("video_codecs_api") { "../../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 cce2dbda53..2856b1c3d4 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 c6d4c948e0..2422ce0c31 100644 --- a/common_types.h +++ b/common_types.h @@ -14,8 +14,6 @@ #include // For size_t #include -// 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 4801e89968..40c843d99c 100644 --- a/media/BUILD.gn +++ b/media/BUILD.gn @@ -190,7 +190,7 @@ rtc_static_library("rtc_simulcast_encoder_adapter") { "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 @@ rtc_static_library("rtc_audio_video") { "../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 ac49b57e99..f0936755fe 100644 --- a/media/engine/simulcast.cc +++ b/media/engine/simulcast.cc @@ -14,7 +14,7 @@ #include #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 7acb726826..0365ce2d8f 100644 --- a/media/engine/simulcast_encoder_adapter.cc +++ b/media/engine/simulcast_encoder_adapter.cc @@ -18,7 +18,7 @@ #include #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 a0dc049aab..7c7eab2347 100644 --- a/media/engine/webrtc_video_engine.cc +++ b/media/engine/webrtc_video_engine.cc @@ -17,6 +17,7 @@ #include #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 @@ bool GetVp9LayersFromFieldTrialGroup(size_t* num_spatial_layers, 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 e058cc84e6..b189c43235 100644 --- a/modules/include/module_common_types.h +++ b/modules/include/module_common_types.h @@ -13,6 +13,7 @@ #include #include +#include #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 d416d44bd3..3524b44c7f 100644 --- a/modules/rtp_rtcp/BUILD.gn +++ b/modules/rtp_rtcp/BUILD.gn @@ -426,6 +426,7 @@ if (rtc_include_tests) { "../../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 acb542e060..89bad12ce4 100644 --- a/modules/rtp_rtcp/source/rtp_sender_unittest.cc +++ b/modules/rtp_rtcp/source/rtp_sender_unittest.cc @@ -12,6 +12,7 @@ #include #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 02047aa822..148ba038b9 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 +#include + #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 50a106c683..f82668aeeb 100644 --- a/video/BUILD.gn +++ b/video/BUILD.gn @@ -499,6 +499,7 @@ if (rtc_include_tests) { "../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 cbbffa6dc6..15327a9fc6 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 821db3a12c..4b7550b374 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 28e06c7980..9d275adae5 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"