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

Side by Side Diff: media/cast/logging/logging_unittest.cc

Issue 136903003: cast: Wire upp logging to be sent over RTCP between receiver and sender. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 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
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 #include <gtest/gtest.h> 5 #include <gtest/gtest.h>
6 6
7 #include "base/rand_util.h" 7 #include "base/rand_util.h"
8 #include "base/test/simple_test_tick_clock.h" 8 #include "base/test/simple_test_tick_clock.h"
9 #include "base/time/tick_clock.h" 9 #include "base/time/tick_clock.h"
10 #include "base/time/time.h" 10 #include "base/time/time.h"
11 #include "media/cast/logging/logging_impl.h" 11 #include "media/cast/logging/logging_impl.h"
12 #include "media/cast/test/fake_task_runner.h" 12 #include "media/cast/test/fake_task_runner.h"
13 13
14 namespace media { 14 namespace media {
15 namespace cast { 15 namespace cast {
16 16
17 // Insert frame duration- one second. 17 // Insert frame duration- one second.
18 const int64 kIntervalTime1S = 1; 18 const int64 kIntervalTime1S = 1;
19 // Test frame rate goal - 30fps. 19 // Test frame rate goal - 30fps.
20 const int kFrameIntervalMs = 33; 20 const int kFrameIntervalMs = 33;
21 21
22 static const int64 kStartMillisecond = GG_INT64_C(12345678900000); 22 static const int64 kStartMillisecond = GG_INT64_C(12345678900000);
23 23
24 class TestLogging : public ::testing::Test { 24 class TestLogging : public ::testing::Test {
25 protected: 25 protected:
26 TestLogging() { 26 TestLogging() : config_(false) {
27 // Enable logging, disable tracing and uma. 27 // Enable logging, disable tracing and uma.
28 config_.enable_data_collection = true; 28 config_.enable_data_collection = true;
29 29
30 testing_clock_.Advance( 30 testing_clock_.Advance(
31 base::TimeDelta::FromMilliseconds(kStartMillisecond)); 31 base::TimeDelta::FromMilliseconds(kStartMillisecond));
32 task_runner_ = new test::FakeTaskRunner(&testing_clock_); 32 task_runner_ = new test::FakeTaskRunner(&testing_clock_);
33 logging_.reset(new LoggingImpl(task_runner_, config_)); 33 logging_.reset(new LoggingImpl(task_runner_, config_));
34 } 34 }
35 35
36 virtual ~TestLogging() {} 36 virtual ~TestLogging() {}
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 EXPECT_EQ(kNumRuns / 4, rit->second.timestamp.size()); 250 EXPECT_EQ(kNumRuns / 4, rit->second.timestamp.size());
251 // Stats - one value per event. 251 // Stats - one value per event.
252 GenericStatsMap::const_iterator sit = stats_map->find(kRttMs); 252 GenericStatsMap::const_iterator sit = stats_map->find(kRttMs);
253 EXPECT_NEAR(kBaseValue, sit->second, 2.5); 253 EXPECT_NEAR(kBaseValue, sit->second, 2.5);
254 sit = stats_map->find(kPacketLoss); 254 sit = stats_map->find(kPacketLoss);
255 EXPECT_NEAR(kBaseValue, sit->second, 2.5); 255 EXPECT_NEAR(kBaseValue, sit->second, 2.5);
256 sit = stats_map->find(kJitterMs); 256 sit = stats_map->find(kJitterMs);
257 EXPECT_NEAR(kBaseValue, sit->second, 2.5); 257 EXPECT_NEAR(kBaseValue, sit->second, 2.5);
258 } 258 }
259 259
260 TEST_F(TestLogging, RtcpMultipleEventFrameLogging) {
261 base::TimeTicks start_time = testing_clock_.NowTicks();
262 base::TimeDelta time_interval = testing_clock_.NowTicks() - start_time;
263 uint32 rtp_timestamp = 0;
264 uint32 frame_id = 0;
265 do {
266 logging_->InsertFrameEvent(testing_clock_.NowTicks(), kAudioFrameCaptured,
267 rtp_timestamp, frame_id);
268 if (frame_id % 2) {
269 logging_->InsertFrameEventWithSize(testing_clock_.NowTicks(),
270 kAudioFrameEncoded, rtp_timestamp, frame_id, 1500);
271 } else if (frame_id % 3) {
272 logging_->InsertFrameEvent(testing_clock_.NowTicks(), kVideoFrameDecoded,
273 rtp_timestamp, frame_id);
274 } else {
275 logging_->InsertFrameEventWithDelay(testing_clock_.NowTicks(),
276 kVideoRenderDelay, rtp_timestamp, frame_id,
277 base::TimeDelta::FromMilliseconds(20));
278 }
279 testing_clock_.Advance(
280 base::TimeDelta::FromMilliseconds(kFrameIntervalMs));
281 rtp_timestamp += kFrameIntervalMs * 90;
282 ++frame_id;
283 time_interval = testing_clock_.NowTicks() - start_time;
284 } while (time_interval.InSeconds() < kIntervalTime1S);
285 // Get logging data.
286 FrameRawMap frame_map = logging_->GetFrameRawData();
287 // Size of map should be equal to the number of frames logged.
288 EXPECT_EQ(frame_id, frame_map.size());
289 // Multiple events captured per frame.
290
291 AudioRtcpRawMap audio_rtcp = logging_->GetAudioRtcpRawData();
292 EXPECT_EQ(0u, audio_rtcp.size());
293
294 VideoRtcpRawMap video_rtcp = logging_->GetVideoRtcpRawData();
295 EXPECT_EQ((frame_id + 1) / 2, video_rtcp.size());
296 }
297
260 } // namespace cast 298 } // namespace cast
261 } // namespace media 299 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698