OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 } | 54 } |
55 ADD_FAILURE() << "This code path should never happen."; | 55 ADD_FAILURE() << "This code path should never happen."; |
56 return -1; | 56 return -1; |
57 } | 57 } |
58 return 0; | 58 return 0; |
59 } | 59 } |
60 }; | 60 }; |
61 | 61 |
62 class RTPCallback : public NullRtpFeedback { | 62 class RTPCallback : public NullRtpFeedback { |
63 public: | 63 public: |
64 int32_t OnInitializeDecoder(const int32_t id, | 64 int32_t OnInitializeDecoder(const int8_t payloadType, |
65 const int8_t payloadType, | |
66 const char payloadName[RTP_PAYLOAD_NAME_SIZE], | 65 const char payloadName[RTP_PAYLOAD_NAME_SIZE], |
67 const int frequency, | 66 const int frequency, |
68 const uint8_t channels, | 67 const uint8_t channels, |
69 const uint32_t rate) override { | 68 const uint32_t rate) override { |
70 if (payloadType == 96) { | 69 if (payloadType == 96) { |
71 EXPECT_EQ(test_rate, rate) << | 70 EXPECT_EQ(test_rate, rate) << |
72 "The rate should be 64K for this payloadType"; | 71 "The rate should be 64K for this payloadType"; |
73 } | 72 } |
74 return 0; | 73 return 0; |
75 } | 74 } |
76 }; | 75 }; |
77 | 76 |
78 class RtpRtcpAudioTest : public ::testing::Test { | 77 class RtpRtcpAudioTest : public ::testing::Test { |
79 protected: | 78 protected: |
80 RtpRtcpAudioTest() : fake_clock(123456) { | 79 RtpRtcpAudioTest() : fake_clock(123456) { |
81 test_CSRC[0] = 1234; | 80 test_CSRC[0] = 1234; |
82 test_CSRC[2] = 2345; | 81 test_CSRC[2] = 2345; |
83 test_id = 123; | |
84 test_ssrc = 3456; | 82 test_ssrc = 3456; |
85 test_timestamp = 4567; | 83 test_timestamp = 4567; |
86 test_sequence_number = 2345; | 84 test_sequence_number = 2345; |
87 } | 85 } |
88 ~RtpRtcpAudioTest() {} | 86 ~RtpRtcpAudioTest() {} |
89 | 87 |
90 void SetUp() override { | 88 void SetUp() override { |
91 audioFeedback = new NullRtpAudioFeedback(); | 89 audioFeedback = new NullRtpAudioFeedback(); |
92 data_receiver1 = new VerifyingAudioReceiver(); | 90 data_receiver1 = new VerifyingAudioReceiver(); |
93 data_receiver2 = new VerifyingAudioReceiver(); | 91 data_receiver2 = new VerifyingAudioReceiver(); |
94 rtp_callback = new RTPCallback(); | 92 rtp_callback = new RTPCallback(); |
95 transport1 = new LoopBackTransport(); | 93 transport1 = new LoopBackTransport(); |
96 transport2 = new LoopBackTransport(); | 94 transport2 = new LoopBackTransport(); |
97 | 95 |
98 receive_statistics1_.reset(ReceiveStatistics::Create(&fake_clock)); | 96 receive_statistics1_.reset(ReceiveStatistics::Create(&fake_clock)); |
99 receive_statistics2_.reset(ReceiveStatistics::Create(&fake_clock)); | 97 receive_statistics2_.reset(ReceiveStatistics::Create(&fake_clock)); |
100 | 98 |
101 rtp_payload_registry1_.reset(new RTPPayloadRegistry( | 99 rtp_payload_registry1_.reset(new RTPPayloadRegistry( |
102 RTPPayloadStrategy::CreateStrategy(true))); | 100 RTPPayloadStrategy::CreateStrategy(true))); |
103 rtp_payload_registry2_.reset(new RTPPayloadRegistry( | 101 rtp_payload_registry2_.reset(new RTPPayloadRegistry( |
104 RTPPayloadStrategy::CreateStrategy(true))); | 102 RTPPayloadStrategy::CreateStrategy(true))); |
105 | 103 |
106 RtpRtcp::Configuration configuration; | 104 RtpRtcp::Configuration configuration; |
107 configuration.id = test_id; | |
108 configuration.audio = true; | 105 configuration.audio = true; |
109 configuration.clock = &fake_clock; | 106 configuration.clock = &fake_clock; |
110 configuration.receive_statistics = receive_statistics1_.get(); | 107 configuration.receive_statistics = receive_statistics1_.get(); |
111 configuration.outgoing_transport = transport1; | 108 configuration.outgoing_transport = transport1; |
112 configuration.audio_messages = audioFeedback; | 109 configuration.audio_messages = audioFeedback; |
113 | 110 |
114 module1 = RtpRtcp::CreateRtpRtcp(configuration); | 111 module1 = RtpRtcp::CreateRtpRtcp(configuration); |
115 rtp_receiver1_.reset(RtpReceiver::CreateAudioReceiver( | 112 rtp_receiver1_.reset(RtpReceiver::CreateAudioReceiver( |
116 test_id, &fake_clock, audioFeedback, data_receiver1, NULL, | 113 &fake_clock, audioFeedback, data_receiver1, NULL, |
117 rtp_payload_registry1_.get())); | 114 rtp_payload_registry1_.get())); |
118 | 115 |
119 configuration.id = test_id + 1; | |
120 configuration.receive_statistics = receive_statistics2_.get(); | 116 configuration.receive_statistics = receive_statistics2_.get(); |
121 configuration.outgoing_transport = transport2; | 117 configuration.outgoing_transport = transport2; |
122 configuration.audio_messages = audioFeedback; | 118 configuration.audio_messages = audioFeedback; |
123 | 119 |
124 module2 = RtpRtcp::CreateRtpRtcp(configuration); | 120 module2 = RtpRtcp::CreateRtpRtcp(configuration); |
125 rtp_receiver2_.reset(RtpReceiver::CreateAudioReceiver( | 121 rtp_receiver2_.reset(RtpReceiver::CreateAudioReceiver( |
126 test_id + 1, &fake_clock, audioFeedback, data_receiver2, NULL, | 122 &fake_clock, audioFeedback, data_receiver2, NULL, |
127 rtp_payload_registry2_.get())); | 123 rtp_payload_registry2_.get())); |
128 | 124 |
129 transport1->SetSendModule(module2, rtp_payload_registry2_.get(), | 125 transport1->SetSendModule(module2, rtp_payload_registry2_.get(), |
130 rtp_receiver2_.get(), receive_statistics2_.get()); | 126 rtp_receiver2_.get(), receive_statistics2_.get()); |
131 transport2->SetSendModule(module1, rtp_payload_registry1_.get(), | 127 transport2->SetSendModule(module1, rtp_payload_registry1_.get(), |
132 rtp_receiver1_.get(), receive_statistics1_.get()); | 128 rtp_receiver1_.get(), receive_statistics1_.get()); |
133 } | 129 } |
134 | 130 |
135 void TearDown() override { | 131 void TearDown() override { |
136 delete module1; | 132 delete module1; |
137 delete module2; | 133 delete module2; |
138 delete transport1; | 134 delete transport1; |
139 delete transport2; | 135 delete transport2; |
140 delete audioFeedback; | 136 delete audioFeedback; |
141 delete data_receiver1; | 137 delete data_receiver1; |
142 delete data_receiver2; | 138 delete data_receiver2; |
143 delete rtp_callback; | 139 delete rtp_callback; |
144 } | 140 } |
145 | 141 |
146 int test_id; | |
147 RtpRtcp* module1; | 142 RtpRtcp* module1; |
148 RtpRtcp* module2; | 143 RtpRtcp* module2; |
149 rtc::scoped_ptr<ReceiveStatistics> receive_statistics1_; | 144 rtc::scoped_ptr<ReceiveStatistics> receive_statistics1_; |
150 rtc::scoped_ptr<ReceiveStatistics> receive_statistics2_; | 145 rtc::scoped_ptr<ReceiveStatistics> receive_statistics2_; |
151 rtc::scoped_ptr<RtpReceiver> rtp_receiver1_; | 146 rtc::scoped_ptr<RtpReceiver> rtp_receiver1_; |
152 rtc::scoped_ptr<RtpReceiver> rtp_receiver2_; | 147 rtc::scoped_ptr<RtpReceiver> rtp_receiver2_; |
153 rtc::scoped_ptr<RTPPayloadRegistry> rtp_payload_registry1_; | 148 rtc::scoped_ptr<RTPPayloadRegistry> rtp_payload_registry1_; |
154 rtc::scoped_ptr<RTPPayloadRegistry> rtp_payload_registry2_; | 149 rtc::scoped_ptr<RTPPayloadRegistry> rtp_payload_registry2_; |
155 VerifyingAudioReceiver* data_receiver1; | 150 VerifyingAudioReceiver* data_receiver1; |
156 VerifyingAudioReceiver* data_receiver2; | 151 VerifyingAudioReceiver* data_receiver2; |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
347 } | 342 } |
348 EXPECT_EQ(0, module1->SendTelephoneEventOutband(32, 9000, 10)); | 343 EXPECT_EQ(0, module1->SendTelephoneEventOutband(32, 9000, 10)); |
349 | 344 |
350 for (;timeStamp <= 740 * 160; timeStamp += 160) { | 345 for (;timeStamp <= 740 * 160; timeStamp += 160) { |
351 EXPECT_EQ(0, module1->SendOutgoingData(webrtc::kAudioFrameSpeech, 96, | 346 EXPECT_EQ(0, module1->SendOutgoingData(webrtc::kAudioFrameSpeech, 96, |
352 timeStamp, -1, test, 4)); | 347 timeStamp, -1, test, 4)); |
353 fake_clock.AdvanceTimeMilliseconds(20); | 348 fake_clock.AdvanceTimeMilliseconds(20); |
354 module1->Process(); | 349 module1->Process(); |
355 } | 350 } |
356 } | 351 } |
OLD | NEW |