| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright 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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 rtc::scoped_refptr<DtmfSender> dtmf_sender( | 69 rtc::scoped_refptr<DtmfSender> dtmf_sender( |
| 70 new rtc::RefCountedObject<DtmfSender>(track, signaling_thread, | 70 new rtc::RefCountedObject<DtmfSender>(track, signaling_thread, |
| 71 provider)); | 71 provider)); |
| 72 return dtmf_sender; | 72 return dtmf_sender; |
| 73 } | 73 } |
| 74 | 74 |
| 75 DtmfSender::DtmfSender(AudioTrackInterface* track, | 75 DtmfSender::DtmfSender(AudioTrackInterface* track, |
| 76 rtc::Thread* signaling_thread, | 76 rtc::Thread* signaling_thread, |
| 77 DtmfProviderInterface* provider) | 77 DtmfProviderInterface* provider) |
| 78 : track_(track), | 78 : track_(track), |
| 79 observer_(NULL), | 79 observer_(nullptr), |
| 80 signaling_thread_(signaling_thread), | 80 signaling_thread_(signaling_thread), |
| 81 provider_(provider), | 81 provider_(provider), |
| 82 duration_(kDtmfDefaultDurationMs), | 82 duration_(kDtmfDefaultDurationMs), |
| 83 inter_tone_gap_(kDtmfDefaultGapMs) { | 83 inter_tone_gap_(kDtmfDefaultGapMs) { |
| 84 RTC_DCHECK(signaling_thread_ != NULL); | 84 RTC_DCHECK(signaling_thread_ != nullptr); |
| 85 // TODO(deadbeef): Once we can use shared_ptr and weak_ptr, | 85 // TODO(deadbeef): Once we can use shared_ptr and weak_ptr, |
| 86 // do that instead of relying on a "destroyed" signal. | 86 // do that instead of relying on a "destroyed" signal. |
| 87 if (provider_) { | 87 if (provider_) { |
| 88 RTC_DCHECK(provider_->GetOnDestroyedSignal() != NULL); | 88 RTC_DCHECK(provider_->GetOnDestroyedSignal() != nullptr); |
| 89 provider_->GetOnDestroyedSignal()->connect( | 89 provider_->GetOnDestroyedSignal()->connect( |
| 90 this, &DtmfSender::OnProviderDestroyed); | 90 this, &DtmfSender::OnProviderDestroyed); |
| 91 } | 91 } |
| 92 } | 92 } |
| 93 | 93 |
| 94 DtmfSender::~DtmfSender() { | 94 DtmfSender::~DtmfSender() { |
| 95 StopSending(); | 95 StopSending(); |
| 96 } | 96 } |
| 97 | 97 |
| 98 void DtmfSender::RegisterObserver(DtmfSenderObserverInterface* observer) { | 98 void DtmfSender::RegisterObserver(DtmfSenderObserverInterface* observer) { |
| 99 observer_ = observer; | 99 observer_ = observer; |
| 100 } | 100 } |
| 101 | 101 |
| 102 void DtmfSender::UnregisterObserver() { | 102 void DtmfSender::UnregisterObserver() { |
| 103 observer_ = NULL; | 103 observer_ = nullptr; |
| 104 } | 104 } |
| 105 | 105 |
| 106 bool DtmfSender::CanInsertDtmf() { | 106 bool DtmfSender::CanInsertDtmf() { |
| 107 RTC_DCHECK(signaling_thread_->IsCurrent()); | 107 RTC_DCHECK(signaling_thread_->IsCurrent()); |
| 108 if (!provider_) { | 108 if (!provider_) { |
| 109 return false; | 109 return false; |
| 110 } | 110 } |
| 111 return provider_->CanInsertDtmf(); | 111 return provider_->CanInsertDtmf(); |
| 112 } | 112 } |
| 113 | 113 |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 222 tones_.erase(0, first_tone_pos + 1); | 222 tones_.erase(0, first_tone_pos + 1); |
| 223 | 223 |
| 224 // Continue with the next tone. | 224 // Continue with the next tone. |
| 225 signaling_thread_->PostDelayed(RTC_FROM_HERE, tone_gap, this, | 225 signaling_thread_->PostDelayed(RTC_FROM_HERE, tone_gap, this, |
| 226 MSG_DO_INSERT_DTMF); | 226 MSG_DO_INSERT_DTMF); |
| 227 } | 227 } |
| 228 | 228 |
| 229 void DtmfSender::OnProviderDestroyed() { | 229 void DtmfSender::OnProviderDestroyed() { |
| 230 LOG(LS_INFO) << "The Dtmf provider is deleted. Clear the sending queue."; | 230 LOG(LS_INFO) << "The Dtmf provider is deleted. Clear the sending queue."; |
| 231 StopSending(); | 231 StopSending(); |
| 232 provider_ = NULL; | 232 provider_ = nullptr; |
| 233 } | 233 } |
| 234 | 234 |
| 235 void DtmfSender::StopSending() { | 235 void DtmfSender::StopSending() { |
| 236 signaling_thread_->Clear(this); | 236 signaling_thread_->Clear(this); |
| 237 } | 237 } |
| 238 | 238 |
| 239 } // namespace webrtc | 239 } // namespace webrtc |
| OLD | NEW |