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

Side by Side Diff: media/cast/test/end2end_unittest.cc

Issue 288103002: [Cast] EncodedAudioFrame+EncodedVideoFrame+reference_time --> EncodedFrame (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 7 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
« no previous file with comments | « media/cast/test/encode_decode_test.cc ('k') | media/cast/transport/cast_transport_config.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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 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 // This test generate synthetic data. For audio it's a sinusoid waveform with 5 // This test generate synthetic data. For audio it's a sinusoid waveform with
6 // frequency kSoundFrequency and different amplitudes. For video it's a pattern 6 // frequency kSoundFrequency and different amplitudes. For video it's a pattern
7 // that is shifting by one pixel per frame, each pixels neighbors right and down 7 // that is shifting by one pixel per frame, each pixels neighbors right and down
8 // is this pixels value +1, since the pixel value is 8 bit it will wrap 8 // is this pixels value +1, since the pixel value is 8 bit it will wrap
9 // frequently within the image. Visually this will create diagonally color bands 9 // frequently within the image. Visually this will create diagonally color bands
10 // that moves across the screen 10 // that moves across the screen
11 11
12 #include <math.h> 12 #include <math.h>
13 #include <stdint.h> 13 #include <stdint.h>
14 14
15 #include <functional> 15 #include <functional>
16 #include <list> 16 #include <list>
17 #include <map> 17 #include <map>
18 18
19 #include "base/bind.h" 19 #include "base/bind.h"
20 #include "base/bind_helpers.h" 20 #include "base/bind_helpers.h"
21 #include "base/stl_util.h"
22 #include "base/strings/string_number_conversions.h" 21 #include "base/strings/string_number_conversions.h"
23 #include "base/sys_byteorder.h" 22 #include "base/sys_byteorder.h"
24 #include "base/test/simple_test_tick_clock.h" 23 #include "base/test/simple_test_tick_clock.h"
25 #include "base/time/tick_clock.h" 24 #include "base/time/tick_clock.h"
26 #include "media/base/audio_bus.h" 25 #include "media/base/audio_bus.h"
27 #include "media/base/video_frame.h" 26 #include "media/base/video_frame.h"
28 #include "media/cast/cast_config.h" 27 #include "media/cast/cast_config.h"
29 #include "media/cast/cast_environment.h" 28 #include "media/cast/cast_environment.h"
30 #include "media/cast/cast_receiver.h" 29 #include "media/cast/cast_receiver.h"
31 #include "media/cast/cast_sender.h" 30 #include "media/cast/cast_sender.h"
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 expected_audio_frame->record_time + 298 expected_audio_frame->record_time +
300 base::TimeDelta::FromMilliseconds(kDefaultRtpMaxDelayMs + 299 base::TimeDelta::FromMilliseconds(kDefaultRtpMaxDelayMs +
301 kTimerErrorMs); 300 kTimerErrorMs);
302 EXPECT_GE(upper_bound, playout_time) 301 EXPECT_GE(upper_bound, playout_time)
303 << "playout_time - upper_bound == " 302 << "playout_time - upper_bound == "
304 << (playout_time - upper_bound).InMicroseconds() << " usec"; 303 << (playout_time - upper_bound).InMicroseconds() << " usec";
305 304
306 EXPECT_TRUE(is_continuous); 305 EXPECT_TRUE(is_continuous);
307 } 306 }
308 307
309 void CheckCodedAudioFrame( 308 void CheckCodedAudioFrame(scoped_ptr<transport::EncodedFrame> audio_frame) {
310 scoped_ptr<transport::EncodedAudioFrame> audio_frame,
311 const base::TimeTicks& playout_time) {
312 ASSERT_TRUE(!!audio_frame); 309 ASSERT_TRUE(!!audio_frame);
313 ASSERT_FALSE(expected_frames_.empty()); 310 ASSERT_FALSE(expected_frames_.empty());
314 const ExpectedAudioFrame& expected_audio_frame = 311 const ExpectedAudioFrame& expected_audio_frame =
315 *(expected_frames_.front()); 312 *(expected_frames_.front());
316 // Note: Just peeking here. Will delegate to CheckAudioFrame() to pop. 313 // Note: Just peeking here. Will delegate to CheckAudioFrame() to pop.
317 314
318 // We need to "decode" the encoded audio frame. The codec is simply to 315 // We need to "decode" the encoded audio frame. The codec is simply to
319 // swizzle the bytes of each int16 from host-->network-->host order to get 316 // swizzle the bytes of each int16 from host-->network-->host order to get
320 // interleaved int16 PCM. Then, make an AudioBus out of that. 317 // interleaved int16 PCM. Then, make an AudioBus out of that.
321 const int num_elements = audio_frame->data.size() / sizeof(int16); 318 const int num_elements = audio_frame->data.size() / sizeof(int16);
322 ASSERT_EQ(expected_audio_frame.audio_bus->channels() * 319 ASSERT_EQ(expected_audio_frame.audio_bus->channels() *
323 expected_audio_frame.audio_bus->frames(), 320 expected_audio_frame.audio_bus->frames(),
324 num_elements); 321 num_elements);
325 int16* const pcm_data = 322 int16* const pcm_data =
326 reinterpret_cast<int16*>(string_as_array(&audio_frame->data)); 323 reinterpret_cast<int16*>(audio_frame->mutable_bytes());
327 for (int i = 0; i < num_elements; ++i) 324 for (int i = 0; i < num_elements; ++i)
328 pcm_data[i] = static_cast<int16>(base::NetToHost16(pcm_data[i])); 325 pcm_data[i] = static_cast<int16>(base::NetToHost16(pcm_data[i]));
329 scoped_ptr<AudioBus> audio_bus( 326 scoped_ptr<AudioBus> audio_bus(
330 AudioBus::Create(expected_audio_frame.audio_bus->channels(), 327 AudioBus::Create(expected_audio_frame.audio_bus->channels(),
331 expected_audio_frame.audio_bus->frames())); 328 expected_audio_frame.audio_bus->frames()));
332 audio_bus->FromInterleaved(pcm_data, audio_bus->frames(), sizeof(int16)); 329 audio_bus->FromInterleaved(pcm_data, audio_bus->frames(), sizeof(int16));
333 330
334 // Delegate the checking from here... 331 // Delegate the checking from here...
335 CheckAudioFrame(audio_bus.Pass(), playout_time, true); 332 CheckAudioFrame(audio_bus.Pass(), audio_frame->reference_time, true);
336 } 333 }
337 334
338 int number_times_called() const { return num_called_; } 335 int number_times_called() const { return num_called_; }
339 336
340 protected: 337 protected:
341 virtual ~TestReceiverAudioCallback() { 338 virtual ~TestReceiverAudioCallback() {
342 STLDeleteElements(&expected_frames_); 339 STLDeleteElements(&expected_frames_);
343 } 340 }
344 341
345 private: 342 private:
(...skipping 1006 matching lines...) Expand 10 before | Expand all | Expand 10 after
1352 EXPECT_LT((video_ticks_.back().second - test_end).InMilliseconds(), 1000); 1349 EXPECT_LT((video_ticks_.back().second - test_end).InMilliseconds(), 1000);
1353 } 1350 }
1354 1351
1355 // TODO(pwestin): Add repeatable packet loss test. 1352 // TODO(pwestin): Add repeatable packet loss test.
1356 // TODO(pwestin): Add test for misaligned send get calls. 1353 // TODO(pwestin): Add test for misaligned send get calls.
1357 // TODO(pwestin): Add more tests that does not resample. 1354 // TODO(pwestin): Add more tests that does not resample.
1358 // TODO(pwestin): Add test when we have starvation for our RunTask. 1355 // TODO(pwestin): Add test when we have starvation for our RunTask.
1359 1356
1360 } // namespace cast 1357 } // namespace cast
1361 } // namespace media 1358 } // namespace media
OLDNEW
« no previous file with comments | « media/cast/test/encode_decode_test.cc ('k') | media/cast/transport/cast_transport_config.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698