| 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 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 | 22 |
| 23 // This strategy deals with the audio/video-specific aspects | 23 // This strategy deals with the audio/video-specific aspects |
| 24 // of payload handling. | 24 // of payload handling. |
| 25 class RTPPayloadStrategy { | 25 class RTPPayloadStrategy { |
| 26 public: | 26 public: |
| 27 virtual ~RTPPayloadStrategy() {} | 27 virtual ~RTPPayloadStrategy() {} |
| 28 | 28 |
| 29 virtual bool CodecsMustBeUnique() const = 0; | 29 virtual bool CodecsMustBeUnique() const = 0; |
| 30 | 30 |
| 31 virtual bool PayloadIsCompatible(const RtpUtility::Payload& payload, | 31 virtual bool PayloadIsCompatible(const RtpUtility::Payload& payload, |
| 32 const uint32_t frequency, | 32 uint32_t frequency, |
| 33 const size_t channels, | 33 size_t channels, |
| 34 const uint32_t rate) const = 0; | 34 uint32_t rate) const = 0; |
| 35 | 35 |
| 36 virtual void UpdatePayloadRate(RtpUtility::Payload* payload, | 36 virtual void UpdatePayloadRate(RtpUtility::Payload* payload, |
| 37 const uint32_t rate) const = 0; | 37 uint32_t rate) const = 0; |
| 38 | 38 |
| 39 virtual RtpUtility::Payload* CreatePayloadType( | 39 virtual RtpUtility::Payload* CreatePayloadType( |
| 40 const char payloadName[RTP_PAYLOAD_NAME_SIZE], | 40 const char payload_name[RTP_PAYLOAD_NAME_SIZE], |
| 41 const int8_t payloadType, | 41 int8_t payload_type, |
| 42 const uint32_t frequency, | 42 uint32_t frequency, |
| 43 const size_t channels, | 43 size_t channels, |
| 44 const uint32_t rate) const = 0; | 44 uint32_t rate) const = 0; |
| 45 | 45 |
| 46 virtual int GetPayloadTypeFrequency( | 46 virtual int GetPayloadTypeFrequency( |
| 47 const RtpUtility::Payload& payload) const = 0; | 47 const RtpUtility::Payload& payload) const = 0; |
| 48 | 48 |
| 49 static RTPPayloadStrategy* CreateStrategy(const bool handling_audio); | 49 static RTPPayloadStrategy* CreateStrategy(bool handling_audio); |
| 50 | 50 |
| 51 protected: | 51 protected: |
| 52 RTPPayloadStrategy() {} | 52 RTPPayloadStrategy() {} |
| 53 }; | 53 }; |
| 54 | 54 |
| 55 class RTPPayloadRegistry { | 55 class RTPPayloadRegistry { |
| 56 public: | 56 public: |
| 57 // The registry takes ownership of the strategy. | 57 // The registry takes ownership of the strategy. |
| 58 explicit RTPPayloadRegistry(RTPPayloadStrategy* rtp_payload_strategy); | 58 explicit RTPPayloadRegistry(RTPPayloadStrategy* rtp_payload_strategy); |
| 59 ~RTPPayloadRegistry(); | 59 ~RTPPayloadRegistry(); |
| 60 | 60 |
| 61 int32_t RegisterReceivePayload( | 61 int32_t RegisterReceivePayload(const char payload_name[RTP_PAYLOAD_NAME_SIZE], |
| 62 const char payload_name[RTP_PAYLOAD_NAME_SIZE], | 62 int8_t payload_type, |
| 63 const int8_t payload_type, | 63 uint32_t frequency, |
| 64 const uint32_t frequency, | 64 size_t channels, |
| 65 const size_t channels, | 65 uint32_t rate, |
| 66 const uint32_t rate, | 66 bool* created_new_payload_type); |
| 67 bool* created_new_payload_type); | |
| 68 | 67 |
| 69 int32_t DeRegisterReceivePayload( | 68 int32_t DeRegisterReceivePayload(int8_t payload_type); |
| 70 const int8_t payload_type); | |
| 71 | 69 |
| 72 int32_t ReceivePayloadType( | 70 int32_t ReceivePayloadType(const char payload_name[RTP_PAYLOAD_NAME_SIZE], |
| 73 const char payload_name[RTP_PAYLOAD_NAME_SIZE], | 71 uint32_t frequency, |
| 74 const uint32_t frequency, | 72 size_t channels, |
| 75 const size_t channels, | 73 uint32_t rate, |
| 76 const uint32_t rate, | 74 int8_t* payload_type) const; |
| 77 int8_t* payload_type) const; | |
| 78 | 75 |
| 79 bool RtxEnabled() const; | 76 bool RtxEnabled() const; |
| 80 | 77 |
| 81 void SetRtxSsrc(uint32_t ssrc); | 78 void SetRtxSsrc(uint32_t ssrc); |
| 82 | 79 |
| 83 bool GetRtxSsrc(uint32_t* ssrc) const; | 80 bool GetRtxSsrc(uint32_t* ssrc) const; |
| 84 | 81 |
| 85 void SetRtxPayloadType(int payload_type, int associated_payload_type); | 82 void SetRtxPayloadType(int payload_type, int associated_payload_type); |
| 86 | 83 |
| 87 bool IsRtx(const RTPHeader& header) const; | 84 bool IsRtx(const RTPHeader& header) const; |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 | 144 |
| 148 void set_use_rtx_payload_mapping_on_restore(bool val) { | 145 void set_use_rtx_payload_mapping_on_restore(bool val) { |
| 149 rtc::CritScope cs(&crit_sect_); | 146 rtc::CritScope cs(&crit_sect_); |
| 150 use_rtx_payload_mapping_on_restore_ = val; | 147 use_rtx_payload_mapping_on_restore_ = val; |
| 151 } | 148 } |
| 152 | 149 |
| 153 private: | 150 private: |
| 154 // Prunes the payload type map of the specific payload type, if it exists. | 151 // Prunes the payload type map of the specific payload type, if it exists. |
| 155 void DeregisterAudioCodecOrRedTypeRegardlessOfPayloadType( | 152 void DeregisterAudioCodecOrRedTypeRegardlessOfPayloadType( |
| 156 const char payload_name[RTP_PAYLOAD_NAME_SIZE], | 153 const char payload_name[RTP_PAYLOAD_NAME_SIZE], |
| 157 const size_t payload_name_length, | 154 size_t payload_name_length, |
| 158 const uint32_t frequency, | 155 uint32_t frequency, |
| 159 const size_t channels, | 156 size_t channels, |
| 160 const uint32_t rate); | 157 uint32_t rate); |
| 161 | 158 |
| 162 bool IsRtxInternal(const RTPHeader& header) const; | 159 bool IsRtxInternal(const RTPHeader& header) const; |
| 163 | 160 |
| 164 rtc::CriticalSection crit_sect_; | 161 rtc::CriticalSection crit_sect_; |
| 165 RtpUtility::PayloadTypeMap payload_type_map_; | 162 RtpUtility::PayloadTypeMap payload_type_map_; |
| 166 std::unique_ptr<RTPPayloadStrategy> rtp_payload_strategy_; | 163 std::unique_ptr<RTPPayloadStrategy> rtp_payload_strategy_; |
| 167 int8_t red_payload_type_; | 164 int8_t red_payload_type_; |
| 168 int8_t ulpfec_payload_type_; | 165 int8_t ulpfec_payload_type_; |
| 169 int8_t incoming_payload_type_; | 166 int8_t incoming_payload_type_; |
| 170 int8_t last_received_payload_type_; | 167 int8_t last_received_payload_type_; |
| 171 int8_t last_received_media_payload_type_; | 168 int8_t last_received_media_payload_type_; |
| 172 bool rtx_; | 169 bool rtx_; |
| 173 // TODO(changbin): Remove rtx_payload_type_ once interop with old clients that | 170 // TODO(changbin): Remove rtx_payload_type_ once interop with old clients that |
| 174 // only understand one RTX PT is no longer needed. | 171 // only understand one RTX PT is no longer needed. |
| 175 int rtx_payload_type_; | 172 int rtx_payload_type_; |
| 176 // Mapping rtx_payload_type_map_[rtx] = associated. | 173 // Mapping rtx_payload_type_map_[rtx] = associated. |
| 177 std::map<int, int> rtx_payload_type_map_; | 174 std::map<int, int> rtx_payload_type_map_; |
| 178 // When true, use rtx_payload_type_map_ when restoring RTX packets to get the | 175 // When true, use rtx_payload_type_map_ when restoring RTX packets to get the |
| 179 // correct payload type. | 176 // correct payload type. |
| 180 bool use_rtx_payload_mapping_on_restore_; | 177 bool use_rtx_payload_mapping_on_restore_; |
| 181 uint32_t ssrc_rtx_; | 178 uint32_t ssrc_rtx_; |
| 182 }; | 179 }; |
| 183 | 180 |
| 184 } // namespace webrtc | 181 } // namespace webrtc |
| 185 | 182 |
| 186 #endif // WEBRTC_MODULES_RTP_RTCP_INCLUDE_RTP_PAYLOAD_REGISTRY_H_ | 183 #endif // WEBRTC_MODULES_RTP_RTCP_INCLUDE_RTP_PAYLOAD_REGISTRY_H_ |
| OLD | NEW |