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 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
205 return 0; | 205 return 0; |
206 } | 206 } |
207 | 207 |
208 // We are not allowed to have any critsects when calling data_callback. | 208 // We are not allowed to have any critsects when calling data_callback. |
209 int32_t RTPReceiverAudio::ParseAudioCodecSpecific( | 209 int32_t RTPReceiverAudio::ParseAudioCodecSpecific( |
210 WebRtcRTPHeader* rtp_header, | 210 WebRtcRTPHeader* rtp_header, |
211 const uint8_t* payload_data, | 211 const uint8_t* payload_data, |
212 size_t payload_length, | 212 size_t payload_length, |
213 const AudioPayload& audio_specific, | 213 const AudioPayload& audio_specific, |
214 bool is_red) { | 214 bool is_red) { |
215 | 215 RTC_DCHECK_GE(payload_length, rtp_header->header.paddingLength); |
216 if (payload_length == 0) { | 216 size_t payload_data_length = |
minyue-webrtc
2017/05/10 13:37:03
nit const
hlundin-webrtc
2017/05/10 13:47:19
Done.
| |
217 return 0; | 217 payload_length - rtp_header->header.paddingLength; |
218 if (payload_data_length == 0) { | |
219 rtp_header->type.Audio.isCNG = false; | |
220 rtp_header->frameType = kEmptyFrame; | |
221 return data_callback_->OnReceivedPayloadData(nullptr, 0, rtp_header); | |
218 } | 222 } |
219 | 223 |
220 bool telephone_event_packet = | 224 bool telephone_event_packet = |
221 TelephoneEventPayloadType(rtp_header->header.payloadType); | 225 TelephoneEventPayloadType(rtp_header->header.payloadType); |
222 if (telephone_event_packet) { | 226 if (telephone_event_packet) { |
223 rtc::CritScope lock(&crit_sect_); | 227 rtc::CritScope lock(&crit_sect_); |
224 | 228 |
225 // RFC 4733 2.3 | 229 // RFC 4733 2.3 |
226 // 0 1 2 3 | 230 // 0 1 2 3 |
227 // 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 | 231 // 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 |
228 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | 232 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
229 // | event |E|R| volume | duration | | 233 // | event |E|R| volume | duration | |
230 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | 234 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
231 // | 235 // |
232 if (payload_length % 4 != 0) { | 236 if (payload_data_length % 4 != 0) { |
233 return -1; | 237 return -1; |
234 } | 238 } |
235 size_t number_of_events = payload_length / 4; | 239 size_t number_of_events = payload_data_length / 4; |
236 | 240 |
237 // sanity | 241 // sanity |
238 if (number_of_events >= MAX_NUMBER_OF_PARALLEL_TELEPHONE_EVENTS) { | 242 if (number_of_events >= MAX_NUMBER_OF_PARALLEL_TELEPHONE_EVENTS) { |
239 number_of_events = MAX_NUMBER_OF_PARALLEL_TELEPHONE_EVENTS; | 243 number_of_events = MAX_NUMBER_OF_PARALLEL_TELEPHONE_EVENTS; |
240 } | 244 } |
241 for (size_t n = 0; n < number_of_events; ++n) { | 245 for (size_t n = 0; n < number_of_events; ++n) { |
246 RTC_DCHECK_GE(payload_data_length, (4 * n) + 2); | |
242 bool end = (payload_data[(4 * n) + 1] & 0x80) ? true : false; | 247 bool end = (payload_data[(4 * n) + 1] & 0x80) ? true : false; |
243 | 248 |
244 std::set<uint8_t>::iterator event = | 249 std::set<uint8_t>::iterator event = |
245 telephone_event_reported_.find(payload_data[4 * n]); | 250 telephone_event_reported_.find(payload_data[4 * n]); |
246 | 251 |
247 if (event != telephone_event_reported_.end()) { | 252 if (event != telephone_event_reported_.end()) { |
248 // we have already seen this event | 253 // we have already seen this event |
249 if (end) { | 254 if (end) { |
250 telephone_event_reported_.erase(payload_data[4 * n]); | 255 telephone_event_reported_.erase(payload_data[4 * n]); |
251 } | 256 } |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
284 } | 289 } |
285 std::set<uint8_t>::iterator first = | 290 std::set<uint8_t>::iterator first = |
286 telephone_event_reported_.begin(); | 291 telephone_event_reported_.begin(); |
287 if (first != telephone_event_reported_.end() && *first > 15) { | 292 if (first != telephone_event_reported_.end() && *first > 15) { |
288 // don't forward non DTMF events | 293 // don't forward non DTMF events |
289 return 0; | 294 return 0; |
290 } | 295 } |
291 } | 296 } |
292 } | 297 } |
293 // TODO(holmer): Break this out to have RED parsing handled generically. | 298 // TODO(holmer): Break this out to have RED parsing handled generically. |
299 RTC_DCHECK_GT(payload_data_length, 0); | |
294 if (is_red && !(payload_data[0] & 0x80)) { | 300 if (is_red && !(payload_data[0] & 0x80)) { |
295 // we recive only one frame packed in a RED packet remove the RED wrapper | 301 // we recive only one frame packed in a RED packet remove the RED wrapper |
296 rtp_header->header.payloadType = payload_data[0]; | 302 rtp_header->header.payloadType = payload_data[0]; |
297 | 303 |
298 // only one frame in the RED strip the one byte to help NetEq | 304 // only one frame in the RED strip the one byte to help NetEq |
299 return data_callback_->OnReceivedPayloadData( | 305 return data_callback_->OnReceivedPayloadData( |
300 payload_data + 1, payload_length - 1, rtp_header); | 306 payload_data + 1, payload_data_length - 1, rtp_header); |
301 } | 307 } |
302 | 308 |
303 rtp_header->type.Audio.channel = audio_specific.channels; | 309 rtp_header->type.Audio.channel = audio_specific.channels; |
304 return data_callback_->OnReceivedPayloadData( | 310 return data_callback_->OnReceivedPayloadData(payload_data, |
305 payload_data, payload_length, rtp_header); | 311 payload_data_length, rtp_header); |
306 } | 312 } |
307 } // namespace webrtc | 313 } // namespace webrtc |
OLD | NEW |