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

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

Issue 955253002: Add metadata to media::VideoFrame and plumb it through IPC/MediaStream. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: tommi's nits addressed Created 5 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') | media/cast/sender/video_sender.cc » ('j') | 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 "base/bind.h" 7 #include "base/bind.h"
8 #include "base/callback_helpers.h" 8 #include "base/callback_helpers.h"
9 #include "base/format_macros.h" 9 #include "base/format_macros.h"
10 #include "base/memory/aligned_memory.h" 10 #include "base/memory/aligned_memory.h"
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after
321 const base::TimeDelta kTimestamp = base::TimeDelta::FromMicroseconds(1337); 321 const base::TimeDelta kTimestamp = base::TimeDelta::FromMicroseconds(1337);
322 322
323 gfx::Size size(kWidth, kHeight); 323 gfx::Size size(kWidth, kHeight);
324 scoped_refptr<media::VideoFrame> frame = VideoFrame::CreateFrame( 324 scoped_refptr<media::VideoFrame> frame = VideoFrame::CreateFrame(
325 media::VideoFrame::YV12, size, gfx::Rect(size), size, kTimestamp); 325 media::VideoFrame::YV12, size, gfx::Rect(size), size, kTimestamp);
326 326
327 for (size_t i = 0; i < VideoFrame::NumPlanes(frame->format()); ++i) 327 for (size_t i = 0; i < VideoFrame::NumPlanes(frame->format()); ++i)
328 EXPECT_EQ(0, frame->data(i)[0]); 328 EXPECT_EQ(0, frame->data(i)[0]);
329 } 329 }
330 330
331 TEST(VideoFrameMetadata, SetAndThenGetAllKeysForAllTypes) {
332 VideoFrameMetadata metadata;
333
334 for (int i = 0; i < VideoFrameMetadata::NUM_KEYS; ++i) {
335 const VideoFrameMetadata::Key key = static_cast<VideoFrameMetadata::Key>(i);
336
337 EXPECT_FALSE(metadata.HasKey(key));
338 metadata.SetBoolean(key, true);
339 EXPECT_TRUE(metadata.HasKey(key));
340 bool bool_value = false;
341 EXPECT_TRUE(metadata.GetBoolean(key, &bool_value));
342 EXPECT_EQ(true, bool_value);
343 metadata.Clear();
344
345 EXPECT_FALSE(metadata.HasKey(key));
346 metadata.SetInteger(key, i);
347 EXPECT_TRUE(metadata.HasKey(key));
348 int int_value = -999;
349 EXPECT_TRUE(metadata.GetInteger(key, &int_value));
350 EXPECT_EQ(i, int_value);
351 metadata.Clear();
352
353 EXPECT_FALSE(metadata.HasKey(key));
354 metadata.SetDouble(key, 3.14 * i);
355 EXPECT_TRUE(metadata.HasKey(key));
356 double double_value = -999.99;
357 EXPECT_TRUE(metadata.GetDouble(key, &double_value));
358 EXPECT_EQ(3.14 * i, double_value);
359 metadata.Clear();
360
361 EXPECT_FALSE(metadata.HasKey(key));
362 metadata.SetString(key, base::StringPrintf("\xfe%d\xff", i));
363 EXPECT_TRUE(metadata.HasKey(key));
364 std::string string_value;
365 EXPECT_TRUE(metadata.GetString(key, &string_value));
366 EXPECT_EQ(base::StringPrintf("\xfe%d\xff", i), string_value);
367 metadata.Clear();
368
369 EXPECT_FALSE(metadata.HasKey(key));
370 metadata.SetTimeTicks(key, base::TimeTicks::FromInternalValue(~(0LL) + i));
371 EXPECT_TRUE(metadata.HasKey(key));
372 base::TimeTicks ticks_value;
373 EXPECT_TRUE(metadata.GetTimeTicks(key, &ticks_value));
374 EXPECT_EQ(base::TimeTicks::FromInternalValue(~(0LL) + i), ticks_value);
375 metadata.Clear();
376
377 EXPECT_FALSE(metadata.HasKey(key));
378 metadata.SetValue(key,
379 scoped_ptr<base::Value>(base::Value::CreateNullValue()));
380 EXPECT_TRUE(metadata.HasKey(key));
381 const base::Value* const null_value = metadata.GetValue(key);
382 EXPECT_TRUE(null_value);
383 EXPECT_EQ(base::Value::TYPE_NULL, null_value->GetType());
384 metadata.Clear();
385 }
386 }
387
388 TEST(VideoFrameMetadata, PassMetadataViaIntermediary) {
389 VideoFrameMetadata expected;
390 for (int i = 0; i < VideoFrameMetadata::NUM_KEYS; ++i) {
391 const VideoFrameMetadata::Key key = static_cast<VideoFrameMetadata::Key>(i);
392 expected.SetInteger(key, i);
393 }
394
395 base::DictionaryValue tmp;
396 expected.MergeInternalValuesInto(&tmp);
397 EXPECT_EQ(static_cast<size_t>(VideoFrameMetadata::NUM_KEYS), tmp.size());
398
399 VideoFrameMetadata result;
400 result.MergeInternalValuesFrom(tmp);
401
402 for (int i = 0; i < VideoFrameMetadata::NUM_KEYS; ++i) {
403 const VideoFrameMetadata::Key key = static_cast<VideoFrameMetadata::Key>(i);
404 int value = -1;
405 EXPECT_TRUE(result.GetInteger(key, &value));
406 EXPECT_EQ(i, value);
407 }
408 }
409
331 } // namespace media 410 } // namespace media
OLDNEW
« no previous file with comments | « media/base/video_frame_metadata.cc ('k') | media/cast/sender/video_sender.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698