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

Side by Side Diff: media/cast/sender/video_encoder_unittest.cc

Issue 1515433002: Replace uses of raw uint32's with a type-checked RtpTimeTicks data type. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Speculative workaround fix for win8_chromium_ng compile error. Created 4 years, 11 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
« no previous file with comments | « media/cast/sender/h264_vt_encoder_unittest.cc ('k') | media/cast/sender/video_sender.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <stdint.h> 5 #include <stdint.h>
6 6
7 #include <utility> 7 #include <utility>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "base/memory/ref_counted.h" 12 #include "base/memory/ref_counted.h"
13 #include "base/memory/scoped_ptr.h" 13 #include "base/memory/scoped_ptr.h"
14 #include "build/build_config.h" 14 #include "build/build_config.h"
15 #include "media/base/video_frame.h" 15 #include "media/base/video_frame.h"
16 #include "media/cast/cast_defines.h" 16 #include "media/cast/cast_defines.h"
17 #include "media/cast/cast_environment.h" 17 #include "media/cast/cast_environment.h"
18 #include "media/cast/common/rtp_time.h"
18 #include "media/cast/sender/fake_video_encode_accelerator_factory.h" 19 #include "media/cast/sender/fake_video_encode_accelerator_factory.h"
19 #include "media/cast/sender/video_encoder.h" 20 #include "media/cast/sender/video_encoder.h"
20 #include "media/cast/sender/video_frame_factory.h" 21 #include "media/cast/sender/video_frame_factory.h"
21 #include "media/cast/test/fake_single_thread_task_runner.h" 22 #include "media/cast/test/fake_single_thread_task_runner.h"
22 #include "media/cast/test/utility/default_config.h" 23 #include "media/cast/test/utility/default_config.h"
23 #include "media/cast/test/utility/video_utility.h" 24 #include "media/cast/test/utility/video_utility.h"
24 #include "testing/gtest/include/gtest/gtest.h" 25 #include "testing/gtest/include/gtest/gtest.h"
25 26
26 #if defined(OS_MACOSX) 27 #if defined(OS_MACOSX)
27 #include "media/cast/sender/h264_vt_encoder.h" 28 #include "media/cast/sender/h264_vt_encoder.h"
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 } 165 }
165 166
166 // Requests encoding the |video_frame| and has the resulting frame delivered 167 // Requests encoding the |video_frame| and has the resulting frame delivered
167 // via a callback that checks for expected results. Returns false if the 168 // via a callback that checks for expected results. Returns false if the
168 // encoder rejected the request. 169 // encoder rejected the request.
169 bool EncodeAndCheckDelivery( 170 bool EncodeAndCheckDelivery(
170 const scoped_refptr<media::VideoFrame>& video_frame, 171 const scoped_refptr<media::VideoFrame>& video_frame,
171 uint32_t frame_id, 172 uint32_t frame_id,
172 uint32_t reference_frame_id) { 173 uint32_t reference_frame_id) {
173 return video_encoder_->EncodeVideoFrame( 174 return video_encoder_->EncodeVideoFrame(
174 video_frame, 175 video_frame, Now(),
175 Now(),
176 base::Bind(&VideoEncoderTest::DeliverEncodedVideoFrame, 176 base::Bind(&VideoEncoderTest::DeliverEncodedVideoFrame,
177 base::Unretained(this), 177 base::Unretained(this), frame_id, reference_frame_id,
178 frame_id, 178 RtpTimeTicks::FromTimeDelta(video_frame->timestamp(),
179 reference_frame_id, 179 kVideoFrequency),
180 TimeDeltaToRtpDelta(video_frame->timestamp(),
181 kVideoFrequency),
182 Now())); 180 Now()));
183 } 181 }
184 182
185 // If the implementation of |video_encoder_| is ExternalVideoEncoder, check 183 // If the implementation of |video_encoder_| is ExternalVideoEncoder, check
186 // that the VEA factory has responded (by running the callbacks) a specific 184 // that the VEA factory has responded (by running the callbacks) a specific
187 // number of times. Otherwise, check that the VEA factory is inactive. 185 // number of times. Otherwise, check that the VEA factory is inactive.
188 void ExpectVEAResponsesForExternalVideoEncoder( 186 void ExpectVEAResponsesForExternalVideoEncoder(
189 int vea_response_count, 187 int vea_response_count,
190 int shm_response_count) const { 188 int shm_response_count) const {
191 if (!vea_factory_) 189 if (!vea_factory_)
(...skipping 19 matching lines...) Expand all
211 // Create the VideoFrameFactory the first time status changes to 209 // Create the VideoFrameFactory the first time status changes to
212 // STATUS_INITIALIZED. 210 // STATUS_INITIALIZED.
213 if (operational_status_ == STATUS_INITIALIZED && !video_frame_factory_) 211 if (operational_status_ == STATUS_INITIALIZED && !video_frame_factory_)
214 video_frame_factory_ = video_encoder_->CreateVideoFrameFactory(); 212 video_frame_factory_ = video_encoder_->CreateVideoFrameFactory();
215 } 213 }
216 214
217 // Checks that |encoded_frame| matches expected values. This is the method 215 // Checks that |encoded_frame| matches expected values. This is the method
218 // bound in the callback returned from EncodeAndCheckDelivery(). 216 // bound in the callback returned from EncodeAndCheckDelivery().
219 void DeliverEncodedVideoFrame(uint32_t expected_frame_id, 217 void DeliverEncodedVideoFrame(uint32_t expected_frame_id,
220 uint32_t expected_last_referenced_frame_id, 218 uint32_t expected_last_referenced_frame_id,
221 uint32_t expected_rtp_timestamp, 219 RtpTimeTicks expected_rtp_timestamp,
222 const base::TimeTicks& expected_reference_time, 220 const base::TimeTicks& expected_reference_time,
223 scoped_ptr<SenderEncodedFrame> encoded_frame) { 221 scoped_ptr<SenderEncodedFrame> encoded_frame) {
224 EXPECT_TRUE(cast_environment_->CurrentlyOn(CastEnvironment::MAIN)); 222 EXPECT_TRUE(cast_environment_->CurrentlyOn(CastEnvironment::MAIN));
225 223
226 EXPECT_EQ(expected_frame_id, encoded_frame->frame_id); 224 EXPECT_EQ(expected_frame_id, encoded_frame->frame_id);
227 EXPECT_EQ(expected_rtp_timestamp, encoded_frame->rtp_timestamp); 225 EXPECT_EQ(expected_rtp_timestamp, encoded_frame->rtp_timestamp);
228 EXPECT_EQ(expected_reference_time, encoded_frame->reference_time); 226 EXPECT_EQ(expected_reference_time, encoded_frame->reference_time);
229 227
230 // The platform encoders are "black boxes" and may choose to vend key frames 228 // The platform encoders are "black boxes" and may choose to vend key frames
231 // and/or empty data at any time. The software encoders, however, should 229 // and/or empty data at any time. The software encoders, however, should
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
421 #endif 419 #endif
422 return values; 420 return values;
423 } 421 }
424 } // namespace 422 } // namespace
425 423
426 INSTANTIATE_TEST_CASE_P( 424 INSTANTIATE_TEST_CASE_P(
427 , VideoEncoderTest, ::testing::ValuesIn(DetermineEncodersToTest())); 425 , VideoEncoderTest, ::testing::ValuesIn(DetermineEncodersToTest()));
428 426
429 } // namespace cast 427 } // namespace cast
430 } // namespace media 428 } // namespace media
OLDNEW
« no previous file with comments | « media/cast/sender/h264_vt_encoder_unittest.cc ('k') | media/cast/sender/video_sender.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698