Rename PlayoutDelay --> VideoPlayoutDelay, move to api/video/video_timing.h

We can then finally delete the top-level common_types.h, and the
corresponding build target webrtc_common.

Bug: webrtc:7660
Change-Id: I1c1096541477586d90774c7a3405b9d36edec14a
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/182800
Commit-Queue: Niels Moller <nisse@webrtc.org>
Reviewed-by: Sebastian Jansson <srte@webrtc.org>
Reviewed-by: Erik Språng <sprang@webrtc.org>
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#32044}
This commit is contained in:
Niels Möller 2020-09-02 15:34:40 +02:00 committed by Commit Bot
parent 3c2033cfb0
commit d381eede92
26 changed files with 58 additions and 96 deletions

1
.gn
View file

@ -21,7 +21,6 @@ secondary_source = "//build/secondary/"
# their includes checked for proper dependencies when you run either
# "gn check" or "gn gen --check".
check_targets = [
":webrtc_common",
"//api/*",
"//audio/*",
"//backup/*",

View file

@ -440,7 +440,6 @@ if (!build_with_chromium) {
defines = []
deps = [
":webrtc_common",
"api:create_peerconnection_factory",
"api:libjingle_peerconnection_api",
"api:rtc_error",
@ -515,15 +514,6 @@ if (!build_with_chromium) {
}
}
rtc_source_set("webrtc_common") {
# Client code SHOULD NOT USE THIS TARGET, but for now it needs to be public
# because there exists client code that uses it.
# TODO(bugs.webrtc.org/9808): Move to private visibility as soon as that
# client code gets updated.
visibility = [ "*" ]
sources = [ "common_types.h" ]
}
if (use_libfuzzer || use_afl) {
# This target is only here for gn to discover fuzzer build targets under
# webrtc/test/fuzzers/.

View file

@ -68,7 +68,6 @@ rtc_library("rtp_headers") {
]
deps = [
":array_view",
"..:webrtc_common",
"units:timestamp",
"video:video_rtp_headers",
]

View file

@ -23,7 +23,6 @@
#include "api/video/video_content_type.h"
#include "api/video/video_rotation.h"
#include "api/video/video_timing.h"
#include "common_types.h" // NOLINT (build/include)
namespace webrtc {
@ -142,7 +141,7 @@ struct RTPHeaderExtension {
bool has_video_timing;
VideoSendTiming video_timing;
PlayoutDelay playout_delay = {-1, -1};
VideoPlayoutDelay playout_delay;
// For identification of a stream when ssrc is not signaled. See
// https://tools.ietf.org/html/draft-ietf-avtext-rid-09

View file

@ -135,7 +135,6 @@ rtc_library("encoded_image") {
"..:refcountedbase",
"..:rtp_packet_info",
"..:scoped_refptr",
"../..:webrtc_common",
"../../rtc_base:checks",
"../../rtc_base:deprecation",
"../../rtc_base:rtc_base_approved",

View file

@ -25,7 +25,6 @@
#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_directory)
#include "rtc_base/checks.h"
#include "rtc_base/deprecation.h"
#include "rtc_base/ref_count.h"
@ -183,7 +182,7 @@ class RTC_EXPORT EncodedImage {
// When an application indicates non-zero values here, it is taken as an
// indication that all future frames will be constrained with those limits
// until the application indicates a change again.
PlayoutDelay playout_delay_ = {-1, -1};
VideoPlayoutDelay playout_delay_;
struct Timing {
uint8_t flags = VideoSendTiming::kInvalid;

View file

@ -100,6 +100,30 @@ struct TimingFrameInfo {
uint8_t flags; // Flags indicating validity and/or why tracing was triggered.
};
// Minimum and maximum playout delay values from capture to render.
// These are best effort values.
//
// A value < 0 indicates no change from previous valid value.
//
// min = max = 0 indicates that the receiver should try and render
// frame as soon as possible.
//
// min = x, max = y indicates that the receiver is free to adapt
// in the range (x, y) based on network jitter.
struct VideoPlayoutDelay {
VideoPlayoutDelay() = default;
VideoPlayoutDelay(int min_ms, int max_ms) : min_ms(min_ms), max_ms(max_ms) {}
int min_ms = -1;
int max_ms = -1;
bool operator==(const VideoPlayoutDelay& rhs) const {
return min_ms == rhs.min_ms && max_ms == rhs.max_ms;
}
};
// TODO(bugs.webrtc.org/7660): Old name, delete after downstream use is updated.
using PlayoutDelay = VideoPlayoutDelay;
} // namespace webrtc
#endif // API_VIDEO_VIDEO_TIMING_H_

View file

@ -1,44 +0,0 @@
/*
* Copyright (c) 2012 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 COMMON_TYPES_H_
#define COMMON_TYPES_H_
namespace webrtc {
// Minimum and maximum playout delay values from capture to render.
// These are best effort values.
//
// A value < 0 indicates no change from previous valid value.
//
// min = max = 0 indicates that the receiver should try and render
// frame as soon as possible.
//
// min = x, max = y indicates that the receiver is free to adapt
// in the range (x, y) based on network jitter.
//
// Note: Given that this gets embedded in a union, it is up-to the owner to
// initialize these values.
struct PlayoutDelay {
PlayoutDelay(int min_ms, int max_ms) : min_ms(min_ms), max_ms(max_ms) {}
int min_ms;
int max_ms;
static PlayoutDelay Noop() { return PlayoutDelay(-1, -1); }
bool IsNoop() const { return min_ms == -1 && max_ms == -1; }
bool operator==(const PlayoutDelay& rhs) const {
return min_ms == rhs.min_ms && max_ms == rhs.max_ms;
}
};
} // namespace webrtc
#endif // COMMON_TYPES_H_

View file

@ -31,7 +31,6 @@ rtc_library("goog_cc") {
":probe_controller",
":pushback_controller",
"../..:module_api",
"../../..:webrtc_common",
"../../../api:network_state_predictor_api",
"../../../api/rtc_event_log",
"../../../api/transport:field_trial_based_config",

View file

@ -354,7 +354,6 @@ rtc_library("rtp_video_header") {
"source/rtp_video_header.h",
]
deps = [
"../../:webrtc_common",
"../../api/transport/rtp:dependency_descriptor",
"../../api/video:video_frame",
"../../api/video:video_frame_type",

View file

@ -371,7 +371,7 @@ constexpr uint8_t PlayoutDelayLimits::kValueSizeBytes;
constexpr const char PlayoutDelayLimits::kUri[];
bool PlayoutDelayLimits::Parse(rtc::ArrayView<const uint8_t> data,
PlayoutDelay* playout_delay) {
VideoPlayoutDelay* playout_delay) {
RTC_DCHECK(playout_delay);
if (data.size() != 3)
return false;
@ -386,7 +386,7 @@ bool PlayoutDelayLimits::Parse(rtc::ArrayView<const uint8_t> data,
}
bool PlayoutDelayLimits::Write(rtc::ArrayView<uint8_t> data,
const PlayoutDelay& playout_delay) {
const VideoPlayoutDelay& playout_delay) {
RTC_DCHECK_EQ(data.size(), 3);
RTC_DCHECK_LE(0, playout_delay.min_ms);
RTC_DCHECK_LE(playout_delay.min_ms, playout_delay.max_ms);

View file

@ -148,7 +148,7 @@ class VideoOrientation {
class PlayoutDelayLimits {
public:
using value_type = PlayoutDelay;
using value_type = VideoPlayoutDelay;
static constexpr RTPExtensionType kId = kRtpExtensionPlayoutDelay;
static constexpr uint8_t kValueSizeBytes = 3;
static constexpr const char kUri[] =
@ -162,10 +162,10 @@ class PlayoutDelayLimits {
static constexpr int kMaxMs = 0xfff * kGranularityMs; // 40950.
static bool Parse(rtc::ArrayView<const uint8_t> data,
PlayoutDelay* playout_delay);
static size_t ValueSize(const PlayoutDelay&) { return kValueSizeBytes; }
VideoPlayoutDelay* playout_delay);
static size_t ValueSize(const VideoPlayoutDelay&) { return kValueSizeBytes; }
static bool Write(rtc::ArrayView<uint8_t> data,
const PlayoutDelay& playout_delay);
const VideoPlayoutDelay& playout_delay);
};
class VideoContentTypeExtension {

View file

@ -249,7 +249,7 @@ TEST(RtpPacketTest, CreateWithTwoByteHeaderExtensionFirst) {
packet.SetTimestamp(kTimestamp);
packet.SetSsrc(kSsrc);
// Set extension that requires two-byte header.
PlayoutDelay playoutDelay = {30, 340};
VideoPlayoutDelay playoutDelay = {30, 340};
ASSERT_TRUE(packet.SetExtension<PlayoutDelayLimits>(playoutDelay));
packet.SetExtension<TransmissionOffset>(kTimeOffset);
packet.SetExtension<AudioLevel>(kVoiceActive, kAudioLevel);
@ -273,7 +273,7 @@ TEST(RtpPacketTest, CreateWithTwoByteHeaderExtensionLast) {
EXPECT_THAT(kPacketWithTOAndAL,
ElementsAreArray(packet.data(), packet.size()));
// Set extension that requires two-byte header.
PlayoutDelay playoutDelay = {30, 340};
VideoPlayoutDelay playoutDelay = {30, 340};
ASSERT_TRUE(packet.SetExtension<PlayoutDelayLimits>(playoutDelay));
EXPECT_THAT(kPacketWithTwoByteExtensionIdLast,
ElementsAreArray(packet.data(), packet.size()));

View file

@ -111,7 +111,7 @@ const char* FrameTypeToString(VideoFrameType frame_type) {
}
#endif
bool IsNoopDelay(const PlayoutDelay& delay) {
bool IsNoopDelay(const VideoPlayoutDelay& delay) {
return delay.min_ms == -1 && delay.max_ms == -1;
}
@ -794,7 +794,7 @@ void RTPSenderVideo::MaybeUpdateCurrentPlayoutDelay(
return;
}
PlayoutDelay requested_delay = header.playout_delay;
VideoPlayoutDelay requested_delay = header.playout_delay;
if (requested_delay.min_ms > PlayoutDelayLimits::kMaxMs ||
requested_delay.max_ms > PlayoutDelayLimits::kMaxMs) {

View file

@ -185,7 +185,7 @@ class RTPSenderVideo {
RTC_GUARDED_BY(send_checker_);
// Current target playout delay.
PlayoutDelay current_playout_delay_ RTC_GUARDED_BY(send_checker_);
VideoPlayoutDelay current_playout_delay_ RTC_GUARDED_BY(send_checker_);
// Flag indicating if we need to propagate |current_playout_delay_| in order
// to guarantee it gets delivered.
bool playout_delay_pending_;

View file

@ -898,7 +898,7 @@ TEST_P(RtpSenderVideoTest, PopulatesPlayoutDelay) {
uint8_t kFrame[kPacketSize];
rtp_module_->RegisterRtpHeaderExtension(PlayoutDelayLimits::kUri,
kPlayoutDelayExtensionId);
const PlayoutDelay kExpectedDelay = {10, 20};
const VideoPlayoutDelay kExpectedDelay = {10, 20};
// Send initial key-frame without playout delay.
RTPVideoHeader hdr;
@ -918,14 +918,14 @@ TEST_P(RtpSenderVideoTest, PopulatesPlayoutDelay) {
vp8_header.temporalIdx = 1;
rtp_sender_video_->SendVideo(kPayload, kType, kTimestamp, 0, kFrame, hdr,
kDefaultExpectedRetransmissionTimeMs);
PlayoutDelay received_delay = PlayoutDelay::Noop();
VideoPlayoutDelay received_delay = VideoPlayoutDelay();
ASSERT_TRUE(transport_.last_sent_packet().GetExtension<PlayoutDelayLimits>(
&received_delay));
EXPECT_EQ(received_delay, kExpectedDelay);
// Set playout delay on a non-discardable frame, the extension should still
// be populated since dilvery wasn't guaranteed on the last one.
hdr.playout_delay = PlayoutDelay::Noop(); // Inidcates "no change".
hdr.playout_delay = VideoPlayoutDelay(); // Indicates "no change".
vp8_header.temporalIdx = 0;
rtp_sender_video_->SendVideo(kPayload, kType, kTimestamp, 0, kFrame, hdr,
kDefaultExpectedRetransmissionTimeMs);

View file

@ -23,7 +23,6 @@
#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_directory)
#include "modules/video_coding/codecs/h264/include/h264_globals.h"
#include "modules/video_coding/codecs/vp8/include/vp8_globals.h"
#include "modules/video_coding/codecs/vp9/include/vp9_globals.h"
@ -74,7 +73,7 @@ struct RTPVideoHeader {
uint8_t simulcastIdx = 0;
VideoCodecType codec = VideoCodecType::kVideoCodecGeneric;
PlayoutDelay playout_delay = {-1, -1};
VideoPlayoutDelay playout_delay;
VideoSendTiming video_timing;
absl::optional<ColorSpace> color_space;
RTPVideoTypeHeader video_type_header;

View file

@ -34,7 +34,7 @@ class RTC_EXPORT VCMEncodedFrame : protected EncodedImage {
_renderTimeMs = renderTimeMs;
}
void SetPlayoutDelay(PlayoutDelay playout_delay) {
void SetPlayoutDelay(VideoPlayoutDelay playout_delay) {
playout_delay_ = playout_delay;
}

View file

@ -280,7 +280,7 @@ TEST_F(TestFrameBuffer2, ZeroPlayoutDelay) {
VCMTiming timing(time_controller_.GetClock());
buffer_.reset(
new FrameBuffer(time_controller_.GetClock(), &timing, &stats_callback_));
const PlayoutDelay kPlayoutDelayMs = {0, 0};
const VideoPlayoutDelay kPlayoutDelayMs = {0, 0};
std::unique_ptr<FrameObjectFake> test_frame(new FrameObjectFake());
test_frame->id.picture_id = 0;
test_frame->SetPlayoutDelay(kPlayoutDelayMs);

View file

@ -100,7 +100,7 @@ void FuzzOneInput(const uint8_t* data, size_t size) {
break;
}
case kRtpExtensionPlayoutDelay: {
PlayoutDelay playout = PlayoutDelay::Noop();
VideoPlayoutDelay playout;
packet.GetExtension<PlayoutDelayLimits>(&playout);
break;
}

View file

@ -1159,11 +1159,11 @@ TEST_F(RtpVideoStreamReceiver2Test, TransformFrame) {
}
// Test default behavior and when playout delay is overridden by field trial.
const PlayoutDelay kTransmittedPlayoutDelay = {100, 200};
const PlayoutDelay kForcedPlayoutDelay = {70, 90};
const VideoPlayoutDelay kTransmittedPlayoutDelay = {100, 200};
const VideoPlayoutDelay kForcedPlayoutDelay = {70, 90};
struct PlayoutDelayOptions {
std::string field_trial;
PlayoutDelay expected_delay;
VideoPlayoutDelay expected_delay;
};
const PlayoutDelayOptions kDefaultBehavior = {
/*field_trial=*/"", /*expected_delay=*/kTransmittedPlayoutDelay};

View file

@ -1217,11 +1217,11 @@ TEST_F(RtpVideoStreamReceiverTest, TransformFrame) {
}
// Test default behavior and when playout delay is overridden by field trial.
const PlayoutDelay kTransmittedPlayoutDelay = {100, 200};
const PlayoutDelay kForcedPlayoutDelay = {70, 90};
const VideoPlayoutDelay kTransmittedPlayoutDelay = {100, 200};
const VideoPlayoutDelay kForcedPlayoutDelay = {70, 90};
struct PlayoutDelayOptions {
std::string field_trial;
PlayoutDelay expected_delay;
VideoPlayoutDelay expected_delay;
};
const PlayoutDelayOptions kDefaultBehavior = {
/*field_trial=*/"", /*expected_delay=*/kTransmittedPlayoutDelay};

View file

@ -562,7 +562,7 @@ void VideoReceiveStream::OnCompleteFrame(
}
last_complete_frame_time_ms_ = time_now_ms;
const PlayoutDelay& playout_delay = frame->EncodedImage().playout_delay_;
const VideoPlayoutDelay& playout_delay = frame->EncodedImage().playout_delay_;
if (playout_delay.min_ms >= 0) {
MutexLock lock(&playout_delay_lock_);
frame_minimum_playout_delay_ms_ = playout_delay.min_ms;

View file

@ -555,7 +555,7 @@ void VideoReceiveStream2::OnCompleteFrame(
}
last_complete_frame_time_ms_ = time_now_ms;
const PlayoutDelay& playout_delay = frame->EncodedImage().playout_delay_;
const VideoPlayoutDelay& playout_delay = frame->EncodedImage().playout_delay_;
if (playout_delay.min_ms >= 0) {
frame_minimum_playout_delay_ms_ = playout_delay.min_ms;
UpdatePlayoutDelays();

View file

@ -170,7 +170,7 @@ TEST_F(VideoReceiveStream2Test, CreateFrameFromH264FmtpSpropAndIdr) {
}
TEST_F(VideoReceiveStream2Test, PlayoutDelay) {
const PlayoutDelay kPlayoutDelayMs = {123, 321};
const VideoPlayoutDelay kPlayoutDelayMs = {123, 321};
std::unique_ptr<FrameObjectFake> test_frame(new FrameObjectFake());
test_frame->id.picture_id = 0;
test_frame->SetPlayoutDelay(kPlayoutDelayMs);
@ -200,7 +200,7 @@ TEST_F(VideoReceiveStream2Test, PlayoutDelay) {
TEST_F(VideoReceiveStream2Test, PlayoutDelayPreservesDefaultMaxValue) {
const int default_max_playout_latency = timing_->max_playout_delay();
const PlayoutDelay kPlayoutDelayMs = {123, -1};
const VideoPlayoutDelay kPlayoutDelayMs = {123, -1};
std::unique_ptr<FrameObjectFake> test_frame(new FrameObjectFake());
test_frame->id.picture_id = 0;
@ -216,7 +216,7 @@ TEST_F(VideoReceiveStream2Test, PlayoutDelayPreservesDefaultMaxValue) {
TEST_F(VideoReceiveStream2Test, PlayoutDelayPreservesDefaultMinValue) {
const int default_min_playout_latency = timing_->min_playout_delay();
const PlayoutDelay kPlayoutDelayMs = {-1, 321};
const VideoPlayoutDelay kPlayoutDelayMs = {-1, 321};
std::unique_ptr<FrameObjectFake> test_frame(new FrameObjectFake());
test_frame->id.picture_id = 0;

View file

@ -167,7 +167,7 @@ TEST_F(VideoReceiveStreamTest, CreateFrameFromH264FmtpSpropAndIdr) {
}
TEST_F(VideoReceiveStreamTest, PlayoutDelay) {
const PlayoutDelay kPlayoutDelayMs = {123, 321};
const VideoPlayoutDelay kPlayoutDelayMs = {123, 321};
std::unique_ptr<FrameObjectFake> test_frame(new FrameObjectFake());
test_frame->id.picture_id = 0;
test_frame->SetPlayoutDelay(kPlayoutDelayMs);
@ -197,7 +197,7 @@ TEST_F(VideoReceiveStreamTest, PlayoutDelay) {
TEST_F(VideoReceiveStreamTest, PlayoutDelayPreservesDefaultMaxValue) {
const int default_max_playout_latency = timing_->max_playout_delay();
const PlayoutDelay kPlayoutDelayMs = {123, -1};
const VideoPlayoutDelay kPlayoutDelayMs = {123, -1};
std::unique_ptr<FrameObjectFake> test_frame(new FrameObjectFake());
test_frame->id.picture_id = 0;
@ -213,7 +213,7 @@ TEST_F(VideoReceiveStreamTest, PlayoutDelayPreservesDefaultMaxValue) {
TEST_F(VideoReceiveStreamTest, PlayoutDelayPreservesDefaultMinValue) {
const int default_min_playout_latency = timing_->min_playout_delay();
const PlayoutDelay kPlayoutDelayMs = {-1, 321};
const VideoPlayoutDelay kPlayoutDelayMs = {-1, 321};
std::unique_ptr<FrameObjectFake> test_frame(new FrameObjectFake());
test_frame->id.picture_id = 0;