| 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_INTERFACE_RTP_PAYLOAD_REGISTRY_H_ | 11 #ifndef WEBRTC_MODULES_RTP_RTCP_INTERFACE_RTP_PAYLOAD_REGISTRY_H_ |
| 12 #define WEBRTC_MODULES_RTP_RTCP_INTERFACE_RTP_PAYLOAD_REGISTRY_H_ | 12 #define WEBRTC_MODULES_RTP_RTCP_INTERFACE_RTP_PAYLOAD_REGISTRY_H_ |
| 13 | 13 |
| 14 #include "webrtc/base/scoped_ptr.h" | 14 #include "webrtc/base/scoped_ptr.h" |
| 15 #include "webrtc/modules/rtp_rtcp/source/rtp_receiver_strategy.h" | 15 #include "webrtc/modules/rtp_rtcp/source/rtp_receiver_strategy.h" |
| 16 #include "webrtc/modules/rtp_rtcp/source/rtp_utility.h" | 16 #include "webrtc/modules/rtp_rtcp/source/rtp_utility.h" |
| 17 | 17 |
| 18 namespace webrtc { | 18 namespace webrtc { |
| 19 | 19 |
| 20 // This strategy deals with the audio/video-specific aspects | 20 // This strategy deals with the audio/video-specific aspects |
| 21 // of payload handling. | 21 // of payload handling. |
| 22 class RTPPayloadStrategy { | 22 class RTPPayloadStrategy { |
| 23 public: | 23 public: |
| 24 virtual ~RTPPayloadStrategy() {} | 24 virtual ~RTPPayloadStrategy() {} |
| 25 | 25 |
| 26 virtual bool CodecsMustBeUnique() const = 0; | 26 virtual bool CodecsMustBeUnique() const = 0; |
| 27 | 27 |
| 28 virtual bool PayloadIsCompatible(const RtpUtility::Payload& payload, | 28 virtual bool PayloadIsCompatible(const RtpUtility::Payload& payload, |
| 29 const uint32_t frequency, | 29 const uint32_t frequency, |
| 30 const uint8_t channels, | 30 const size_t channels, |
| 31 const uint32_t rate) const = 0; | 31 const uint32_t rate) const = 0; |
| 32 | 32 |
| 33 virtual void UpdatePayloadRate(RtpUtility::Payload* payload, | 33 virtual void UpdatePayloadRate(RtpUtility::Payload* payload, |
| 34 const uint32_t rate) const = 0; | 34 const uint32_t rate) const = 0; |
| 35 | 35 |
| 36 virtual RtpUtility::Payload* CreatePayloadType( | 36 virtual RtpUtility::Payload* CreatePayloadType( |
| 37 const char payloadName[RTP_PAYLOAD_NAME_SIZE], | 37 const char payloadName[RTP_PAYLOAD_NAME_SIZE], |
| 38 const int8_t payloadType, | 38 const int8_t payloadType, |
| 39 const uint32_t frequency, | 39 const uint32_t frequency, |
| 40 const uint8_t channels, | 40 const size_t channels, |
| 41 const uint32_t rate) const = 0; | 41 const uint32_t rate) const = 0; |
| 42 | 42 |
| 43 virtual int GetPayloadTypeFrequency( | 43 virtual int GetPayloadTypeFrequency( |
| 44 const RtpUtility::Payload& payload) const = 0; | 44 const RtpUtility::Payload& payload) const = 0; |
| 45 | 45 |
| 46 static RTPPayloadStrategy* CreateStrategy(const bool handling_audio); | 46 static RTPPayloadStrategy* CreateStrategy(const bool handling_audio); |
| 47 | 47 |
| 48 protected: | 48 protected: |
| 49 RTPPayloadStrategy() {} | 49 RTPPayloadStrategy() {} |
| 50 }; | 50 }; |
| 51 | 51 |
| 52 class RTPPayloadRegistry { | 52 class RTPPayloadRegistry { |
| 53 public: | 53 public: |
| 54 // The registry takes ownership of the strategy. | 54 // The registry takes ownership of the strategy. |
| 55 RTPPayloadRegistry(RTPPayloadStrategy* rtp_payload_strategy); | 55 RTPPayloadRegistry(RTPPayloadStrategy* rtp_payload_strategy); |
| 56 ~RTPPayloadRegistry(); | 56 ~RTPPayloadRegistry(); |
| 57 | 57 |
| 58 int32_t RegisterReceivePayload( | 58 int32_t RegisterReceivePayload( |
| 59 const char payload_name[RTP_PAYLOAD_NAME_SIZE], | 59 const char payload_name[RTP_PAYLOAD_NAME_SIZE], |
| 60 const int8_t payload_type, | 60 const int8_t payload_type, |
| 61 const uint32_t frequency, | 61 const uint32_t frequency, |
| 62 const uint8_t channels, | 62 const size_t channels, |
| 63 const uint32_t rate, | 63 const uint32_t rate, |
| 64 bool* created_new_payload_type); | 64 bool* created_new_payload_type); |
| 65 | 65 |
| 66 int32_t DeRegisterReceivePayload( | 66 int32_t DeRegisterReceivePayload( |
| 67 const int8_t payload_type); | 67 const int8_t payload_type); |
| 68 | 68 |
| 69 int32_t ReceivePayloadType( | 69 int32_t ReceivePayloadType( |
| 70 const char payload_name[RTP_PAYLOAD_NAME_SIZE], | 70 const char payload_name[RTP_PAYLOAD_NAME_SIZE], |
| 71 const uint32_t frequency, | 71 const uint32_t frequency, |
| 72 const uint8_t channels, | 72 const size_t channels, |
| 73 const uint32_t rate, | 73 const uint32_t rate, |
| 74 int8_t* payload_type) const; | 74 int8_t* payload_type) const; |
| 75 | 75 |
| 76 bool RtxEnabled() const; | 76 bool RtxEnabled() const; |
| 77 | 77 |
| 78 void SetRtxSsrc(uint32_t ssrc); | 78 void SetRtxSsrc(uint32_t ssrc); |
| 79 | 79 |
| 80 bool GetRtxSsrc(uint32_t* ssrc) const; | 80 bool GetRtxSsrc(uint32_t* ssrc) const; |
| 81 | 81 |
| 82 void SetRtxPayloadType(int payload_type, int associated_payload_type); | 82 void SetRtxPayloadType(int payload_type, int associated_payload_type); |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 CriticalSectionScoped cs(crit_sect_.get()); | 137 CriticalSectionScoped cs(crit_sect_.get()); |
| 138 return last_received_media_payload_type_; | 138 return last_received_media_payload_type_; |
| 139 }; | 139 }; |
| 140 | 140 |
| 141 private: | 141 private: |
| 142 // Prunes the payload type map of the specific payload type, if it exists. | 142 // Prunes the payload type map of the specific payload type, if it exists. |
| 143 void DeregisterAudioCodecOrRedTypeRegardlessOfPayloadType( | 143 void DeregisterAudioCodecOrRedTypeRegardlessOfPayloadType( |
| 144 const char payload_name[RTP_PAYLOAD_NAME_SIZE], | 144 const char payload_name[RTP_PAYLOAD_NAME_SIZE], |
| 145 const size_t payload_name_length, | 145 const size_t payload_name_length, |
| 146 const uint32_t frequency, | 146 const uint32_t frequency, |
| 147 const uint8_t channels, | 147 const size_t channels, |
| 148 const uint32_t rate); | 148 const uint32_t rate); |
| 149 | 149 |
| 150 bool IsRtxInternal(const RTPHeader& header) const; | 150 bool IsRtxInternal(const RTPHeader& header) const; |
| 151 | 151 |
| 152 rtc::scoped_ptr<CriticalSectionWrapper> crit_sect_; | 152 rtc::scoped_ptr<CriticalSectionWrapper> crit_sect_; |
| 153 RtpUtility::PayloadTypeMap payload_type_map_; | 153 RtpUtility::PayloadTypeMap payload_type_map_; |
| 154 rtc::scoped_ptr<RTPPayloadStrategy> rtp_payload_strategy_; | 154 rtc::scoped_ptr<RTPPayloadStrategy> rtp_payload_strategy_; |
| 155 int8_t red_payload_type_; | 155 int8_t red_payload_type_; |
| 156 int8_t ulpfec_payload_type_; | 156 int8_t ulpfec_payload_type_; |
| 157 int8_t incoming_payload_type_; | 157 int8_t incoming_payload_type_; |
| 158 int8_t last_received_payload_type_; | 158 int8_t last_received_payload_type_; |
| 159 int8_t last_received_media_payload_type_; | 159 int8_t last_received_media_payload_type_; |
| 160 bool rtx_; | 160 bool rtx_; |
| 161 // TODO(changbin): Remove rtx_payload_type_ once interop with old clients that | 161 // TODO(changbin): Remove rtx_payload_type_ once interop with old clients that |
| 162 // only understand one RTX PT is no longer needed. | 162 // only understand one RTX PT is no longer needed. |
| 163 int rtx_payload_type_; | 163 int rtx_payload_type_; |
| 164 // Mapping rtx_payload_type_map_[rtx] = associated. | 164 // Mapping rtx_payload_type_map_[rtx] = associated. |
| 165 std::map<int, int> rtx_payload_type_map_; | 165 std::map<int, int> rtx_payload_type_map_; |
| 166 uint32_t ssrc_rtx_; | 166 uint32_t ssrc_rtx_; |
| 167 }; | 167 }; |
| 168 | 168 |
| 169 } // namespace webrtc | 169 } // namespace webrtc |
| 170 | 170 |
| 171 #endif // WEBRTC_MODULES_RTP_RTCP_INTERFACE_RTP_PAYLOAD_REGISTRY_H_ | 171 #endif // WEBRTC_MODULES_RTP_RTCP_INTERFACE_RTP_PAYLOAD_REGISTRY_H_ |
| OLD | NEW |