webrtc codec
Posted 我叫刘航阿
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了webrtc codec相关的知识,希望对你有一定的参考价值。
1、视频
std::unique_ptr<VideoEncoder> InternalEncoderFactory::CreateVideoEncoder( const SdpVideoFormat& format) { if (absl::EqualsIgnoreCase(format.name, cricket::kVp8CodecName)) return VP8Encoder::Create(); if (absl::EqualsIgnoreCase(format.name, cricket::kVp9CodecName)) return VP9Encoder::Create(cricket::VideoCodec(format)); if (absl::EqualsIgnoreCase(format.name, cricket::kH264CodecName)) return H264Encoder::Create(cricket::VideoCodec(format)); RTC_LOG(LS_ERROR) << "Trying to created encoder of unsupported format " << format.name; return nullptr; }
从上到下的优先级的形式设置
2 音频
WebRtcVoiceMediaChannel::SetRecvCodecs
WebRtcVoiceMediaChannel::SetSendCodecs
for (const AudioCodec& voice_codec : codecs) { if (!(IsCodec(voice_codec, kCnCodecName) || IsCodec(voice_codec, kDtmfCodecName) || IsCodec(voice_codec, kRedCodecName))) { webrtc::SdpAudioFormat format(voice_codec.name, voice_codec.clockrate, voice_codec.channels, voice_codec.params); voice_codec_info = engine()->encoder_factory_->QueryAudioEncoder(format); if (!voice_codec_info) { RTC_LOG(LS_WARNING) << "Unknown codec " << ToString(voice_codec); continue; }
这个里边 从codecs的列表里 从头到尾的优先级找到当前使用的codec。
而这个codecs的列表数据,是音频引擎在启动的时候,获取到的,代码如下:
void WebRtcVoiceEngine::Init() { RTC_DCHECK(worker_thread_checker_.IsCurrent()); RTC_LOG(LS_INFO) << "WebRtcVoiceEngine::Init"; // TaskQueue expects to be created/destroyed on the same thread. low_priority_worker_queue_.reset( new rtc::TaskQueue(task_queue_factory_->CreateTaskQueue( "rtc-low-prio", webrtc::TaskQueueFactory::Priority::LOW))); // Load our audio codec lists. RTC_LOG(LS_VERBOSE) << "Supported send codecs in order of preference:"; send_codecs_ = CollectCodecs(encoder_factory_->GetSupportedEncoders()); for (const AudioCodec& codec : send_codecs_) { RTC_LOG(LS_VERBOSE) << ToString(codec); } RTC_LOG(LS_VERBOSE) << "Supported recv codecs in order of preference:"; recv_codecs_ = CollectCodecs(decoder_factory_->GetSupportedDecoders()); for (const AudioCodec& codec : recv_codecs_) { RTC_LOG(LS_VERBOSE) << ToString(codec); }
以上是关于webrtc codec的主要内容,如果未能解决你的问题,请参考以下文章