Index: webrtc/modules/rtp_rtcp/include/rtp_payload_registry.h |
diff --git a/webrtc/modules/rtp_rtcp/include/rtp_payload_registry.h b/webrtc/modules/rtp_rtcp/include/rtp_payload_registry.h |
index 668fe876f2e326b90b2ea118d7e99918ef68180f..8f9d5829f9cc066c0416d991994205af4d38fe24 100644 |
--- a/webrtc/modules/rtp_rtcp/include/rtp_payload_registry.h |
+++ b/webrtc/modules/rtp_rtcp/include/rtp_payload_registry.h |
@@ -25,24 +25,46 @@ |
struct CodecInst; |
class VideoCodec; |
-// TODO(magjed): Remove once external code is updated. |
+// This strategy deals with the audio/video-specific aspects |
+// of payload handling. |
class RTPPayloadStrategy { |
public: |
- static RTPPayloadStrategy* CreateStrategy(bool handling_audio) { |
- return nullptr; |
- } |
+ virtual ~RTPPayloadStrategy() {} |
+ |
+ virtual bool CodecsMustBeUnique() const = 0; |
+ |
+ virtual bool PayloadIsCompatible(const RtpUtility::Payload& payload, |
+ uint32_t frequency, |
+ size_t channels, |
+ uint32_t rate) const = 0; |
+ |
+ virtual void UpdatePayloadRate(RtpUtility::Payload* payload, |
+ uint32_t rate) const = 0; |
+ |
+ virtual RtpUtility::Payload* CreatePayloadType(const char* payload_name, |
+ int8_t payload_type, |
+ uint32_t frequency, |
+ size_t channels, |
+ uint32_t rate) const = 0; |
+ |
+ virtual int GetPayloadTypeFrequency( |
+ const RtpUtility::Payload& payload) const = 0; |
+ |
+ static RTPPayloadStrategy* CreateStrategy(bool handling_audio); |
+ |
+ protected: |
+ RTPPayloadStrategy() {} |
}; |
class RTPPayloadRegistry { |
public: |
- RTPPayloadRegistry(); |
+ // The registry takes ownership of the strategy. |
+ explicit RTPPayloadRegistry(RTPPayloadStrategy* rtp_payload_strategy); |
~RTPPayloadRegistry(); |
- // TODO(magjed): Remove once external code is updated. |
- explicit RTPPayloadRegistry(RTPPayloadStrategy* rtp_payload_strategy) |
- : RTPPayloadRegistry() {} |
// TODO(magjed): Split RTPPayloadRegistry into separate Audio and Video class |
- // and simplify the code. http://crbug/webrtc/6743. |
+ // and remove RTPPayloadStrategy, RTPPayloadVideoStrategy, |
+ // RTPPayloadAudioStrategy, and simplify the code. http://crbug/webrtc/6743. |
int32_t RegisterReceivePayload(const CodecInst& audio_codec, |
bool* created_new_payload_type); |
int32_t RegisterReceivePayload(const VideoCodec& video_codec); |
@@ -96,9 +118,13 @@ |
// Returns true if the new media payload type has not changed. |
bool ReportMediaPayloadType(uint8_t media_payload_type); |
- int8_t red_payload_type() const { return GetPayloadTypeWithName("red"); } |
+ int8_t red_payload_type() const { |
+ rtc::CritScope cs(&crit_sect_); |
+ return red_payload_type_; |
+ } |
int8_t ulpfec_payload_type() const { |
- return GetPayloadTypeWithName("ulpfec"); |
+ rtc::CritScope cs(&crit_sect_); |
+ return ulpfec_payload_type_; |
} |
int8_t last_received_payload_type() const { |
rtc::CritScope cs(&crit_sect_); |
@@ -117,17 +143,34 @@ |
RTC_DEPRECATED void set_use_rtx_payload_mapping_on_restore(bool val) {} |
private: |
+ int32_t RegisterReceivePayload(const char* payload_name, |
+ int8_t payload_type, |
+ uint32_t frequency, |
+ size_t channels, |
+ uint32_t rate, |
+ bool* created_new_payload_type); |
+ |
+ int32_t ReceivePayloadType(const char* payload_name, |
+ uint32_t frequency, |
+ size_t channels, |
+ uint32_t rate, |
+ int8_t* payload_type) const; |
+ |
// Prunes the payload type map of the specific payload type, if it exists. |
void DeregisterAudioCodecOrRedTypeRegardlessOfPayloadType( |
- const CodecInst& audio_codec); |
+ const char* payload_name, |
+ size_t payload_name_length, |
+ uint32_t frequency, |
+ size_t channels, |
+ uint32_t rate); |
bool IsRtxInternal(const RTPHeader& header) const; |
- // Returns the payload type for the payload with name |payload_name|, or -1 if |
- // no such payload is registered. |
- int8_t GetPayloadTypeWithName(const char* payload_name) const; |
rtc::CriticalSection crit_sect_; |
- std::map<int, RtpUtility::Payload> payload_type_map_; |
+ RtpUtility::PayloadTypeMap payload_type_map_; |
+ std::unique_ptr<RTPPayloadStrategy> rtp_payload_strategy_; |
+ int8_t red_payload_type_; |
+ int8_t ulpfec_payload_type_; |
int8_t incoming_payload_type_; |
int8_t last_received_payload_type_; |
int8_t last_received_media_payload_type_; |