1 /* 2 * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 * 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 6 * tree. An additional intellectual property rights grant can be found 7 * in the file PATENTS. All contributing project authors may 8 * be found in the AUTHORS file in the root of the source tree. 9 */ 10 11 #include "modules/rtp_rtcp/source/dtmf_queue.h" 12 13 #include <stddef.h> 14 15 #include "rtc_base/checks.h" 16 17 namespace { 18 constexpr size_t kDtmfOutbandMax = 20; 19 } 20 21 namespace webrtc { DtmfQueue()22DtmfQueue::DtmfQueue() {} 23 ~DtmfQueue()24DtmfQueue::~DtmfQueue() {} 25 AddDtmf(const Event & event)26bool DtmfQueue::AddDtmf(const Event& event) { 27 MutexLock lock(&dtmf_mutex_); 28 if (queue_.size() >= kDtmfOutbandMax) { 29 return false; 30 } 31 queue_.push_back(event); 32 return true; 33 } 34 NextDtmf(Event * event)35bool DtmfQueue::NextDtmf(Event* event) { 36 RTC_DCHECK(event); 37 MutexLock lock(&dtmf_mutex_); 38 if (queue_.empty()) { 39 return false; 40 } 41 42 *event = queue_.front(); 43 queue_.pop_front(); 44 return true; 45 } 46 PendingDtmf() const47bool DtmfQueue::PendingDtmf() const { 48 MutexLock lock(&dtmf_mutex_); 49 return !queue_.empty(); 50 } 51 } // namespace webrtc 52