Line data Source code
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 "webrtc/modules/rtp_rtcp/source/dtmf_queue.h"
12 :
13 : namespace {
14 : constexpr size_t kDtmfOutbandMax = 20;
15 : }
16 :
17 : namespace webrtc {
18 0 : DtmfQueue::DtmfQueue() {}
19 :
20 0 : DtmfQueue::~DtmfQueue() {}
21 :
22 0 : bool DtmfQueue::AddDtmf(const Event& event) {
23 0 : rtc::CritScope lock(&dtmf_critsect_);
24 0 : if (queue_.size() >= kDtmfOutbandMax) {
25 0 : return false;
26 : }
27 0 : queue_.push_back(event);
28 0 : return true;
29 : }
30 :
31 0 : bool DtmfQueue::NextDtmf(Event* event) {
32 0 : RTC_DCHECK(event);
33 0 : rtc::CritScope lock(&dtmf_critsect_);
34 0 : if (queue_.empty()) {
35 0 : return false;
36 : }
37 :
38 0 : *event = queue_.front();
39 0 : queue_.pop_front();
40 0 : return true;
41 : }
42 :
43 0 : bool DtmfQueue::PendingDtmf() const {
44 0 : rtc::CritScope lock(&dtmf_critsect_);
45 0 : return !queue_.empty();
46 : }
47 : } // namespace webrtc
|