Reland "WebRtcVoiceMediaChannel::AddRecvStream: Don't call SetRecPayloadType"
BUG=webrtc:5805 Review-Url: https://codereview.webrtc.org/2774833003 Cr-Commit-Position: refs/heads/master@{#17391}
This commit is contained in:
@ -123,6 +123,38 @@ void DecoderDatabase::Reset() {
|
||||
active_cng_decoder_type_ = -1;
|
||||
}
|
||||
|
||||
std::vector<int> DecoderDatabase::SetCodecs(
|
||||
const std::map<int, SdpAudioFormat>& codecs) {
|
||||
// First collect all payload types that we'll remove or reassign, then remove
|
||||
// them from the database.
|
||||
std::vector<int> changed_payload_types;
|
||||
for (const std::pair<uint8_t, const DecoderInfo&> kv : decoders_) {
|
||||
auto i = codecs.find(kv.first);
|
||||
if (i == codecs.end() || i->second != kv.second.GetFormat()) {
|
||||
changed_payload_types.push_back(kv.first);
|
||||
}
|
||||
}
|
||||
for (int pl_type : changed_payload_types) {
|
||||
Remove(pl_type);
|
||||
}
|
||||
|
||||
// Enter the new and changed payload type mappings into the database.
|
||||
for (const auto& kv : codecs) {
|
||||
const int& rtp_payload_type = kv.first;
|
||||
const SdpAudioFormat& audio_format = kv.second;
|
||||
RTC_DCHECK_GE(rtp_payload_type, 0);
|
||||
RTC_DCHECK_LE(rtp_payload_type, 0x7f);
|
||||
if (decoders_.count(rtp_payload_type) == 0) {
|
||||
decoders_.insert(std::make_pair(
|
||||
rtp_payload_type, DecoderInfo(audio_format, decoder_factory_.get())));
|
||||
} else {
|
||||
// The mapping for this payload type hasn't changed.
|
||||
}
|
||||
}
|
||||
|
||||
return changed_payload_types;
|
||||
}
|
||||
|
||||
int DecoderDatabase::RegisterPayload(uint8_t rtp_payload_type,
|
||||
NetEqDecoder codec_type,
|
||||
const std::string& name) {
|
||||
|
||||
@ -149,6 +149,11 @@ class DecoderDatabase {
|
||||
// using InsertExternal().
|
||||
virtual void Reset();
|
||||
|
||||
// Replaces the existing set of decoders with the given set. Returns the
|
||||
// payload types that were reassigned or removed while doing so.
|
||||
virtual std::vector<int> SetCodecs(
|
||||
const std::map<int, SdpAudioFormat>& codecs);
|
||||
|
||||
// Registers |rtp_payload_type| as a decoder of type |codec_type|. The |name|
|
||||
// is only used to populate the name field in the DecoderInfo struct in the
|
||||
// database, and can be arbitrary (including empty). Returns kOK on success;
|
||||
|
||||
@ -157,6 +157,9 @@ class NetEq {
|
||||
// Returns kOK on success, or kFail in case of an error.
|
||||
virtual int GetAudio(AudioFrame* audio_frame, bool* muted) = 0;
|
||||
|
||||
// Replaces the current set of decoders with the given one.
|
||||
virtual void SetCodecs(const std::map<int, SdpAudioFormat>& codecs) = 0;
|
||||
|
||||
// Associates |rtp_payload_type| with |codec| and |codec_name|, and stores the
|
||||
// information in the codec database. Returns 0 on success, -1 on failure.
|
||||
// The name is only used to provide information back to the caller about the
|
||||
|
||||
@ -212,6 +212,15 @@ int NetEqImpl::GetAudio(AudioFrame* audio_frame, bool* muted) {
|
||||
return kOK;
|
||||
}
|
||||
|
||||
void NetEqImpl::SetCodecs(const std::map<int, SdpAudioFormat>& codecs) {
|
||||
rtc::CritScope lock(&crit_sect_);
|
||||
const std::vector<int> changed_payload_types =
|
||||
decoder_database_->SetCodecs(codecs);
|
||||
for (const int pt : changed_payload_types) {
|
||||
packet_buffer_->DiscardPacketsWithPayloadType(pt);
|
||||
}
|
||||
}
|
||||
|
||||
int NetEqImpl::RegisterPayloadType(NetEqDecoder codec,
|
||||
const std::string& name,
|
||||
uint8_t rtp_payload_type) {
|
||||
|
||||
@ -111,6 +111,8 @@ class NetEqImpl : public webrtc::NetEq {
|
||||
|
||||
int GetAudio(AudioFrame* audio_frame, bool* muted) override;
|
||||
|
||||
void SetCodecs(const std::map<int, SdpAudioFormat>& codecs) override;
|
||||
|
||||
int RegisterPayloadType(NetEqDecoder codec,
|
||||
const std::string& codec_name,
|
||||
uint8_t rtp_payload_type) override;
|
||||
|
||||
Reference in New Issue
Block a user