Revert of Remove RTPPayloadStrategy and simplify RTPPayloadRegistry (patchset #7 id:240001 of https://codereview.webrtc.org/2524923002/ )

Reason for revert:
Breaks downstream projects.

Original issue's description:
> Remove RTPPayloadStrategy and simplify RTPPayloadRegistry
>
> This CL removes RTPPayloadStrategy that is currently used to handle
> audio/video specific aspects of payload handling. Instead, the audio and
> video specific aspects will now have different functions, with linear
> code flow.
>
> This CL does not contain any functional changes, and is just a
> preparation for future CL:s.
>
> The main purpose with this CL is to add this function:
> bool PayloadIsCompatible(const RtpUtility::Payload& payload,
>                          const webrtc::VideoCodec& video_codec);
> that can easily be extended in a future CL to look at video codec
> specific information.
>
> BUG=webrtc:6743
>
> Committed: https://crrev.com/b881254dc86d2cc80a52e08155433458be002166
> Cr-Commit-Position: refs/heads/master@{#15232}

TBR=danilchap@webrtc.org,solenberg@webrtc.org,mflodman@webrtc.org
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=webrtc:6743

Review-Url: https://codereview.webrtc.org/2528993002
Cr-Commit-Position: refs/heads/master@{#15234}
This commit is contained in:
magjed
2016-11-24 11:08:39 -08:00
committed by Commit bot
parent 69b627d89d
commit 33c81d0561
16 changed files with 558 additions and 291 deletions

View File

@ -25,24 +25,46 @@ namespace webrtc {
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 @@ class RTPPayloadRegistry {
// 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 @@ class RTPPayloadRegistry {
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_;