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

Side by Side Diff: media/base/video_frame_unittest.cc

Issue 1752243002: Modifying video_frame.cc to copy all metadata values, instead of only END_OF_STREAM, and updating u… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressing last comment Created 4 years, 9 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 unified diff | Download patch
« no previous file with comments | « media/base/video_frame_metadata.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "media/base/video_frame.h" 5 #include "media/base/video_frame.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 222
223 static void FrameNoLongerNeededCallback( 223 static void FrameNoLongerNeededCallback(
224 const scoped_refptr<media::VideoFrame>& frame, 224 const scoped_refptr<media::VideoFrame>& frame,
225 bool* triggered) { 225 bool* triggered) {
226 *triggered = true; 226 *triggered = true;
227 } 227 }
228 228
229 TEST(VideoFrame, WrapVideoFrame) { 229 TEST(VideoFrame, WrapVideoFrame) {
230 const int kWidth = 4; 230 const int kWidth = 4;
231 const int kHeight = 4; 231 const int kHeight = 4;
232 const base::TimeDelta kFrameDuration = base::TimeDelta::FromMicroseconds(42);
233
232 scoped_refptr<media::VideoFrame> frame; 234 scoped_refptr<media::VideoFrame> frame;
233 bool done_callback_was_run = false; 235 bool done_callback_was_run = false;
234 { 236 {
235 scoped_refptr<media::VideoFrame> wrapped_frame = 237 scoped_refptr<media::VideoFrame> wrapped_frame =
236 VideoFrame::CreateBlackFrame(gfx::Size(kWidth, kHeight)); 238 VideoFrame::CreateBlackFrame(gfx::Size(kWidth, kHeight));
237 ASSERT_TRUE(wrapped_frame.get()); 239 ASSERT_TRUE(wrapped_frame.get());
238 240
239 gfx::Rect visible_rect(1, 1, 1, 1); 241 gfx::Rect visible_rect(1, 1, 1, 1);
240 gfx::Size natural_size = visible_rect.size(); 242 gfx::Size natural_size = visible_rect.size();
241 frame = media::VideoFrame::WrapVideoFrame( 243 wrapped_frame->metadata()->SetTimeDelta(
242 wrapped_frame, visible_rect, natural_size); 244 media::VideoFrameMetadata::FRAME_DURATION, kFrameDuration);
243 frame->AddDestructionObserver( 245 frame = media::VideoFrame::WrapVideoFrame(wrapped_frame, visible_rect,
244 base::Bind(&FrameNoLongerNeededCallback, wrapped_frame, 246 natural_size);
245 &done_callback_was_run)); 247 frame->AddDestructionObserver(base::Bind(
248 &FrameNoLongerNeededCallback, wrapped_frame, &done_callback_was_run));
249
246 EXPECT_EQ(wrapped_frame->coded_size(), frame->coded_size()); 250 EXPECT_EQ(wrapped_frame->coded_size(), frame->coded_size());
247 EXPECT_EQ(wrapped_frame->data(media::VideoFrame::kYPlane), 251 EXPECT_EQ(wrapped_frame->data(media::VideoFrame::kYPlane),
248 frame->data(media::VideoFrame::kYPlane)); 252 frame->data(media::VideoFrame::kYPlane));
249 EXPECT_NE(wrapped_frame->visible_rect(), frame->visible_rect()); 253 EXPECT_NE(wrapped_frame->visible_rect(), frame->visible_rect());
250 EXPECT_EQ(visible_rect, frame->visible_rect()); 254 EXPECT_EQ(visible_rect, frame->visible_rect());
251 EXPECT_NE(wrapped_frame->natural_size(), frame->natural_size()); 255 EXPECT_NE(wrapped_frame->natural_size(), frame->natural_size());
252 EXPECT_EQ(natural_size, frame->natural_size()); 256 EXPECT_EQ(natural_size, frame->natural_size());
257
258 // Verify metadata was copied to the wrapped frame.
259 base::TimeDelta frame_duration;
260 ASSERT_TRUE(frame->metadata()->GetTimeDelta(
261 media::VideoFrameMetadata::FRAME_DURATION, &frame_duration));
262
263 EXPECT_EQ(frame_duration, kFrameDuration);
264
265 // Verify the metadata copy was a deep copy.
266 wrapped_frame->metadata()->Clear();
267 EXPECT_NE(
268 wrapped_frame->metadata()->HasKey(
269 media::VideoFrameMetadata::FRAME_DURATION),
270 frame->metadata()->HasKey(media::VideoFrameMetadata::FRAME_DURATION));
253 } 271 }
254 272
255 EXPECT_FALSE(done_callback_was_run); 273 EXPECT_FALSE(done_callback_was_run);
256 frame = NULL; 274 frame = NULL;
257 EXPECT_TRUE(done_callback_was_run); 275 EXPECT_TRUE(done_callback_was_run);
258 } 276 }
259 277
260 // Ensure each frame is properly sized and allocated. Will trigger OOB reads 278 // Ensure each frame is properly sized and allocated. Will trigger OOB reads
261 // and writes as well as incorrect frame hashes otherwise. 279 // and writes as well as incorrect frame hashes otherwise.
262 TEST(VideoFrame, CheckFrameExtents) { 280 TEST(VideoFrame, CheckFrameExtents) {
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
489 507
490 for (int i = 0; i < VideoFrameMetadata::NUM_KEYS; ++i) { 508 for (int i = 0; i < VideoFrameMetadata::NUM_KEYS; ++i) {
491 const VideoFrameMetadata::Key key = static_cast<VideoFrameMetadata::Key>(i); 509 const VideoFrameMetadata::Key key = static_cast<VideoFrameMetadata::Key>(i);
492 int value = -1; 510 int value = -1;
493 EXPECT_TRUE(result.GetInteger(key, &value)); 511 EXPECT_TRUE(result.GetInteger(key, &value));
494 EXPECT_EQ(i, value); 512 EXPECT_EQ(i, value);
495 } 513 }
496 } 514 }
497 515
498 } // namespace media 516 } // namespace media
OLDNEW
« no previous file with comments | « media/base/video_frame_metadata.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698