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

Side by Side Diff: content/renderer/media/rtc_video_decoder_unittest.cc

Issue 7193001: Move rtc_video_decoder* from media/filter/ to content/renderer/media/. (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: '' Created 9 years, 5 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 <deque> 5 #include <deque>
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/memory/singleton.h" 8 #include "base/memory/singleton.h"
9 #include "base/string_util.h" 9 #include "base/string_util.h"
10 #include "content/renderer/media/rtc_video_decoder.h"
10 #include "media/base/data_buffer.h" 11 #include "media/base/data_buffer.h"
11 #include "media/base/filters.h" 12 #include "media/base/filters.h"
12 #include "media/base/limits.h" 13 #include "media/base/limits.h"
13 #include "media/base/mock_callback.h" 14 #include "media/base/mock_callback.h"
14 #include "media/base/mock_filter_host.h" 15 #include "media/base/mock_filter_host.h"
15 #include "media/base/mock_filters.h" 16 #include "media/base/mock_filters.h"
16 #include "media/base/mock_task.h" 17 #include "media/base/mock_task.h"
17 #include "media/base/video_frame.h" 18 #include "media/base/video_frame.h"
18 #include "media/filters/rtc_video_decoder.h"
19 #include "testing/gtest/include/gtest/gtest.h" 19 #include "testing/gtest/include/gtest/gtest.h"
20 20
21 using ::testing::_; 21 using ::testing::_;
22 using ::testing::AnyNumber; 22 using ::testing::AnyNumber;
23 using ::testing::DoAll; 23 using ::testing::DoAll;
24 using ::testing::Message; 24 using ::testing::Message;
25 using ::testing::Return; 25 using ::testing::Return;
26 using ::testing::ReturnNull; 26 using ::testing::ReturnNull;
27 using ::testing::SetArgumentPointee; 27 using ::testing::SetArgumentPointee;
28 using ::testing::StrictMock; 28 using ::testing::StrictMock;
29 using ::testing::WithArg; 29 using ::testing::WithArg;
30 using ::testing::Invoke; 30 using ::testing::Invoke;
31 31 using media::Limits;
32 namespace media { 32 using media::MediaFormat;
33 using media::MockStatisticsCallback;
34 using media::MockVideoRenderer;
35 using media::MockFilterHost;
36 using media::NewExpectedCallback;
37 using media::PipelineStatistics;
38 using media::PIPELINE_OK;
39 using media::StatisticsCallback;
33 40
34 class RTCVideoDecoderTest : public testing::Test { 41 class RTCVideoDecoderTest : public testing::Test {
35 protected: 42 protected:
36 static const int kWidth; 43 static const int kWidth;
37 static const int kHeight; 44 static const int kHeight;
38 static const char* kUrl; 45 static const char* kUrl;
39 static const PipelineStatistics kStatistics; 46 static const PipelineStatistics kStatistics;
40 47
41 RTCVideoDecoderTest() { 48 RTCVideoDecoderTest() {
42 MediaFormat media_format; 49 MediaFormat media_format;
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 117
111 // Expect Seek and verify the results. 118 // Expect Seek and verify the results.
112 EXPECT_CALL(*renderer_.get(), ConsumeVideoFrame(_)) 119 EXPECT_CALL(*renderer_.get(), ConsumeVideoFrame(_))
113 .Times(Limits::kMaxVideoFrames); 120 .Times(Limits::kMaxVideoFrames);
114 decoder_->Seek(kZero, NewExpectedStatusCB(PIPELINE_OK)); 121 decoder_->Seek(kZero, NewExpectedStatusCB(PIPELINE_OK));
115 122
116 message_loop_.RunAllPending(); 123 message_loop_.RunAllPending();
117 EXPECT_EQ(RTCVideoDecoder::kNormal, decoder_->state_); 124 EXPECT_EQ(RTCVideoDecoder::kNormal, decoder_->state_);
118 } 125 }
119 126
120 TEST_F(RTCVideoDecoderTest, DoDeliverFrame) { 127 TEST_F(RTCVideoDecoderTest, DoRenderFrame) {
121 const base::TimeDelta kZero; 128 const base::TimeDelta kZero;
122 EXPECT_CALL(host_, GetTime()).WillRepeatedly(Return(base::TimeDelta())); 129 EXPECT_CALL(host_, GetTime()).WillRepeatedly(Return(base::TimeDelta()));
123 130
124 InitializeDecoderSuccessfully(); 131 InitializeDecoderSuccessfully();
125 132
126 // Pass the frame back to decoder 133 // Pass the frame back to decoder
127 decoder_->set_consume_video_frame_callback( 134 decoder_->set_consume_video_frame_callback(
128 base::Bind(&RTCVideoDecoder::ProduceVideoFrame, 135 base::Bind(&RTCVideoDecoder::ProduceVideoFrame,
129 base::Unretained(decoder_.get()))); 136 base::Unretained(decoder_.get())));
130 decoder_->Seek(kZero, NewExpectedStatusCB(PIPELINE_OK)); 137 decoder_->Seek(kZero, NewExpectedStatusCB(PIPELINE_OK));
131 138
132 decoder_->set_consume_video_frame_callback( 139 decoder_->set_consume_video_frame_callback(
133 base::Bind(&MockVideoRenderer::ConsumeVideoFrame, 140 base::Bind(&MockVideoRenderer::ConsumeVideoFrame,
134 base::Unretained(renderer_.get()))); 141 base::Unretained(renderer_.get())));
135 EXPECT_CALL(*renderer_.get(), ConsumeVideoFrame(_)) 142 EXPECT_CALL(*renderer_.get(), ConsumeVideoFrame(_))
136 .Times(Limits::kMaxVideoFrames); 143 .Times(Limits::kMaxVideoFrames);
137 144
138 unsigned int video_frame_size = decoder_->width_*decoder_->height_*3/2; 145 cricket::NullVideoFrame video_frame;
139 unsigned char* video_frame = new unsigned char[video_frame_size];
140
141 for (size_t i = 0; i < Limits::kMaxVideoFrames; ++i) { 146 for (size_t i = 0; i < Limits::kMaxVideoFrames; ++i) {
142 decoder_->DeliverFrame(video_frame, video_frame_size); 147 decoder_->RenderFrame(&video_frame);
143 } 148 }
144 delete [] video_frame;
145 149
146 message_loop_.RunAllPending(); 150 message_loop_.RunAllPending();
147 EXPECT_EQ(RTCVideoDecoder::kNormal, decoder_->state_); 151 EXPECT_EQ(RTCVideoDecoder::kNormal, decoder_->state_);
148 } 152 }
149 153
150 TEST_F(RTCVideoDecoderTest, DoFrameSizeChange) { 154 TEST_F(RTCVideoDecoderTest, DoSetSize) {
151 InitializeDecoderSuccessfully(); 155 InitializeDecoderSuccessfully();
152 156
153 int new_width = kWidth * 2; 157 int new_width = kWidth * 2;
154 int new_height = kHeight * 2; 158 int new_height = kHeight * 2;
155 int new_number_of_streams = 0; 159 int reserved = 0;
156 160
157 EXPECT_CALL(host_, 161 EXPECT_CALL(host_,
158 SetVideoSize(new_width, new_height)).WillRepeatedly(Return()); 162 SetVideoSize(new_width, new_height)).WillRepeatedly(Return());
159 163
160 decoder_->FrameSizeChange(new_width, new_height, new_number_of_streams); 164 decoder_->SetSize(new_width, new_height, reserved);
161 165
162 const MediaFormat& media_format = decoder_->media_format(); 166 const MediaFormat& media_format = decoder_->media_format();
163 int width = 0; 167 int width = 0;
164 int height = 0; 168 int height = 0;
165 EXPECT_TRUE(media_format.GetAsInteger(MediaFormat::kWidth, &width)); 169 EXPECT_TRUE(media_format.GetAsInteger(MediaFormat::kWidth, &width));
166 EXPECT_EQ(new_width, width); 170 EXPECT_EQ(new_width, width);
167 EXPECT_TRUE(media_format.GetAsInteger(MediaFormat::kHeight, &height)); 171 EXPECT_TRUE(media_format.GetAsInteger(MediaFormat::kHeight, &height));
168 EXPECT_EQ(new_height, height); 172 EXPECT_EQ(new_height, height);
169 173
170 message_loop_.RunAllPending(); 174 message_loop_.RunAllPending();
171 } 175 }
172
173
174 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698