Voip Server | Voip Client

Voip Server:

import pyaudio
import socket
import sys

# Atamalar
chunk = 1024
p = pyaudio.PyAudio()

stream = p.open(format = pyaudio.paInt16,
channels = 1,
rate = 10240,
output = True)

# Socket Tanimlamalari
host = ”
port = 50000
backlog = 5
size = 1024
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.bind((host,port))
s.listen(backlog)

client, address = s.accept()

# Ana Fonksiyon
while 1:
data = client.recv(size)
if data:
# ses datasi yaziliyor
stream.write(data) # ses datasi stream a yaziliyor
client.send(‘ACK’) # ACK iletiliyor

client.close()
stream.close()
p.terminate()

Voip Client:

import pyaudio
import socket
import sys
import time

# Atamalar
chunk = 1024
FORMAT = pyaudio.paInt16
CHANNELS = 1
RATE = 10240

p = pyaudio.PyAudio()

stream = p.open(format = FORMAT,
channels = CHANNELS,
rate = RATE,
input = True,
frames_per_buffer = chunk)

# Socket Tanimlamalari
host = ‘localhost’
port = 50000
size = 1024
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((host,port))

# Ana Fonksiyon
while 1:
data = stream.read(chunk)
s.send(data)
s.recv(size)

s.close()
stream.close()
p.terminate()

Bir Cevap Yazın

E-posta hesabınız yayımlanmayacak. Gerekli alanlar * ile işaretlenmişlerdir

Şu HTML etiketlerini ve özelliklerini kullanabilirsiniz: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>