| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2012 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 |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 // is not known when the first packet describing it is sent. To deal with that, | 92 // is not known when the first packet describing it is sent. To deal with that, |
| 93 // the RFC 4733 specifies that multiple packets are sent for one and the same | 93 // the RFC 4733 specifies that multiple packets are sent for one and the same |
| 94 // event as it is being created (typically, as the user is pressing the key). | 94 // event as it is being created (typically, as the user is pressing the key). |
| 95 // These packets will all share the same start timestamp and event number, | 95 // These packets will all share the same start timestamp and event number, |
| 96 // while the duration will be the cumulative duration from the start. When | 96 // while the duration will be the cumulative duration from the start. When |
| 97 // inserting a new event, the InsertEvent method tries to find a matching event | 97 // inserting a new event, the InsertEvent method tries to find a matching event |
| 98 // already in the buffer. If so, the new event is simply merged with the | 98 // already in the buffer. If so, the new event is simply merged with the |
| 99 // existing one. | 99 // existing one. |
| 100 int DtmfBuffer::InsertEvent(const DtmfEvent& event) { | 100 int DtmfBuffer::InsertEvent(const DtmfEvent& event) { |
| 101 if (event.event_no < 0 || event.event_no > 15 || | 101 if (event.event_no < 0 || event.event_no > 15 || |
| 102 event.volume < 0 || event.volume > 36 || | 102 event.volume < 0 || event.volume > 63 || |
| 103 event.duration <= 0 || event.duration > 65535) { | 103 event.duration <= 0 || event.duration > 65535) { |
| 104 LOG(LS_WARNING) << "InsertEvent invalid parameters"; | 104 LOG(LS_WARNING) << "InsertEvent invalid parameters"; |
| 105 return kInvalidEventParameters; | 105 return kInvalidEventParameters; |
| 106 } | 106 } |
| 107 DtmfList::iterator it = buffer_.begin(); | 107 DtmfList::iterator it = buffer_.begin(); |
| 108 while (it != buffer_.end()) { | 108 while (it != buffer_.end()) { |
| 109 if (MergeEvents(it, event)) { | 109 if (MergeEvents(it, event)) { |
| 110 // A matching event was found and the new event was merged. | 110 // A matching event was found and the new event was merged. |
| 111 return kOK; | 111 return kOK; |
| 112 } | 112 } |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 239 // that belong to the same events, and therefore sharing the same start | 239 // that belong to the same events, and therefore sharing the same start |
| 240 // timestamp, have already been merged before the sort method is called. | 240 // timestamp, have already been merged before the sort method is called. |
| 241 bool DtmfBuffer::CompareEvents(const DtmfEvent& a, const DtmfEvent& b) { | 241 bool DtmfBuffer::CompareEvents(const DtmfEvent& a, const DtmfEvent& b) { |
| 242 if (a.timestamp == b.timestamp) { | 242 if (a.timestamp == b.timestamp) { |
| 243 return a.event_no < b.event_no; | 243 return a.event_no < b.event_no; |
| 244 } | 244 } |
| 245 // Take wrap-around into account. | 245 // Take wrap-around into account. |
| 246 return (static_cast<uint32_t>(b.timestamp - a.timestamp) < 0xFFFFFFFF / 2); | 246 return (static_cast<uint32_t>(b.timestamp - a.timestamp) < 0xFFFFFFFF / 2); |
| 247 } | 247 } |
| 248 } // namespace webrtc | 248 } // namespace webrtc |
| OLD | NEW |