diff --git a/webrtc/common_video/i420_video_frame.cc b/webrtc/common_video/i420_video_frame.cc index a0ade46185..dcead6289c 100644 --- a/webrtc/common_video/i420_video_frame.cc +++ b/webrtc/common_video/i420_video_frame.cc @@ -159,17 +159,6 @@ void I420VideoFrame::ShallowCopy(const I420VideoFrame& videoFrame) { rotation_ = videoFrame.rotation_; } -I420VideoFrame* I420VideoFrame::CloneFrame() const { - rtc::scoped_ptr new_frame(new I420VideoFrame()); - if (new_frame->CopyFrame(*this) == -1) { - // TODO(pbos): Make void, not war. - // CopyFrame failed this shouldn't happen. - RTC_NOTREACHED(); - return NULL; - } - return new_frame.release(); -} - void I420VideoFrame::SwapFrame(I420VideoFrame* videoFrame) { video_frame_buffer_.swap(videoFrame->video_frame_buffer_); std::swap(timestamp_, videoFrame->timestamp_); diff --git a/webrtc/common_video/i420_video_frame_unittest.cc b/webrtc/common_video/i420_video_frame_unittest.cc index 44d5060829..5e223a72ad 100644 --- a/webrtc/common_video/i420_video_frame_unittest.cc +++ b/webrtc/common_video/i420_video_frame_unittest.cc @@ -199,28 +199,6 @@ TEST(TestI420VideoFrame, Reset) { EXPECT_TRUE(frame.video_frame_buffer() == NULL); } -TEST(TestI420VideoFrame, CloneFrame) { - I420VideoFrame frame1; - rtc::scoped_ptr frame2; - const int kSizeY = 400; - const int kSizeU = 100; - const int kSizeV = 100; - uint8_t buffer_y[kSizeY]; - uint8_t buffer_u[kSizeU]; - uint8_t buffer_v[kSizeV]; - memset(buffer_y, 16, kSizeY); - memset(buffer_u, 8, kSizeU); - memset(buffer_v, 4, kSizeV); - frame1.CreateFrame(buffer_y, buffer_u, buffer_v, 20, 20, 20, 10, 10); - frame1.set_timestamp(1); - frame1.set_ntp_time_ms(2); - frame1.set_render_time_ms(3); - - frame2.reset(frame1.CloneFrame()); - EXPECT_TRUE(frame2.get() != NULL); - EXPECT_TRUE(EqualFrames(frame1, *frame2)); -} - TEST(TestI420VideoFrame, CopyBuffer) { I420VideoFrame frame1, frame2; int width = 15; @@ -365,14 +343,6 @@ TEST(TestI420VideoFrame, RefCount) { EXPECT_EQ(0, handle.ref_count()); } -TEST(TestI420VideoFrame, CloneTextureFrame) { - NativeHandleImpl handle; - I420VideoFrame frame1(&handle, 640, 480, 100, 200); - rtc::scoped_ptr frame2(frame1.CloneFrame()); - EXPECT_TRUE(frame2.get() != NULL); - EXPECT_TRUE(EqualTextureFrames(frame1, *frame2)); -} - bool EqualPlane(const uint8_t* data1, const uint8_t* data2, int stride, diff --git a/webrtc/video/video_send_stream_tests.cc b/webrtc/video/video_send_stream_tests.cc index 19fe076194..9ba3b6206a 100644 --- a/webrtc/video/video_send_stream_tests.cc +++ b/webrtc/video/video_send_stream_tests.cc @@ -8,6 +8,7 @@ * be found in the AUTHORS file in the root of the source tree. */ #include // max +#include #include "testing/gtest/include/gtest/gtest.h" @@ -24,7 +25,6 @@ #include "webrtc/system_wrappers/interface/critical_section_wrapper.h" #include "webrtc/system_wrappers/interface/event_wrapper.h" #include "webrtc/system_wrappers/interface/ref_count.h" -#include "webrtc/system_wrappers/interface/scoped_vector.h" #include "webrtc/system_wrappers/interface/sleep.h" #include "webrtc/system_wrappers/interface/thread_wrapper.h" #include "webrtc/system_wrappers/interface/logging.h" @@ -46,9 +46,9 @@ void ExpectEqualTextureFrames(const I420VideoFrame& frame1, const I420VideoFrame& frame2); void ExpectEqualBufferFrames(const I420VideoFrame& frame1, const I420VideoFrame& frame2); -void ExpectEqualFramesVector(const std::vector& frames1, - const std::vector& frames2); -I420VideoFrame* CreateI420VideoFrame(int width, int height, uint8_t data); +void ExpectEqualFramesVector(const std::vector& frames1, + const std::vector& frames2); +I420VideoFrame CreateI420VideoFrame(int width, int height, uint8_t data); class FakeNativeHandle : public NativeHandle { public: @@ -1031,8 +1031,7 @@ TEST_F(VideoSendStreamTest, CapturesTextureAndI420VideoFrames) { FrameObserver() : output_frame_event_(EventWrapper::Create()) {} void FrameCallback(I420VideoFrame* video_frame) override { - // Clone the frame because the caller owns it. - output_frames_.push_back(video_frame->CloneFrame()); + output_frames_.push_back(*video_frame); output_frame_event_->Set(); } @@ -1042,13 +1041,13 @@ TEST_F(VideoSendStreamTest, CapturesTextureAndI420VideoFrames) { << "Timeout while waiting for output frames."; } - const std::vector& output_frames() const { - return output_frames_.get(); + const std::vector& output_frames() const { + return output_frames_; } private: // Delivered output frames. - ScopedVector output_frames_; + std::vector output_frames_; // Indicate an output frame has arrived. rtc::scoped_ptr output_frame_event_; @@ -1065,7 +1064,7 @@ TEST_F(VideoSendStreamTest, CapturesTextureAndI420VideoFrames) { // Prepare five input frames. Send ordinary I420VideoFrame and texture frames // alternatively. - ScopedVector input_frames; + std::vector input_frames; int width = static_cast(encoder_config_.streams[0].width); int height = static_cast(encoder_config_.streams[0].height); webrtc::RefCountImpl* handle1 = @@ -1074,15 +1073,15 @@ TEST_F(VideoSendStreamTest, CapturesTextureAndI420VideoFrames) { new webrtc::RefCountImpl(); webrtc::RefCountImpl* handle3 = new webrtc::RefCountImpl(); - input_frames.push_back(new I420VideoFrame(handle1, width, height, 1, 1)); - input_frames.push_back(new I420VideoFrame(handle2, width, height, 2, 2)); + input_frames.push_back(I420VideoFrame(handle1, width, height, 1, 1)); + input_frames.push_back(I420VideoFrame(handle2, width, height, 2, 2)); input_frames.push_back(CreateI420VideoFrame(width, height, 3)); input_frames.push_back(CreateI420VideoFrame(width, height, 4)); - input_frames.push_back(new I420VideoFrame(handle3, width, height, 5, 5)); + input_frames.push_back(I420VideoFrame(handle3, width, height, 5, 5)); send_stream_->Start(); for (size_t i = 0; i < input_frames.size(); i++) { - send_stream_->Input()->IncomingCapturedFrame(*input_frames[i]); + send_stream_->Input()->IncomingCapturedFrame(input_frames[i]); // Do not send the next frame too fast, so the frame dropper won't drop it. if (i < input_frames.size() - 1) SleepMs(1000 / encoder_config_.streams[0].max_framerate); @@ -1094,7 +1093,7 @@ TEST_F(VideoSendStreamTest, CapturesTextureAndI420VideoFrames) { // Test if the input and output frames are the same. render_time_ms and // timestamp are not compared because capturer sets those values. - ExpectEqualFramesVector(input_frames.get(), observer.output_frames()); + ExpectEqualFramesVector(input_frames, observer.output_frames()); DestroyStreams(); } @@ -1140,28 +1139,22 @@ void ExpectEqualBufferFrames(const I420VideoFrame& frame1, frame1.allocated_size(kVPlane))); } -void ExpectEqualFramesVector(const std::vector& frames1, - const std::vector& frames2) { +void ExpectEqualFramesVector(const std::vector& frames1, + const std::vector& frames2) { EXPECT_EQ(frames1.size(), frames2.size()); for (size_t i = 0; i < std::min(frames1.size(), frames2.size()); ++i) - ExpectEqualFrames(*frames1[i], *frames2[i]); + ExpectEqualFrames(frames1[i], frames2[i]); } -I420VideoFrame* CreateI420VideoFrame(int width, int height, uint8_t data) { - I420VideoFrame* frame = new I420VideoFrame(); +I420VideoFrame CreateI420VideoFrame(int width, int height, uint8_t data) { const int kSizeY = width * height * 2; rtc::scoped_ptr buffer(new uint8_t[kSizeY]); memset(buffer.get(), data, kSizeY); - frame->CreateFrame(buffer.get(), - buffer.get(), - buffer.get(), - width, - height, - width, - width / 2, - width / 2); - frame->set_timestamp(data); - frame->set_render_time_ms(data); + I420VideoFrame frame; + frame.CreateFrame(buffer.get(), buffer.get(), buffer.get(), width, height, + width, width / 2, width / 2); + frame.set_timestamp(data); + frame.set_render_time_ms(data); return frame; } diff --git a/webrtc/video_frame.h b/webrtc/video_frame.h index d2f94fe0b5..353d7e2a6a 100644 --- a/webrtc/video_frame.h +++ b/webrtc/video_frame.h @@ -87,10 +87,6 @@ class I420VideoFrame { // reference to the video buffer also retained by |videoFrame|. void ShallowCopy(const I420VideoFrame& videoFrame); - // Make a copy of |this|. The caller owns the returned frame. - // Return value: a new frame on success, NULL on error. - I420VideoFrame* CloneFrame() const; - // Swap Frame. void SwapFrame(I420VideoFrame* videoFrame);