Skip to content

Commit

Permalink
#5 Implemented the Streamer class
Browse files Browse the repository at this point in the history
Created the Streamer class for the TCP image transfer.
  • Loading branch information
mkristofic committed Dec 30, 2019
1 parent d6d3dc4 commit 2899e9f
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions modules/Streamer.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import socket
from modules.Recorder import Recorder

class Streamer(object):
'''
Sets the socket and the server address and get the camera from the Recorder class.2
Arguments:
host(str) IP address of a server to stream to
port(str) port of a server to stream to
'''
def __init__(self, host, port, camera_num):
self.sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
self.server_address = (host, port)
self.camera = Recorder(camera_num)

'''
Gets a frame from camera and sends it to the server via UDP.
'''
def send_to_server(self):
while True:
frame = self.camera.get_frame()
length = len(frame)
# print("Len: " + str(length))
if(length < 65536):
self.sock.sendto(frame, self.server_address)

0 comments on commit 2899e9f

Please sign in to comment.