mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2024-11-22 19:00:01 +08:00
RTC: webrtc偏好音视频codec可配置(#1214)
This commit is contained in:
parent
a5fc3b04d3
commit
a7d6e2ba38
@ -234,6 +234,12 @@ port=8000
|
||||
#设置remb比特率,非0时关闭twcc并开启remb。该设置在rtc推流时有效,可以控制推流画质
|
||||
#目前已经实现twcc自动调整码率,关闭remb根据真实网络状况调整码率
|
||||
rembBitRate=0
|
||||
#rtc支持的音频codec类型,在前面的优先级更高
|
||||
#以下范例为所有支持的音频codec
|
||||
preferredCodecA=PCMU,PCMA,opus,mpeg4-generic
|
||||
#rtc支持的视频codec类型,在前面的优先级更高
|
||||
#以下范例为所有支持的视频codec
|
||||
preferredCodecV=H264,H265,AV1X,VP9,VP8
|
||||
|
||||
[rtsp]
|
||||
#rtsp专有鉴权方式是采用base64还是md5方式
|
||||
|
@ -13,6 +13,16 @@
|
||||
#include <cinttypes>
|
||||
using namespace mediakit;
|
||||
|
||||
namespace RTC {
|
||||
#define RTC_FIELD "rtc."
|
||||
const string kPreferredCodecA = RTC_FIELD"preferredCodecA";
|
||||
const string kPreferredCodecV = RTC_FIELD"preferredCodecV";
|
||||
static onceToken token([]() {
|
||||
mINI::Instance()[kPreferredCodecA] = "PCMU,PCMA,opus,mpeg4-generic";
|
||||
mINI::Instance()[kPreferredCodecV] = "H264,H265,AV1X,VP9,VP8";
|
||||
});
|
||||
}
|
||||
|
||||
using onCreateSdpItem = function<SdpItem::Ptr(const string &key, const string &value)>;
|
||||
static map<string, onCreateSdpItem, StrCaseCompare> sdpItemCreator;
|
||||
|
||||
@ -1372,6 +1382,18 @@ void RtcConfigure::RtcTrackConfigure::enableREMB(bool enable){
|
||||
}
|
||||
}
|
||||
|
||||
static vector<CodecId> toCodecArray(const string &str){
|
||||
vector<CodecId> ret;
|
||||
auto vec = split(str, ",");
|
||||
for (auto &s : vec) {
|
||||
auto codec = getCodecId(trim(s));
|
||||
if (codec != CodecInvalid) {
|
||||
ret.emplace_back(codec);
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
void RtcConfigure::RtcTrackConfigure::setDefaultSetting(TrackType type){
|
||||
rtcp_mux = true;
|
||||
rtcp_rsize = false;
|
||||
@ -1385,7 +1407,10 @@ void RtcConfigure::RtcTrackConfigure::setDefaultSetting(TrackType type){
|
||||
switch (type) {
|
||||
case TrackAudio: {
|
||||
//此处调整偏好的编码格式优先级
|
||||
preferred_codec = {CodecAAC, CodecG711U, CodecG711A, CodecOpus};
|
||||
GET_CONFIG_FUNC(vector<CodecId>, s_preferred_codec, RTC::kPreferredCodecA, toCodecArray);
|
||||
CHECK(!s_preferred_codec.empty(), "rtc音频偏好codec不能为空");
|
||||
preferred_codec = s_preferred_codec;
|
||||
|
||||
rtcp_fb = {SdpConst::kTWCCRtcpFb, SdpConst::kRembRtcpFb};
|
||||
extmap = {
|
||||
{RtpExtType::ssrc_audio_level, RtpDirection::sendrecv},
|
||||
@ -1401,7 +1426,10 @@ void RtcConfigure::RtcTrackConfigure::setDefaultSetting(TrackType type){
|
||||
}
|
||||
case TrackVideo: {
|
||||
//此处调整偏好的编码格式优先级
|
||||
preferred_codec = {CodecH264, CodecH265, CodecAV1};
|
||||
GET_CONFIG_FUNC(vector<CodecId>, s_preferred_codec, RTC::kPreferredCodecV, toCodecArray);
|
||||
CHECK(!s_preferred_codec.empty(), "rtc视频偏好codec不能为空");
|
||||
preferred_codec = s_preferred_codec;
|
||||
|
||||
rtcp_fb = {SdpConst::kTWCCRtcpFb, SdpConst::kRembRtcpFb, "nack", "ccm fir", "nack pli"};
|
||||
extmap = {
|
||||
{RtpExtType::abs_send_time, RtpDirection::sendrecv},
|
||||
|
Loading…
Reference in New Issue
Block a user