Delete method webrtc::VideoFrame::Reset.
Mainly affects VideoCaptureInput. BUG=webrtc:5682 Review URL: https://codereview.webrtc.org/1889443002 Cr-Commit-Position: refs/heads/master@{#12439}
This commit is contained in:
@ -164,21 +164,6 @@ TEST(TestVideoFrame, ShallowCopy) {
|
||||
EXPECT_NE(frame2.rotation(), frame1.rotation());
|
||||
}
|
||||
|
||||
TEST(TestVideoFrame, Reset) {
|
||||
VideoFrame frame;
|
||||
frame.CreateEmptyFrame(5, 5, 5, 5, 5);
|
||||
frame.set_ntp_time_ms(1);
|
||||
frame.set_timestamp(2);
|
||||
frame.set_render_time_ms(3);
|
||||
ASSERT_TRUE(frame.video_frame_buffer() != NULL);
|
||||
|
||||
frame.Reset();
|
||||
EXPECT_EQ(0u, frame.ntp_time_ms());
|
||||
EXPECT_EQ(0u, frame.render_time_ms());
|
||||
EXPECT_EQ(0u, frame.timestamp());
|
||||
EXPECT_TRUE(frame.video_frame_buffer() == NULL);
|
||||
}
|
||||
|
||||
TEST(TestVideoFrame, CopyBuffer) {
|
||||
VideoFrame frame1, frame2;
|
||||
int width = 15;
|
||||
|
||||
@ -29,11 +29,12 @@ int ExpectedSize(int plane_stride, int image_height, PlaneType type) {
|
||||
return plane_stride * ((image_height + 1) / 2);
|
||||
}
|
||||
|
||||
VideoFrame::VideoFrame() {
|
||||
// Intentionally using Reset instead of initializer list so that any missed
|
||||
// fields in Reset will be caught by memory checkers.
|
||||
Reset();
|
||||
}
|
||||
VideoFrame::VideoFrame()
|
||||
: video_frame_buffer_(nullptr),
|
||||
timestamp_(0),
|
||||
ntp_time_ms_(0),
|
||||
render_time_ms_(0),
|
||||
rotation_(kVideoRotation_0) {}
|
||||
|
||||
VideoFrame::VideoFrame(const rtc::scoped_refptr<VideoFrameBuffer>& buffer,
|
||||
uint32_t timestamp,
|
||||
@ -129,14 +130,6 @@ void VideoFrame::ShallowCopy(const VideoFrame& videoFrame) {
|
||||
rotation_ = videoFrame.rotation_;
|
||||
}
|
||||
|
||||
void VideoFrame::Reset() {
|
||||
video_frame_buffer_ = nullptr;
|
||||
timestamp_ = 0;
|
||||
ntp_time_ms_ = 0;
|
||||
render_time_ms_ = 0;
|
||||
rotation_ = kVideoRotation_0;
|
||||
}
|
||||
|
||||
uint8_t* VideoFrame::buffer(PlaneType type) {
|
||||
return video_frame_buffer_ ? video_frame_buffer_->MutableData(type)
|
||||
: nullptr;
|
||||
|
||||
@ -84,10 +84,11 @@ void VideoCaptureInput::IncomingCapturedFrame(const VideoFrame& video_frame) {
|
||||
return;
|
||||
}
|
||||
|
||||
captured_frame_.ShallowCopy(incoming_frame);
|
||||
captured_frame_.reset(new VideoFrame);
|
||||
captured_frame_->ShallowCopy(incoming_frame);
|
||||
last_captured_timestamp_ = incoming_frame.ntp_time_ms();
|
||||
|
||||
overuse_detector_->FrameCaptured(captured_frame_);
|
||||
overuse_detector_->FrameCaptured(*captured_frame_);
|
||||
|
||||
TRACE_EVENT_ASYNC_BEGIN1("webrtc", "Video", video_frame.render_time_ms(),
|
||||
"render_time", video_frame.render_time_ms());
|
||||
@ -97,11 +98,11 @@ void VideoCaptureInput::IncomingCapturedFrame(const VideoFrame& video_frame) {
|
||||
|
||||
bool VideoCaptureInput::GetVideoFrame(VideoFrame* video_frame) {
|
||||
rtc::CritScope lock(&crit_);
|
||||
if (captured_frame_.IsZeroSize())
|
||||
if (!captured_frame_)
|
||||
return false;
|
||||
|
||||
*video_frame = captured_frame_;
|
||||
captured_frame_.Reset();
|
||||
*video_frame = *captured_frame_;
|
||||
captured_frame_.reset();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@ -53,7 +53,7 @@ class VideoCaptureInput : public webrtc::VideoCaptureInput {
|
||||
SendStatisticsProxy* const stats_proxy_;
|
||||
rtc::Event* const capture_event_;
|
||||
|
||||
VideoFrame captured_frame_ GUARDED_BY(crit_);
|
||||
std::unique_ptr<VideoFrame> captured_frame_ GUARDED_BY(crit_);
|
||||
Clock* const clock_;
|
||||
// Used to make sure incoming time stamp is increasing for every frame.
|
||||
int64_t last_captured_timestamp_;
|
||||
|
||||
@ -94,6 +94,7 @@ TEST_F(VideoCaptureInputTest, DoesNotRetainHandleNorCopyBuffer) {
|
||||
rtc::Event* const event_;
|
||||
};
|
||||
|
||||
{
|
||||
VideoFrame frame(
|
||||
new rtc::RefCountedObject<TestBuffer>(&frame_destroyed_event), 1, 1,
|
||||
kVideoRotation_0);
|
||||
@ -104,7 +105,7 @@ TEST_F(VideoCaptureInputTest, DoesNotRetainHandleNorCopyBuffer) {
|
||||
EXPECT_EQ(output_frames_[0]->video_frame_buffer().get(),
|
||||
frame.video_frame_buffer().get());
|
||||
output_frames_.clear();
|
||||
frame.Reset();
|
||||
}
|
||||
EXPECT_TRUE(frame_destroyed_event.Wait(FRAME_TIMEOUT_MS));
|
||||
}
|
||||
|
||||
|
||||
@ -21,6 +21,7 @@
|
||||
#include "webrtc/base/checks.h"
|
||||
#include "webrtc/base/event.h"
|
||||
#include "webrtc/base/format_macros.h"
|
||||
#include "webrtc/base/optional.h"
|
||||
#include "webrtc/base/timeutils.h"
|
||||
#include "webrtc/call.h"
|
||||
#include "webrtc/common_video/libyuv/include/webrtc_libyuv.h"
|
||||
@ -146,8 +147,8 @@ class VideoAnalyzer : public PacketReceiver,
|
||||
|
||||
{
|
||||
rtc::CritScope lock(&crit_);
|
||||
if (first_send_frame_.IsZeroSize() && rtp_timestamp_delta_ == 0)
|
||||
first_send_frame_ = copy;
|
||||
if (!first_send_timestamp_ && rtp_timestamp_delta_ == 0)
|
||||
first_send_timestamp_ = rtc::Optional<uint32_t>(copy.timestamp());
|
||||
|
||||
frames_.push_back(copy);
|
||||
}
|
||||
@ -169,8 +170,8 @@ class VideoAnalyzer : public PacketReceiver,
|
||||
rtc::CritScope lock(&crit_);
|
||||
|
||||
if (rtp_timestamp_delta_ == 0) {
|
||||
rtp_timestamp_delta_ = header.timestamp - first_send_frame_.timestamp();
|
||||
first_send_frame_.Reset();
|
||||
rtp_timestamp_delta_ = header.timestamp - *first_send_timestamp_;
|
||||
first_send_timestamp_ = rtc::Optional<uint32_t>();
|
||||
}
|
||||
int64_t timestamp =
|
||||
wrap_handler_.Unwrap(header.timestamp - rtp_timestamp_delta_);
|
||||
@ -622,7 +623,7 @@ class VideoAnalyzer : public PacketReceiver,
|
||||
std::map<int64_t, int64_t> send_times_ GUARDED_BY(crit_);
|
||||
std::map<int64_t, int64_t> recv_times_ GUARDED_BY(crit_);
|
||||
std::map<int64_t, size_t> encoded_frame_sizes_ GUARDED_BY(crit_);
|
||||
VideoFrame first_send_frame_ GUARDED_BY(crit_);
|
||||
rtc::Optional<uint32_t> first_send_timestamp_ GUARDED_BY(crit_);
|
||||
const double avg_psnr_threshold_;
|
||||
const double avg_ssim_threshold_;
|
||||
|
||||
|
||||
@ -65,9 +65,6 @@ class VideoFrame {
|
||||
// reference to the video buffer also retained by |videoFrame|.
|
||||
void ShallowCopy(const VideoFrame& videoFrame);
|
||||
|
||||
// Release frame buffer and reset time stamps.
|
||||
void Reset();
|
||||
|
||||
// Get pointer to buffer per plane.
|
||||
uint8_t* buffer(PlaneType type);
|
||||
// Overloading with const.
|
||||
|
||||
Reference in New Issue
Block a user