Make VideoFrameType an enum class, and move to separate file and target
Bug: webrtc:5876, webrtc:6883
Change-Id: I1435cfa9e8e54c4ba2978261048ff3fbb993ce0e
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/126225
Commit-Queue: Niels Moller <nisse@webrtc.org>
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#27239}
diff --git a/api/BUILD.gn b/api/BUILD.gn
index 6b78a6c..d368124 100644
--- a/api/BUILD.gn
+++ b/api/BUILD.gn
@@ -350,8 +350,8 @@
]
deps = [
- "..:webrtc_common",
"../modules:module_fec_api",
+ "video:video_frame_type",
]
}
@@ -480,6 +480,7 @@
"..:webrtc_common",
"../modules/video_coding:video_codec_interface",
"../rtc_base:stringutils",
+ "video:video_frame_type",
"video_codecs:video_codecs_api",
]
}
diff --git a/api/fec_controller.h b/api/fec_controller.h
index 6cc46dd..3e5f7bb 100644
--- a/api/fec_controller.h
+++ b/api/fec_controller.h
@@ -14,7 +14,7 @@
#include <memory>
#include <vector>
-#include "common_types.h" // NOLINT(build/include)
+#include "api/video/video_frame_type.h"
#include "modules/include/module_fec_types.h"
namespace webrtc {
diff --git a/api/test/videocodec_test_stats.cc b/api/test/videocodec_test_stats.cc
index 7289060..df45919 100644
--- a/api/test/videocodec_test_stats.cc
+++ b/api/test/videocodec_test_stats.cc
@@ -24,7 +24,7 @@
ss << " temporal_idx " << temporal_idx;
ss << " inter_layer_predicted " << inter_layer_predicted;
ss << " non_ref_for_inter_layer_pred " << non_ref_for_inter_layer_pred;
- ss << " frame_type " << frame_type;
+ ss << " frame_type " << static_cast<int>(frame_type);
ss << " length_bytes " << length_bytes;
ss << " qp " << qp;
ss << " psnr " << psnr;
diff --git a/api/test/videocodec_test_stats.h b/api/test/videocodec_test_stats.h
index c9eada3..85384ef 100644
--- a/api/test/videocodec_test_stats.h
+++ b/api/test/videocodec_test_stats.h
@@ -16,7 +16,7 @@
#include <string>
#include <vector>
-#include "common_types.h" // NOLINT(build/include)
+#include "api/video/video_frame_type.h"
namespace webrtc {
namespace test {
@@ -43,7 +43,7 @@
size_t encode_time_us = 0;
size_t target_bitrate_kbps = 0;
size_t length_bytes = 0;
- webrtc::VideoFrameType frame_type = kVideoFrameDelta;
+ VideoFrameType frame_type = VideoFrameType::kVideoFrameDelta;
// Layering.
size_t spatial_idx = 0;
diff --git a/api/video/BUILD.gn b/api/video/BUILD.gn
index aef213e..33ebd25 100644
--- a/api/video/BUILD.gn
+++ b/api/video/BUILD.gn
@@ -41,6 +41,13 @@
]
}
+rtc_source_set("video_frame_type") {
+ visibility = [ "*" ]
+ sources = [
+ "video_frame_type.h",
+ ]
+}
+
rtc_source_set("video_frame_i420") {
visibility = [ "*" ]
sources = [
@@ -83,6 +90,7 @@
deps = [
":video_codec_constants",
":video_frame",
+ ":video_frame_type",
"../..:webrtc_common",
"../../rtc_base:checks",
"../../rtc_base:rtc_base_approved",
diff --git a/api/video/encoded_image.h b/api/video/encoded_image.h
index 611da13..304a798 100644
--- a/api/video/encoded_image.h
+++ b/api/video/encoded_image.h
@@ -18,6 +18,7 @@
#include "api/video/video_codec_constants.h"
#include "api/video/video_codec_type.h"
#include "api/video/video_content_type.h"
+#include "api/video/video_frame_type.h"
#include "api/video/video_rotation.h"
#include "api/video/video_timing.h"
#include "common_types.h" // NOLINT(build/include)
@@ -109,7 +110,7 @@
// NTP time of the capture time in local timebase in milliseconds.
int64_t ntp_time_ms_ = 0;
int64_t capture_time_ms_ = 0;
- VideoFrameType _frameType = kVideoFrameDelta;
+ VideoFrameType _frameType = VideoFrameType::kVideoFrameDelta;
VideoRotation rotation_ = kVideoRotation_0;
VideoContentType content_type_ = VideoContentType::UNSPECIFIED;
bool _completeFrame = false;
diff --git a/api/video/video_frame_type.h b/api/video/video_frame_type.h
new file mode 100644
index 0000000..4a96f1f
--- /dev/null
+++ b/api/video/video_frame_type.h
@@ -0,0 +1,26 @@
+/*
+ * 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_FRAME_TYPE_H_
+#define API_VIDEO_VIDEO_FRAME_TYPE_H_
+
+namespace webrtc {
+
+enum class VideoFrameType {
+ kEmptyFrame = 0,
+ // Wire format for MultiplexEncodedImagePacker seems to depend on numerical
+ // values of these constants.
+ kVideoFrameKey = 3,
+ kVideoFrameDelta = 4,
+};
+
+} // namespace webrtc
+
+#endif // API_VIDEO_VIDEO_FRAME_TYPE_H_
diff --git a/api/video_codecs/test/video_decoder_software_fallback_wrapper_unittest.cc b/api/video_codecs/test/video_decoder_software_fallback_wrapper_unittest.cc
index 06b893c..b84ec36 100644
--- a/api/video_codecs/test/video_decoder_software_fallback_wrapper_unittest.cc
+++ b/api/video_codecs/test/video_decoder_software_fallback_wrapper_unittest.cc
@@ -88,7 +88,7 @@
EXPECT_EQ(1, fake_decoder_->init_decode_count_);
EncodedImage encoded_image;
- encoded_image._frameType = kVideoFrameKey;
+ encoded_image._frameType = VideoFrameType::kVideoFrameKey;
fallback_wrapper_->Decode(encoded_image, false, nullptr, -1);
EXPECT_EQ(1, fake_decoder_->init_decode_count_)
<< "Initialized decoder should not be reinitialized.";
@@ -103,7 +103,7 @@
EXPECT_EQ(1, fake_decoder_->init_decode_count_);
EncodedImage encoded_image;
- encoded_image._frameType = kVideoFrameKey;
+ encoded_image._frameType = VideoFrameType::kVideoFrameKey;
fallback_wrapper_->Decode(encoded_image, false, nullptr, -1);
EXPECT_EQ(1, fake_decoder_->init_decode_count_)
<< "Should not have attempted reinitializing the fallback decoder on "
@@ -124,7 +124,7 @@
EXPECT_EQ(1, fake_decoder_->decode_count_);
// Software fallback should be sticky, fake_decoder_ shouldn't be used.
- encoded_image._frameType = kVideoFrameKey;
+ encoded_image._frameType = VideoFrameType::kVideoFrameKey;
fallback_wrapper_->Decode(encoded_image, false, nullptr, -1);
EXPECT_EQ(1, fake_decoder_->decode_count_)
<< "Decoder shouldn't be used after failure.";
@@ -242,7 +242,7 @@
EXPECT_EQ(1, sw_fallback_decoder_->init_decode_count_);
EncodedImage encoded_image;
- encoded_image._frameType = kVideoFrameKey;
+ encoded_image._frameType = VideoFrameType::kVideoFrameKey;
fallback_wrapper_->Decode(encoded_image, false, nullptr, -1);
EXPECT_EQ(1, sw_fallback_decoder_->init_decode_count_);
EXPECT_EQ(1, sw_fallback_decoder_->decode_count_);
diff --git a/api/video_codecs/test/video_encoder_software_fallback_wrapper_unittest.cc b/api/video_codecs/test/video_encoder_software_fallback_wrapper_unittest.cc
index 5ebd86f..de245c8 100644
--- a/api/video_codecs/test/video_encoder_software_fallback_wrapper_unittest.cc
+++ b/api/video_codecs/test/video_encoder_software_fallback_wrapper_unittest.cc
@@ -180,7 +180,7 @@
rtc::scoped_refptr<I420Buffer> buffer =
I420Buffer::Create(codec_.width, codec_.height);
I420Buffer::SetBlack(buffer);
- std::vector<VideoFrameType> types(1, kVideoFrameKey);
+ std::vector<VideoFrameType> types(1, VideoFrameType::kVideoFrameKey);
frame_ =
absl::make_unique<VideoFrame>(VideoFrame::Builder()
@@ -292,7 +292,7 @@
EXPECT_EQ(&callback2, fake_encoder_->encode_complete_callback_);
// Encoding a frame using the fallback should arrive at the new callback.
- std::vector<VideoFrameType> types(1, kVideoFrameKey);
+ std::vector<VideoFrameType> types(1, VideoFrameType::kVideoFrameKey);
frame_->set_timestamp(frame_->timestamp() + 1000);
EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK, fallback_wrapper_->Encode(*frame_, &types));