Peer to peer client with peerjs and python user

老子叫甜甜 提交于 2020-12-15 05:44:14

问题


  1. Download and unrar this file in htdocs folder (for example C:/xampp/htdocs/telephone_calls)

  2. Run this ngrok command: ngrok http 192.168.1.24:80 (replace 192.168.1.24 with your lan ip address)

  3. Replace lines 118 and 119 of file manage_calls.py with your own.

  4. cd to telephone_calls directory and run python manage_calls.py

  5. With another device open a browser and go to https://25f4a7e689ce.ngrok.io/telephone_calls/client.html (replace 25f4a7e689ce with your own)

  6. Press the blue button "Τηλεφωνική επικοινωνία". After this action you will hear the ring sound in the computer that you run manage_calls.py file and a button will appear.

  7. If you press Answer call 1 button in the first computer a audio connection will be established between the two pcs.

code in file server.html:

var recorder_1 = new MediaRecorder(remoteStream);
                            
                            recorder_1.ondataavailable = event => {

                                // get the Blob from the event
                                var blob = event.data;
                        
                        
                                blob.arrayBuffer().then(blob_buffer => {
                                    audio_data = new Uint8Array(blob_buffer)
                                    handler.send_call_1_data(audio_data);
                                });
                                
                            };

                            // make data available event fire every ten milliseconds
                            recorder_1.start(200);

code in file manage_calls.py

@pyqtSlot(QVariant,result=QVariant) 
def send_call_1_data(self,Call1BufferArray):
    Call1BufferArray = list(Call1BufferArray)
    #print(Call1BufferArray)
    blob_bytes = b""
    for i in Call1BufferArray:
        blob_bytes = blob_bytes+int(i).to_bytes(8, 'little')
    
    #print(blob_bytes)
    self.call_1_data.setData(blob_bytes)
    if(self.call_1_decoded_start==False):
        self.call_1_decoded_start=True
        self.decoder_1 = QtMultimedia.QAudioDecoder()
        self.decoder_1.bufferReady.connect(self.readBuffer_1)
        self.decoder_1.setAudioFormat(self.desiredFormat)
        self.decoder_1.setSourceDevice(self.call_1_data)    
        #self.decoder_1.start()
    return "ok"

The error is: QBuffer::setData: Buffer is open. I don't know if i have decoded correctly. Can anyone help me please?

来源:https://stackoverflow.com/questions/65099562/peer-to-peer-client-with-peerjs-and-python-user

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!