Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/154.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 在webrtc对等连接中创建UDP套接字失败_C++_Webrtc_Libjingle_Peer Connection - Fatal编程技术网

C++ 在webrtc对等连接中创建UDP套接字失败

C++ 在webrtc对等连接中创建UDP套接字失败,c++,webrtc,libjingle,peer-connection,C++,Webrtc,Libjingle,Peer Connection,我正在处理webrtc PeerConnection,我发现UDP套接字创建失败 下面介绍了调用CreatePeerConnection方法的代码段。 我使用了我自己的stun和turn服务器,并在给定的代码中提到了它们的ip和端口,我也尝试过使用google stun服务器地址和端口(stun:stun.l.google.com:19302),但遇到了同样的问题 webrtc::PeerConnectionInterface::IceServers ice_servers; webrtc::P

我正在处理webrtc PeerConnection,我发现UDP套接字创建失败 下面介绍了调用CreatePeerConnection方法的代码段。 我使用了我自己的stun和turn服务器,并在给定的代码中提到了它们的ip和端口,我也尝试过使用google stun服务器地址和端口(
stun:stun.l.google.com:19302
),但遇到了同样的问题

webrtc::PeerConnectionInterface::IceServers ice_servers;
webrtc::PeerConnectionInterface::IceServer ice_server;
webrtc::PeerConnectionInterface::RTCConfiguration config;
ice_server.uri = "stun:address_stun:port_stun";
config.servers.push_back(ice_server);

webrtc::PeerConnectionInterface::IceServer turn_server;
std::string url = "turn:address_turn:port_turn?transport=udp";

turn_server.urls.push_back(url);
turn_server.username = "username";
turn_server.password = "password";
config.servers.push_back(turn_server);

webrtc::FakeConstraints constraints;
constraints.AddOptional(webrtc::MediaConstraintsInterface::kEnableDtlsSrtp, "true");

config.candidate_network_policy = webrtc::PeerConnectionInterface::kCandidateNetworkPolicyLowCost;
config.tcp_candidate_policy = webrtc::PeerConnectionInterface::kTcpCandidatePolicyDisabled;

constraints.AddOptional(webrtc::MediaConstraintsInterface::kEnableDtlsSrtp,
                   webrtc::MediaConstraintsInterface::kValueFalse);
constraints.AddMandatory(webrtc::MediaConstraintsInterface::kOfferToReceiveAudio,
                    webrtc::MediaConstraintsInterface::kValueTrue);


rtc::ThreadManager::Instance()->WrapCurrentThread();

u_worker_thread = rtc::Thread::Create();
u_worker_thread->SetName("worker_thread", NULL);
RTC_CHECK(u_worker_thread->Start()) << "Failed to start thread";

u_signaling_thread = rtc::Thread::Create();
u_signaling_thread->SetName("signaling_thread", NULL);
RTC_CHECK(u_signaling_thread->Start()) << "Failed to start thread";


m_networkThread = rtc::Thread::Create();
m_networkThread->SetName("networking_thread", NULL);
RTC_CHECK(m_networkThread->Start()) << "Failed to start thread";


cricket::WebRtcVideoEncoderFactory* video_encoder_factory = nullptr;
cricket::WebRtcVideoDecoderFactory* video_decoder_factory = nullptr;
auto audio_encoder_factory = webrtc::CreateBuiltinAudioEncoderFactory();
auto audio_decoder_factory = webrtc::CreateBuiltinAudioDecoderFactory();


webrtc::AudioDeviceModule* adm = nullptr;

fake_network_manager_.reset(new rtc::FakeNetworkManager());
static const SocketAddress kDefaultLocalAddress("local_ip", 0);
fake_network_manager_->AddInterface(kDefaultLocalAddress);
std::unique_ptr<cricket::PortAllocator> port_allocator_(new cricket::BasicPortAllocator(fake_network_manager_.get()));

_peerConnectionFactory = webrtc::CreatePeerConnectionFactory(m_networkThread.get(),u_worker_thread.get(),u_signaling_thread.get(),adm,audio_encoder_factory,audio_decoder_factory,video_encoder_factory,video_decoder_factory); 

if (!_peerConnectionFactory.get()) {

}
else
{
    __android_log_print(ANDROID_LOG_INFO, TAG,"Going to initialise CreatePeerConnection" );
    _peerConnection = _peerConnectionFactory->CreatePeerConnection(
                        config, &constraints, std::move(port_allocator_), NULL, this);

}
webrtc::PeerConnectionInterface::IceServers ice\u服务器;
webrtc::PeerConnectionInterface::IceServer ice_服务器;
webrtc::PeerConnectionInterface::RTC配置;
ice\u server.uri=“stun:address\u stun:port\u stun”;
config.servers.push_back(ice_服务器);
webrtc::PeerConnectionInterface::IceServer turn\u服务器;
std::string url=“turn:address\u turn:port\u turn?transport=udp”;
打开服务器.url.push-back(url);
打开\u server.username=“username”;
打开\u server.password=“password”;
config.servers.push_back(打开_服务器);
webrtc::伪造约束;
AddOptional(webrtc::MediaConstraintsInterface::kEnableDtlsSrtp,“true”);
config.candidate\u network\u policy=webrtc::PeerConnectionInterface::kCandidateNetworkPolicyLowCost;
config.tcp_candidate_policy=webrtc::PeerConnectionInterface::kTcpCandidatePolicyDisabled;
constraints.AddOptional(webrtc::MediaConstraintsInterface::kEnableDtlsSrtp、,
webrtc::MediaConstraintInterface::kValueFalse);
constraints.add强制(webrtc::MediaConstraintsInterface::kOfferToReceiveAudio,
webrtc::MediaConstraintInterface::kValueTrue);
rtc::ThreadManager::Instance()->WrapCurrentThread();
u_worker_thread=rtc::thread::Create();
工作线程->设置名称(“工作线程”,NULL);
RTC_CHECK(u_worker_thread->Start())SetName(“signaling_thread”,NULL);
RTC_检查(u_信令_线程->开始())SetName(“网络_线程”,NULL);
RTC_CHECK(m_networkThread->Start())AddInterface(kDefaultLocalAddress);
std::unique_ptr port_分配器(新的cricket::BasicPortAllocator(伪网络管理器_u.get());
_peerConnectionFactory=webrtc::CreatePeerConnectionFactory(m_networkThread.get()、u_worker_thread.get()、u_信令_thread.get()、adm、音频编码器工厂、音频解码器工厂、视频编码器工厂、视频解码器工厂);
if(!\u peerConnectionFactory.get()){
}
其他的
{
__android_log_print(android_log_信息,标签,“将初始化CreatePeerConnection”);
_peerConnection=\u peerConnectionFactory->CreatePeerConnection(
配置和约束,std::move(端口分配器),NULL,this);
}

我也面临同样的问题