| 183 | } |
| 184 | |
| 185 | int CChannelIce::CreateDataChannel(bool bDataChannel) |
| 186 | { |
| 187 | m_peerConnection = std::make_shared<rtc::PeerConnection>(m_Config); |
| 188 | if(!m_peerConnection) |
| 189 | { |
| 190 | qDebug(m_Log) << "Peer connect don't open"; |
| 191 | return -1; |
| 192 | } |
| 193 | m_peerConnection->onStateChange([this](rtc::PeerConnection::State state) { |
| 194 | qDebug(m_Log) << "PeerConnection State:" << (int)state; |
| 195 | }); |
| 196 | m_peerConnection->onGatheringStateChange( |
| 197 | [this](rtc::PeerConnection::GatheringState state) { |
| 198 | Q_UNUSED(state) |
| 199 | qDebug(m_Log) << "Gathering status:" << (int)state; |
| 200 | }); |
| 201 | m_peerConnection->onLocalDescription( |
| 202 | [this](rtc::Description description) { |
| 203 | //qDebug(m_Log) << "The thread id:" << QThread::currentThreadId(); |
| 204 | /* |
| 205 | qDebug(m_Log) << "user:" << GetUser() |
| 206 | << "peer:" << GetPeerUser() |
| 207 | << "channel:" << GetChannelId() |
| 208 | << "onLocalDescription:" |
| 209 | << std::string(description).c_str());//*/ |
| 210 | // Send to the peer through the signal channel |
| 211 | if(m_szPeerUser.isEmpty() || m_szChannelId.isEmpty()) |
| 212 | { |
| 213 | qCritical(m_Log) << "Please set peer user and channel id"; |
| 214 | return; |
| 215 | } |
| 216 | m_pSignal->SendDescription(GetPeerUser(), GetChannelId(), description, GetUser()); |
| 217 | }); |
| 218 | m_peerConnection->onLocalCandidate( |
| 219 | [this](rtc::Candidate candidate){ |
| 220 | //qDebug(m_Log) << "The thread id:" << QThread::currentThreadId(); |
| 221 | /* |
| 222 | qDebug(m_Log) << "user:" << GetUser() |
| 223 | << "peer:" << GetPeerUser() |
| 224 | << "channel:" << GetChannelId() |
| 225 | << "onLocalCandidate:" << std::string(candidate).c_str() |
| 226 | << "mid:" << candidate.mid().c_str();//*/ |
| 227 | // Send to the peer through the signal channel |
| 228 | if(m_szPeerUser.isEmpty() || m_szChannelId.isEmpty()) |
| 229 | { |
| 230 | qDebug(m_Log) << "Please set peer user and channel id"; |
| 231 | return; |
| 232 | } |
| 233 | m_pSignal->SendCandidate(m_szPeerUser, m_szChannelId, candidate); |
| 234 | }); |
| 235 | m_peerConnection->onDataChannel([this](std::shared_ptr<rtc::DataChannel> dc) { |
| 236 | qInfo(m_Log) << "Open data channel:" << dc->label().c_str(); |
| 237 | if(dc->label().c_str() != GetChannelId()) |
| 238 | { |
| 239 | qDebug(m_Log) << "Channel label different:" << GetChannelId() |
| 240 | << dc->label().c_str(); |
| 241 | return; |
| 242 | } |
nothing calls this directly
no test coverage detected