| 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 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 164 const RTPHeader& rtp_header, | 164 const RTPHeader& rtp_header, |
| 165 const uint8_t* payload, | 165 const uint8_t* payload, |
| 166 size_t payload_length, | 166 size_t payload_length, |
| 167 PayloadUnion payload_specific, | 167 PayloadUnion payload_specific, |
| 168 bool in_order) { | 168 bool in_order) { |
| 169 // Trigger our callbacks. | 169 // Trigger our callbacks. |
| 170 CheckSSRCChanged(rtp_header); | 170 CheckSSRCChanged(rtp_header); |
| 171 | 171 |
| 172 int8_t first_payload_byte = payload_length > 0 ? payload[0] : 0; | 172 int8_t first_payload_byte = payload_length > 0 ? payload[0] : 0; |
| 173 bool is_red = false; | 173 bool is_red = false; |
| 174 bool should_reset_statistics = false; | |
| 175 | 174 |
| 176 if (CheckPayloadChanged(rtp_header, | 175 if (CheckPayloadChanged(rtp_header, first_payload_byte, is_red, |
| 177 first_payload_byte, | 176 &payload_specific) == -1) { |
| 178 is_red, | |
| 179 &payload_specific, | |
| 180 &should_reset_statistics) == -1) { | |
| 181 if (payload_length == 0) { | 177 if (payload_length == 0) { |
| 182 // OK, keep-alive packet. | 178 // OK, keep-alive packet. |
| 183 return true; | 179 return true; |
| 184 } | 180 } |
| 185 LOG(LS_WARNING) << "Receiving invalid payload type."; | 181 LOG(LS_WARNING) << "Receiving invalid payload type."; |
| 186 return false; | 182 return false; |
| 187 } | 183 } |
| 188 | 184 |
| 189 if (should_reset_statistics) { | |
| 190 cb_rtp_feedback_->ResetStatistics(ssrc_); | |
| 191 } | |
| 192 | |
| 193 WebRtcRTPHeader webrtc_rtp_header; | 185 WebRtcRTPHeader webrtc_rtp_header; |
| 194 memset(&webrtc_rtp_header, 0, sizeof(webrtc_rtp_header)); | 186 memset(&webrtc_rtp_header, 0, sizeof(webrtc_rtp_header)); |
| 195 webrtc_rtp_header.header = rtp_header; | 187 webrtc_rtp_header.header = rtp_header; |
| 196 CheckCSRC(webrtc_rtp_header); | 188 CheckCSRC(webrtc_rtp_header); |
| 197 | 189 |
| 198 size_t payload_data_length = payload_length - rtp_header.paddingLength; | 190 size_t payload_data_length = payload_length - rtp_header.paddingLength; |
| 199 | 191 |
| 200 bool is_first_packet_in_frame = false; | 192 bool is_first_packet_in_frame = false; |
| 201 { | 193 { |
| 202 CriticalSectionScoped lock(critical_section_rtp_receiver_.get()); | 194 CriticalSectionScoped lock(critical_section_rtp_receiver_.get()); |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 269 { | 261 { |
| 270 CriticalSectionScoped lock(critical_section_rtp_receiver_.get()); | 262 CriticalSectionScoped lock(critical_section_rtp_receiver_.get()); |
| 271 | 263 |
| 272 int8_t last_received_payload_type = | 264 int8_t last_received_payload_type = |
| 273 rtp_payload_registry_->last_received_payload_type(); | 265 rtp_payload_registry_->last_received_payload_type(); |
| 274 if (ssrc_ != rtp_header.ssrc || | 266 if (ssrc_ != rtp_header.ssrc || |
| 275 (last_received_payload_type == -1 && ssrc_ == 0)) { | 267 (last_received_payload_type == -1 && ssrc_ == 0)) { |
| 276 // We need the payload_type_ to make the call if the remote SSRC is 0. | 268 // We need the payload_type_ to make the call if the remote SSRC is 0. |
| 277 new_ssrc = true; | 269 new_ssrc = true; |
| 278 | 270 |
| 279 cb_rtp_feedback_->ResetStatistics(ssrc_); | |
| 280 | |
| 281 last_received_timestamp_ = 0; | 271 last_received_timestamp_ = 0; |
| 282 last_received_sequence_number_ = 0; | 272 last_received_sequence_number_ = 0; |
| 283 last_received_frame_time_ms_ = -1; | 273 last_received_frame_time_ms_ = -1; |
| 284 | 274 |
| 285 // Do we have a SSRC? Then the stream is restarted. | 275 // Do we have a SSRC? Then the stream is restarted. |
| 286 if (ssrc_ != 0) { | 276 if (ssrc_ != 0) { |
| 287 // Do we have the same codec? Then re-initialize coder. | 277 // Do we have the same codec? Then re-initialize coder. |
| 288 if (rtp_header.payloadType == last_received_payload_type) { | 278 if (rtp_header.payloadType == last_received_payload_type) { |
| 289 re_initialize_decoder = true; | 279 re_initialize_decoder = true; |
| 290 | 280 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 323 } | 313 } |
| 324 } | 314 } |
| 325 | 315 |
| 326 // Implementation note: must not hold critsect when called. | 316 // Implementation note: must not hold critsect when called. |
| 327 // TODO(phoglund): Move as much as possible of this code path into the media | 317 // TODO(phoglund): Move as much as possible of this code path into the media |
| 328 // specific receivers. Basically this method goes through a lot of trouble to | 318 // specific receivers. Basically this method goes through a lot of trouble to |
| 329 // compute something which is only used by the media specific parts later. If | 319 // compute something which is only used by the media specific parts later. If |
| 330 // this code path moves we can get rid of some of the rtp_receiver -> | 320 // this code path moves we can get rid of some of the rtp_receiver -> |
| 331 // media_specific interface (such as CheckPayloadChange, possibly get/set | 321 // media_specific interface (such as CheckPayloadChange, possibly get/set |
| 332 // last known payload). | 322 // last known payload). |
| 333 int32_t RtpReceiverImpl::CheckPayloadChanged( | 323 int32_t RtpReceiverImpl::CheckPayloadChanged(const RTPHeader& rtp_header, |
| 334 const RTPHeader& rtp_header, | 324 const int8_t first_payload_byte, |
| 335 const int8_t first_payload_byte, | 325 bool& is_red, |
| 336 bool& is_red, | 326 PayloadUnion* specific_payload) { |
| 337 PayloadUnion* specific_payload, | |
| 338 bool* should_reset_statistics) { | |
| 339 bool re_initialize_decoder = false; | 327 bool re_initialize_decoder = false; |
| 340 | 328 |
| 341 char payload_name[RTP_PAYLOAD_NAME_SIZE]; | 329 char payload_name[RTP_PAYLOAD_NAME_SIZE]; |
| 342 int8_t payload_type = rtp_header.payloadType; | 330 int8_t payload_type = rtp_header.payloadType; |
| 343 | 331 |
| 344 { | 332 { |
| 345 CriticalSectionScoped lock(critical_section_rtp_receiver_.get()); | 333 CriticalSectionScoped lock(critical_section_rtp_receiver_.get()); |
| 346 | 334 |
| 347 int8_t last_received_payload_type = | 335 int8_t last_received_payload_type = |
| 348 rtp_payload_registry_->last_received_payload_type(); | 336 rtp_payload_registry_->last_received_payload_type(); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 360 // longer catch corrupt packets at this level. | 348 // longer catch corrupt packets at this level. |
| 361 return -1; | 349 return -1; |
| 362 } | 350 } |
| 363 | 351 |
| 364 // When we receive RED we need to check the real payload type. | 352 // When we receive RED we need to check the real payload type. |
| 365 if (payload_type == last_received_payload_type) { | 353 if (payload_type == last_received_payload_type) { |
| 366 rtp_media_receiver_->GetLastMediaSpecificPayload(specific_payload); | 354 rtp_media_receiver_->GetLastMediaSpecificPayload(specific_payload); |
| 367 return 0; | 355 return 0; |
| 368 } | 356 } |
| 369 } | 357 } |
| 370 *should_reset_statistics = false; | |
| 371 bool should_discard_changes = false; | 358 bool should_discard_changes = false; |
| 372 | 359 |
| 373 rtp_media_receiver_->CheckPayloadChanged( | 360 rtp_media_receiver_->CheckPayloadChanged( |
| 374 payload_type, specific_payload, should_reset_statistics, | 361 payload_type, specific_payload, |
| 375 &should_discard_changes); | 362 &should_discard_changes); |
| 376 | 363 |
| 377 if (should_discard_changes) { | 364 if (should_discard_changes) { |
| 378 is_red = false; | 365 is_red = false; |
| 379 return 0; | 366 return 0; |
| 380 } | 367 } |
| 381 | 368 |
| 382 Payload* payload; | 369 Payload* payload; |
| 383 if (!rtp_payload_registry_->PayloadTypeToPayload(payload_type, payload)) { | 370 if (!rtp_payload_registry_->PayloadTypeToPayload(payload_type, payload)) { |
| 384 // Not a registered payload type. | 371 // Not a registered payload type. |
| (...skipping 11 matching lines...) Expand all Loading... |
| 396 rtp_media_receiver_->GetLastMediaSpecificPayload(specific_payload); | 383 rtp_media_receiver_->GetLastMediaSpecificPayload(specific_payload); |
| 397 | 384 |
| 398 if (!payload->audio) { | 385 if (!payload->audio) { |
| 399 bool media_type_unchanged = | 386 bool media_type_unchanged = |
| 400 rtp_payload_registry_->ReportMediaPayloadType(payload_type); | 387 rtp_payload_registry_->ReportMediaPayloadType(payload_type); |
| 401 if (media_type_unchanged) { | 388 if (media_type_unchanged) { |
| 402 // Only reset the decoder if the media codec type has changed. | 389 // Only reset the decoder if the media codec type has changed. |
| 403 re_initialize_decoder = false; | 390 re_initialize_decoder = false; |
| 404 } | 391 } |
| 405 } | 392 } |
| 406 if (re_initialize_decoder) { | |
| 407 *should_reset_statistics = true; | |
| 408 } | |
| 409 } else { | 393 } else { |
| 410 rtp_media_receiver_->GetLastMediaSpecificPayload(specific_payload); | 394 rtp_media_receiver_->GetLastMediaSpecificPayload(specific_payload); |
| 411 is_red = false; | 395 is_red = false; |
| 412 } | 396 } |
| 413 } // End critsect. | 397 } // End critsect. |
| 414 | 398 |
| 415 if (re_initialize_decoder) { | 399 if (re_initialize_decoder) { |
| 416 if (-1 == rtp_media_receiver_->InvokeOnInitializeDecoder( | 400 if (-1 == rtp_media_receiver_->InvokeOnInitializeDecoder( |
| 417 cb_rtp_feedback_, id_, payload_type, payload_name, | 401 cb_rtp_feedback_, id_, payload_type, payload_name, |
| 418 *specific_payload)) { | 402 *specific_payload)) { |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 498 // implementations might have CSRC 0 as a valid value. | 482 // implementations might have CSRC 0 as a valid value. |
| 499 if (num_csrcs_diff > 0) { | 483 if (num_csrcs_diff > 0) { |
| 500 cb_rtp_feedback_->OnIncomingCSRCChanged(id_, 0, true); | 484 cb_rtp_feedback_->OnIncomingCSRCChanged(id_, 0, true); |
| 501 } else if (num_csrcs_diff < 0) { | 485 } else if (num_csrcs_diff < 0) { |
| 502 cb_rtp_feedback_->OnIncomingCSRCChanged(id_, 0, false); | 486 cb_rtp_feedback_->OnIncomingCSRCChanged(id_, 0, false); |
| 503 } | 487 } |
| 504 } | 488 } |
| 505 } | 489 } |
| 506 | 490 |
| 507 } // namespace webrtc | 491 } // namespace webrtc |
| OLD | NEW |