Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(525)

Unified Diff: media/base/video_frame_unittest.cc

Issue 187573006: Allow wrapping a media::VideoFrame with a new view_rect. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Only allow sub rect of original view_rect. Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« media/base/video_frame.cc ('K') | « media/base/video_frame_pool.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/base/video_frame_unittest.cc
diff --git a/media/base/video_frame_unittest.cc b/media/base/video_frame_unittest.cc
index 05465d9b09dc1ec28751511bf97d205a71635378..271610d838a761590641e411b606a8c5668d2dae 100644
--- a/media/base/video_frame_unittest.cc
+++ b/media/base/video_frame_unittest.cc
@@ -200,6 +200,39 @@ TEST(VideoFrame, CreateBlackFrame) {
}
}
+static void FrameNoLongerNeededCallback(
+ const scoped_refptr<media::VideoFrame>& frame,
+ bool* triggered) {
+ *triggered = true;
+}
+
+TEST(VideoFrame, WrapVideoFrame) {
+ const int kWidth = 4;
+ const int kHeight = 4;
+ scoped_refptr<media::VideoFrame> frame;
+ bool no_longer_needed_triggered = false;
+ {
+ scoped_refptr<media::VideoFrame> wrapped_frame =
+ VideoFrame::CreateBlackFrame(gfx::Size(kWidth, kHeight));
+ ASSERT_TRUE(wrapped_frame.get());
+
+ gfx::Rect visible_rect(1, 1, 1, 1);
+ frame = media::VideoFrame::WrapVideoFrame(
+ wrapped_frame, visible_rect,
+ base::Bind(&FrameNoLongerNeededCallback, wrapped_frame,
+ &no_longer_needed_triggered));
+ EXPECT_EQ(wrapped_frame->coded_size(), frame->coded_size());
+ EXPECT_EQ(wrapped_frame->data(media::VideoFrame::kYPlane),
+ frame->data(media::VideoFrame::kYPlane));
+ EXPECT_NE(wrapped_frame->visible_rect(), frame->visible_rect());
+ EXPECT_EQ(visible_rect, frame->visible_rect());
+ }
+
+ EXPECT_FALSE(no_longer_needed_triggered);
+ frame = NULL;
+ EXPECT_TRUE(no_longer_needed_triggered);
+}
+
// Ensure each frame is properly sized and allocated. Will trigger OOB reads
// and writes as well as incorrect frame hashes otherwise.
TEST(VideoFrame, CheckFrameExtents) {
« media/base/video_frame.cc ('K') | « media/base/video_frame_pool.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698