File tree Expand file tree Collapse file tree
webrtc/modules/audio_coding Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -245,12 +245,27 @@ void AcmReceiver::FlushBuffers() {
245245 neteq_->FlushBuffers ();
246246}
247247
248- void AcmReceiver::RemoveAllCodecs () {
248+ // If failed in removing one of the codecs, this method continues to remove as
249+ // many as it can.
250+ int AcmReceiver::RemoveAllCodecs () {
251+ int ret_val = 0 ;
249252 rtc::CritScope lock (&crit_sect_);
250- neteq_->RemoveAllPayloadTypes ();
251- decoders_.clear ();
253+ for (auto it = decoders_.begin (); it != decoders_.end (); ) {
254+ auto cur = it;
255+ ++it; // it will be valid even if we erase cur
256+ if (neteq_->RemovePayloadType (cur->second .payload_type ) == 0 ) {
257+ decoders_.erase (cur);
258+ } else {
259+ LOG_F (LS_ERROR) << " Cannot remove payload "
260+ << static_cast <int >(cur->second .payload_type );
261+ ret_val = -1 ;
262+ }
263+ }
264+
265+ // No codec is registered, invalidate last audio decoder.
252266 last_audio_decoder_ = rtc::Optional<CodecInst>();
253267 last_packet_sample_rate_hz_ = rtc::Optional<int >();
268+ return ret_val;
254269}
255270
256271int AcmReceiver::RemoveCodec (uint8_t payload_type) {
Original file line number Diff line number Diff line change @@ -186,7 +186,7 @@ class AcmReceiver {
186186 //
187187 // Remove all registered codecs.
188188 //
189- void RemoveAllCodecs ();
189+ int RemoveAllCodecs ();
190190
191191 // Returns the RTP timestamp for the last sample delivered by GetAudio().
192192 // The return value will be empty if no valid timestamp is available.
Original file line number Diff line number Diff line change @@ -948,8 +948,10 @@ int AudioCodingModuleImpl::InitializeReceiverSafe() {
948948 // If the receiver is already initialized then we want to destroy any
949949 // existing decoders. After a call to this function, we should have a clean
950950 // start-up.
951- if (receiver_initialized_)
952- receiver_.RemoveAllCodecs ();
951+ if (receiver_initialized_) {
952+ if (receiver_.RemoveAllCodecs () < 0 )
953+ return -1 ;
954+ }
953955 receiver_.ResetInitialDelay ();
954956 receiver_.SetMinimumDelay (0 );
955957 receiver_.SetMaximumDelay (0 );
Original file line number Diff line number Diff line change @@ -169,12 +169,6 @@ int DecoderDatabase::Remove(uint8_t rtp_payload_type) {
169169 return kOK ;
170170}
171171
172- void DecoderDatabase::RemoveAll () {
173- decoders_.clear ();
174- active_decoder_type_ = -1 ; // No active decoder.
175- active_cng_decoder_type_ = -1 ; // No active CNG decoder.
176- }
177-
178172const DecoderDatabase::DecoderInfo* DecoderDatabase::GetDecoderInfo (
179173 uint8_t rtp_payload_type) const {
180174 DecoderMap::const_iterator it = decoders_.find (rtp_payload_type);
Original file line number Diff line number Diff line change @@ -136,9 +136,6 @@ class DecoderDatabase {
136136 // Returns kDecoderNotFound or kOK depending on the outcome of the operation.
137137 virtual int Remove (uint8_t rtp_payload_type);
138138
139- // Remove all entries.
140- void RemoveAll ();
141-
142139 // Returns a pointer to the DecoderInfo struct for |rtp_payload_type|. If
143140 // no decoder is registered with that |rtp_payload_type|, NULL is returned.
144141 virtual const DecoderInfo* GetDecoderInfo (uint8_t rtp_payload_type) const ;
Original file line number Diff line number Diff line change @@ -183,9 +183,6 @@ class NetEq {
183183 // -1 on failure.
184184 virtual int RemovePayloadType (uint8_t rtp_payload_type) = 0;
185185
186- // Removes all payload types from the codec database.
187- virtual void RemoveAllPayloadTypes () = 0;
188-
189186 // Sets a minimum delay in millisecond for packet buffer. The minimum is
190187 // maintained unless a higher latency is dictated by channel condition.
191188 // Returns true if the minimum is successfully applied, otherwise false is
Original file line number Diff line number Diff line change @@ -291,11 +291,6 @@ int NetEqImpl::RemovePayloadType(uint8_t rtp_payload_type) {
291291 return kFail ;
292292}
293293
294- void NetEqImpl::RemoveAllPayloadTypes () {
295- rtc::CritScope lock (&crit_sect_);
296- decoder_database_->RemoveAll ();
297- }
298-
299294bool NetEqImpl::SetMinimumDelay (int delay_ms) {
300295 rtc::CritScope lock (&crit_sect_);
301296 if (delay_ms >= 0 && delay_ms < 10000 ) {
Original file line number Diff line number Diff line change @@ -123,8 +123,6 @@ class NetEqImpl : public webrtc::NetEq {
123123 // -1 on failure.
124124 int RemovePayloadType (uint8_t rtp_payload_type) override ;
125125
126- void RemoveAllPayloadTypes () override ;
127-
128126 bool SetMinimumDelay (int delay_ms) override ;
129127
130128 bool SetMaximumDelay (int delay_ms) override ;
You can’t perform that action at this time.
0 commit comments