| OLD | NEW |
| 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" |
| 11 #include "media/cast/cast_environment.h" | 11 #include "media/cast/cast_environment.h" |
| 12 #include "media/cast/net/pacing/mock_paced_packet_sender.h" | |
| 13 #include "media/cast/rtcp/test_rtcp_packet_builder.h" | 12 #include "media/cast/rtcp/test_rtcp_packet_builder.h" |
| 14 #include "media/cast/test/fake_task_runner.h" | 13 #include "media/cast/test/fake_task_runner.h" |
| 14 #include "media/cast/transport/pacing/mock_paced_packet_sender.h" |
| 15 #include "testing/gmock/include/gmock/gmock.h" | 15 #include "testing/gmock/include/gmock/gmock.h" |
| 16 | 16 |
| 17 namespace media { | 17 namespace media { |
| 18 namespace cast { | 18 namespace cast { |
| 19 | 19 |
| 20 static const int64 kStartMillisecond = GG_INT64_C(12345678900000); | 20 static const int64 kStartMillisecond = GG_INT64_C(12345678900000); |
| 21 | 21 |
| 22 namespace { | 22 namespace { |
| 23 class TestAudioEncoderCallback : | 23 class TestAudioEncoderCallback : |
| 24 public base::RefCountedThreadSafe<TestAudioEncoderCallback> { | 24 public base::RefCountedThreadSafe<TestAudioEncoderCallback> { |
| (...skipping 26 matching lines...) Expand all Loading... |
| 51 int num_called_; | 51 int num_called_; |
| 52 uint8 expected_frame_id_; | 52 uint8 expected_frame_id_; |
| 53 base::TimeTicks expected_playout_time_; | 53 base::TimeTicks expected_playout_time_; |
| 54 }; | 54 }; |
| 55 } // namespace | 55 } // namespace |
| 56 | 56 |
| 57 class PeerAudioReceiver : public AudioReceiver { | 57 class PeerAudioReceiver : public AudioReceiver { |
| 58 public: | 58 public: |
| 59 PeerAudioReceiver(scoped_refptr<CastEnvironment> cast_environment, | 59 PeerAudioReceiver(scoped_refptr<CastEnvironment> cast_environment, |
| 60 const AudioReceiverConfig& audio_config, | 60 const AudioReceiverConfig& audio_config, |
| 61 PacedPacketSender* const packet_sender) | 61 transport::PacedPacketSender* const packet_sender) |
| 62 : AudioReceiver(cast_environment, audio_config, packet_sender) {} | 62 : AudioReceiver(cast_environment, audio_config, packet_sender) {} |
| 63 | 63 |
| 64 using AudioReceiver::IncomingParsedRtpPacket; | 64 using AudioReceiver::IncomingParsedRtpPacket; |
| 65 }; | 65 }; |
| 66 | 66 |
| 67 class AudioReceiverTest : public ::testing::Test { | 67 class AudioReceiverTest : public ::testing::Test { |
| 68 protected: | 68 protected: |
| 69 AudioReceiverTest() { | 69 AudioReceiverTest() { |
| 70 // Configure the audio receiver to use PCM16. | 70 // Configure the audio receiver to use PCM16. |
| 71 audio_config_.rtp_payload_type = 127; | 71 audio_config_.rtp_payload_type = 127; |
| (...skipping 29 matching lines...) Expand all Loading... |
| 101 rtp_header_.max_packet_id = 0; | 101 rtp_header_.max_packet_id = 0; |
| 102 rtp_header_.is_reference = false; | 102 rtp_header_.is_reference = false; |
| 103 rtp_header_.reference_frame_id = 0; | 103 rtp_header_.reference_frame_id = 0; |
| 104 rtp_header_.webrtc.header.timestamp = 0; | 104 rtp_header_.webrtc.header.timestamp = 0; |
| 105 } | 105 } |
| 106 | 106 |
| 107 AudioReceiverConfig audio_config_; | 107 AudioReceiverConfig audio_config_; |
| 108 std::vector<uint8> payload_; | 108 std::vector<uint8> payload_; |
| 109 RtpCastHeader rtp_header_; | 109 RtpCastHeader rtp_header_; |
| 110 base::SimpleTestTickClock testing_clock_; | 110 base::SimpleTestTickClock testing_clock_; |
| 111 MockPacedPacketSender mock_transport_; | 111 transport::MockPacedPacketSender mock_transport_; |
| 112 scoped_refptr<test::FakeTaskRunner> task_runner_; | 112 scoped_refptr<test::FakeTaskRunner> task_runner_; |
| 113 scoped_ptr<PeerAudioReceiver> receiver_; | 113 scoped_ptr<PeerAudioReceiver> receiver_; |
| 114 scoped_refptr<CastEnvironment> cast_environment_; | 114 scoped_refptr<CastEnvironment> cast_environment_; |
| 115 scoped_refptr<TestAudioEncoderCallback> test_audio_encoder_callback_; | 115 scoped_refptr<TestAudioEncoderCallback> test_audio_encoder_callback_; |
| 116 }; | 116 }; |
| 117 | 117 |
| 118 TEST_F(AudioReceiverTest, GetOnePacketEncodedframe) { | 118 TEST_F(AudioReceiverTest, GetOnePacketEncodedframe) { |
| 119 Configure(true); | 119 Configure(true); |
| 120 EXPECT_CALL(mock_transport_, SendRtcpPacket(testing::_)).Times(1); | 120 EXPECT_CALL(mock_transport_, SendRtcpPacket(testing::_)).Times(1); |
| 121 | 121 |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 208 task_runner_->RunTasks(); | 208 task_runner_->RunTasks(); |
| 209 EXPECT_EQ(3, test_audio_encoder_callback_->number_times_called()); | 209 EXPECT_EQ(3, test_audio_encoder_callback_->number_times_called()); |
| 210 } | 210 } |
| 211 | 211 |
| 212 // TODO(mikhal): Add encoded frames. | 212 // TODO(mikhal): Add encoded frames. |
| 213 TEST_F(AudioReceiverTest, GetRawFrame) { | 213 TEST_F(AudioReceiverTest, GetRawFrame) { |
| 214 } | 214 } |
| 215 | 215 |
| 216 } // namespace cast | 216 } // namespace cast |
| 217 } // namespace media | 217 } // namespace media |
| OLD | NEW |