modules/audio_coding/acm2/codec_manager.cc
// Check if the given codec is a valid to be registered as send codec.
Check if the given codec is a valid to be registered as send codec.
Check if the given codec is a valid to be registered as send codec .
int IsValidSendCodec(const CodecInst& send_codec) {
  int dummy_id = 0;
  if ((send_codec.channels != 1) && (send_codec.channels != 2)) {
    WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, dummy_id,
                 "Wrong number of channels (%d, only mono and stereo are "
                 "supported)",
                 send_codec.channels);
    return -1;
  }
  auto maybe_codec_id = RentACodec::CodecIdByInst(send_codec);
  if (!maybe_codec_id) {
    WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, dummy_id,
                 "Invalid codec setting for the send codec.");
    return -1;
  }
  if (!STR_CASE_CMP(send_codec.plname, "telephone-event")) {
    WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, dummy_id,
                 "telephone-event cannot be a send codec");
    return -1;
  }
  if (!RentACodec::IsSupportedNumChannels(*maybe_codec_id, send_codec.channels)
           .value_or(false)) {
    WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, dummy_id,
                 "%d number of channels not supportedn for %s.",
                 send_codec.channels, send_codec.plname);
    return -1;
  }
  return RentACodec::CodecIndexFromId(*maybe_codec_id).value_or(-1);
}
int IsValidSendCodec ( const CodecInst & send_codec ) { int dummy_id = 0 ; if ( ( send_codec . channels != 1 ) && ( send_codec . channels != 2 ) ) { WEBRTC_TRACE ( webrtc :: kTraceError , webrtc :: kTraceAudioCoding , dummy_id , " " " " , send_codec . channels ) ; return -1 ; } auto maybe_codec_id = RentACodec :: CodecIdByInst ( send_codec ) ; if ( ! maybe_codec_id ) { WEBRTC_TRACE ( webrtc :: kTraceError , webrtc :: kTraceAudioCoding , dummy_id , " " ) ; return -1 ; } if ( ! STR_CASE_CMP ( send_codec . plname , " " ) ) { WEBRTC_TRACE ( webrtc :: kTraceError , webrtc :: kTraceAudioCoding , dummy_id , " " ) ; return -1 ; } if ( ! RentACodec :: IsSupportedNumChannels ( * maybe_codec_id , send_codec . channels ) . value_or ( false ) ) { WEBRTC_TRACE ( webrtc :: kTraceError , webrtc :: kTraceAudioCoding , dummy_id , " " , send_codec . channels , send_codec . plname ) ; return -1 ; } return RentACodec :: CodecIndexFromId ( * maybe_codec_id ) . value_or ( -1 ) ; }
Check if the given codec is a valid to be registered as send codec.
Check if the given codec is a valid to be registered as send codec .
// Telephone-event cannot be a send codec.