Replace rtc:🦗:Settable with rtc::Maybe
The former is very similar to the latter, but less general (mostly in naming). This CL, which is the first to use Maybe at scale, also removes the implicit conversion from T to Maybe<T>, since it was agreed that the increased verbosity increased legibility. Review URL: https://codereview.webrtc.org/1430433004 Cr-Commit-Position: refs/heads/master@{#10461}
This commit is contained in:
@ -61,9 +61,10 @@ rtc::Maybe<NetEqDecoder> RentACodec::NetEqDecoderFromCodecId(CodecId codec_id,
|
||||
if (!i)
|
||||
return rtc::Maybe<NetEqDecoder>();
|
||||
const NetEqDecoder ned = ACMCodecDB::neteq_decoders_[*i];
|
||||
return (ned == NetEqDecoder::kDecoderOpus && num_channels == 2)
|
||||
? NetEqDecoder::kDecoderOpus_2ch
|
||||
: ned;
|
||||
return rtc::Maybe<NetEqDecoder>(
|
||||
(ned == NetEqDecoder::kDecoderOpus && num_channels == 2)
|
||||
? NetEqDecoder::kDecoderOpus_2ch
|
||||
: ned);
|
||||
}
|
||||
|
||||
} // namespace acm2
|
||||
|
||||
@ -133,12 +133,14 @@ class RentACodec {
|
||||
|
||||
static inline rtc::Maybe<int> CodecIndexFromId(CodecId codec_id) {
|
||||
const int i = static_cast<int>(codec_id);
|
||||
return i < static_cast<int>(NumberOfCodecs()) ? i : rtc::Maybe<int>();
|
||||
return i < static_cast<int>(NumberOfCodecs()) ? rtc::Maybe<int>(i)
|
||||
: rtc::Maybe<int>();
|
||||
}
|
||||
|
||||
static inline rtc::Maybe<CodecId> CodecIdFromIndex(int codec_index) {
|
||||
return static_cast<size_t>(codec_index) < NumberOfCodecs()
|
||||
? static_cast<RentACodec::CodecId>(codec_index)
|
||||
? rtc::Maybe<RentACodec::CodecId>(
|
||||
static_cast<RentACodec::CodecId>(codec_index))
|
||||
: rtc::Maybe<RentACodec::CodecId>();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user