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

Side by Side Diff: media/mojo/services/mojo_cdm_allocator_unittest.cc

Issue 2908303003: media: Create Mojo StructTraits for VideoFrame (Closed)
Patch Set: Eagerly initialize the context object. Created 3 years, 6 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
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 <stddef.h> 5 #include <stddef.h>
6 #include <stdint.h> 6 #include <stdint.h>
7 7
8 #include <cstring> 8 #include <cstring>
9 9
10 #include "base/macros.h" 10 #include "base/macros.h"
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 for (int i = 0; i < 10; ++i) { 79 for (int i = 0; i < 10; ++i) {
80 buffer_size += kBufferSizeIncrease; 80 buffer_size += kBufferSizeIncrease;
81 cdm::Buffer* buffer = CreateCdmBuffer(buffer_size); 81 cdm::Buffer* buffer = CreateCdmBuffer(buffer_size);
82 buffer->Destroy(); 82 buffer->Destroy();
83 EXPECT_LE(GetAvailableBufferCount(), kMaxExpectedFreeBuffers); 83 EXPECT_LE(GetAvailableBufferCount(), kMaxExpectedFreeBuffers);
84 } 84 }
85 } 85 }
86 86
87 TEST_F(MojoCdmAllocatorTest, CreateCdmVideoFrame) { 87 TEST_F(MojoCdmAllocatorTest, CreateCdmVideoFrame) {
88 const int kHeight = 16; 88 const int kHeight = 16;
89 const int kWidth = 9; 89 const int kWidth = 9;
xhwang 2017/06/09 16:54:52 nit: It's odd that width < height. Switch the valu
sandersd (OOO until July 31) 2017/06/09 18:26:33 Done.
90 const VideoPixelFormat kFormat = PIXEL_FORMAT_I420; 90 const VideoPixelFormat kFormat = PIXEL_FORMAT_I420;
91 const gfx::Size kSize(kHeight, kWidth); 91 const gfx::Size kSize(kHeight, kWidth);
xhwang 2017/06/09 16:54:52 hmm, this should also be (kWidth, kHeight)?
sandersd (OOO until July 31) 2017/06/09 18:26:33 Done.
92 const size_t kBufferSize = VideoFrame::AllocationSize(kFormat, kSize); 92 const size_t kBufferSize = VideoFrame::AllocationSize(kFormat, kSize);
93 93
94 // Create a VideoFrameImpl and initialize it. 94 // Create a VideoFrameImpl and initialize it.
95 std::unique_ptr<VideoFrameImpl> video_frame = CreateCdmVideoFrame(); 95 std::unique_ptr<VideoFrameImpl> video_frame = CreateCdmVideoFrame();
96 video_frame->SetFormat(cdm::kI420); 96 video_frame->SetFormat(cdm::kI420);
97 video_frame->SetSize(cdm::Size(kHeight, kWidth)); 97 video_frame->SetSize(cdm::Size(kWidth, kHeight));
98 video_frame->SetStride(VideoFrameImpl::kYPlane, 98 video_frame->SetStride(VideoFrameImpl::kYPlane,
99 static_cast<uint32_t>(VideoFrame::RowBytes( 99 static_cast<uint32_t>(VideoFrame::RowBytes(
100 VideoFrame::kYPlane, kFormat, kWidth))); 100 VideoFrame::kYPlane, kFormat, kWidth)));
101 video_frame->SetStride(VideoFrameImpl::kUPlane, 101 video_frame->SetStride(VideoFrameImpl::kUPlane,
102 static_cast<uint32_t>(VideoFrame::RowBytes( 102 static_cast<uint32_t>(VideoFrame::RowBytes(
103 VideoFrame::kUPlane, kFormat, kWidth))); 103 VideoFrame::kUPlane, kFormat, kWidth)));
104 video_frame->SetStride(VideoFrameImpl::kVPlane, 104 video_frame->SetStride(VideoFrameImpl::kVPlane,
105 static_cast<uint32_t>(VideoFrame::RowBytes( 105 static_cast<uint32_t>(VideoFrame::RowBytes(
106 VideoFrame::kVPlane, kFormat, kWidth))); 106 VideoFrame::kVPlane, kFormat, kWidth)));
107 EXPECT_EQ(nullptr, video_frame->FrameBuffer()); 107 EXPECT_EQ(nullptr, video_frame->FrameBuffer());
(...skipping 14 matching lines...) Expand all
122 // Check that the buffer is still in use. It will be freed when |frame| 122 // Check that the buffer is still in use. It will be freed when |frame|
123 // is destroyed. 123 // is destroyed.
124 EXPECT_EQ(0u, GetAvailableBufferCount()); 124 EXPECT_EQ(0u, GetAvailableBufferCount());
125 frame = nullptr; 125 frame = nullptr;
126 126
127 // Check that the buffer is now in the free list. 127 // Check that the buffer is now in the free list.
128 EXPECT_EQ(1u, GetAvailableBufferCount()); 128 EXPECT_EQ(1u, GetAvailableBufferCount());
129 } 129 }
130 130
131 } // namespace media 131 } // namespace media
OLDNEW
« no previous file with comments | « media/mojo/interfaces/video_frame_struct_traits_unittest.cc ('k') | media/mojo/services/mojo_decryptor_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698