Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2013 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 |
| 11 #include "webrtc/modules/rtp_rtcp/include/rtp_payload_registry.h" | 11 #include "webrtc/modules/rtp_rtcp/include/rtp_payload_registry.h" |
| 12 | 12 |
| 13 #include "webrtc/base/logging.h" | 13 #include "webrtc/base/logging.h" |
| 14 #include "webrtc/modules/rtp_rtcp/source/byte_io.h" | 14 #include "webrtc/modules/rtp_rtcp/source/byte_io.h" |
| 15 | 15 |
| 16 namespace webrtc { | 16 namespace webrtc { |
| 17 | 17 |
| 18 RTPPayloadRegistry::RTPPayloadRegistry(RTPPayloadStrategy* rtp_payload_strategy) | 18 RTPPayloadRegistry::RTPPayloadRegistry(RTPPayloadStrategy* rtp_payload_strategy) |
| 19 : crit_sect_(CriticalSectionWrapper::CreateCriticalSection()), | 19 : crit_sect_(CriticalSectionWrapper::CreateCriticalSection()), |
| 20 rtp_payload_strategy_(rtp_payload_strategy), | 20 rtp_payload_strategy_(rtp_payload_strategy), |
| 21 red_payload_type_(-1), | 21 red_payload_type_(-1), |
| 22 ulpfec_payload_type_(-1), | 22 ulpfec_payload_type_(-1), |
| 23 incoming_payload_type_(-1), | 23 incoming_payload_type_(-1), |
| 24 last_received_payload_type_(-1), | 24 last_received_payload_type_(-1), |
| 25 last_received_media_payload_type_(-1), | 25 last_received_media_payload_type_(-1), |
| 26 rtx_(false), | 26 rtx_(false), |
| 27 rtx_payload_type_(-1), | 27 rtx_payload_type_(-1), |
| 28 use_rtx_payload_mapping_on_restore_(false), | |
| 29 ssrc_rtx_(0) {} | 28 ssrc_rtx_(0) {} |
| 30 | 29 |
| 31 RTPPayloadRegistry::~RTPPayloadRegistry() { | 30 RTPPayloadRegistry::~RTPPayloadRegistry() { |
| 32 while (!payload_type_map_.empty()) { | 31 while (!payload_type_map_.empty()) { |
| 33 RtpUtility::PayloadTypeMap::iterator it = payload_type_map_.begin(); | 32 RtpUtility::PayloadTypeMap::iterator it = payload_type_map_.begin(); |
| 34 delete it->second; | 33 delete it->second; |
| 35 payload_type_map_.erase(it); | 34 payload_type_map_.erase(it); |
| 36 } | 35 } |
| 37 } | 36 } |
| 38 | 37 |
| (...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 264 ByteWriter<uint16_t>::WriteBigEndian(restored_packet + 2, | 263 ByteWriter<uint16_t>::WriteBigEndian(restored_packet + 2, |
| 265 original_sequence_number); | 264 original_sequence_number); |
| 266 ByteWriter<uint32_t>::WriteBigEndian(restored_packet + 8, original_ssrc); | 265 ByteWriter<uint32_t>::WriteBigEndian(restored_packet + 8, original_ssrc); |
| 267 | 266 |
| 268 CriticalSectionScoped cs(crit_sect_.get()); | 267 CriticalSectionScoped cs(crit_sect_.get()); |
| 269 if (!rtx_) | 268 if (!rtx_) |
| 270 return true; | 269 return true; |
| 271 | 270 |
| 272 int associated_payload_type; | 271 int associated_payload_type; |
| 273 auto apt_mapping = rtx_payload_type_map_.find(header.payloadType); | 272 auto apt_mapping = rtx_payload_type_map_.find(header.payloadType); |
| 274 if (use_rtx_payload_mapping_on_restore_ && | 273 if (apt_mapping == rtx_payload_type_map_.end()) |
| 275 apt_mapping != rtx_payload_type_map_.end()) { | 274 return false; |
| 276 associated_payload_type = apt_mapping->second; | 275 associated_payload_type = apt_mapping->second; |
| 277 } else { | 276 if (red_payload_type_ != -1) { |
|
pbos-webrtc
2016/02/01 14:32:19
Does this path still have test coverage? It should
stefan-webrtc
2016/02/01 15:26:08
I added a test which specifically tests this path.
| |
| 278 // In the future, this will be a bug. For now, just assume this RTX packet | 277 // Assume red will be used if it's configured. |
| 279 // matches the last non-RTX payload type we received. There are cases where | 278 // This is a workaround for a Chrome sdp bug where rtx is associated |
| 280 // this could break, especially where RTX is sent outside of NACKing (e.g. | 279 // with the media codec even though media is sent over red. |
| 281 // padding with redundant payloads). | 280 // TODO(holmer): Remove once the Chrome versions exposing this bug are |
| 282 if (rtx_payload_type_ == -1 || incoming_payload_type_ == -1) { | 281 // old enough. |
|
pbos-webrtc
2016/02/01 14:32:19
Put which Chrome versions these are, so you can re
stefan-webrtc
2016/02/01 15:26:08
Done.
| |
| 283 LOG(LS_WARNING) << "Incorrect RTX configuration, dropping packet."; | 282 associated_payload_type = red_payload_type_; |
| 284 return false; | |
| 285 } | |
| 286 associated_payload_type = incoming_payload_type_; | |
| 287 } | 283 } |
| 288 | |
| 289 restored_packet[1] = static_cast<uint8_t>(associated_payload_type); | 284 restored_packet[1] = static_cast<uint8_t>(associated_payload_type); |
| 290 if (header.markerBit) { | 285 if (header.markerBit) { |
| 291 restored_packet[1] |= kRtpMarkerBitMask; // Marker bit is set. | 286 restored_packet[1] |= kRtpMarkerBitMask; // Marker bit is set. |
| 292 } | 287 } |
| 293 return true; | 288 return true; |
| 294 } | 289 } |
| 295 | 290 |
| 296 void RTPPayloadRegistry::SetRtxSsrc(uint32_t ssrc) { | 291 void RTPPayloadRegistry::SetRtxSsrc(uint32_t ssrc) { |
| 297 CriticalSectionScoped cs(crit_sect_.get()); | 292 CriticalSectionScoped cs(crit_sect_.get()); |
| 298 ssrc_rtx_ = ssrc; | 293 ssrc_rtx_ = ssrc; |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 481 RTPPayloadStrategy* RTPPayloadStrategy::CreateStrategy( | 476 RTPPayloadStrategy* RTPPayloadStrategy::CreateStrategy( |
| 482 const bool handling_audio) { | 477 const bool handling_audio) { |
| 483 if (handling_audio) { | 478 if (handling_audio) { |
| 484 return new RTPPayloadAudioStrategy(); | 479 return new RTPPayloadAudioStrategy(); |
| 485 } else { | 480 } else { |
| 486 return new RTPPayloadVideoStrategy(); | 481 return new RTPPayloadVideoStrategy(); |
| 487 } | 482 } |
| 488 } | 483 } |
| 489 | 484 |
| 490 } // namespace webrtc | 485 } // namespace webrtc |
| OLD | NEW |