问题
Download and unrar this file in htdocs folder (for example C:/xampp/htdocs/telephone_calls)
Run this ngrok command: ngrok http 192.168.1.24:80 (replace 192.168.1.24 with your lan ip address)
Replace lines 118 and 119 of file manage_calls.py with your own.
cd to telephone_calls directory and run python manage_calls.py
With another device open a browser and go to https://25f4a7e689ce.ngrok.io/telephone_calls/client.html (replace 25f4a7e689ce with your own)
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.
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