Remove dead code in cricket::FakeVideoRenderer
Remove unused accessors move helper implementation into .cc file Bug: None Change-Id: Iccd877180901b278af4800f681669089b8a046ce Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/262254 Commit-Queue: Niels Moller <nisse@webrtc.org> Auto-Submit: Danil Chapovalov <danilchap@webrtc.org> Reviewed-by: Niels Moller <nisse@webrtc.org> Cr-Commit-Position: refs/heads/main@{#36881}
This commit is contained in:
parent
181ea6e414
commit
8f44ae4fa5
@ -11,31 +11,77 @@
|
||||
#include "media/base/fake_video_renderer.h"
|
||||
|
||||
namespace cricket {
|
||||
|
||||
FakeVideoRenderer::FakeVideoRenderer() = default;
|
||||
|
||||
void FakeVideoRenderer::OnFrame(const webrtc::VideoFrame& frame) {
|
||||
webrtc::MutexLock lock(&mutex_);
|
||||
namespace {
|
||||
bool CheckFrameColorYuv(const webrtc::VideoFrame& frame) {
|
||||
// TODO(zhurunz) Check with VP8 team to see if we can remove this
|
||||
// tolerance on Y values. Some unit tests produce Y values close
|
||||
// to 16 rather than close to zero, for supposedly black frames.
|
||||
// Largest value observed is 34, e.g., running
|
||||
// PeerConnectionIntegrationTest.SendAndReceive16To9AspectRatio.
|
||||
black_frame_ = CheckFrameColorYuv(0, 48, 128, 128, 128, 128, &frame);
|
||||
// Treat unexpected frame size as error.
|
||||
static constexpr uint8_t y_min = 0;
|
||||
static constexpr uint8_t y_max = 48;
|
||||
static constexpr uint8_t u_min = 128;
|
||||
static constexpr uint8_t u_max = 128;
|
||||
static constexpr uint8_t v_min = 128;
|
||||
static constexpr uint8_t v_max = 128;
|
||||
|
||||
if (!frame.video_frame_buffer()) {
|
||||
return false;
|
||||
}
|
||||
rtc::scoped_refptr<const webrtc::I420BufferInterface> i420_buffer =
|
||||
frame.video_frame_buffer()->ToI420();
|
||||
// Y
|
||||
int y_width = frame.width();
|
||||
int y_height = frame.height();
|
||||
const uint8_t* y_plane = i420_buffer->DataY();
|
||||
const uint8_t* y_pos = y_plane;
|
||||
int32_t y_pitch = i420_buffer->StrideY();
|
||||
for (int i = 0; i < y_height; ++i) {
|
||||
for (int j = 0; j < y_width; ++j) {
|
||||
uint8_t y_value = *(y_pos + j);
|
||||
if (y_value < y_min || y_value > y_max) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
y_pos += y_pitch;
|
||||
}
|
||||
// U and V
|
||||
int chroma_width = i420_buffer->ChromaWidth();
|
||||
int chroma_height = i420_buffer->ChromaHeight();
|
||||
const uint8_t* u_plane = i420_buffer->DataU();
|
||||
const uint8_t* v_plane = i420_buffer->DataV();
|
||||
const uint8_t* u_pos = u_plane;
|
||||
const uint8_t* v_pos = v_plane;
|
||||
int32_t u_pitch = i420_buffer->StrideU();
|
||||
int32_t v_pitch = i420_buffer->StrideV();
|
||||
for (int i = 0; i < chroma_height; ++i) {
|
||||
for (int j = 0; j < chroma_width; ++j) {
|
||||
uint8_t u_value = *(u_pos + j);
|
||||
if (u_value < u_min || u_value > u_max) {
|
||||
return false;
|
||||
}
|
||||
uint8_t v_value = *(v_pos + j);
|
||||
if (v_value < v_min || v_value > v_max) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
u_pos += u_pitch;
|
||||
v_pos += v_pitch;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
FakeVideoRenderer::FakeVideoRenderer() = default;
|
||||
|
||||
void FakeVideoRenderer::OnFrame(const webrtc::VideoFrame& frame) {
|
||||
webrtc::MutexLock lock(&mutex_);
|
||||
black_frame_ = CheckFrameColorYuv(frame);
|
||||
++num_rendered_frames_;
|
||||
width_ = frame.width();
|
||||
height_ = frame.height();
|
||||
rotation_ = frame.rotation();
|
||||
timestamp_us_ = frame.timestamp_us();
|
||||
ntp_timestamp_ms_ = frame.ntp_time_ms();
|
||||
color_space_ = frame.color_space();
|
||||
packet_infos_ = frame.packet_infos();
|
||||
frame_rendered_event_.Set();
|
||||
}
|
||||
|
||||
bool FakeVideoRenderer::WaitForRenderedFrame(int64_t timeout_ms) {
|
||||
return frame_rendered_event_.Wait(timeout_ms);
|
||||
}
|
||||
|
||||
} // namespace cricket
|
||||
|
||||
@ -18,7 +18,6 @@
|
||||
#include "api/video/video_frame_buffer.h"
|
||||
#include "api/video/video_rotation.h"
|
||||
#include "api/video/video_sink_interface.h"
|
||||
#include "rtc_base/event.h"
|
||||
#include "rtc_base/synchronization/mutex.h"
|
||||
|
||||
namespace cricket {
|
||||
@ -30,8 +29,6 @@ class FakeVideoRenderer : public rtc::VideoSinkInterface<webrtc::VideoFrame> {
|
||||
|
||||
void OnFrame(const webrtc::VideoFrame& frame) override;
|
||||
|
||||
int errors() const { return errors_; }
|
||||
|
||||
int width() const {
|
||||
webrtc::MutexLock lock(&mutex_);
|
||||
return width_;
|
||||
@ -61,89 +58,14 @@ class FakeVideoRenderer : public rtc::VideoSinkInterface<webrtc::VideoFrame> {
|
||||
return black_frame_;
|
||||
}
|
||||
|
||||
int64_t ntp_time_ms() const {
|
||||
webrtc::MutexLock lock(&mutex_);
|
||||
return ntp_timestamp_ms_;
|
||||
}
|
||||
|
||||
absl::optional<webrtc::ColorSpace> color_space() const {
|
||||
webrtc::MutexLock lock(&mutex_);
|
||||
return color_space_;
|
||||
}
|
||||
|
||||
webrtc::RtpPacketInfos packet_infos() const {
|
||||
webrtc::MutexLock lock(&mutex_);
|
||||
return packet_infos_;
|
||||
}
|
||||
|
||||
bool WaitForRenderedFrame(int64_t timeout_ms);
|
||||
|
||||
private:
|
||||
static bool CheckFrameColorYuv(uint8_t y_min,
|
||||
uint8_t y_max,
|
||||
uint8_t u_min,
|
||||
uint8_t u_max,
|
||||
uint8_t v_min,
|
||||
uint8_t v_max,
|
||||
const webrtc::VideoFrame* frame) {
|
||||
if (!frame || !frame->video_frame_buffer()) {
|
||||
return false;
|
||||
}
|
||||
rtc::scoped_refptr<const webrtc::I420BufferInterface> i420_buffer =
|
||||
frame->video_frame_buffer()->ToI420();
|
||||
// Y
|
||||
int y_width = frame->width();
|
||||
int y_height = frame->height();
|
||||
const uint8_t* y_plane = i420_buffer->DataY();
|
||||
const uint8_t* y_pos = y_plane;
|
||||
int32_t y_pitch = i420_buffer->StrideY();
|
||||
for (int i = 0; i < y_height; ++i) {
|
||||
for (int j = 0; j < y_width; ++j) {
|
||||
uint8_t y_value = *(y_pos + j);
|
||||
if (y_value < y_min || y_value > y_max) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
y_pos += y_pitch;
|
||||
}
|
||||
// U and V
|
||||
int chroma_width = i420_buffer->ChromaWidth();
|
||||
int chroma_height = i420_buffer->ChromaHeight();
|
||||
const uint8_t* u_plane = i420_buffer->DataU();
|
||||
const uint8_t* v_plane = i420_buffer->DataV();
|
||||
const uint8_t* u_pos = u_plane;
|
||||
const uint8_t* v_pos = v_plane;
|
||||
int32_t u_pitch = i420_buffer->StrideU();
|
||||
int32_t v_pitch = i420_buffer->StrideV();
|
||||
for (int i = 0; i < chroma_height; ++i) {
|
||||
for (int j = 0; j < chroma_width; ++j) {
|
||||
uint8_t u_value = *(u_pos + j);
|
||||
if (u_value < u_min || u_value > u_max) {
|
||||
return false;
|
||||
}
|
||||
uint8_t v_value = *(v_pos + j);
|
||||
if (v_value < v_min || v_value > v_max) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
u_pos += u_pitch;
|
||||
v_pos += v_pitch;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
int errors_ = 0;
|
||||
int width_ = 0;
|
||||
int height_ = 0;
|
||||
webrtc::VideoRotation rotation_ = webrtc::kVideoRotation_0;
|
||||
int64_t timestamp_us_ = 0;
|
||||
int num_rendered_frames_ = 0;
|
||||
int64_t ntp_timestamp_ms_ = 0;
|
||||
bool black_frame_ = false;
|
||||
mutable webrtc::Mutex mutex_;
|
||||
rtc::Event frame_rendered_event_;
|
||||
absl::optional<webrtc::ColorSpace> color_space_;
|
||||
webrtc::RtpPacketInfos packet_infos_;
|
||||
};
|
||||
|
||||
} // namespace cricket
|
||||
|
||||
@ -229,14 +229,12 @@ class MockVideoSource : public rtc::VideoSourceInterface<webrtc::VideoFrame> {
|
||||
#define EXPECT_FRAME_WAIT(c, w, h, t) \
|
||||
EXPECT_EQ_WAIT((c), renderer_.num_rendered_frames(), (t)); \
|
||||
EXPECT_EQ((w), renderer_.width()); \
|
||||
EXPECT_EQ((h), renderer_.height()); \
|
||||
EXPECT_EQ(0, renderer_.errors());
|
||||
EXPECT_EQ((h), renderer_.height());
|
||||
|
||||
#define EXPECT_FRAME_ON_RENDERER_WAIT(r, c, w, h, t) \
|
||||
EXPECT_EQ_WAIT((c), (r).num_rendered_frames(), (t)); \
|
||||
EXPECT_EQ((w), (r).width()); \
|
||||
EXPECT_EQ((h), (r).height()); \
|
||||
EXPECT_EQ(0, (r).errors());
|
||||
EXPECT_EQ((h), (r).height());
|
||||
|
||||
namespace cricket {
|
||||
class WebRtcVideoEngineTest : public ::testing::Test {
|
||||
@ -1438,7 +1436,6 @@ class WebRtcVideoChannelEncodedFrameCallbackTest : public ::testing::Test {
|
||||
void DeliverKeyFrameAndWait(uint32_t ssrc) {
|
||||
DeliverKeyFrame(ssrc);
|
||||
EXPECT_EQ_WAIT(1, renderer_.num_rendered_frames(), kTimeout);
|
||||
EXPECT_EQ(0, renderer_.errors());
|
||||
}
|
||||
|
||||
static const std::vector<webrtc::SdpVideoFormat> kSdpVideoFormats;
|
||||
@ -1469,7 +1466,6 @@ TEST_F(WebRtcVideoChannelEncodedFrameCallbackTest,
|
||||
EXPECT_TRUE(channel_->SetSink(kSsrc, &renderer_));
|
||||
DeliverKeyFrame(kSsrc);
|
||||
EXPECT_EQ_WAIT(1, renderer_.num_rendered_frames(), kTimeout);
|
||||
EXPECT_EQ(0, renderer_.errors());
|
||||
channel_->RemoveRecvStream(kSsrc);
|
||||
}
|
||||
|
||||
@ -1483,7 +1479,6 @@ TEST_F(WebRtcVideoChannelEncodedFrameCallbackTest,
|
||||
channel_->SetRecordableEncodedFrameCallback(kSsrc, callback.AsStdFunction());
|
||||
DeliverKeyFrame(kSsrc);
|
||||
EXPECT_EQ_WAIT(1, renderer_.num_rendered_frames(), kTimeout);
|
||||
EXPECT_EQ(0, renderer_.errors());
|
||||
channel_->RemoveRecvStream(kSsrc);
|
||||
}
|
||||
|
||||
@ -1497,7 +1492,6 @@ TEST_F(WebRtcVideoChannelEncodedFrameCallbackTest,
|
||||
channel_->SetRecordableEncodedFrameCallback(kSsrc, callback.AsStdFunction());
|
||||
DeliverKeyFrame(kSsrc);
|
||||
EXPECT_EQ_WAIT(1, renderer_.num_rendered_frames(), kTimeout);
|
||||
EXPECT_EQ(0, renderer_.errors());
|
||||
channel_->RemoveRecvStream(kSsrc);
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user