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 : rtp_payload_strategy_(rtp_payload_strategy), | 19 : rtp_payload_strategy_(rtp_payload_strategy), |
20 red_payload_type_(-1), | 20 red_payload_type_(-1), |
21 ulpfec_payload_type_(-1), | 21 ulpfec_payload_type_(-1), |
22 incoming_payload_type_(-1), | 22 incoming_payload_type_(-1), |
23 last_received_payload_type_(-1), | 23 last_received_payload_type_(-1), |
24 last_received_media_payload_type_(-1), | 24 last_received_media_payload_type_(-1), |
25 rtx_(false), | 25 rtx_(false), |
26 rtx_payload_type_(-1), | |
27 ssrc_rtx_(0) {} | 26 ssrc_rtx_(0) {} |
28 | 27 |
29 RTPPayloadRegistry::~RTPPayloadRegistry() { | 28 RTPPayloadRegistry::~RTPPayloadRegistry() { |
30 while (!payload_type_map_.empty()) { | 29 while (!payload_type_map_.empty()) { |
31 RtpUtility::PayloadTypeMap::iterator it = payload_type_map_.begin(); | 30 RtpUtility::PayloadTypeMap::iterator it = payload_type_map_.begin(); |
32 delete it->second; | 31 delete it->second; |
33 payload_type_map_.erase(it); | 32 payload_type_map_.erase(it); |
34 } | 33 } |
35 } | 34 } |
36 | 35 |
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
251 | 250 |
252 // Replace the SSRC and the sequence number with the originals. | 251 // Replace the SSRC and the sequence number with the originals. |
253 ByteWriter<uint16_t>::WriteBigEndian(restored_packet + 2, | 252 ByteWriter<uint16_t>::WriteBigEndian(restored_packet + 2, |
254 original_sequence_number); | 253 original_sequence_number); |
255 ByteWriter<uint32_t>::WriteBigEndian(restored_packet + 8, original_ssrc); | 254 ByteWriter<uint32_t>::WriteBigEndian(restored_packet + 8, original_ssrc); |
256 | 255 |
257 rtc::CritScope cs(&crit_sect_); | 256 rtc::CritScope cs(&crit_sect_); |
258 if (!rtx_) | 257 if (!rtx_) |
259 return true; | 258 return true; |
260 | 259 |
261 int associated_payload_type; | 260 int associated_payload_type; |
danilchap
2016/11/02 13:56:52
might as well remove this variable and use apt_map
brandtr
2016/11/03 12:02:48
Kept, because now I use it in multiple places.
| |
262 auto apt_mapping = rtx_payload_type_map_.find(header.payloadType); | 261 auto apt_mapping = rtx_payload_type_map_.find(header.payloadType); |
263 if (apt_mapping == rtx_payload_type_map_.end()) | 262 if (apt_mapping == rtx_payload_type_map_.end()) { |
263 LOG(LS_WARNING) << "No RTX associated payload type mapping was available; " | |
danilchap
2016/11/02 13:56:52
Better to ensure you do not spam this messages (If
brandtr
2016/11/03 12:02:48
Done.
| |
264 "not able to restore original packet from RTX packet " | |
265 "with payload type: " | |
266 << header.payloadType << "."; | |
264 return false; | 267 return false; |
268 } | |
265 associated_payload_type = apt_mapping->second; | 269 associated_payload_type = apt_mapping->second; |
266 if (red_payload_type_ != -1) { | |
267 // Assume red will be used if it's configured. | |
268 // This is a workaround for a Chrome sdp bug where rtx is associated | |
269 // with the media codec even though media is sent over red. | |
270 // TODO(holmer): Remove once the Chrome versions exposing this bug are | |
271 // old enough, which should be once Chrome Stable reaches M53 as this | |
272 // work-around went into M50. | |
273 associated_payload_type = red_payload_type_; | |
274 } | |
275 restored_packet[1] = static_cast<uint8_t>(associated_payload_type); | 270 restored_packet[1] = static_cast<uint8_t>(associated_payload_type); |
276 if (header.markerBit) { | 271 if (header.markerBit) { |
277 restored_packet[1] |= kRtpMarkerBitMask; // Marker bit is set. | 272 restored_packet[1] |= kRtpMarkerBitMask; // Marker bit is set. |
278 } | 273 } |
279 return true; | 274 return true; |
280 } | 275 } |
281 | 276 |
282 void RTPPayloadRegistry::SetRtxSsrc(uint32_t ssrc) { | 277 void RTPPayloadRegistry::SetRtxSsrc(uint32_t ssrc) { |
283 rtc::CritScope cs(&crit_sect_); | 278 rtc::CritScope cs(&crit_sect_); |
284 ssrc_rtx_ = ssrc; | 279 ssrc_rtx_ = ssrc; |
285 rtx_ = true; | 280 rtx_ = true; |
286 } | 281 } |
287 | 282 |
288 bool RTPPayloadRegistry::GetRtxSsrc(uint32_t* ssrc) const { | 283 bool RTPPayloadRegistry::GetRtxSsrc(uint32_t* ssrc) const { |
289 rtc::CritScope cs(&crit_sect_); | 284 rtc::CritScope cs(&crit_sect_); |
290 *ssrc = ssrc_rtx_; | 285 *ssrc = ssrc_rtx_; |
291 return rtx_; | 286 return rtx_; |
292 } | 287 } |
293 | 288 |
294 void RTPPayloadRegistry::SetRtxPayloadType(int payload_type, | 289 void RTPPayloadRegistry::SetRtxPayloadType(int payload_type, |
295 int associated_payload_type) { | 290 int associated_payload_type) { |
296 rtc::CritScope cs(&crit_sect_); | 291 rtc::CritScope cs(&crit_sect_); |
297 if (payload_type < 0) { | 292 if (payload_type < 0) { |
298 LOG(LS_ERROR) << "Invalid RTX payload type: " << payload_type; | 293 LOG(LS_ERROR) << "Invalid RTX payload type: " << payload_type; |
299 return; | 294 return; |
300 } | 295 } |
301 | 296 |
302 rtx_payload_type_map_[payload_type] = associated_payload_type; | 297 rtx_payload_type_map_[payload_type] = associated_payload_type; |
303 rtx_ = true; | 298 rtx_ = true; |
304 rtx_payload_type_ = payload_type; | |
305 } | 299 } |
306 | 300 |
307 bool RTPPayloadRegistry::IsRed(const RTPHeader& header) const { | 301 bool RTPPayloadRegistry::IsRed(const RTPHeader& header) const { |
308 rtc::CritScope cs(&crit_sect_); | 302 rtc::CritScope cs(&crit_sect_); |
309 return red_payload_type_ == header.payloadType; | 303 return red_payload_type_ == header.payloadType; |
310 } | 304 } |
311 | 305 |
312 bool RTPPayloadRegistry::IsEncapsulated(const RTPHeader& header) const { | 306 bool RTPPayloadRegistry::IsEncapsulated(const RTPHeader& header) const { |
313 return IsRed(header) || IsRtx(header); | 307 return IsRed(header) || IsRtx(header); |
314 } | 308 } |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
466 RTPPayloadStrategy* RTPPayloadStrategy::CreateStrategy( | 460 RTPPayloadStrategy* RTPPayloadStrategy::CreateStrategy( |
467 const bool handling_audio) { | 461 const bool handling_audio) { |
468 if (handling_audio) { | 462 if (handling_audio) { |
469 return new RTPPayloadAudioStrategy(); | 463 return new RTPPayloadAudioStrategy(); |
470 } else { | 464 } else { |
471 return new RTPPayloadVideoStrategy(); | 465 return new RTPPayloadVideoStrategy(); |
472 } | 466 } |
473 } | 467 } |
474 | 468 |
475 } // namespace webrtc | 469 } // namespace webrtc |
OLD | NEW |