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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 // and has so far lasted as long as indicated by this parameter. | 63 // and has so far lasted as long as indicated by this parameter. |
64 // The event may or may not have ended. If the event duration | 64 // The event may or may not have ended. If the event duration |
65 // exceeds the maximum representable by the duration field, the | 65 // exceeds the maximum representable by the duration field, the |
66 // event is split into several contiguous segments. The buffer will | 66 // event is split into several contiguous segments. The buffer will |
67 // discard zero-duration events. | 67 // discard zero-duration events. |
68 // | 68 // |
69 int DtmfBuffer::ParseEvent(uint32_t rtp_timestamp, | 69 int DtmfBuffer::ParseEvent(uint32_t rtp_timestamp, |
70 const uint8_t* payload, | 70 const uint8_t* payload, |
71 size_t payload_length_bytes, | 71 size_t payload_length_bytes, |
72 DtmfEvent* event) { | 72 DtmfEvent* event) { |
73 CHECK(payload); | 73 RTC_CHECK(payload); |
74 CHECK(event); | 74 RTC_CHECK(event); |
75 if (payload_length_bytes < 4) { | 75 if (payload_length_bytes < 4) { |
76 LOG(LS_WARNING) << "ParseEvent payload too short"; | 76 LOG(LS_WARNING) << "ParseEvent payload too short"; |
77 return kPayloadTooShort; | 77 return kPayloadTooShort; |
78 } | 78 } |
79 | 79 |
80 event->event_no = payload[0]; | 80 event->event_no = payload[0]; |
81 event->end_bit = ((payload[1] & 0x80) != 0); | 81 event->end_bit = ((payload[1] & 0x80) != 0); |
82 event->volume = (payload[1] & 0x3F); | 82 event->volume = (payload[1] & 0x3F); |
83 event->duration = payload[2] << 8 | payload[3]; | 83 event->duration = payload[2] << 8 | payload[3]; |
84 event->timestamp = rtp_timestamp; | 84 event->timestamp = rtp_timestamp; |
(...skipping 154 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 |