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

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

Issue 1877253002: Replaced CriticalSectionWrapper with rtc::CriticalSection in rtp_rtcp module (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: git cl format dtmf_queue.cc Created 4 years, 8 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
13 #include <string.h> 13 #include <string.h>
14 14
15 namespace webrtc { 15 namespace webrtc {
16 DTMFqueue::DTMFqueue() 16 DTMFqueue::DTMFqueue() : next_empty_index_(0) {
17 : dtmf_critsect_(CriticalSectionWrapper::CreateCriticalSection()),
18 next_empty_index_(0) {
19 memset(dtmf_key_, 0, sizeof(dtmf_key_)); 17 memset(dtmf_key_, 0, sizeof(dtmf_key_));
20 memset(dtmf_length, 0, sizeof(dtmf_length)); 18 memset(dtmf_length, 0, sizeof(dtmf_length));
21 memset(dtmf_level_, 0, sizeof(dtmf_level_)); 19 memset(dtmf_level_, 0, sizeof(dtmf_level_));
22 } 20 }
23 21
24 DTMFqueue::~DTMFqueue() { 22 DTMFqueue::~DTMFqueue() {}
25 delete dtmf_critsect_;
26 }
27 23
28 int32_t DTMFqueue::AddDTMF(uint8_t key, uint16_t len, uint8_t level) { 24 int32_t DTMFqueue::AddDTMF(uint8_t key, uint16_t len, uint8_t level) {
29 CriticalSectionScoped lock(dtmf_critsect_); 25 rtc::CritScope lock(&dtmf_critsect_);
30 26
31 if (next_empty_index_ >= DTMF_OUTBAND_MAX) { 27 if (next_empty_index_ >= DTMF_OUTBAND_MAX) {
32 return -1; 28 return -1;
33 } 29 }
34 int32_t index = next_empty_index_; 30 int32_t index = next_empty_index_;
35 dtmf_key_[index] = key; 31 dtmf_key_[index] = key;
36 dtmf_length[index] = len; 32 dtmf_length[index] = len;
37 dtmf_level_[index] = level; 33 dtmf_level_[index] = level;
38 next_empty_index_++; 34 next_empty_index_++;
39 return 0; 35 return 0;
40 } 36 }
41 37
42 int8_t DTMFqueue::NextDTMF(uint8_t* dtmf_key, uint16_t* len, uint8_t* level) { 38 int8_t DTMFqueue::NextDTMF(uint8_t* dtmf_key, uint16_t* len, uint8_t* level) {
43 CriticalSectionScoped lock(dtmf_critsect_); 39 rtc::CritScope lock(&dtmf_critsect_);
44 if (next_empty_index_ == 0) 40 if (next_empty_index_ == 0)
45 return -1; 41 return -1;
46 42
47 *dtmf_key = dtmf_key_[0]; 43 *dtmf_key = dtmf_key_[0];
48 *len = dtmf_length[0]; 44 *len = dtmf_length[0];
49 *level = dtmf_level_[0]; 45 *level = dtmf_level_[0];
50 46
51 memmove(&(dtmf_key_[0]), &(dtmf_key_[1]), 47 memmove(&(dtmf_key_[0]), &(dtmf_key_[1]),
52 next_empty_index_ * sizeof(uint8_t)); 48 next_empty_index_ * sizeof(uint8_t));
53 memmove(&(dtmf_length[0]), &(dtmf_length[1]), 49 memmove(&(dtmf_length[0]), &(dtmf_length[1]),
54 next_empty_index_ * sizeof(uint16_t)); 50 next_empty_index_ * sizeof(uint16_t));
55 memmove(&(dtmf_level_[0]), &(dtmf_level_[1]), 51 memmove(&(dtmf_level_[0]), &(dtmf_level_[1]),
56 next_empty_index_ * sizeof(uint8_t)); 52 next_empty_index_ * sizeof(uint8_t));
57 53
58 next_empty_index_--; 54 next_empty_index_--;
59 return 0; 55 return 0;
60 } 56 }
61 57
62 bool DTMFqueue::PendingDTMF() { 58 bool DTMFqueue::PendingDTMF() {
63 CriticalSectionScoped lock(dtmf_critsect_); 59 rtc::CritScope lock(&dtmf_critsect_);
64 return next_empty_index_ > 0; 60 return next_empty_index_ > 0;
65 } 61 }
66 62
67 void DTMFqueue::ResetDTMF() { 63 void DTMFqueue::ResetDTMF() {
68 CriticalSectionScoped lock(dtmf_critsect_); 64 rtc::CritScope lock(&dtmf_critsect_);
69 next_empty_index_ = 0; 65 next_empty_index_ = 0;
70 } 66 }
71 } // namespace webrtc 67 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/rtp_rtcp/source/dtmf_queue.h ('k') | webrtc/modules/rtp_rtcp/source/fec_receiver_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698