Move decoder instance ownership to VideoReceiver2

This moves the ownership away from VideoReceiveStream2 and closer to
VCMDecoderDataBase. That facilitates unregistration (upcoming change)
without recreating receive streams.

Bug: none
Change-Id: I812175134730a0ffbf7077fd149c8489481c73d8
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/272481
Reviewed-by: Danil Chapovalov <danilchap@webrtc.org>
Commit-Queue: Tomas Gunnarsson <tommi@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#37866}
This commit is contained in:
Tommi
2022-08-22 12:56:38 +02:00
committed by WebRTC LUCI CQ
parent ae0ec3a5d9
commit bd02e70629
7 changed files with 49 additions and 35 deletions

View File

@ -19,13 +19,14 @@ VCMDecoderDataBase::VCMDecoderDataBase() {
decoder_sequence_checker_.Detach();
}
bool VCMDecoderDataBase::DeregisterExternalDecoder(uint8_t payload_type) {
VideoDecoder* VCMDecoderDataBase::DeregisterExternalDecoder(
uint8_t payload_type) {
RTC_DCHECK_RUN_ON(&decoder_sequence_checker_);
auto it = decoders_.find(payload_type);
if (it == decoders_.end()) {
// Not found.
return false;
return nullptr;
}
// We can't use payload_type to check if the decoder is currently in use,
// because payload type may be out of date (e.g. before we decode the first
// frame after RegisterReceiveCodec).
@ -33,8 +34,9 @@ bool VCMDecoderDataBase::DeregisterExternalDecoder(uint8_t payload_type) {
// Release it if it was registered and in use.
current_decoder_ = absl::nullopt;
}
VideoDecoder* ret = it->second;
decoders_.erase(it);
return true;
return ret;
}
// Add the external decoder object to the list of external decoders.