| 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 #ifndef WEBRTC_MODULES_RTP_RTCP_INCLUDE_RTP_PAYLOAD_REGISTRY_H_ | 11 #ifndef WEBRTC_MODULES_RTP_RTCP_INCLUDE_RTP_PAYLOAD_REGISTRY_H_ |
| 12 #define WEBRTC_MODULES_RTP_RTCP_INCLUDE_RTP_PAYLOAD_REGISTRY_H_ | 12 #define WEBRTC_MODULES_RTP_RTCP_INCLUDE_RTP_PAYLOAD_REGISTRY_H_ |
| 13 | 13 |
| 14 #include <map> | 14 #include <map> |
| 15 #include <memory> | 15 #include <memory> |
| 16 #include <set> |
| 16 | 17 |
| 17 #include "webrtc/base/criticalsection.h" | 18 #include "webrtc/base/criticalsection.h" |
| 19 #include "webrtc/base/deprecation.h" |
| 18 #include "webrtc/modules/rtp_rtcp/source/rtp_receiver_strategy.h" | 20 #include "webrtc/modules/rtp_rtcp/source/rtp_receiver_strategy.h" |
| 19 #include "webrtc/modules/rtp_rtcp/source/rtp_utility.h" | 21 #include "webrtc/modules/rtp_rtcp/source/rtp_utility.h" |
| 20 | 22 |
| 21 namespace webrtc { | 23 namespace webrtc { |
| 22 | 24 |
| 23 // This strategy deals with the audio/video-specific aspects | 25 // This strategy deals with the audio/video-specific aspects |
| 24 // of payload handling. | 26 // of payload handling. |
| 25 class RTPPayloadStrategy { | 27 class RTPPayloadStrategy { |
| 26 public: | 28 public: |
| 27 virtual ~RTPPayloadStrategy() {} | 29 virtual ~RTPPayloadStrategy() {} |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 bool GetRtxSsrc(uint32_t* ssrc) const; | 82 bool GetRtxSsrc(uint32_t* ssrc) const; |
| 81 | 83 |
| 82 void SetRtxPayloadType(int payload_type, int associated_payload_type); | 84 void SetRtxPayloadType(int payload_type, int associated_payload_type); |
| 83 | 85 |
| 84 bool IsRtx(const RTPHeader& header) const; | 86 bool IsRtx(const RTPHeader& header) const; |
| 85 | 87 |
| 86 bool RestoreOriginalPacket(uint8_t* restored_packet, | 88 bool RestoreOriginalPacket(uint8_t* restored_packet, |
| 87 const uint8_t* packet, | 89 const uint8_t* packet, |
| 88 size_t* packet_length, | 90 size_t* packet_length, |
| 89 uint32_t original_ssrc, | 91 uint32_t original_ssrc, |
| 90 const RTPHeader& header) const; | 92 const RTPHeader& header); |
| 91 | 93 |
| 92 bool IsRed(const RTPHeader& header) const; | 94 bool IsRed(const RTPHeader& header) const; |
| 93 | 95 |
| 94 // Returns true if the media of this RTP packet is encapsulated within an | 96 // Returns true if the media of this RTP packet is encapsulated within an |
| 95 // extra header, such as RTX or RED. | 97 // extra header, such as RTX or RED. |
| 96 bool IsEncapsulated(const RTPHeader& header) const; | 98 bool IsEncapsulated(const RTPHeader& header) const; |
| 97 | 99 |
| 98 bool GetPayloadSpecifics(uint8_t payload_type, PayloadUnion* payload) const; | 100 bool GetPayloadSpecifics(uint8_t payload_type, PayloadUnion* payload) const; |
| 99 | 101 |
| 100 int GetPayloadTypeFrequency(uint8_t payload_type) const; | 102 int GetPayloadTypeFrequency(uint8_t payload_type) const; |
| (...skipping 29 matching lines...) Expand all Loading... |
| 130 void set_last_received_payload_type(int8_t last_received_payload_type) { | 132 void set_last_received_payload_type(int8_t last_received_payload_type) { |
| 131 rtc::CritScope cs(&crit_sect_); | 133 rtc::CritScope cs(&crit_sect_); |
| 132 last_received_payload_type_ = last_received_payload_type; | 134 last_received_payload_type_ = last_received_payload_type; |
| 133 } | 135 } |
| 134 | 136 |
| 135 int8_t last_received_media_payload_type() const { | 137 int8_t last_received_media_payload_type() const { |
| 136 rtc::CritScope cs(&crit_sect_); | 138 rtc::CritScope cs(&crit_sect_); |
| 137 return last_received_media_payload_type_; | 139 return last_received_media_payload_type_; |
| 138 } | 140 } |
| 139 | 141 |
| 140 bool use_rtx_payload_mapping_on_restore() const { | 142 RTC_DEPRECATED void set_use_rtx_payload_mapping_on_restore(bool val) {} |
| 141 rtc::CritScope cs(&crit_sect_); | |
| 142 return use_rtx_payload_mapping_on_restore_; | |
| 143 } | |
| 144 | |
| 145 void set_use_rtx_payload_mapping_on_restore(bool val) { | |
| 146 rtc::CritScope cs(&crit_sect_); | |
| 147 use_rtx_payload_mapping_on_restore_ = val; | |
| 148 } | |
| 149 | 143 |
| 150 private: | 144 private: |
| 151 // Prunes the payload type map of the specific payload type, if it exists. | 145 // Prunes the payload type map of the specific payload type, if it exists. |
| 152 void DeregisterAudioCodecOrRedTypeRegardlessOfPayloadType( | 146 void DeregisterAudioCodecOrRedTypeRegardlessOfPayloadType( |
| 153 const char payload_name[RTP_PAYLOAD_NAME_SIZE], | 147 const char payload_name[RTP_PAYLOAD_NAME_SIZE], |
| 154 size_t payload_name_length, | 148 size_t payload_name_length, |
| 155 uint32_t frequency, | 149 uint32_t frequency, |
| 156 size_t channels, | 150 size_t channels, |
| 157 uint32_t rate); | 151 uint32_t rate); |
| 158 | 152 |
| 159 bool IsRtxInternal(const RTPHeader& header) const; | 153 bool IsRtxInternal(const RTPHeader& header) const; |
| 160 | 154 |
| 161 rtc::CriticalSection crit_sect_; | 155 rtc::CriticalSection crit_sect_; |
| 162 RtpUtility::PayloadTypeMap payload_type_map_; | 156 RtpUtility::PayloadTypeMap payload_type_map_; |
| 163 std::unique_ptr<RTPPayloadStrategy> rtp_payload_strategy_; | 157 std::unique_ptr<RTPPayloadStrategy> rtp_payload_strategy_; |
| 164 int8_t red_payload_type_; | 158 int8_t red_payload_type_; |
| 165 int8_t ulpfec_payload_type_; | 159 int8_t ulpfec_payload_type_; |
| 166 int8_t incoming_payload_type_; | 160 int8_t incoming_payload_type_; |
| 167 int8_t last_received_payload_type_; | 161 int8_t last_received_payload_type_; |
| 168 int8_t last_received_media_payload_type_; | 162 int8_t last_received_media_payload_type_; |
| 169 bool rtx_; | 163 bool rtx_; |
| 170 // TODO(changbin): Remove rtx_payload_type_ once interop with old clients that | |
| 171 // only understand one RTX PT is no longer needed. | |
| 172 int rtx_payload_type_; | |
| 173 // Mapping rtx_payload_type_map_[rtx] = associated. | 164 // Mapping rtx_payload_type_map_[rtx] = associated. |
| 174 std::map<int, int> rtx_payload_type_map_; | 165 std::map<int, int> rtx_payload_type_map_; |
| 175 // When true, use rtx_payload_type_map_ when restoring RTX packets to get the | |
| 176 // correct payload type. | |
| 177 bool use_rtx_payload_mapping_on_restore_; | |
| 178 uint32_t ssrc_rtx_; | 166 uint32_t ssrc_rtx_; |
| 167 // Only warn once per payload type, if an RTX packet is received but |
| 168 // no associated payload type found in |rtx_payload_type_map_|. |
| 169 std::set<int> payload_types_with_suppressed_warnings_ GUARDED_BY(crit_sect_); |
| 179 }; | 170 }; |
| 180 | 171 |
| 181 } // namespace webrtc | 172 } // namespace webrtc |
| 182 | 173 |
| 183 #endif // WEBRTC_MODULES_RTP_RTCP_INCLUDE_RTP_PAYLOAD_REGISTRY_H_ | 174 #endif // WEBRTC_MODULES_RTP_RTCP_INCLUDE_RTP_PAYLOAD_REGISTRY_H_ |
| OLD | NEW |