Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1610)

Side by Side Diff: webrtc/modules/rtp_rtcp/source/dtmf_queue.cc

Issue 2392883002: Multi frequency DTMF support - sender side (Closed)
Patch Set: WVoMC unittests for multi rate DTMF send Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2011 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
11 #include "webrtc/modules/rtp_rtcp/source/dtmf_queue.h" 11 #include "webrtc/modules/rtp_rtcp/source/dtmf_queue.h"
12 12 #include "webrtc/modules/rtp_rtcp/source/rtp_rtcp_config.h"
hlundin-webrtc 2016/10/28 08:12:36 I'd rather you moved DTMF_OUTBAND_MAX to this file
the sun 2016/11/07 13:33:31 Agree.
13 #include <string.h>
14 13
15 namespace webrtc { 14 namespace webrtc {
16 DTMFqueue::DTMFqueue() : next_empty_index_(0) { 15 DTMFQueue::DTMFQueue() {}
17 memset(dtmf_key_, 0, sizeof(dtmf_key_));
18 memset(dtmf_length, 0, sizeof(dtmf_length));
19 memset(dtmf_level_, 0, sizeof(dtmf_level_));
20 }
21 16
22 DTMFqueue::~DTMFqueue() {} 17 DTMFQueue::~DTMFQueue() {}
23 18
24 int32_t DTMFqueue::AddDTMF(uint8_t key, uint16_t len, uint8_t level) { 19 int DTMFQueue::AddDTMF(const Event& event) {
hlundin-webrtc 2016/10/28 08:12:36 This looks like a bool-returning method to me.
the sun 2016/11/07 13:33:31 Done.
25 rtc::CritScope lock(&dtmf_critsect_); 20 rtc::CritScope lock(&dtmf_critsect_);
26 21 if (queue_.size() >= DTMF_OUTBAND_MAX) {
hlundin-webrtc 2016/10/28 08:12:36 Probably no longer needed as such, since queue_ is
the sun 2016/11/07 13:33:31 Yes.
27 if (next_empty_index_ >= DTMF_OUTBAND_MAX) {
28 return -1; 22 return -1;
29 } 23 }
30 int32_t index = next_empty_index_; 24 queue_.push_back(event);
31 dtmf_key_[index] = key;
32 dtmf_length[index] = len;
33 dtmf_level_[index] = level;
34 next_empty_index_++;
35 return 0; 25 return 0;
36 } 26 }
37 27
38 int8_t DTMFqueue::NextDTMF(uint8_t* dtmf_key, uint16_t* len, uint8_t* level) { 28 int DTMFQueue::NextDTMF(Event* event) {
hlundin-webrtc 2016/10/28 08:12:36 Wouldn't hurt to change this to return an rtc::Opt
the sun 2016/11/07 13:33:31 Changed it at first, but decided against. since it
hlundin-webrtc 2016/11/08 09:01:59 Acknowledged.
29 RTC_DCHECK(event);
39 rtc::CritScope lock(&dtmf_critsect_); 30 rtc::CritScope lock(&dtmf_critsect_);
40 if (next_empty_index_ == 0) 31 if (queue_.empty()) {
41 return -1; 32 return -1;
33 }
42 34
43 *dtmf_key = dtmf_key_[0]; 35 *event = queue_.front();
44 *len = dtmf_length[0]; 36 queue_.pop_front();
45 *level = dtmf_level_[0];
46
47 memmove(&(dtmf_key_[0]), &(dtmf_key_[1]),
48 next_empty_index_ * sizeof(uint8_t));
49 memmove(&(dtmf_length[0]), &(dtmf_length[1]),
50 next_empty_index_ * sizeof(uint16_t));
51 memmove(&(dtmf_level_[0]), &(dtmf_level_[1]),
52 next_empty_index_ * sizeof(uint8_t));
53
54 next_empty_index_--;
55 return 0; 37 return 0;
56 } 38 }
57 39
58 bool DTMFqueue::PendingDTMF() { 40 bool DTMFQueue::PendingDTMF() {
59 rtc::CritScope lock(&dtmf_critsect_); 41 rtc::CritScope lock(&dtmf_critsect_);
60 return next_empty_index_ > 0; 42 return !queue_.empty();
61 } 43 }
62 } // namespace webrtc 44 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698