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

Side by Side Diff: media/cast/video_sender/external_video_encoder_unittest.cc

Issue 207593002: Cast: Enable use of VideoEncodeAccelerator for hardware video encoding (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: typedef Created 6 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 <vector> 5 #include <vector>
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/memory/ref_counted.h" 8 #include "base/memory/ref_counted.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "media/base/video_frame.h" 10 #include "media/base/video_frame.h"
11 #include "media/cast/cast_defines.h" 11 #include "media/cast/cast_defines.h"
12 #include "media/cast/cast_environment.h" 12 #include "media/cast/cast_environment.h"
13 #include "media/cast/test/fake_gpu_video_accelerator_factories.h"
14 #include "media/cast/test/fake_single_thread_task_runner.h" 13 #include "media/cast/test/fake_single_thread_task_runner.h"
15 #include "media/cast/test/fake_video_encode_accelerator.h" 14 #include "media/cast/test/fake_video_encode_accelerator.h"
16 #include "media/cast/test/utility/video_utility.h" 15 #include "media/cast/test/utility/video_utility.h"
17 #include "media/cast/video_sender/external_video_encoder.h" 16 #include "media/cast/video_sender/external_video_encoder.h"
18 #include "testing/gmock/include/gmock/gmock.h" 17 #include "testing/gmock/include/gmock/gmock.h"
19 18
20 namespace media { 19 namespace media {
21 namespace cast { 20 namespace cast {
22 21
23 using testing::_; 22 using testing::_;
24 23
25 namespace { 24 namespace {
25
26 void CreateVideoEncodeAccelerator(
27 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner,
28 scoped_ptr<VideoEncodeAccelerator> fake_vea,
29 const ReceiveVideoEncodeAcceleratorCallback& callback) {
30 callback.Run(task_runner, fake_vea.Pass());
31 }
32
33 void CreateSharedMemory(
34 size_t size, const ReceiveVideoEncodeMemoryCallback& callback) {
35 scoped_ptr<base::SharedMemory> shm(new base::SharedMemory());
36 if (!shm->CreateAndMapAnonymous(size)) {
37 NOTREACHED();
38 return;
39 }
40 callback.Run(shm.Pass());
41 }
42
26 class TestVideoEncoderCallback 43 class TestVideoEncoderCallback
27 : public base::RefCountedThreadSafe<TestVideoEncoderCallback> { 44 : public base::RefCountedThreadSafe<TestVideoEncoderCallback> {
28 public: 45 public:
29 TestVideoEncoderCallback() {} 46 TestVideoEncoderCallback() {}
30 47
31 void SetExpectedResult(bool expected_key_frame, 48 void SetExpectedResult(bool expected_key_frame,
32 uint8 expected_frame_id, 49 uint8 expected_frame_id,
33 uint8 expected_last_referenced_frame_id, 50 uint8 expected_last_referenced_frame_id,
34 const base::TimeTicks& expected_capture_time) { 51 const base::TimeTicks& expected_capture_time) {
35 expected_key_frame_ = expected_key_frame; 52 expected_key_frame_ = expected_key_frame;
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 105
89 testing_clock_ = new base::SimpleTestTickClock(); 106 testing_clock_ = new base::SimpleTestTickClock();
90 task_runner_ = new test::FakeSingleThreadTaskRunner(testing_clock_); 107 task_runner_ = new test::FakeSingleThreadTaskRunner(testing_clock_);
91 cast_environment_ = 108 cast_environment_ =
92 new CastEnvironment(scoped_ptr<base::TickClock>(testing_clock_).Pass(), 109 new CastEnvironment(scoped_ptr<base::TickClock>(testing_clock_).Pass(),
93 task_runner_, 110 task_runner_,
94 task_runner_, 111 task_runner_,
95 task_runner_, 112 task_runner_,
96 task_runner_, 113 task_runner_,
97 GetDefaultCastSenderLoggingConfig()); 114 GetDefaultCastSenderLoggingConfig());
98 video_encoder_.reset(new ExternalVideoEncoder( 115 scoped_ptr<VideoEncodeAccelerator> fake_vea(
99 cast_environment_, 116 new test::FakeVideoEncodeAccelerator());
100 video_config_, 117 video_encoder_.reset(
101 new test::FakeGpuVideoAcceleratorFactories(task_runner_))); 118 new ExternalVideoEncoder(cast_environment_,
119 video_config_,
120 base::Bind(&CreateVideoEncodeAccelerator,
121 task_runner_,
122 base::Passed(&fake_vea)),
123 base::Bind(&CreateSharedMemory)));
102 } 124 }
103 125
104 virtual ~ExternalVideoEncoderTest() {} 126 virtual ~ExternalVideoEncoderTest() {}
105 127
106 base::SimpleTestTickClock* testing_clock_; // Owned by CastEnvironment. 128 base::SimpleTestTickClock* testing_clock_; // Owned by CastEnvironment.
107 scoped_refptr<TestVideoEncoderCallback> test_video_encoder_callback_; 129 scoped_refptr<TestVideoEncoderCallback> test_video_encoder_callback_;
108 VideoSenderConfig video_config_; 130 VideoSenderConfig video_config_;
109 scoped_refptr<test::FakeSingleThreadTaskRunner> task_runner_; 131 scoped_refptr<test::FakeSingleThreadTaskRunner> task_runner_;
110 scoped_ptr<VideoEncoder> video_encoder_; 132 scoped_ptr<VideoEncoder> video_encoder_;
111 scoped_refptr<media::VideoFrame> video_frame_; 133 scoped_refptr<media::VideoFrame> video_frame_;
(...skipping 24 matching lines...) Expand all
136 video_frame_, capture_time, frame_encoded_callback)); 158 video_frame_, capture_time, frame_encoded_callback));
137 task_runner_->RunTasks(); 159 task_runner_->RunTasks();
138 } 160 }
139 // We need to run the task to cleanup the GPU instance. 161 // We need to run the task to cleanup the GPU instance.
140 video_encoder_.reset(NULL); 162 video_encoder_.reset(NULL);
141 task_runner_->RunTasks(); 163 task_runner_->RunTasks();
142 } 164 }
143 165
144 } // namespace cast 166 } // namespace cast
145 } // namespace media 167 } // namespace media
OLDNEW
« no previous file with comments | « media/cast/video_sender/external_video_encoder.cc ('k') | media/cast/video_sender/video_sender.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698