| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "base/file_path.h" | 5 #include "base/file_path.h" |
| 6 #include "base/file_util.h" | 6 #include "base/file_util.h" |
| 7 #include "base/message_loop.h" | 7 #include "base/message_loop.h" |
| 8 #include "base/path_service.h" | 8 #include "base/path_service.h" |
| 9 #include "base/ref_counted.h" | 9 #include "base/ref_counted.h" |
| 10 #include "base/scoped_ptr.h" | 10 #include "base/scoped_ptr.h" |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 virtual void OnUninitializeComplete() { | 118 virtual void OnUninitializeComplete() { |
| 119 uninit_count_++; | 119 uninit_count_++; |
| 120 } | 120 } |
| 121 virtual void OnFlushComplete() { | 121 virtual void OnFlushComplete() { |
| 122 flush_count_++; | 122 flush_count_++; |
| 123 } | 123 } |
| 124 virtual void OnSeekComplete() {} | 124 virtual void OnSeekComplete() {} |
| 125 virtual void OnError() {} | 125 virtual void OnError() {} |
| 126 virtual void OnFormatChange(VideoStreamInfo stream_info) { | 126 virtual void OnFormatChange(VideoStreamInfo stream_info) { |
| 127 format_change_count_++; | 127 format_change_count_++; |
| 128 info_.stream_info_ = stream_info; | 128 info_.stream_info = stream_info; |
| 129 } | 129 } |
| 130 virtual void ProduceVideoSample(scoped_refptr<Buffer> buffer) { | 130 virtual void ProduceVideoSample(scoped_refptr<Buffer> buffer) { |
| 131 if (reader_.get() && decoder_) { | 131 if (reader_.get() && decoder_) { |
| 132 empty_buffer_callback_count_++; | 132 empty_buffer_callback_count_++; |
| 133 scoped_refptr<DataBuffer> input; | 133 scoped_refptr<DataBuffer> input; |
| 134 reader_->ReadCallback(&input); | 134 reader_->ReadCallback(&input); |
| 135 decoder_->ConsumeVideoSample(input); | 135 decoder_->ConsumeVideoSample(input); |
| 136 } | 136 } |
| 137 } | 137 } |
| 138 virtual void ConsumeVideoFrame(scoped_refptr<VideoFrame> frame) { | 138 virtual void ConsumeVideoFrame(scoped_refptr<VideoFrame> frame) { |
| (...skipping 26 matching lines...) Expand all Loading... |
| 165 } | 165 } |
| 166 | 166 |
| 167 TEST_F(MftH264DecoderTest, DecoderUninitializedAtFirst) { | 167 TEST_F(MftH264DecoderTest, DecoderUninitializedAtFirst) { |
| 168 scoped_ptr<MftH264Decoder> decoder(new MftH264Decoder(true)); | 168 scoped_ptr<MftH264Decoder> decoder(new MftH264Decoder(true)); |
| 169 ASSERT_TRUE(decoder.get()); | 169 ASSERT_TRUE(decoder.get()); |
| 170 EXPECT_EQ(MftH264Decoder::kUninitialized, decoder->state()); | 170 EXPECT_EQ(MftH264Decoder::kUninitialized, decoder->state()); |
| 171 } | 171 } |
| 172 | 172 |
| 173 TEST_F(MftH264DecoderTest, DecoderInitMissingArgs) { | 173 TEST_F(MftH264DecoderTest, DecoderInitMissingArgs) { |
| 174 VideoCodecConfig config; | 174 VideoCodecConfig config; |
| 175 config.width_ = 800; | 175 config.width = 800; |
| 176 config.height_ = 600; | 176 config.height = 600; |
| 177 scoped_ptr<MftH264Decoder> decoder(new MftH264Decoder(false)); | 177 scoped_ptr<MftH264Decoder> decoder(new MftH264Decoder(false)); |
| 178 ASSERT_TRUE(decoder.get()); | 178 ASSERT_TRUE(decoder.get()); |
| 179 decoder->Initialize(NULL, NULL, config); | 179 decoder->Initialize(NULL, NULL, config); |
| 180 EXPECT_EQ(MftH264Decoder::kUninitialized, decoder->state()); | 180 EXPECT_EQ(MftH264Decoder::kUninitialized, decoder->state()); |
| 181 } | 181 } |
| 182 | 182 |
| 183 TEST_F(MftH264DecoderTest, DecoderInitNoDxva) { | 183 TEST_F(MftH264DecoderTest, DecoderInitNoDxva) { |
| 184 MessageLoop loop; | 184 MessageLoop loop; |
| 185 SimpleMftH264DecoderHandler handler; | 185 SimpleMftH264DecoderHandler handler; |
| 186 VideoCodecConfig config; | 186 VideoCodecConfig config; |
| 187 config.width_ = 800; | 187 config.width = 800; |
| 188 config.height_ = 600; | 188 config.height = 600; |
| 189 scoped_ptr<MftH264Decoder> decoder(new MftH264Decoder(false)); | 189 scoped_ptr<MftH264Decoder> decoder(new MftH264Decoder(false)); |
| 190 ASSERT_TRUE(decoder.get()); | 190 ASSERT_TRUE(decoder.get()); |
| 191 decoder->Initialize(&loop, &handler, config); | 191 decoder->Initialize(&loop, &handler, config); |
| 192 EXPECT_EQ(1, handler.init_count_); | 192 EXPECT_EQ(1, handler.init_count_); |
| 193 EXPECT_EQ(MftH264Decoder::kNormal, decoder->state()); | 193 EXPECT_EQ(MftH264Decoder::kNormal, decoder->state()); |
| 194 decoder->Uninitialize(); | 194 decoder->Uninitialize(); |
| 195 } | 195 } |
| 196 | 196 |
| 197 TEST_F(MftH264DecoderTest, DecoderInitDxva) { | 197 TEST_F(MftH264DecoderTest, DecoderInitDxva) { |
| 198 MessageLoop loop; | 198 MessageLoop loop; |
| 199 SimpleMftH264DecoderHandler handler; | 199 SimpleMftH264DecoderHandler handler; |
| 200 VideoCodecConfig config; | 200 VideoCodecConfig config; |
| 201 config.width_ = 800; | 201 config.width = 800; |
| 202 config.height_ = 600; | 202 config.height = 600; |
| 203 scoped_ptr<MftH264Decoder> decoder(new MftH264Decoder(true)); | 203 scoped_ptr<MftH264Decoder> decoder(new MftH264Decoder(true)); |
| 204 ASSERT_TRUE(decoder.get()); | 204 ASSERT_TRUE(decoder.get()); |
| 205 decoder->Initialize(&loop, &handler, config); | 205 decoder->Initialize(&loop, &handler, config); |
| 206 EXPECT_EQ(1, handler.init_count_); | 206 EXPECT_EQ(1, handler.init_count_); |
| 207 EXPECT_EQ(MftH264Decoder::kNormal, decoder->state()); | 207 EXPECT_EQ(MftH264Decoder::kNormal, decoder->state()); |
| 208 decoder->Uninitialize(); | 208 decoder->Uninitialize(); |
| 209 } | 209 } |
| 210 | 210 |
| 211 TEST_F(MftH264DecoderTest, DecoderUninit) { | 211 TEST_F(MftH264DecoderTest, DecoderUninit) { |
| 212 MessageLoop loop; | 212 MessageLoop loop; |
| 213 SimpleMftH264DecoderHandler handler; | 213 SimpleMftH264DecoderHandler handler; |
| 214 VideoCodecConfig config; | 214 VideoCodecConfig config; |
| 215 config.width_ = 800; | 215 config.width = 800; |
| 216 config.height_ = 600; | 216 config.height = 600; |
| 217 scoped_ptr<MftH264Decoder> decoder(new MftH264Decoder(false)); | 217 scoped_ptr<MftH264Decoder> decoder(new MftH264Decoder(false)); |
| 218 ASSERT_TRUE(decoder.get()); | 218 ASSERT_TRUE(decoder.get()); |
| 219 decoder->Initialize(&loop, &handler, config); | 219 decoder->Initialize(&loop, &handler, config); |
| 220 EXPECT_EQ(MftH264Decoder::kNormal, decoder->state()); | 220 EXPECT_EQ(MftH264Decoder::kNormal, decoder->state()); |
| 221 decoder->Uninitialize(); | 221 decoder->Uninitialize(); |
| 222 EXPECT_EQ(1, handler.uninit_count_); | 222 EXPECT_EQ(1, handler.uninit_count_); |
| 223 EXPECT_EQ(MftH264Decoder::kUninitialized, decoder->state()); | 223 EXPECT_EQ(MftH264Decoder::kUninitialized, decoder->state()); |
| 224 } | 224 } |
| 225 | 225 |
| 226 TEST_F(MftH264DecoderTest, UninitBeforeInit) { | 226 TEST_F(MftH264DecoderTest, UninitBeforeInit) { |
| 227 MessageLoop loop; | 227 MessageLoop loop; |
| 228 SimpleMftH264DecoderHandler handler; | 228 SimpleMftH264DecoderHandler handler; |
| 229 VideoCodecConfig config; | 229 VideoCodecConfig config; |
| 230 config.width_ = 800; | 230 config.width = 800; |
| 231 config.height_ = 600; | 231 config.height = 600; |
| 232 scoped_ptr<MftH264Decoder> decoder(new MftH264Decoder(false)); | 232 scoped_ptr<MftH264Decoder> decoder(new MftH264Decoder(false)); |
| 233 ASSERT_TRUE(decoder.get()); | 233 ASSERT_TRUE(decoder.get()); |
| 234 decoder->Uninitialize(); | 234 decoder->Uninitialize(); |
| 235 EXPECT_EQ(0, handler.uninit_count_); | 235 EXPECT_EQ(0, handler.uninit_count_); |
| 236 } | 236 } |
| 237 | 237 |
| 238 TEST_F(MftH264DecoderTest, InitWithNegativeDimensions) { | 238 TEST_F(MftH264DecoderTest, InitWithNegativeDimensions) { |
| 239 MessageLoop loop; | 239 MessageLoop loop; |
| 240 SimpleMftH264DecoderHandler handler; | 240 SimpleMftH264DecoderHandler handler; |
| 241 VideoCodecConfig config; | 241 VideoCodecConfig config; |
| 242 config.width_ = -123; | 242 config.width = -123; |
| 243 config.height_ = -456; | 243 config.height = -456; |
| 244 scoped_ptr<MftH264Decoder> decoder(new MftH264Decoder(false)); | 244 scoped_ptr<MftH264Decoder> decoder(new MftH264Decoder(false)); |
| 245 ASSERT_TRUE(decoder.get()); | 245 ASSERT_TRUE(decoder.get()); |
| 246 decoder->Initialize(&loop, &handler, config); | 246 decoder->Initialize(&loop, &handler, config); |
| 247 EXPECT_EQ(MftH264Decoder::kNormal, decoder->state()); | 247 EXPECT_EQ(MftH264Decoder::kNormal, decoder->state()); |
| 248 EXPECT_EQ(kDecoderMaxWidth, handler.info_.stream_info_.surface_width_); | 248 EXPECT_EQ(kDecoderMaxWidth, handler.info_.stream_info.surface_width); |
| 249 EXPECT_EQ(kDecoderMaxHeight, handler.info_.stream_info_.surface_height_); | 249 EXPECT_EQ(kDecoderMaxHeight, handler.info_.stream_info.surface_height); |
| 250 decoder->Uninitialize(); | 250 decoder->Uninitialize(); |
| 251 } | 251 } |
| 252 | 252 |
| 253 TEST_F(MftH264DecoderTest, InitWithTooHighDimensions) { | 253 TEST_F(MftH264DecoderTest, InitWithTooHighDimensions) { |
| 254 MessageLoop loop; | 254 MessageLoop loop; |
| 255 SimpleMftH264DecoderHandler handler; | 255 SimpleMftH264DecoderHandler handler; |
| 256 VideoCodecConfig config; | 256 VideoCodecConfig config; |
| 257 config.width_ = kDecoderMaxWidth + 1; | 257 config.width = kDecoderMaxWidth + 1; |
| 258 config.height_ = kDecoderMaxHeight + 1; | 258 config.height = kDecoderMaxHeight + 1; |
| 259 scoped_ptr<MftH264Decoder> decoder(new MftH264Decoder(false)); | 259 scoped_ptr<MftH264Decoder> decoder(new MftH264Decoder(false)); |
| 260 ASSERT_TRUE(decoder.get()); | 260 ASSERT_TRUE(decoder.get()); |
| 261 decoder->Initialize(&loop, &handler, config); | 261 decoder->Initialize(&loop, &handler, config); |
| 262 EXPECT_EQ(MftH264Decoder::kNormal, decoder->state()); | 262 EXPECT_EQ(MftH264Decoder::kNormal, decoder->state()); |
| 263 EXPECT_EQ(kDecoderMaxWidth, handler.info_.stream_info_.surface_width_); | 263 EXPECT_EQ(kDecoderMaxWidth, handler.info_.stream_info.surface_width); |
| 264 EXPECT_EQ(kDecoderMaxHeight, handler.info_.stream_info_.surface_height_); | 264 EXPECT_EQ(kDecoderMaxHeight, handler.info_.stream_info.surface_height); |
| 265 decoder->Uninitialize(); | 265 decoder->Uninitialize(); |
| 266 } | 266 } |
| 267 | 267 |
| 268 TEST_F(MftH264DecoderTest, DrainOnEmptyBuffer) { | 268 TEST_F(MftH264DecoderTest, DrainOnEmptyBuffer) { |
| 269 MessageLoop loop; | 269 MessageLoop loop; |
| 270 SimpleMftH264DecoderHandler handler; | 270 SimpleMftH264DecoderHandler handler; |
| 271 VideoCodecConfig config; | 271 VideoCodecConfig config; |
| 272 config.width_ = 1024; | 272 config.width = 1024; |
| 273 config.height_ = 768; | 273 config.height = 768; |
| 274 scoped_ptr<MftH264Decoder> decoder(new MftH264Decoder(false)); | 274 scoped_ptr<MftH264Decoder> decoder(new MftH264Decoder(false)); |
| 275 ASSERT_TRUE(decoder.get()); | 275 ASSERT_TRUE(decoder.get()); |
| 276 decoder->Initialize(&loop, &handler, config); | 276 decoder->Initialize(&loop, &handler, config); |
| 277 EXPECT_EQ(MftH264Decoder::kNormal, decoder->state()); | 277 EXPECT_EQ(MftH264Decoder::kNormal, decoder->state()); |
| 278 scoped_refptr<Buffer> buffer(new DataBuffer(0)); | 278 scoped_refptr<Buffer> buffer(new DataBuffer(0)); |
| 279 | 279 |
| 280 // Decoder should switch to drain mode because of this NULL buffer, and then | 280 // Decoder should switch to drain mode because of this NULL buffer, and then |
| 281 // switch to kStopped when it says it needs more input during drain mode. | 281 // switch to kStopped when it says it needs more input during drain mode. |
| 282 decoder->ConsumeVideoSample(buffer); | 282 decoder->ConsumeVideoSample(buffer); |
| 283 EXPECT_EQ(MftH264Decoder::kStopped, decoder->state()); | 283 EXPECT_EQ(MftH264Decoder::kStopped, decoder->state()); |
| 284 | 284 |
| 285 // Should have called back with one empty frame. | 285 // Should have called back with one empty frame. |
| 286 EXPECT_EQ(1, handler.fill_buffer_callback_count_); | 286 EXPECT_EQ(1, handler.fill_buffer_callback_count_); |
| 287 ASSERT_TRUE(handler.current_frame_.get()); | 287 ASSERT_TRUE(handler.current_frame_.get()); |
| 288 EXPECT_EQ(VideoFrame::EMPTY, handler.current_frame_->format()); | 288 EXPECT_EQ(VideoFrame::EMPTY, handler.current_frame_->format()); |
| 289 decoder->Uninitialize(); | 289 decoder->Uninitialize(); |
| 290 } | 290 } |
| 291 | 291 |
| 292 TEST_F(MftH264DecoderTest, NoOutputOnGarbageInput) { | 292 TEST_F(MftH264DecoderTest, NoOutputOnGarbageInput) { |
| 293 // 100 samples of garbage. | 293 // 100 samples of garbage. |
| 294 const int kNumFrames = 100; | 294 const int kNumFrames = 100; |
| 295 scoped_refptr<FakeMftReader> reader(new FakeMftReader(kNumFrames)); | 295 scoped_refptr<FakeMftReader> reader(new FakeMftReader(kNumFrames)); |
| 296 ASSERT_TRUE(reader.get()); | 296 ASSERT_TRUE(reader.get()); |
| 297 | 297 |
| 298 MessageLoop loop; | 298 MessageLoop loop; |
| 299 SimpleMftH264DecoderHandler handler; | 299 SimpleMftH264DecoderHandler handler; |
| 300 VideoCodecConfig config; | 300 VideoCodecConfig config; |
| 301 config.width_ = 1024; | 301 config.width = 1024; |
| 302 config.height_ = 768; | 302 config.height = 768; |
| 303 scoped_ptr<MftH264Decoder> decoder(new MftH264Decoder(false)); | 303 scoped_ptr<MftH264Decoder> decoder(new MftH264Decoder(false)); |
| 304 ASSERT_TRUE(decoder.get()); | 304 ASSERT_TRUE(decoder.get()); |
| 305 decoder->Initialize(&loop, &handler, config); | 305 decoder->Initialize(&loop, &handler, config); |
| 306 EXPECT_EQ(MftH264Decoder::kNormal, decoder->state()); | 306 EXPECT_EQ(MftH264Decoder::kNormal, decoder->state()); |
| 307 handler.SetReader(reader); | 307 handler.SetReader(reader); |
| 308 handler.SetDecoder(decoder.get()); | 308 handler.SetDecoder(decoder.get()); |
| 309 while (MftH264Decoder::kStopped != decoder->state()) { | 309 while (MftH264Decoder::kStopped != decoder->state()) { |
| 310 scoped_refptr<VideoFrame> frame; | 310 scoped_refptr<VideoFrame> frame; |
| 311 decoder->ProduceVideoFrame(frame); | 311 decoder->ProduceVideoFrame(frame); |
| 312 } | 312 } |
| 313 | 313 |
| 314 // Output callback should only be invoked once - the empty frame to indicate | 314 // Output callback should only be invoked once - the empty frame to indicate |
| 315 // end of stream. | 315 // end of stream. |
| 316 EXPECT_EQ(1, handler.fill_buffer_callback_count_); | 316 EXPECT_EQ(1, handler.fill_buffer_callback_count_); |
| 317 ASSERT_TRUE(handler.current_frame_.get()); | 317 ASSERT_TRUE(handler.current_frame_.get()); |
| 318 EXPECT_EQ(VideoFrame::EMPTY, handler.current_frame_->format()); | 318 EXPECT_EQ(VideoFrame::EMPTY, handler.current_frame_->format()); |
| 319 | 319 |
| 320 // One extra count because of the end of stream NULL sample. | 320 // One extra count because of the end of stream NULL sample. |
| 321 EXPECT_EQ(kNumFrames, handler.empty_buffer_callback_count_ - 1); | 321 EXPECT_EQ(kNumFrames, handler.empty_buffer_callback_count_ - 1); |
| 322 decoder->Uninitialize(); | 322 decoder->Uninitialize(); |
| 323 } | 323 } |
| 324 | 324 |
| 325 TEST_F(MftH264DecoderTest, FlushAtStart) { | 325 TEST_F(MftH264DecoderTest, FlushAtStart) { |
| 326 MessageLoop loop; | 326 MessageLoop loop; |
| 327 SimpleMftH264DecoderHandler handler; | 327 SimpleMftH264DecoderHandler handler; |
| 328 VideoCodecConfig config; | 328 VideoCodecConfig config; |
| 329 config.width_ = 1024; | 329 config.width = 1024; |
| 330 config.height_ = 768; | 330 config.height = 768; |
| 331 scoped_ptr<MftH264Decoder> decoder(new MftH264Decoder(false)); | 331 scoped_ptr<MftH264Decoder> decoder(new MftH264Decoder(false)); |
| 332 ASSERT_TRUE(decoder.get()); | 332 ASSERT_TRUE(decoder.get()); |
| 333 decoder->Initialize(&loop, &handler, config); | 333 decoder->Initialize(&loop, &handler, config); |
| 334 EXPECT_EQ(MftH264Decoder::kNormal, decoder->state()); | 334 EXPECT_EQ(MftH264Decoder::kNormal, decoder->state()); |
| 335 decoder->Flush(); | 335 decoder->Flush(); |
| 336 | 336 |
| 337 // Flush should succeed even if input/output are empty. | 337 // Flush should succeed even if input/output are empty. |
| 338 EXPECT_EQ(1, handler.flush_count_); | 338 EXPECT_EQ(1, handler.flush_count_); |
| 339 decoder->Uninitialize(); | 339 decoder->Uninitialize(); |
| 340 } | 340 } |
| 341 | 341 |
| 342 TEST_F(MftH264DecoderTest, NoFlushAtStopped) { | 342 TEST_F(MftH264DecoderTest, NoFlushAtStopped) { |
| 343 scoped_refptr<BaseMftReader> reader(new FakeMftReader()); | 343 scoped_refptr<BaseMftReader> reader(new FakeMftReader()); |
| 344 ASSERT_TRUE(reader.get()); | 344 ASSERT_TRUE(reader.get()); |
| 345 | 345 |
| 346 MessageLoop loop; | 346 MessageLoop loop; |
| 347 SimpleMftH264DecoderHandler handler; | 347 SimpleMftH264DecoderHandler handler; |
| 348 VideoCodecConfig config; | 348 VideoCodecConfig config; |
| 349 config.width_ = 1024; | 349 config.width = 1024; |
| 350 config.height_ = 768; | 350 config.height = 768; |
| 351 scoped_ptr<MftH264Decoder> decoder(new MftH264Decoder(false)); | 351 scoped_ptr<MftH264Decoder> decoder(new MftH264Decoder(false)); |
| 352 ASSERT_TRUE(decoder.get()); | 352 ASSERT_TRUE(decoder.get()); |
| 353 decoder->Initialize(&loop, &handler, config); | 353 decoder->Initialize(&loop, &handler, config); |
| 354 EXPECT_EQ(MftH264Decoder::kNormal, decoder->state()); | 354 EXPECT_EQ(MftH264Decoder::kNormal, decoder->state()); |
| 355 handler.SetReader(reader); | 355 handler.SetReader(reader); |
| 356 handler.SetDecoder(decoder.get()); | 356 handler.SetDecoder(decoder.get()); |
| 357 while (MftH264Decoder::kStopped != decoder->state()) { | 357 while (MftH264Decoder::kStopped != decoder->state()) { |
| 358 scoped_refptr<VideoFrame> frame; | 358 scoped_refptr<VideoFrame> frame; |
| 359 decoder->ProduceVideoFrame(frame); | 359 decoder->ProduceVideoFrame(frame); |
| 360 } | 360 } |
| (...skipping 21 matching lines...) Expand all Loading... |
| 382 ASSERT_TRUE(file_util::PathExists(path)); | 382 ASSERT_TRUE(file_util::PathExists(path)); |
| 383 ASSERT_TRUE(reader->InitReader(WideToASCII(path.value()))); | 383 ASSERT_TRUE(reader->InitReader(WideToASCII(path.value()))); |
| 384 int actual_width; | 384 int actual_width; |
| 385 int actual_height; | 385 int actual_height; |
| 386 ASSERT_TRUE(reader->GetWidth(&actual_width)); | 386 ASSERT_TRUE(reader->GetWidth(&actual_width)); |
| 387 ASSERT_TRUE(reader->GetHeight(&actual_height)); | 387 ASSERT_TRUE(reader->GetHeight(&actual_height)); |
| 388 | 388 |
| 389 MessageLoop loop; | 389 MessageLoop loop; |
| 390 SimpleMftH264DecoderHandler handler; | 390 SimpleMftH264DecoderHandler handler; |
| 391 VideoCodecConfig config; | 391 VideoCodecConfig config; |
| 392 config.width_ = 1; | 392 config.width = 1; |
| 393 config.height_ = 1; | 393 config.height = 1; |
| 394 scoped_ptr<MftH264Decoder> decoder(new MftH264Decoder(dxva)); | 394 scoped_ptr<MftH264Decoder> decoder(new MftH264Decoder(dxva)); |
| 395 ASSERT_TRUE(decoder.get()); | 395 ASSERT_TRUE(decoder.get()); |
| 396 decoder->Initialize(&loop, &handler, config); | 396 decoder->Initialize(&loop, &handler, config); |
| 397 EXPECT_EQ(MftH264Decoder::kNormal, decoder->state()); | 397 EXPECT_EQ(MftH264Decoder::kNormal, decoder->state()); |
| 398 handler.SetReader(reader); | 398 handler.SetReader(reader); |
| 399 handler.SetDecoder(decoder.get()); | 399 handler.SetDecoder(decoder.get()); |
| 400 while (MftH264Decoder::kStopped != decoder->state()) { | 400 while (MftH264Decoder::kStopped != decoder->state()) { |
| 401 scoped_refptr<VideoFrame> frame; | 401 scoped_refptr<VideoFrame> frame; |
| 402 decoder->ProduceVideoFrame(frame); | 402 decoder->ProduceVideoFrame(frame); |
| 403 } | 403 } |
| 404 | 404 |
| 405 // We expect a format change when decoder receives enough data to determine | 405 // We expect a format change when decoder receives enough data to determine |
| 406 // the actual frame width/height. | 406 // the actual frame width/height. |
| 407 EXPECT_GT(handler.format_change_count_, 0); | 407 EXPECT_GT(handler.format_change_count_, 0); |
| 408 EXPECT_EQ(actual_width, handler.info_.stream_info_.surface_width_); | 408 EXPECT_EQ(actual_width, handler.info_.stream_info.surface_width); |
| 409 EXPECT_EQ(actual_height, handler.info_.stream_info_.surface_height_); | 409 EXPECT_EQ(actual_height, handler.info_.stream_info.surface_height); |
| 410 EXPECT_GE(handler.empty_buffer_callback_count_, num_frames); | 410 EXPECT_GE(handler.empty_buffer_callback_count_, num_frames); |
| 411 EXPECT_EQ(num_frames, handler.fill_buffer_callback_count_ - 1); | 411 EXPECT_EQ(num_frames, handler.fill_buffer_callback_count_ - 1); |
| 412 decoder->Uninitialize(); | 412 decoder->Uninitialize(); |
| 413 } | 413 } |
| 414 | 414 |
| 415 TEST_F(MftH264DecoderTest, DecodeValidVideoDxva) { | 415 TEST_F(MftH264DecoderTest, DecodeValidVideoDxva) { |
| 416 DecodeValidVideo("bear.1280x720.mp4", 82, true); | 416 DecodeValidVideo("bear.1280x720.mp4", 82, true); |
| 417 } | 417 } |
| 418 | 418 |
| 419 TEST_F(MftH264DecoderTest, DecodeValidVideoNoDxva) { | 419 TEST_F(MftH264DecoderTest, DecodeValidVideoNoDxva) { |
| 420 DecodeValidVideo("bear.1280x720.mp4", 82, false); | 420 DecodeValidVideo("bear.1280x720.mp4", 82, false); |
| 421 } | 421 } |
| 422 | 422 |
| 423 } // namespace media | 423 } // namespace media |
| OLD | NEW |