Browse Source

implements IceCtroller **Texture methods

Natenom/support-murmur-13-1446181288462
withgod 15 years ago
parent
commit
7a2e4c9866
  1. 38
      pyweb/mumble/MumbleCtlIce.py
  2. 7
      pyweb/mumble/mctl.py
  3. 4
      pyweb/settings.py

38
pyweb/mumble/MumbleCtlIce.py

@ -164,11 +164,41 @@ class MumbleCtlIce(MumbleCtlBase):
self._getIceServerObject(srvid).setACL(id, acls, groups, inherit)
def getTexture(self, srvid, mumbleid):
print self._getIceServerObject(srvid).getTexture(mumbleid)
#return Image.fromstring( "RGBA", ( 600, 60 ), self._getIceServerObject(srvid).getTexture(mumbleid));
texture = self._getIceServerObject(srvid).getTexture(mumbleid)
if len(texture) == 0:
raise ValueError( "No Texture has been set." );
# this returns a list of bytes.
decompressed = decompress( texture );
# iterate over 4 byte chunks of the string
imgdata = "";
for idx in range( 0, len(decompressed), 4 ):
# read 4 bytes = BGRA and convert to RGBA
# manual wrote getTexture returns "Textures are stored as zlib compress()ed 600x60 32-bit RGBA data."
# http://mumble.sourceforge.net/slice/Murmur/Server.html#getTexture
# but return values BGRA X(
bgra = unpack( "4B", decompressed[idx:idx+4] );
imgdata += pack( "4B", bgra[2], bgra[1], bgra[0], bgra[3] );
# return an 600x60 RGBA image object created from the data
return Image.fromstring( "RGBA", ( 600, 60 ), imgdata);
def setTexture(self, srvid, mumbleid, infile):
# open image, convert to RGBA, and resize to 600x60
img = Image.open( infile ).convert( "RGBA" ).transform( ( 600, 60 ), Image.EXTENT, ( 0, 0, 600, 60 ) );
# iterate over the list and pack everything into a string
bgrastring = "";
for ent in list( img.getdata() ):
# ent is in RGBA format, but Murmur wants BGRA (ARGB inverse), so stuff needs
# to be reordered when passed to pack()
bgrastring += pack( "4B", ent[2], ent[1], ent[0], ent[3] );
# compress using zlib
compressed = compress( bgrastring );
# pack the original length in 4 byte big endian, and concat the compressed
# data to it to emulate qCompress().
texture = pack( ">L", len(bgrastring) ) + compressed;
# finally call murmur and set the texture
self._getIceServerObject(srvid).setTexture(mumbleid, texture)
@staticmethod
def setUnicodeFlag(data):

7
pyweb/mumble/mctl.py

@ -97,7 +97,7 @@ if __name__ == "__main__":
x = int(sys.argv[1])
dbusCtl = MumbleCtlDbus()
iceCtl = MumbleCtlIce()
"""
print "equal test ---"
print "getBootedServers [%s]" % (dbusCtl.getBootedServers() == iceCtl.getBootedServers())
print "getChannels [%s]" % (dbusCtl.getChannels(x) == iceCtl.getChannels(x))
@ -108,6 +108,7 @@ if __name__ == "__main__":
print "getAllConf(x) [%s]" % (dbusCtl.getAllConf(x) == iceCtl.getAllConf(x))
print "getRegisteredPlayers(x) [%s]" % (dbusCtl.getRegisteredPlayers(x) == iceCtl.getRegisteredPlayers(x))
print "getTexture(2, 30) [%s]" % (dbusCtl.getTexture(2, 30) == iceCtl.getTexture(2, 30))
#print iceCtl.getTexture(2, 30).__class__
"""
dbusCtl.getTexture(2, 30).__class__
iceCtl.getTexture(2, 30).__class__
#print dbusCtl.getTexture(2, 30).__class__

4
pyweb/settings.py

@ -56,8 +56,8 @@ if not MUMBLE_DJANGO_ROOT or not exists( MUMBLE_DJANGO_ROOT ):
DEBUG = True
TEMPLATE_DEBUG = DEBUG
#DAOTYPE='ice'
DAOTYPE='dbus'
DAOTYPE='ice'
#DAOTYPE='dbus'
ADMINS = (
# ('Your Name', 'your_email@domain.com'),

Loading…
Cancel
Save