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

Side by Side Diff: media/cast/audio_receiver/audio_receiver_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/audio_receiver/audio_receiver.cc ('k') | media/cast/audio_sender/audio_encoder.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 #include "base/bind.h" 5 #include "base/bind.h"
6 #include "base/memory/ref_counted.h" 6 #include "base/memory/ref_counted.h"
7 #include "base/memory/scoped_ptr.h" 7 #include "base/memory/scoped_ptr.h"
8 #include "base/test/simple_test_tick_clock.h" 8 #include "base/test/simple_test_tick_clock.h"
9 #include "media/cast/audio_receiver/audio_receiver.h" 9 #include "media/cast/audio_receiver/audio_receiver.h"
10 #include "media/cast/cast_defines.h" 10 #include "media/cast/cast_defines.h"
(...skipping 19 matching lines...) Expand all
30 FakeAudioClient() : num_called_(0) {} 30 FakeAudioClient() : num_called_(0) {}
31 virtual ~FakeAudioClient() {} 31 virtual ~FakeAudioClient() {}
32 32
33 void SetNextExpectedResult(uint32 expected_frame_id, 33 void SetNextExpectedResult(uint32 expected_frame_id,
34 const base::TimeTicks& expected_playout_time) { 34 const base::TimeTicks& expected_playout_time) {
35 expected_frame_id_ = expected_frame_id; 35 expected_frame_id_ = expected_frame_id;
36 expected_playout_time_ = expected_playout_time; 36 expected_playout_time_ = expected_playout_time;
37 } 37 }
38 38
39 void DeliverEncodedAudioFrame( 39 void DeliverEncodedAudioFrame(
40 scoped_ptr<transport::EncodedAudioFrame> audio_frame, 40 scoped_ptr<transport::EncodedFrame> audio_frame) {
41 const base::TimeTicks& playout_time) {
42 ASSERT_FALSE(!audio_frame) 41 ASSERT_FALSE(!audio_frame)
43 << "If at shutdown: There were unsatisfied requests enqueued."; 42 << "If at shutdown: There were unsatisfied requests enqueued.";
44 EXPECT_EQ(expected_frame_id_, audio_frame->frame_id); 43 EXPECT_EQ(expected_frame_id_, audio_frame->frame_id);
45 EXPECT_EQ(transport::kPcm16, audio_frame->codec); 44 EXPECT_EQ(expected_playout_time_, audio_frame->reference_time);
46 EXPECT_EQ(expected_playout_time_, playout_time);
47 num_called_++; 45 num_called_++;
48 } 46 }
49 47
50 int number_times_called() const { return num_called_; } 48 int number_times_called() const { return num_called_; }
51 49
52 private: 50 private:
53 int num_called_; 51 int num_called_;
54 uint32 expected_frame_id_; 52 uint32 expected_frame_id_;
55 base::TimeTicks expected_playout_time_; 53 base::TimeTicks expected_playout_time_;
56 54
(...skipping 28 matching lines...) Expand all
85 } 83 }
86 84
87 virtual ~AudioReceiverTest() {} 85 virtual ~AudioReceiverTest() {}
88 86
89 virtual void SetUp() { 87 virtual void SetUp() {
90 payload_.assign(kMaxIpPacketSize, 0); 88 payload_.assign(kMaxIpPacketSize, 0);
91 rtp_header_.is_key_frame = true; 89 rtp_header_.is_key_frame = true;
92 rtp_header_.frame_id = kFirstFrameId; 90 rtp_header_.frame_id = kFirstFrameId;
93 rtp_header_.packet_id = 0; 91 rtp_header_.packet_id = 0;
94 rtp_header_.max_packet_id = 0; 92 rtp_header_.max_packet_id = 0;
95 rtp_header_.reference_frame_id = 0; 93 rtp_header_.reference_frame_id = rtp_header_.frame_id;
96 rtp_header_.rtp_timestamp = 0; 94 rtp_header_.rtp_timestamp = 0;
97 } 95 }
98 96
99 void FeedOneFrameIntoReceiver() { 97 void FeedOneFrameIntoReceiver() {
100 receiver_->OnReceivedPayloadData( 98 receiver_->OnReceivedPayloadData(
101 payload_.data(), payload_.size(), rtp_header_); 99 payload_.data(), payload_.size(), rtp_header_);
102 } 100 }
103 101
104 AudioReceiverConfig audio_config_; 102 AudioReceiverConfig audio_config_;
105 std::vector<uint8> payload_; 103 std::vector<uint8> payload_;
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 EXPECT_EQ(rtp_header_.rtp_timestamp, frame_events.begin()->rtp_timestamp); 145 EXPECT_EQ(rtp_header_.rtp_timestamp, frame_events.begin()->rtp_timestamp);
148 146
149 cast_environment_->Logging()->RemoveRawEventSubscriber(&event_subscriber); 147 cast_environment_->Logging()->RemoveRawEventSubscriber(&event_subscriber);
150 } 148 }
151 149
152 TEST_F(AudioReceiverTest, MultiplePendingGetCalls) { 150 TEST_F(AudioReceiverTest, MultiplePendingGetCalls) {
153 EXPECT_CALL(mock_transport_, SendRtcpPacket(_, _)) 151 EXPECT_CALL(mock_transport_, SendRtcpPacket(_, _))
154 .WillRepeatedly(testing::Return(true)); 152 .WillRepeatedly(testing::Return(true));
155 153
156 // Enqueue a request for an audio frame. 154 // Enqueue a request for an audio frame.
157 const AudioFrameEncodedCallback frame_encoded_callback = 155 const FrameEncodedCallback frame_encoded_callback =
158 base::Bind(&FakeAudioClient::DeliverEncodedAudioFrame, 156 base::Bind(&FakeAudioClient::DeliverEncodedAudioFrame,
159 base::Unretained(&fake_audio_client_)); 157 base::Unretained(&fake_audio_client_));
160 receiver_->GetEncodedAudioFrame(frame_encoded_callback); 158 receiver_->GetEncodedAudioFrame(frame_encoded_callback);
161 task_runner_->RunTasks(); 159 task_runner_->RunTasks();
162 EXPECT_EQ(0, fake_audio_client_.number_times_called()); 160 EXPECT_EQ(0, fake_audio_client_.number_times_called());
163 161
164 // Receive one audio frame and expect to see the first request satisfied. 162 // Receive one audio frame and expect to see the first request satisfied.
165 fake_audio_client_.SetNextExpectedResult(kFirstFrameId, 163 fake_audio_client_.SetNextExpectedResult(kFirstFrameId,
166 testing_clock_->NowTicks()); 164 testing_clock_->NowTicks());
167 FeedOneFrameIntoReceiver(); 165 FeedOneFrameIntoReceiver();
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 222
225 // Move forward another 100 ms and run any pending tasks (there should be 223 // Move forward another 100 ms and run any pending tasks (there should be
226 // none). Expect no additional frames where emitted. 224 // none). Expect no additional frames where emitted.
227 testing_clock_->Advance(base::TimeDelta::FromMilliseconds(100)); 225 testing_clock_->Advance(base::TimeDelta::FromMilliseconds(100));
228 task_runner_->RunTasks(); 226 task_runner_->RunTasks();
229 EXPECT_EQ(3, fake_audio_client_.number_times_called()); 227 EXPECT_EQ(3, fake_audio_client_.number_times_called());
230 } 228 }
231 229
232 } // namespace cast 230 } // namespace cast
233 } // namespace media 231 } // namespace media
OLDNEW
« no previous file with comments | « media/cast/audio_receiver/audio_receiver.cc ('k') | media/cast/audio_sender/audio_encoder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698