Delete dead code in RtpReceiverImpl and RTPPayloadRegistry.
Bug: webrtc:8995 Change-Id: I5460c699c2dc6cf17b2f88be74698b913d4c29b8 Reviewed-on: https://webrtc-review.googlesource.com/64447 Reviewed-by: Danil Chapovalov <danilchap@webrtc.org> Commit-Queue: Niels Moller <nisse@webrtc.org> Cr-Commit-Position: refs/heads/master@{#22607}
This commit is contained in:
parent
250155d0db
commit
e08a4c01b9
@ -54,12 +54,8 @@ class RTPPayloadRegistry {
|
||||
void ResetLastReceivedPayloadTypes() {
|
||||
rtc::CritScope cs(&crit_sect_);
|
||||
last_received_payload_type_ = -1;
|
||||
last_received_media_payload_type_ = -1;
|
||||
}
|
||||
|
||||
// Returns true if the new media payload type has not changed.
|
||||
bool ReportMediaPayloadType(uint8_t media_payload_type);
|
||||
|
||||
int8_t last_received_payload_type() const {
|
||||
rtc::CritScope cs(&crit_sect_);
|
||||
return last_received_payload_type_;
|
||||
@ -69,11 +65,6 @@ class RTPPayloadRegistry {
|
||||
last_received_payload_type_ = last_received_payload_type;
|
||||
}
|
||||
|
||||
int8_t last_received_media_payload_type() const {
|
||||
rtc::CritScope cs(&crit_sect_);
|
||||
return last_received_media_payload_type_;
|
||||
}
|
||||
|
||||
private:
|
||||
// Prunes the payload type map of the specific payload type, if it exists.
|
||||
void DeregisterAudioCodecOrRedTypeRegardlessOfPayloadType(
|
||||
@ -82,7 +73,6 @@ class RTPPayloadRegistry {
|
||||
rtc::CriticalSection crit_sect_;
|
||||
std::map<int, RtpUtility::Payload> payload_type_map_;
|
||||
int8_t last_received_payload_type_;
|
||||
int8_t last_received_media_payload_type_;
|
||||
|
||||
// As a first step in splitting this class up in separate cases for audio and
|
||||
// video, DCHECK that no instance is used for both audio and video.
|
||||
|
||||
@ -103,8 +103,7 @@ bool IsPayloadTypeValid(int8_t payload_type) {
|
||||
} // namespace
|
||||
|
||||
RTPPayloadRegistry::RTPPayloadRegistry()
|
||||
: last_received_payload_type_(-1),
|
||||
last_received_media_payload_type_(-1) {}
|
||||
: last_received_payload_type_(-1) {}
|
||||
|
||||
RTPPayloadRegistry::~RTPPayloadRegistry() = default;
|
||||
|
||||
@ -129,7 +128,6 @@ void RTPPayloadRegistry::SetAudioReceivePayloads(
|
||||
// Clear the value of last received payload type since it might mean
|
||||
// something else now.
|
||||
last_received_payload_type_ = -1;
|
||||
last_received_media_payload_type_ = -1;
|
||||
}
|
||||
|
||||
int32_t RTPPayloadRegistry::RegisterReceivePayload(
|
||||
@ -170,7 +168,6 @@ int32_t RTPPayloadRegistry::RegisterReceivePayload(
|
||||
// Successful set of payload type, clear the value of last received payload
|
||||
// type since it might mean something else.
|
||||
last_received_payload_type_ = -1;
|
||||
last_received_media_payload_type_ = -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -204,7 +201,6 @@ int32_t RTPPayloadRegistry::RegisterReceivePayload(
|
||||
// Successful set of payload type, clear the value of last received payload
|
||||
// type since it might mean something else.
|
||||
last_received_payload_type_ = -1;
|
||||
last_received_media_payload_type_ = -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -280,14 +276,4 @@ rtc::Optional<RtpUtility::Payload> RTPPayloadRegistry::PayloadTypeToPayload(
|
||||
: rtc::Optional<RtpUtility::Payload>(it->second);
|
||||
}
|
||||
|
||||
bool RTPPayloadRegistry::ReportMediaPayloadType(uint8_t media_payload_type) {
|
||||
rtc::CritScope cs(&crit_sect_);
|
||||
if (last_received_media_payload_type_ == media_payload_type) {
|
||||
// Media type unchanged.
|
||||
return true;
|
||||
}
|
||||
last_received_media_payload_type_ = media_payload_type;
|
||||
return false;
|
||||
}
|
||||
|
||||
} // namespace webrtc
|
||||
|
||||
@ -155,11 +155,6 @@ TEST(RtpPayloadRegistryTest,
|
||||
rtp_payload_registry.set_last_received_payload_type(17);
|
||||
EXPECT_EQ(17, rtp_payload_registry.last_received_payload_type());
|
||||
|
||||
bool media_type_unchanged = rtp_payload_registry.ReportMediaPayloadType(18);
|
||||
EXPECT_FALSE(media_type_unchanged);
|
||||
media_type_unchanged = rtp_payload_registry.ReportMediaPayloadType(18);
|
||||
EXPECT_TRUE(media_type_unchanged);
|
||||
|
||||
bool ignored;
|
||||
constexpr int payload_type = 34;
|
||||
const SdpAudioFormat audio_format("name", 44000, 1);
|
||||
@ -167,8 +162,6 @@ TEST(RtpPayloadRegistryTest,
|
||||
payload_type, audio_format, &ignored));
|
||||
|
||||
EXPECT_EQ(-1, rtp_payload_registry.last_received_payload_type());
|
||||
media_type_unchanged = rtp_payload_registry.ReportMediaPayloadType(18);
|
||||
EXPECT_FALSE(media_type_unchanged);
|
||||
}
|
||||
|
||||
class ParameterizedRtpPayloadRegistryTest
|
||||
|
||||
@ -272,8 +272,6 @@ bool RtpReceiverImpl::GetLatestTimestamps(uint32_t* timestamp,
|
||||
// Implementation note: must not hold critsect when called.
|
||||
void RtpReceiverImpl::CheckSSRCChanged(const RTPHeader& rtp_header) {
|
||||
bool new_ssrc = false;
|
||||
// TODO(nisse): This is unused, delete any corresponding dead code.
|
||||
rtc::Optional<AudioPayload> reinitialize_audio_payload;
|
||||
|
||||
{
|
||||
rtc::CritScope lock(&critical_section_rtp_receiver_);
|
||||
@ -288,23 +286,6 @@ void RtpReceiverImpl::CheckSSRCChanged(const RTPHeader& rtp_header) {
|
||||
last_received_timestamp_ = 0;
|
||||
last_received_frame_time_ms_ = -1;
|
||||
|
||||
// Do we have a SSRC? Then the stream is restarted.
|
||||
if (ssrc_ != 0) {
|
||||
// Do we have the same codec? Then re-initialize coder.
|
||||
if (rtp_header.payloadType == last_received_payload_type) {
|
||||
const auto payload = rtp_payload_registry_->PayloadTypeToPayload(
|
||||
rtp_header.payloadType);
|
||||
if (!payload) {
|
||||
return;
|
||||
}
|
||||
if (payload->typeSpecific.is_audio()) {
|
||||
reinitialize_audio_payload.emplace(
|
||||
payload->typeSpecific.audio_payload());
|
||||
} else {
|
||||
// OnInitializeDecoder() is only used for audio.
|
||||
}
|
||||
}
|
||||
}
|
||||
ssrc_ = rtp_header.ssrc;
|
||||
}
|
||||
}
|
||||
@ -326,10 +307,6 @@ void RtpReceiverImpl::CheckSSRCChanged(const RTPHeader& rtp_header) {
|
||||
int32_t RtpReceiverImpl::CheckPayloadChanged(const RTPHeader& rtp_header,
|
||||
const int8_t first_payload_byte,
|
||||
PayloadUnion* specific_payload) {
|
||||
// TODO(nisse): re_initialize_decoder is unused, and most or all of
|
||||
// this code can likely be deleted.
|
||||
bool re_initialize_decoder = false;
|
||||
|
||||
int8_t payload_type = rtp_header.payloadType;
|
||||
|
||||
{
|
||||
@ -357,22 +334,6 @@ int32_t RtpReceiverImpl::CheckPayloadChanged(const RTPHeader& rtp_header,
|
||||
return -1;
|
||||
}
|
||||
rtp_payload_registry_->set_last_received_payload_type(payload_type);
|
||||
|
||||
re_initialize_decoder = true;
|
||||
|
||||
rtp_media_receiver_->SetLastMediaSpecificPayload(payload->typeSpecific);
|
||||
rtp_media_receiver_->GetLastMediaSpecificPayload(specific_payload);
|
||||
|
||||
if (!payload->typeSpecific.is_audio()) {
|
||||
bool media_type_unchanged =
|
||||
rtp_payload_registry_->ReportMediaPayloadType(payload_type);
|
||||
if (media_type_unchanged) {
|
||||
// Only reset the decoder if the media codec type has changed.
|
||||
re_initialize_decoder = false;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
rtp_media_receiver_->GetLastMediaSpecificPayload(specific_payload);
|
||||
}
|
||||
} // End critsect.
|
||||
|
||||
|
||||
@ -19,20 +19,6 @@ RTPReceiverStrategy::RTPReceiverStrategy(RtpData* data_callback)
|
||||
|
||||
RTPReceiverStrategy::~RTPReceiverStrategy() = default;
|
||||
|
||||
void RTPReceiverStrategy::GetLastMediaSpecificPayload(
|
||||
PayloadUnion* payload) const {
|
||||
rtc::CritScope cs(&crit_sect_);
|
||||
if (last_payload_) {
|
||||
*payload = *last_payload_;
|
||||
}
|
||||
}
|
||||
|
||||
void RTPReceiverStrategy::SetLastMediaSpecificPayload(
|
||||
const PayloadUnion& payload) {
|
||||
rtc::CritScope cs(&crit_sect_);
|
||||
last_payload_.emplace(payload);
|
||||
}
|
||||
|
||||
void RTPReceiverStrategy::CheckPayloadChanged(int8_t payload_type,
|
||||
PayloadUnion* specific_payload,
|
||||
bool* should_discard_changes) {
|
||||
|
||||
@ -67,10 +67,6 @@ class RTPReceiverStrategy {
|
||||
|
||||
virtual int Energy(uint8_t array_of_energy[kRtpCsrcSize]) const;
|
||||
|
||||
// Stores / retrieves the last media specific payload for later reference.
|
||||
void GetLastMediaSpecificPayload(PayloadUnion* payload) const;
|
||||
void SetLastMediaSpecificPayload(const PayloadUnion& payload);
|
||||
|
||||
protected:
|
||||
// The data callback is where we should send received payload data.
|
||||
// See ParseRtpPacket. This class does not claim ownership of the callback.
|
||||
@ -83,7 +79,6 @@ class RTPReceiverStrategy {
|
||||
explicit RTPReceiverStrategy(RtpData* data_callback);
|
||||
|
||||
rtc::CriticalSection crit_sect_;
|
||||
rtc::Optional<PayloadUnion> last_payload_;
|
||||
RtpData* data_callback_;
|
||||
};
|
||||
} // namespace webrtc
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user