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 30 matching lines...) Expand all Loading... |
41 dtmf_time_last_sent_(0), | 41 dtmf_time_last_sent_(0), |
42 dtmf_timestamp_last_sent_(0), | 42 dtmf_timestamp_last_sent_(0), |
43 inband_vad_active_(false), | 43 inband_vad_active_(false), |
44 cngnb_payload_type_(-1), | 44 cngnb_payload_type_(-1), |
45 cngwb_payload_type_(-1), | 45 cngwb_payload_type_(-1), |
46 cngswb_payload_type_(-1), | 46 cngswb_payload_type_(-1), |
47 cngfb_payload_type_(-1), | 47 cngfb_payload_type_(-1), |
48 last_payload_type_(-1), | 48 last_payload_type_(-1), |
49 audio_level_dbov_(0) {} | 49 audio_level_dbov_(0) {} |
50 | 50 |
51 RTPSenderAudio::~RTPSenderAudio() {} | |
52 | |
53 int RTPSenderAudio::AudioFrequency() const { | 51 int RTPSenderAudio::AudioFrequency() const { |
54 return kDtmfFrequencyHz; | 52 return kDtmfFrequencyHz; |
55 } | 53 } |
56 | 54 |
57 // set audio packet size, used to determine when it's time to send a DTMF packet | 55 // set audio packet size, used to determine when it's time to send a DTMF packet |
58 // in silence (CNG) | 56 // in silence (CNG) |
59 int32_t RTPSenderAudio::SetAudioPacketSize(uint16_t packet_size_samples) { | 57 int32_t RTPSenderAudio::SetAudioPacketSize(uint16_t packet_size_samples) { |
60 rtc::CritScope cs(&send_audio_critsect_); | 58 rtc::CritScope cs(&send_audio_critsect_); |
61 packet_size_samples_ = packet_size_samples; | 59 packet_size_samples_ = packet_size_samples; |
62 return 0; | 60 return 0; |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 int8_t dtmf_payload_type; | 160 int8_t dtmf_payload_type; |
163 uint16_t packet_size_samples; | 161 uint16_t packet_size_samples; |
164 { | 162 { |
165 rtc::CritScope cs(&send_audio_critsect_); | 163 rtc::CritScope cs(&send_audio_critsect_); |
166 audio_level_dbov = audio_level_dbov_; | 164 audio_level_dbov = audio_level_dbov_; |
167 dtmf_payload_type = dtmf_payload_type_; | 165 dtmf_payload_type = dtmf_payload_type_; |
168 packet_size_samples = packet_size_samples_; | 166 packet_size_samples = packet_size_samples_; |
169 } | 167 } |
170 | 168 |
171 // Check if we have pending DTMFs to send | 169 // Check if we have pending DTMFs to send |
172 if (!dtmf_event_is_on_ && PendingDTMF()) { | 170 if (!dtmf_event_is_on_ && dtmf_queue_.PendingDTMF()) { |
173 int64_t delaySinceLastDTMF = | 171 int64_t delaySinceLastDTMF = |
174 clock_->TimeInMilliseconds() - dtmf_time_last_sent_; | 172 clock_->TimeInMilliseconds() - dtmf_time_last_sent_; |
175 | 173 |
176 if (delaySinceLastDTMF > 100) { | 174 if (delaySinceLastDTMF > 100) { |
177 // New tone to play | 175 // New tone to play |
178 dtmf_timestamp_ = rtp_timestamp; | 176 dtmf_timestamp_ = rtp_timestamp; |
179 if (NextDTMF(&key, &dtmf_length_ms, &dtmf_level_) >= 0) { | 177 if (dtmf_queue_.NextDTMF(&key, &dtmf_length_ms, &dtmf_level_) >= 0) { |
180 dtmf_event_first_packet_sent_ = false; | 178 dtmf_event_first_packet_sent_ = false; |
181 dtmf_key_ = key; | 179 dtmf_key_ = key; |
182 dtmf_length_samples_ = (kDtmfFrequencyHz / 1000) * dtmf_length_ms; | 180 dtmf_length_samples_ = (kDtmfFrequencyHz / 1000) * dtmf_length_ms; |
183 dtmf_event_is_on_ = true; | 181 dtmf_event_is_on_ = true; |
184 } | 182 } |
185 } | 183 } |
186 } | 184 } |
187 | 185 |
188 // A source MAY send events and coded audio packets for the same time | 186 // A source MAY send events and coded audio packets for the same time |
189 // but we don't support it | 187 // but we don't support it |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
303 int32_t RTPSenderAudio::SendTelephoneEvent(uint8_t key, | 301 int32_t RTPSenderAudio::SendTelephoneEvent(uint8_t key, |
304 uint16_t time_ms, | 302 uint16_t time_ms, |
305 uint8_t level) { | 303 uint8_t level) { |
306 { | 304 { |
307 rtc::CritScope lock(&send_audio_critsect_); | 305 rtc::CritScope lock(&send_audio_critsect_); |
308 if (dtmf_payload_type_ < 0) { | 306 if (dtmf_payload_type_ < 0) { |
309 // TelephoneEvent payloadtype not configured | 307 // TelephoneEvent payloadtype not configured |
310 return -1; | 308 return -1; |
311 } | 309 } |
312 } | 310 } |
313 return AddDTMF(key, time_ms, level); | 311 return dtmf_queue_.AddDTMF(key, time_ms, level); |
314 } | 312 } |
315 | 313 |
316 bool RTPSenderAudio::SendTelephoneEventPacket(bool ended, | 314 bool RTPSenderAudio::SendTelephoneEventPacket(bool ended, |
317 int8_t dtmf_payload_type, | 315 int8_t dtmf_payload_type, |
318 uint32_t dtmf_timestamp, | 316 uint32_t dtmf_timestamp, |
319 uint16_t duration, | 317 uint16_t duration, |
320 bool marker_bit) { | 318 bool marker_bit) { |
321 uint8_t send_count = 1; | 319 uint8_t send_count = 1; |
322 bool result = true; | 320 bool result = true; |
323 | 321 |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
365 TRACE_DISABLED_BY_DEFAULT("webrtc_rtp"), "Audio::SendTelephoneEvent", | 363 TRACE_DISABLED_BY_DEFAULT("webrtc_rtp"), "Audio::SendTelephoneEvent", |
366 "timestamp", packet->Timestamp(), "seqnum", packet->SequenceNumber()); | 364 "timestamp", packet->Timestamp(), "seqnum", packet->SequenceNumber()); |
367 result = rtp_sender_->SendToNetwork(std::move(packet), kAllowRetransmission, | 365 result = rtp_sender_->SendToNetwork(std::move(packet), kAllowRetransmission, |
368 RtpPacketSender::kHighPriority); | 366 RtpPacketSender::kHighPriority); |
369 send_count--; | 367 send_count--; |
370 } while (send_count > 0 && result); | 368 } while (send_count > 0 && result); |
371 | 369 |
372 return result; | 370 return result; |
373 } | 371 } |
374 } // namespace webrtc | 372 } // namespace webrtc |
OLD | NEW |