| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 "content/common/gpu/media/android_video_decode_accelerator.h" | 5 #include "content/common/gpu/media/android_video_decode_accelerator.h" |
| 6 | 6 |
| 7 #include "base/android/jni_android.h" | 7 #include "base/android/jni_android.h" |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 new gpu::gles2::MockGLES2Decoder()); | 65 new gpu::gles2::MockGLES2Decoder()); |
| 66 scoped_ptr<MockVideoDecodeAcceleratorClient> client( | 66 scoped_ptr<MockVideoDecodeAcceleratorClient> client( |
| 67 new MockVideoDecodeAcceleratorClient()); | 67 new MockVideoDecodeAcceleratorClient()); |
| 68 accelerator_.reset(new AndroidVideoDecodeAccelerator( | 68 accelerator_.reset(new AndroidVideoDecodeAccelerator( |
| 69 decoder->AsWeakPtr(), base::Bind(&MockMakeContextCurrent))); | 69 decoder->AsWeakPtr(), base::Bind(&MockMakeContextCurrent))); |
| 70 } | 70 } |
| 71 | 71 |
| 72 bool Configure(media::VideoCodec codec) { | 72 bool Configure(media::VideoCodec codec) { |
| 73 AndroidVideoDecodeAccelerator* accelerator = | 73 AndroidVideoDecodeAccelerator* accelerator = |
| 74 static_cast<AndroidVideoDecodeAccelerator*>(accelerator_.get()); | 74 static_cast<AndroidVideoDecodeAccelerator*>(accelerator_.get()); |
| 75 accelerator->surface_texture_ = new gfx::SurfaceTexture(0); | 75 accelerator->surface_texture_ = gfx::SurfaceTexture::Create(0); |
| 76 accelerator->codec_ = codec; | 76 accelerator->codec_ = codec; |
| 77 return accelerator->ConfigureMediaCodec(); | 77 return accelerator->ConfigureMediaCodec(); |
| 78 } | 78 } |
| 79 | 79 |
| 80 private: | 80 private: |
| 81 scoped_ptr<media::VideoDecodeAccelerator> accelerator_; | 81 scoped_ptr<media::VideoDecodeAccelerator> accelerator_; |
| 82 }; | 82 }; |
| 83 | 83 |
| 84 TEST_F(AndroidVideoDecodeAcceleratorTest, ConfigureUnsupportedCodec) { | 84 TEST_F(AndroidVideoDecodeAcceleratorTest, ConfigureUnsupportedCodec) { |
| 85 if (!media::MediaCodecBridge::IsAvailable()) | 85 if (!media::MediaCodecBridge::IsAvailable()) |
| 86 return; | 86 return; |
| 87 EXPECT_FALSE(Configure(media::kUnknownVideoCodec)); | 87 EXPECT_FALSE(Configure(media::kUnknownVideoCodec)); |
| 88 } | 88 } |
| 89 | 89 |
| 90 TEST_F(AndroidVideoDecodeAcceleratorTest, ConfigureSupportedCodec) { | 90 TEST_F(AndroidVideoDecodeAcceleratorTest, ConfigureSupportedCodec) { |
| 91 if (!media::MediaCodecBridge::IsAvailable()) | 91 if (!media::MediaCodecBridge::IsAvailable()) |
| 92 return; | 92 return; |
| 93 EXPECT_TRUE(Configure(media::kCodecVP8)); | 93 EXPECT_TRUE(Configure(media::kCodecVP8)); |
| 94 } | 94 } |
| 95 | 95 |
| 96 } // namespace content | 96 } // namespace content |
| 97 | 97 |
| 98 int main(int argc, char **argv) { | 98 int main(int argc, char **argv) { |
| 99 testing::InitGoogleTest(&argc, argv); | 99 testing::InitGoogleTest(&argc, argv); |
| 100 return RUN_ALL_TESTS(); | 100 return RUN_ALL_TESTS(); |
| 101 } | 101 } |
| OLD | NEW |