2015-09-23 24 views
5

Sto implementando una connessione Peer to Peer WebRTC per la chiamata audio utilizzando C++.Collegamento Peer to Peer WebRTC

Ho due fili _worker_thread e _signaling_thread. Ora quando provo a creare _peerConnectionFactory chiamando il metodo webrtc::CreatePeerConnectionFactory(), la mia app si arresta in modo anomalo. Come posso farlo funzionare?

_signaling_thread.reset(new rtc::Thread()); 
if(!_signaling_thread->Start()) 
{ 
    printf("_signaling_thread is Failed"); 
    return; 
} 
_worker_thread.reset(new rtc::Thread()); 
if (!_worker_thread->Start()) { 
    printf("_worker_thread is Failed"); 
    return; 
} 

_peerConnectionFactory = webrtc::CreatePeerConnectionFactory(_worker_thread.get(),_signaling_thread.get(),NULL,NULL,NULL); 

Questa è la backtrace sto ottenendo

* thread #15: tid = 0x17e516, 0x00000001008d5674 MyAPP`rtc::MessageQueue::Get(rtc::Message*, int, bool) + 816, stop reason = EXC_BAD_ACCESS (code=1, address=0x100000038)            
* frame #0: 0x00000001008d5674 MyAPP`rtc::MessageQueue::Get(rtc::Message*, int, bool) + 816 
frame #1: 0x00000001008e5fb0 MyAPP`rtc::Thread::ProcessMessages(int) + 100 
frame #2: 0x00000001008e5e44 MyAPP`rtc::Thread::PreRun(void*) + 88 
frame #3: 0x0000000199337b3c libsystem_pthread.dylib`_pthread_body + 156 
frame #4: 0x0000000199337aa0 libsystem_pthread.dylib`_pthread_start + 1 
+0

Non c'è alcuna domanda nel post, eppure in qualche modo è stato messo in onda 2 volte. Mi chiedo chi ha fatto il upvoting e perché. – SergeyA

+0

@SergeyA Ho bisogno della soluzione per cui non funziona per me, c'è un modo per risolvere questo problema? E cos'altro hai bisogno di sapere per favore fammi sapere. – Aagman

+0

Non è chiaro in che modo il backtrace si riferisce al codice pubblicato. Cosa succede all'offset 816 da 'rtc :: MessageQueue :: Get'? Perché e quando viene chiamata questa funzione? Dalle righe 'pthread', immagino che stia succedendo in uno dei thread in background. Puoi dire quale? –

risposta

1

Dopo aver dato un'occhiata ai campioni PeerConnection situati all'interno del codice sorgente del WebRTC, ho sempre inizializzare i moduli SSL prima di creare i thread come questo:

bool Core::Init() { 
    rtc::InitializeSSL(); 
    rtc::InitRandom(rtc::Time()); 
    rtc::ThreadManager::Instance()->WrapCurrentThread(); 

    _signalingThread = new rtc::Thread(); 
    _workerThread = new rtc::Thread(); 

    _signalingThread->SetName("signaling_thread", NULL); 
    _workerThread->SetName("worker_thread", NULL); 

    if (!_signalingThread->Start() || !_workerThread->Start()) { 
    return false; 
    } 

    _peerConnectionFactory = 
     webrtc::CreatePeerConnectionFactory(_signalingThread, 
              _workerThread, 
              NULL, NULL, NULL).release(); 

    return true; 
} 
+0

Perché si chiama 'release()' su peerConnectionFactory? – Phylliida

Problemi correlati