Add pixel factor in the server so that clients ca push more effective pixels
This commit is contained in:
parent
d81f12480a
commit
9b6190b186
2 changed files with 37 additions and 4 deletions
23
protocol.md
Normal file
23
protocol.md
Normal file
|
|
@ -0,0 +1,23 @@
|
||||||
|
# The protocol for the UDP pixelvloed client and server (v1)
|
||||||
|
|
||||||
|
Pixelvloed allows clients to send up to a configurable amount of pixels per message.
|
||||||
|
Each message should contain the RGB or RGBA mode indentifier, and the version bit.
|
||||||
|
Each pixel in the message is a set of (x,y,r,g,b) or (x,y,r,g,b,a)
|
||||||
|
X and Y are the positions on screen, and should be unsigned shorts
|
||||||
|
rgb and a are unsigned chars
|
||||||
|
|
||||||
|
All values should be little endian.
|
||||||
|
|
||||||
|
Mixing rgb and rgba pixels in one message is not supported.
|
||||||
|
|
||||||
|
# The Autodetection system
|
||||||
|
|
||||||
|
A pixelvloed server should broadcast a package advertising its settings with the following string content
|
||||||
|
|
||||||
|
"%s:%f %s:%d %d*%d" % (PROTOCOL_PREAMBLE, PROTOCOL_VERSION, UDP_IP, UDP_PORT, width, height)
|
||||||
|
|
||||||
|
A client should listen for these packages, split it on spaces and check the preample and protocol_version to see if it is capable of speaking the requested protocol.
|
||||||
|
|
||||||
|
An example of a broadcasted packet would be:
|
||||||
|
|
||||||
|
pixelvloed:1.00 192.168.0.1:5005 1920*1080
|
||||||
18
vloed.py
18
vloed.py
|
|
@ -40,6 +40,7 @@ class Canvas(object):
|
||||||
self.screen = None
|
self.screen = None
|
||||||
self.udp_ip = UDP_IP
|
self.udp_ip = UDP_IP
|
||||||
self.udp_port = UDP_PORT
|
self.udp_port = UDP_PORT
|
||||||
|
self.factor = options.factor if options.factor else 1
|
||||||
self.width = options.width if options.width else DEFAULT_WIDTH
|
self.width = options.width if options.width else DEFAULT_WIDTH
|
||||||
self.height = options.height if options.height else DEFAULT_HEIGHT
|
self.height = options.height if options.height else DEFAULT_HEIGHT
|
||||||
self.canvas()
|
self.canvas()
|
||||||
|
|
@ -74,7 +75,13 @@ class Canvas(object):
|
||||||
"""Print a pixel to the screen"""
|
"""Print a pixel to the screen"""
|
||||||
try:
|
try:
|
||||||
if a == 255:
|
if a == 255:
|
||||||
self.pixels[x][y] = (r*256*256) + (g*256) + b
|
color = (r*256*256) + (g*256) + b
|
||||||
|
if self.factor>1:
|
||||||
|
for w in xrange(0, self.factor):
|
||||||
|
for h in xrange(0, self.factor):
|
||||||
|
self.pixels[(x*self.factor) + w][(y*self.factor) + h] = color
|
||||||
|
else:
|
||||||
|
self.pixels[x][y] = color
|
||||||
else:
|
else:
|
||||||
old = self.pixels[x][y]
|
old = self.pixels[x][y]
|
||||||
oldr = old >> 16
|
oldr = old >> 16
|
||||||
|
|
@ -148,9 +155,10 @@ class Canvas(object):
|
||||||
"""Lets send out our ip/port/resolution to any listening clients"""
|
"""Lets send out our ip/port/resolution to any listening clients"""
|
||||||
try:
|
try:
|
||||||
self.broadcastsocket.sendto(
|
self.broadcastsocket.sendto(
|
||||||
'%s:%f %s:%d %d*%d' % (PROTOCOL_PREAMBLE, PROTOCOL_VERSION,
|
'%s:%f %s:%d %d*%d' % (
|
||||||
UDP_IP, UDP_PORT,
|
PROTOCOL_PREAMBLE, PROTOCOL_VERSION,
|
||||||
self.width, self.height),
|
UDP_IP, UDP_PORT,
|
||||||
|
self.width/self.factor, self.height/self.factor),
|
||||||
('<broadcast>', DISCOVER_PORT))
|
('<broadcast>', DISCOVER_PORT))
|
||||||
if self.debug:
|
if self.debug:
|
||||||
print 'sending discovery packet'
|
print 'sending discovery packet'
|
||||||
|
|
@ -324,5 +332,7 @@ if __name__ == '__main__':
|
||||||
type="int")
|
type="int")
|
||||||
parser.add_option('-m', action="store", dest="maxpixels", default=MAX_PIXELS,
|
parser.add_option('-m', action="store", dest="maxpixels", default=MAX_PIXELS,
|
||||||
type="int")
|
type="int")
|
||||||
|
parser.add_option('-f', action="store", dest="factor", default=1,
|
||||||
|
type="int")
|
||||||
options, remainder = parser.parse_args()
|
options, remainder = parser.parse_args()
|
||||||
RunServer(options)
|
RunServer(options)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue