当前位置:网站首页>基于Webrtc和Janus的多人视频会议系统开发7 - publish和subscribe声音设备冲突导致对方听不到声音
基于Webrtc和Janus的多人视频会议系统开发7 - publish和subscribe声音设备冲突导致对方听不到声音
2022-08-04 05:32:00 【睏哥RTC】
这里说下C++原生SDK开发过程遇到一个比较大的坑:在只有publish时,对方(WEB)拉流是可以听到我方的声音的,但是增加了subscribe对方的流后,对方就听不到我方的声音了,这个问题查了比较久,专门写出来供大家参考避坑。
问题产生的原因在于:windows音频部分默认内部开启了AEC功能,但必须要求先初始化Playout再初始化Record.由于目前推流是不需要初始化Playout,导致的Record无法初始化通过。
解决的方法:目前采用的方式是"篡改" sdp 把Playout初始化
void RtcConnection::onJanusPeerSdp(std::string sdptype, std::string sdp)
{
webrtc::SdpParseError error;
rtc::Optional<SdpType> type_maybe = webrtc::SdpTypeFromString(sdptype);
if (!type_maybe) {
RTC_LOG(LS_ERROR) << "Unknown SDP type: " << sdptype;
return;
}
SdpType type = *type_maybe;
if (is_myself()) {
//TODO windows音频部分默认内部开启了AEC功能,但必须要求先初始化Playout再初始化Record.由于目前推流是不需要初始化Playout
//导致的Record无法初始化通过,目前采用的方式是"篡改" sdp 把Playout初始化。
blog(emLOG_INFO," %s is_myself() ==true ",__func__);
webrtc::JsepSessionDescription jdesc(type);
webrtc::SdpDeserialize(sdp, &jdesc, NULL);
auto audio_desc = (jdesc.description())->GetContentByName("audio")->media_description();
audio_desc->as_audio()->set_direction(webrtc::RtpTransceiverDirection::kSendRecv);
cricket::StreamParams stream_;
stream_.add_ssrc(0x12345678);
stream_.cname = rtc::CreateRandomString(8);
std::vector<std::string> vec_;
vec_.push_back("local_fake_audio");
stream_.set_stream_ids(vec_);
stream_.id = "local_fake_stream";
audio_desc->as_audio()->AddStream(stream_);
jdesc.ToString(&sdp);
}
if (!InitializePeerConnection())
{
///onError callback
return;
}
std::unique_ptr<webrtc::SessionDescriptionInterface> session_description = webrtc::CreateSessionDescription(type, sdp, &error);
if (!session_description) {
blog(emLOG_WARNING, "%s Can't parse received session description message. SdpParseError was: %s",__func__ ,error.description.c_str() );
return;
}
peer_connection_->SetRemoteDescription(DummySetSessionDescriptionObserver::Create(), session_description.release());
if (type == SdpType::kOffer) {
peer_connection_->CreateAnswer(this, NULL);
}
}
到这篇文章,webrtc的基础入门Janus原生c++ SDK开发就结束了,后面是如何一步步改造,把整个系统的优化改进,做成一个可实用的实时会议系统。
边栏推荐
- Object. RequireNonNull method
- The usefulness of bind() system call
- LeetCode_Nov_5th_Week
- IEEE802.X协议族
- arm-2-基础阶段
- Introduction to Convolutional Neural Networks
- MySQL批量修改时间字段
- LeetCode_Nov_4th_Week
- [Copy Siege Lion Log] Flying Pulp Academy Intensive Learning 7-Day Punch Camp-Study Notes
- The Unity of ML - agents interpret parameter Settings
猜你喜欢
随机推荐
MVC custom configuration
Copy Siege Lion 5-minute online experience MindIR format model generation
Install Minikube Cluster in AWS-EC2
LeetCode_Dec_3rd_Week
MySQL批量修改时间字段
AWS uses EC2 to reduce the training cost of DeepRacer: DeepRacer-for-cloud practical operation
C语言结构体(必须掌握版)
C语言静态变量static的分析
Fabric v1.1 环境搭建
LeetCode_Dec_1st_Week
The Unity of ML - agents interpret parameter Settings
第三章 标准单元库(上)
Implementation of CAS lock-free queue
tmux概念和使用
FAREWARE ADDRESS
A code example of the PCL method in the domain of DG (Domain Generalization)
How to grow into a senior engineer?
[English learning][sentence] good sentence
结构体内存对齐-C语言
Deep Learning Theory - Overfitting, Underfitting, Regularization, Optimizers