| 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 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 163 const uint8_t* payload, | 163 const uint8_t* payload, |
| 164 size_t payload_length, | 164 size_t payload_length, |
| 165 PayloadUnion payload_specific, | 165 PayloadUnion payload_specific, |
| 166 bool in_order) { | 166 bool in_order) { |
| 167 // Trigger our callbacks. | 167 // Trigger our callbacks. |
| 168 CheckSSRCChanged(rtp_header); | 168 CheckSSRCChanged(rtp_header); |
| 169 | 169 |
| 170 int8_t first_payload_byte = payload_length > 0 ? payload[0] : 0; | 170 int8_t first_payload_byte = payload_length > 0 ? payload[0] : 0; |
| 171 bool is_red = false; | 171 bool is_red = false; |
| 172 | 172 |
| 173 if (CheckPayloadChanged(rtp_header, first_payload_byte, is_red, | 173 if (CheckPayloadChanged(rtp_header, first_payload_byte, &is_red, |
| 174 &payload_specific) == -1) { | 174 &payload_specific) == -1) { |
| 175 if (payload_length == 0) { | 175 if (payload_length == 0) { |
| 176 // OK, keep-alive packet. | 176 // OK, keep-alive packet. |
| 177 return true; | 177 return true; |
| 178 } | 178 } |
| 179 LOG(LS_WARNING) << "Receiving invalid payload type."; | 179 LOG(LS_WARNING) << "Receiving invalid payload type."; |
| 180 return false; | 180 return false; |
| 181 } | 181 } |
| 182 | 182 |
| 183 WebRtcRTPHeader webrtc_rtp_header; | 183 WebRtcRTPHeader webrtc_rtp_header; |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 313 | 313 |
| 314 // Implementation note: must not hold critsect when called. | 314 // Implementation note: must not hold critsect when called. |
| 315 // TODO(phoglund): Move as much as possible of this code path into the media | 315 // TODO(phoglund): Move as much as possible of this code path into the media |
| 316 // specific receivers. Basically this method goes through a lot of trouble to | 316 // specific receivers. Basically this method goes through a lot of trouble to |
| 317 // compute something which is only used by the media specific parts later. If | 317 // compute something which is only used by the media specific parts later. If |
| 318 // this code path moves we can get rid of some of the rtp_receiver -> | 318 // this code path moves we can get rid of some of the rtp_receiver -> |
| 319 // media_specific interface (such as CheckPayloadChange, possibly get/set | 319 // media_specific interface (such as CheckPayloadChange, possibly get/set |
| 320 // last known payload). | 320 // last known payload). |
| 321 int32_t RtpReceiverImpl::CheckPayloadChanged(const RTPHeader& rtp_header, | 321 int32_t RtpReceiverImpl::CheckPayloadChanged(const RTPHeader& rtp_header, |
| 322 const int8_t first_payload_byte, | 322 const int8_t first_payload_byte, |
| 323 bool& is_red, | 323 bool* is_red, |
| 324 PayloadUnion* specific_payload) { | 324 PayloadUnion* specific_payload) { |
| 325 bool re_initialize_decoder = false; | 325 bool re_initialize_decoder = false; |
| 326 | 326 |
| 327 char payload_name[RTP_PAYLOAD_NAME_SIZE]; | 327 char payload_name[RTP_PAYLOAD_NAME_SIZE]; |
| 328 int8_t payload_type = rtp_header.payloadType; | 328 int8_t payload_type = rtp_header.payloadType; |
| 329 | 329 |
| 330 { | 330 { |
| 331 CriticalSectionScoped lock(critical_section_rtp_receiver_.get()); | 331 CriticalSectionScoped lock(critical_section_rtp_receiver_.get()); |
| 332 | 332 |
| 333 int8_t last_received_payload_type = | 333 int8_t last_received_payload_type = |
| 334 rtp_payload_registry_->last_received_payload_type(); | 334 rtp_payload_registry_->last_received_payload_type(); |
| 335 // TODO(holmer): Remove this code when RED parsing has been broken out from | 335 // TODO(holmer): Remove this code when RED parsing has been broken out from |
| 336 // RtpReceiverAudio. | 336 // RtpReceiverAudio. |
| 337 if (payload_type != last_received_payload_type) { | 337 if (payload_type != last_received_payload_type) { |
| 338 if (rtp_payload_registry_->red_payload_type() == payload_type) { | 338 if (rtp_payload_registry_->red_payload_type() == payload_type) { |
| 339 // Get the real codec payload type. | 339 // Get the real codec payload type. |
| 340 payload_type = first_payload_byte & 0x7f; | 340 payload_type = first_payload_byte & 0x7f; |
| 341 is_red = true; | 341 *is_red = true; |
| 342 | 342 |
| 343 if (rtp_payload_registry_->red_payload_type() == payload_type) { | 343 if (rtp_payload_registry_->red_payload_type() == payload_type) { |
| 344 // Invalid payload type, traced by caller. If we proceeded here, | 344 // Invalid payload type, traced by caller. If we proceeded here, |
| 345 // this would be set as |_last_received_payload_type|, and we would no | 345 // this would be set as |_last_received_payload_type|, and we would no |
| 346 // longer catch corrupt packets at this level. | 346 // longer catch corrupt packets at this level. |
| 347 return -1; | 347 return -1; |
| 348 } | 348 } |
| 349 | 349 |
| 350 // When we receive RED we need to check the real payload type. | 350 // When we receive RED we need to check the real payload type. |
| 351 if (payload_type == last_received_payload_type) { | 351 if (payload_type == last_received_payload_type) { |
| 352 rtp_media_receiver_->GetLastMediaSpecificPayload(specific_payload); | 352 rtp_media_receiver_->GetLastMediaSpecificPayload(specific_payload); |
| 353 return 0; | 353 return 0; |
| 354 } | 354 } |
| 355 } | 355 } |
| 356 bool should_discard_changes = false; | 356 bool should_discard_changes = false; |
| 357 | 357 |
| 358 rtp_media_receiver_->CheckPayloadChanged( | 358 rtp_media_receiver_->CheckPayloadChanged( |
| 359 payload_type, specific_payload, | 359 payload_type, specific_payload, |
| 360 &should_discard_changes); | 360 &should_discard_changes); |
| 361 | 361 |
| 362 if (should_discard_changes) { | 362 if (should_discard_changes) { |
| 363 is_red = false; | 363 *is_red = false; |
| 364 return 0; | 364 return 0; |
| 365 } | 365 } |
| 366 | 366 |
| 367 const Payload* payload = | 367 const Payload* payload = |
| 368 rtp_payload_registry_->PayloadTypeToPayload(payload_type); | 368 rtp_payload_registry_->PayloadTypeToPayload(payload_type); |
| 369 if (!payload) { | 369 if (!payload) { |
| 370 // Not a registered payload type. | 370 // Not a registered payload type. |
| 371 return -1; | 371 return -1; |
| 372 } | 372 } |
| 373 payload_name[RTP_PAYLOAD_NAME_SIZE - 1] = 0; | 373 payload_name[RTP_PAYLOAD_NAME_SIZE - 1] = 0; |
| 374 strncpy(payload_name, payload->name, RTP_PAYLOAD_NAME_SIZE - 1); | 374 strncpy(payload_name, payload->name, RTP_PAYLOAD_NAME_SIZE - 1); |
| 375 | 375 |
| 376 rtp_payload_registry_->set_last_received_payload_type(payload_type); | 376 rtp_payload_registry_->set_last_received_payload_type(payload_type); |
| 377 | 377 |
| 378 re_initialize_decoder = true; | 378 re_initialize_decoder = true; |
| 379 | 379 |
| 380 rtp_media_receiver_->SetLastMediaSpecificPayload(payload->typeSpecific); | 380 rtp_media_receiver_->SetLastMediaSpecificPayload(payload->typeSpecific); |
| 381 rtp_media_receiver_->GetLastMediaSpecificPayload(specific_payload); | 381 rtp_media_receiver_->GetLastMediaSpecificPayload(specific_payload); |
| 382 | 382 |
| 383 if (!payload->audio) { | 383 if (!payload->audio) { |
| 384 bool media_type_unchanged = | 384 bool media_type_unchanged = |
| 385 rtp_payload_registry_->ReportMediaPayloadType(payload_type); | 385 rtp_payload_registry_->ReportMediaPayloadType(payload_type); |
| 386 if (media_type_unchanged) { | 386 if (media_type_unchanged) { |
| 387 // Only reset the decoder if the media codec type has changed. | 387 // Only reset the decoder if the media codec type has changed. |
| 388 re_initialize_decoder = false; | 388 re_initialize_decoder = false; |
| 389 } | 389 } |
| 390 } | 390 } |
| 391 } else { | 391 } else { |
| 392 rtp_media_receiver_->GetLastMediaSpecificPayload(specific_payload); | 392 rtp_media_receiver_->GetLastMediaSpecificPayload(specific_payload); |
| 393 is_red = false; | 393 *is_red = false; |
| 394 } | 394 } |
| 395 } // End critsect. | 395 } // End critsect. |
| 396 | 396 |
| 397 if (re_initialize_decoder) { | 397 if (re_initialize_decoder) { |
| 398 if (-1 == | 398 if (-1 == |
| 399 rtp_media_receiver_->InvokeOnInitializeDecoder( | 399 rtp_media_receiver_->InvokeOnInitializeDecoder( |
| 400 cb_rtp_feedback_, payload_type, payload_name, *specific_payload)) { | 400 cb_rtp_feedback_, payload_type, payload_name, *specific_payload)) { |
| 401 return -1; // Wrong payload type. | 401 return -1; // Wrong payload type. |
| 402 } | 402 } |
| 403 } | 403 } |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 480 // implementations might have CSRC 0 as a valid value. | 480 // implementations might have CSRC 0 as a valid value. |
| 481 if (num_csrcs_diff > 0) { | 481 if (num_csrcs_diff > 0) { |
| 482 cb_rtp_feedback_->OnIncomingCSRCChanged(0, true); | 482 cb_rtp_feedback_->OnIncomingCSRCChanged(0, true); |
| 483 } else if (num_csrcs_diff < 0) { | 483 } else if (num_csrcs_diff < 0) { |
| 484 cb_rtp_feedback_->OnIncomingCSRCChanged(0, false); | 484 cb_rtp_feedback_->OnIncomingCSRCChanged(0, false); |
| 485 } | 485 } |
| 486 } | 486 } |
| 487 } | 487 } |
| 488 | 488 |
| 489 } // namespace webrtc | 489 } // namespace webrtc |
| OLD | NEW |