Chromium Code Reviews| 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> | |
| 15 | |
| 14 #include "webrtc/base/scoped_ptr.h" | 16 #include "webrtc/base/scoped_ptr.h" |
| 15 #include "webrtc/modules/rtp_rtcp/source/rtp_receiver_strategy.h" | 17 #include "webrtc/modules/rtp_rtcp/source/rtp_receiver_strategy.h" |
| 16 #include "webrtc/modules/rtp_rtcp/source/rtp_utility.h" | 18 #include "webrtc/modules/rtp_rtcp/source/rtp_utility.h" |
| 17 | 19 |
| 18 namespace webrtc { | 20 namespace webrtc { |
| 19 | 21 |
| 20 // This strategy deals with the audio/video-specific aspects | 22 // This strategy deals with the audio/video-specific aspects |
| 21 // of payload handling. | 23 // of payload handling. |
| 22 class RTPPayloadStrategy { | 24 class RTPPayloadStrategy { |
| 23 public: | 25 public: |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 45 | 47 |
| 46 static RTPPayloadStrategy* CreateStrategy(const bool handling_audio); | 48 static RTPPayloadStrategy* CreateStrategy(const bool handling_audio); |
| 47 | 49 |
| 48 protected: | 50 protected: |
| 49 RTPPayloadStrategy() {} | 51 RTPPayloadStrategy() {} |
| 50 }; | 52 }; |
| 51 | 53 |
| 52 class RTPPayloadRegistry { | 54 class RTPPayloadRegistry { |
| 53 public: | 55 public: |
| 54 // The registry takes ownership of the strategy. | 56 // The registry takes ownership of the strategy. |
| 55 RTPPayloadRegistry(RTPPayloadStrategy* rtp_payload_strategy); | 57 explicit RTPPayloadRegistry(RTPPayloadStrategy* rtp_payload_strategy); |
| 56 ~RTPPayloadRegistry(); | 58 ~RTPPayloadRegistry(); |
| 57 | 59 |
| 58 int32_t RegisterReceivePayload( | 60 int32_t RegisterReceivePayload( |
| 59 const char payload_name[RTP_PAYLOAD_NAME_SIZE], | 61 const char payload_name[RTP_PAYLOAD_NAME_SIZE], |
| 60 const int8_t payload_type, | 62 const int8_t payload_type, |
| 61 const uint32_t frequency, | 63 const uint32_t frequency, |
| 62 const uint8_t channels, | 64 const uint8_t channels, |
| 63 const uint32_t rate, | 65 const uint32_t rate, |
| 64 bool* created_new_payload_type); | 66 bool* created_new_payload_type); |
| 65 | 67 |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 101 bool IsRed(const RTPHeader& header) const; | 103 bool IsRed(const RTPHeader& header) const; |
| 102 | 104 |
| 103 // Returns true if the media of this RTP packet is encapsulated within an | 105 // Returns true if the media of this RTP packet is encapsulated within an |
| 104 // extra header, such as RTX or RED. | 106 // extra header, such as RTX or RED. |
| 105 bool IsEncapsulated(const RTPHeader& header) const; | 107 bool IsEncapsulated(const RTPHeader& header) const; |
| 106 | 108 |
| 107 bool GetPayloadSpecifics(uint8_t payload_type, PayloadUnion* payload) const; | 109 bool GetPayloadSpecifics(uint8_t payload_type, PayloadUnion* payload) const; |
| 108 | 110 |
| 109 int GetPayloadTypeFrequency(uint8_t payload_type) const; | 111 int GetPayloadTypeFrequency(uint8_t payload_type) const; |
| 110 | 112 |
| 113 // DEPRECATED. Use PayloadTypeToPayload below that returns const Payload* | |
| 114 // instead of taking output parameter. | |
| 115 // TODO(danilchap): Remove this when all callers have been updated. | |
| 111 bool PayloadTypeToPayload(const uint8_t payload_type, | 116 bool PayloadTypeToPayload(const uint8_t payload_type, |
| 112 RtpUtility::Payload*& payload) const; | 117 RtpUtility::Payload*& payload) const { // NOLINT |
| 118 payload = | |
| 119 const_cast<RtpUtility::Payload*>(PayloadTypeToPayload(payload_type)); | |
| 120 return payload; | |
|
mflodman
2015/12/10 08:24:23
Here I'd still prefer to return != nullptr to cler
danilchap
2015/12/10 09:01:15
I have arguments both for and against it, but both
| |
| 121 } | |
| 122 const RtpUtility::Payload* PayloadTypeToPayload(uint8_t payload_type) const; | |
| 113 | 123 |
| 114 void ResetLastReceivedPayloadTypes() { | 124 void ResetLastReceivedPayloadTypes() { |
| 115 CriticalSectionScoped cs(crit_sect_.get()); | 125 CriticalSectionScoped cs(crit_sect_.get()); |
| 116 last_received_payload_type_ = -1; | 126 last_received_payload_type_ = -1; |
| 117 last_received_media_payload_type_ = -1; | 127 last_received_media_payload_type_ = -1; |
| 118 } | 128 } |
| 119 | 129 |
| 120 // This sets the payload type of the packets being received from the network | 130 // This sets the payload type of the packets being received from the network |
| 121 // on the media SSRC. For instance if packets are encapsulated with RED, this | 131 // on the media SSRC. For instance if packets are encapsulated with RED, this |
| 122 // payload type will be the RED payload type. | 132 // payload type will be the RED payload type. |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 138 return last_received_payload_type_; | 148 return last_received_payload_type_; |
| 139 } | 149 } |
| 140 void set_last_received_payload_type(int8_t last_received_payload_type) { | 150 void set_last_received_payload_type(int8_t last_received_payload_type) { |
| 141 CriticalSectionScoped cs(crit_sect_.get()); | 151 CriticalSectionScoped cs(crit_sect_.get()); |
| 142 last_received_payload_type_ = last_received_payload_type; | 152 last_received_payload_type_ = last_received_payload_type; |
| 143 } | 153 } |
| 144 | 154 |
| 145 int8_t last_received_media_payload_type() const { | 155 int8_t last_received_media_payload_type() const { |
| 146 CriticalSectionScoped cs(crit_sect_.get()); | 156 CriticalSectionScoped cs(crit_sect_.get()); |
| 147 return last_received_media_payload_type_; | 157 return last_received_media_payload_type_; |
| 148 }; | 158 } |
| 149 | 159 |
| 150 bool use_rtx_payload_mapping_on_restore() const { | 160 bool use_rtx_payload_mapping_on_restore() const { |
| 151 CriticalSectionScoped cs(crit_sect_.get()); | 161 CriticalSectionScoped cs(crit_sect_.get()); |
| 152 return use_rtx_payload_mapping_on_restore_; | 162 return use_rtx_payload_mapping_on_restore_; |
| 153 } | 163 } |
| 154 | 164 |
| 155 void set_use_rtx_payload_mapping_on_restore(bool val) { | 165 void set_use_rtx_payload_mapping_on_restore(bool val) { |
| 156 CriticalSectionScoped cs(crit_sect_.get()); | 166 CriticalSectionScoped cs(crit_sect_.get()); |
| 157 use_rtx_payload_mapping_on_restore_ = val; | 167 use_rtx_payload_mapping_on_restore_ = val; |
| 158 } | 168 } |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 184 std::map<int, int> rtx_payload_type_map_; | 194 std::map<int, int> rtx_payload_type_map_; |
| 185 // When true, use rtx_payload_type_map_ when restoring RTX packets to get the | 195 // When true, use rtx_payload_type_map_ when restoring RTX packets to get the |
| 186 // correct payload type. | 196 // correct payload type. |
| 187 bool use_rtx_payload_mapping_on_restore_; | 197 bool use_rtx_payload_mapping_on_restore_; |
| 188 uint32_t ssrc_rtx_; | 198 uint32_t ssrc_rtx_; |
| 189 }; | 199 }; |
| 190 | 200 |
| 191 } // namespace webrtc | 201 } // namespace webrtc |
| 192 | 202 |
| 193 #endif // WEBRTC_MODULES_RTP_RTCP_INCLUDE_RTP_PAYLOAD_REGISTRY_H_ | 203 #endif // WEBRTC_MODULES_RTP_RTCP_INCLUDE_RTP_PAYLOAD_REGISTRY_H_ |
| OLD | NEW |