| 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 | 15 |
| 16 #include "webrtc/base/criticalsection.h" |
| 16 #include "webrtc/base/scoped_ptr.h" | 17 #include "webrtc/base/scoped_ptr.h" |
| 17 #include "webrtc/modules/rtp_rtcp/source/rtp_receiver_strategy.h" | 18 #include "webrtc/modules/rtp_rtcp/source/rtp_receiver_strategy.h" |
| 18 #include "webrtc/modules/rtp_rtcp/source/rtp_utility.h" | 19 #include "webrtc/modules/rtp_rtcp/source/rtp_utility.h" |
| 19 | 20 |
| 20 namespace webrtc { | 21 namespace webrtc { |
| 21 | 22 |
| 22 // This strategy deals with the audio/video-specific aspects | 23 // This strategy deals with the audio/video-specific aspects |
| 23 // of payload handling. | 24 // of payload handling. |
| 24 class RTPPayloadStrategy { | 25 class RTPPayloadStrategy { |
| 25 public: | 26 public: |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 // TODO(danilchap): Remove this when all callers have been updated. | 116 // TODO(danilchap): Remove this when all callers have been updated. |
| 116 bool PayloadTypeToPayload(const uint8_t payload_type, | 117 bool PayloadTypeToPayload(const uint8_t payload_type, |
| 117 RtpUtility::Payload*& payload) const { // NOLINT | 118 RtpUtility::Payload*& payload) const { // NOLINT |
| 118 payload = | 119 payload = |
| 119 const_cast<RtpUtility::Payload*>(PayloadTypeToPayload(payload_type)); | 120 const_cast<RtpUtility::Payload*>(PayloadTypeToPayload(payload_type)); |
| 120 return payload != nullptr; | 121 return payload != nullptr; |
| 121 } | 122 } |
| 122 const RtpUtility::Payload* PayloadTypeToPayload(uint8_t payload_type) const; | 123 const RtpUtility::Payload* PayloadTypeToPayload(uint8_t payload_type) const; |
| 123 | 124 |
| 124 void ResetLastReceivedPayloadTypes() { | 125 void ResetLastReceivedPayloadTypes() { |
| 125 CriticalSectionScoped cs(crit_sect_.get()); | 126 rtc::CritScope cs(&crit_sect_); |
| 126 last_received_payload_type_ = -1; | 127 last_received_payload_type_ = -1; |
| 127 last_received_media_payload_type_ = -1; | 128 last_received_media_payload_type_ = -1; |
| 128 } | 129 } |
| 129 | 130 |
| 130 // This sets the payload type of the packets being received from the network | 131 // This sets the payload type of the packets being received from the network |
| 131 // on the media SSRC. For instance if packets are encapsulated with RED, this | 132 // on the media SSRC. For instance if packets are encapsulated with RED, this |
| 132 // payload type will be the RED payload type. | 133 // payload type will be the RED payload type. |
| 133 void SetIncomingPayloadType(const RTPHeader& header); | 134 void SetIncomingPayloadType(const RTPHeader& header); |
| 134 | 135 |
| 135 // Returns true if the new media payload type has not changed. | 136 // Returns true if the new media payload type has not changed. |
| 136 bool ReportMediaPayloadType(uint8_t media_payload_type); | 137 bool ReportMediaPayloadType(uint8_t media_payload_type); |
| 137 | 138 |
| 138 int8_t red_payload_type() const { | 139 int8_t red_payload_type() const { |
| 139 CriticalSectionScoped cs(crit_sect_.get()); | 140 rtc::CritScope cs(&crit_sect_); |
| 140 return red_payload_type_; | 141 return red_payload_type_; |
| 141 } | 142 } |
| 142 int8_t ulpfec_payload_type() const { | 143 int8_t ulpfec_payload_type() const { |
| 143 CriticalSectionScoped cs(crit_sect_.get()); | 144 rtc::CritScope cs(&crit_sect_); |
| 144 return ulpfec_payload_type_; | 145 return ulpfec_payload_type_; |
| 145 } | 146 } |
| 146 int8_t last_received_payload_type() const { | 147 int8_t last_received_payload_type() const { |
| 147 CriticalSectionScoped cs(crit_sect_.get()); | 148 rtc::CritScope cs(&crit_sect_); |
| 148 return last_received_payload_type_; | 149 return last_received_payload_type_; |
| 149 } | 150 } |
| 150 void set_last_received_payload_type(int8_t last_received_payload_type) { | 151 void set_last_received_payload_type(int8_t last_received_payload_type) { |
| 151 CriticalSectionScoped cs(crit_sect_.get()); | 152 rtc::CritScope cs(&crit_sect_); |
| 152 last_received_payload_type_ = last_received_payload_type; | 153 last_received_payload_type_ = last_received_payload_type; |
| 153 } | 154 } |
| 154 | 155 |
| 155 int8_t last_received_media_payload_type() const { | 156 int8_t last_received_media_payload_type() const { |
| 156 CriticalSectionScoped cs(crit_sect_.get()); | 157 rtc::CritScope cs(&crit_sect_); |
| 157 return last_received_media_payload_type_; | 158 return last_received_media_payload_type_; |
| 158 } | 159 } |
| 159 | 160 |
| 160 bool use_rtx_payload_mapping_on_restore() const { | 161 bool use_rtx_payload_mapping_on_restore() const { |
| 161 CriticalSectionScoped cs(crit_sect_.get()); | 162 rtc::CritScope cs(&crit_sect_); |
| 162 return use_rtx_payload_mapping_on_restore_; | 163 return use_rtx_payload_mapping_on_restore_; |
| 163 } | 164 } |
| 164 | 165 |
| 165 void set_use_rtx_payload_mapping_on_restore(bool val) { | 166 void set_use_rtx_payload_mapping_on_restore(bool val) { |
| 166 CriticalSectionScoped cs(crit_sect_.get()); | 167 rtc::CritScope cs(&crit_sect_); |
| 167 use_rtx_payload_mapping_on_restore_ = val; | 168 use_rtx_payload_mapping_on_restore_ = val; |
| 168 } | 169 } |
| 169 | 170 |
| 170 private: | 171 private: |
| 171 // Prunes the payload type map of the specific payload type, if it exists. | 172 // Prunes the payload type map of the specific payload type, if it exists. |
| 172 void DeregisterAudioCodecOrRedTypeRegardlessOfPayloadType( | 173 void DeregisterAudioCodecOrRedTypeRegardlessOfPayloadType( |
| 173 const char payload_name[RTP_PAYLOAD_NAME_SIZE], | 174 const char payload_name[RTP_PAYLOAD_NAME_SIZE], |
| 174 const size_t payload_name_length, | 175 const size_t payload_name_length, |
| 175 const uint32_t frequency, | 176 const uint32_t frequency, |
| 176 const size_t channels, | 177 const size_t channels, |
| 177 const uint32_t rate); | 178 const uint32_t rate); |
| 178 | 179 |
| 179 bool IsRtxInternal(const RTPHeader& header) const; | 180 bool IsRtxInternal(const RTPHeader& header) const; |
| 180 | 181 |
| 181 rtc::scoped_ptr<CriticalSectionWrapper> crit_sect_; | 182 rtc::CriticalSection crit_sect_; |
| 182 RtpUtility::PayloadTypeMap payload_type_map_; | 183 RtpUtility::PayloadTypeMap payload_type_map_; |
| 183 rtc::scoped_ptr<RTPPayloadStrategy> rtp_payload_strategy_; | 184 rtc::scoped_ptr<RTPPayloadStrategy> rtp_payload_strategy_; |
| 184 int8_t red_payload_type_; | 185 int8_t red_payload_type_; |
| 185 int8_t ulpfec_payload_type_; | 186 int8_t ulpfec_payload_type_; |
| 186 int8_t incoming_payload_type_; | 187 int8_t incoming_payload_type_; |
| 187 int8_t last_received_payload_type_; | 188 int8_t last_received_payload_type_; |
| 188 int8_t last_received_media_payload_type_; | 189 int8_t last_received_media_payload_type_; |
| 189 bool rtx_; | 190 bool rtx_; |
| 190 // TODO(changbin): Remove rtx_payload_type_ once interop with old clients that | 191 // TODO(changbin): Remove rtx_payload_type_ once interop with old clients that |
| 191 // only understand one RTX PT is no longer needed. | 192 // only understand one RTX PT is no longer needed. |
| 192 int rtx_payload_type_; | 193 int rtx_payload_type_; |
| 193 // Mapping rtx_payload_type_map_[rtx] = associated. | 194 // Mapping rtx_payload_type_map_[rtx] = associated. |
| 194 std::map<int, int> rtx_payload_type_map_; | 195 std::map<int, int> rtx_payload_type_map_; |
| 195 // When true, use rtx_payload_type_map_ when restoring RTX packets to get the | 196 // When true, use rtx_payload_type_map_ when restoring RTX packets to get the |
| 196 // correct payload type. | 197 // correct payload type. |
| 197 bool use_rtx_payload_mapping_on_restore_; | 198 bool use_rtx_payload_mapping_on_restore_; |
| 198 uint32_t ssrc_rtx_; | 199 uint32_t ssrc_rtx_; |
| 199 }; | 200 }; |
| 200 | 201 |
| 201 } // namespace webrtc | 202 } // namespace webrtc |
| 202 | 203 |
| 203 #endif // WEBRTC_MODULES_RTP_RTCP_INCLUDE_RTP_PAYLOAD_REGISTRY_H_ | 204 #endif // WEBRTC_MODULES_RTP_RTCP_INCLUDE_RTP_PAYLOAD_REGISTRY_H_ |
| OLD | NEW |