2011-07-07 08:21:25 +00:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
|
|
|
|
|
*
|
|
|
|
|
* Use of this source code is governed by a BSD-style license
|
|
|
|
|
* that can be found in the LICENSE file in the root of the source
|
|
|
|
|
* tree. An additional intellectual property rights grant can be found
|
|
|
|
|
* in the file PATENTS. All contributing project authors may
|
|
|
|
|
* be found in the AUTHORS file in the root of the source tree.
|
|
|
|
|
*/
|
|
|
|
|
|
2017-09-15 06:47:31 +02:00
|
|
|
#include "modules/rtp_rtcp/source/dtmf_queue.h"
|
2011-07-07 08:21:25 +00:00
|
|
|
|
2018-10-23 12:03:01 +02:00
|
|
|
#include <stddef.h>
|
|
|
|
|
|
|
|
|
|
#include "rtc_base/checks.h"
|
|
|
|
|
|
2016-11-17 05:25:37 -08:00
|
|
|
namespace {
|
|
|
|
|
constexpr size_t kDtmfOutbandMax = 20;
|
|
|
|
|
}
|
2011-07-07 08:21:25 +00:00
|
|
|
|
|
|
|
|
namespace webrtc {
|
2016-11-17 05:25:37 -08:00
|
|
|
DtmfQueue::DtmfQueue() {}
|
2011-07-07 08:21:25 +00:00
|
|
|
|
2016-11-17 05:25:37 -08:00
|
|
|
DtmfQueue::~DtmfQueue() {}
|
2011-07-07 08:21:25 +00:00
|
|
|
|
2016-11-17 05:25:37 -08:00
|
|
|
bool DtmfQueue::AddDtmf(const Event& event) {
|
2020-07-07 11:44:28 +02:00
|
|
|
MutexLock lock(&dtmf_mutex_);
|
2016-11-17 05:25:37 -08:00
|
|
|
if (queue_.size() >= kDtmfOutbandMax) {
|
|
|
|
|
return false;
|
2013-05-08 10:04:06 +00:00
|
|
|
}
|
2016-11-17 05:25:37 -08:00
|
|
|
queue_.push_back(event);
|
|
|
|
|
return true;
|
2011-07-07 08:21:25 +00:00
|
|
|
}
|
|
|
|
|
|
2016-11-17 05:25:37 -08:00
|
|
|
bool DtmfQueue::NextDtmf(Event* event) {
|
|
|
|
|
RTC_DCHECK(event);
|
2020-07-07 11:44:28 +02:00
|
|
|
MutexLock lock(&dtmf_mutex_);
|
2016-11-17 05:25:37 -08:00
|
|
|
if (queue_.empty()) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
*event = queue_.front();
|
|
|
|
|
queue_.pop_front();
|
|
|
|
|
return true;
|
2011-07-07 08:21:25 +00:00
|
|
|
}
|
|
|
|
|
|
2016-11-17 05:25:37 -08:00
|
|
|
bool DtmfQueue::PendingDtmf() const {
|
2020-07-07 11:44:28 +02:00
|
|
|
MutexLock lock(&dtmf_mutex_);
|
2016-11-17 05:25:37 -08:00
|
|
|
return !queue_.empty();
|
2015-02-12 12:20:08 +00:00
|
|
|
}
|
2013-05-08 10:04:06 +00:00
|
|
|
} // namespace webrtc
|