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