Finally fixed the mythtv / Gstreamer issue and playback from Myth is now smooth :) :) :)

Further updates to menu theme code
Found regression in roll_menu - still unfixed
This commit is contained in:
noisymime 2008-01-03 12:26:38 +00:00
parent 718e142557
commit 591b9c201e
7 changed files with 95 additions and 94 deletions

View File

@ -50,9 +50,9 @@ class GlossMgr:
def transition_fade_zoom(self, fromMenu, toMenu):
oldGroup = fromMenu.getItemGroup()
oldMenuGroup = fromMenu.getMenuGroup()
oldMenuGroup = fromMenu #.getMenuGroup()
newGroup = toMenu.getItemGroup()
newMenuGroup = toMenu.getMenuGroup()
newMenuGroup = toMenu #.getMenuGroup()
oldGroup.set_opacity(255)
@ -179,23 +179,16 @@ class GlossMgr:
class MenuSelector(clutter.Texture):
x_offset = -50
width = 400
def __init__ (self, menuMgr):
def __init__ (self, glossMgr):
clutter.Texture.__init__ (self)
self.menuMgr = menuMgr
pixbuf = gtk.gdk.pixbuf_new_from_file("ui/active_bar.png")
self.set_pixbuf(pixbuf)
self.set_width(self.width)
#pixbuf = gtk.gdk.pixbuf_new_from_file("ui/spinner1.gif")
#self.spinner = clutter.Texture()
#self.spinner.set_pixbuf(pixbuf)
#self.spinner.hide()
def selectItem(self, selectee, timeline):
self.glossMgr = glossMgr
glossMgr.themeMgr.get_texture("selector_bar", glossMgr.stage, self)
self.set_position(0, self.get_y())
self.x_offset = int(glossMgr.themeMgr.get_value("texture", "selector_bar", "position.x"))
#This is a utility function that gets the coordinates of an that has been scaled
def get_true_abs_position(self, selectee):
#This whole clone label thing is a HORRIBLE hack but is there to compensate for the movement caused by scaling using GRAVITY_WEST
#Essentially a clone of the selectee is made and scaled to its final position to retrieve the final abs_position coords
cloneLabel = clutter.Label()
@ -204,14 +197,20 @@ class MenuSelector(clutter.Texture):
(scale_x, scale_y) = selectee.get_scale()
cloneLabel.set_scale_with_gravity(scale_x, scale_y, clutter.GRAVITY_WEST)
selectee.get_parent().add(cloneLabel)
cloneLabel.set_position(selectee.get_x(), selectee.get_y())
#Now that all the cloning is done, find out what the scale is to become and set it on the clone
scale = selectee.currentZoom
cloneLabel.set_scale_with_gravity(scale, scale, clutter.GRAVITY_WEST)
return cloneLabel.get_abs_position()
def selectItem(self, selectee, timeline):
#Now get the end position of the clone
(x, y) = cloneLabel.get_abs_position()
(x, y) = self.get_true_abs_position(selectee)
#Do some minor adjustments for centering etc
x = x + self.x_offset
@ -274,8 +273,6 @@ class MenuSelector(clutter.Texture):
def get_x_offset(self):
return self.x_offset
def get_width(self):
return self.width
class message():
font = "Lucida Grande "

59
Menu.py
View File

@ -6,7 +6,6 @@ import time
from ReflectionTexture import Texture_Reflection
class Menu(clutter.Group):
item_gap = 10 #Distance between items
font = ""
zoomLevel = 0.5
opacityStep = 120
@ -15,6 +14,7 @@ class Menu(clutter.Group):
clutter.Group.__init__(self)
self.glossMgr = glossMgr
self.stage = self.glossMgr.get_stage()
self.itemGroup = clutter.Group()
self.glossMgr.themeMgr.setup_menu("main", self)
self.menuItems = []
@ -23,33 +23,35 @@ class Menu(clutter.Group):
self.moveQueue = 0
self.displaySize = self.displayMax - self.displayMin
self.displayPosition = (0, 0)
self.itemGroup = clutter.Group()
#self.menuGroup = clutter.Group()
self.stage.add(self.itemGroup)
#self.stage.add(self.menuGroup)
#self.hasTimeline = False
self.timeline = clutter.Timeline(15, 75) #This timeline is used on any movements that occur when changing items
self.timeline_completed=True
self.glossMgr.addMenu(self)
#self.itemGroup.hide_all()
self.stage.add(self)
def addItem(self, itemLabel, imagePath):
if len(self.menuItems) == 0:
label_height = 0
tempLabel = clutter.Label()
tempLabel.set_font_name(self.font)
tempLabel.set_text("S")
#tempLabel.set_scale_with_gravity(self.zoomStep0, self.zoomStep0, clutter.GRAVITY_WEST)
self.label_height = tempLabel.get_height()
#self.label_height = self.label_height * self.zoomStep1
label_width = 0
else:
(label_width, label_height) = self.menuItems[0].get_size()
label_y = label_height * len(self.menuItems)+self.item_gap
#else:
# (label_width, label_height) = self.menuItems[0].get_size()
label_y = len(self.menuItems) * (self.label_height + self.item_gap)
print "Label height: " + str(self.label_height)
newItem = ListItem(self, itemLabel, label_y, imagePath)
self.menuItems.append(newItem)
self.itemGroup.add(newItem)
group_x = self.itemGroup.get_x()
group_y = self.itemGroup.get_y() - (label_height)
self.itemGroup.set_position(group_x, group_y)
#group_x = self.itemGroup.get_x()
#group_y = self.itemGroup.get_y() - (self.label_height)
#self.itemGroup.set_position(group_x, group_y)
return newItem
@ -71,17 +73,17 @@ class Menu(clutter.Group):
return self.glossMgr
def setMenuPositionByName(self, location):
return None
if location == "center":
menu_y = (self.stage.get_height()-self.itemGroup.get_height())/2
menu_x = (self.stage.get_width()-self.itemGroup.get_width())/2
self.itemGroup.set_position(menu_x, menu_y)
self.displayPosition = (menu_x, menu_y)
#print "Original Group size: " + str(self.itemGroup.get_width())
#print "Starting at : " + str(menu_x) + ":" + str(menu_y)
#The display position is the x, y coords of where the menu is when it is active
def get_display_position(self):
return self.displayPosition
return (self.itemGroup.get_x(), self.itemGroup.get_y())
def setMenuPosition(self, x, y):
self.itemGroup.set_position(x,y)
@ -89,9 +91,6 @@ class Menu(clutter.Group):
def getItemGroup(self):
return self.itemGroup
def getMenuGroup(self):
return self.menuGroup
def setListFont(self, newFont):
currentY= 0 #self.itemGroup.get_y()
self.font = newFont
@ -228,26 +227,28 @@ class Menu(clutter.Group):
def rollMenu(self, incomingMenuItem, outgoingMenuItem, timeline):
(group_x, group_y) = self.itemGroup.get_abs_position()
(bar_x, bar_y) = self.glossMgr.get_selector_bar().get_abs_position() # incomingMenuItem.get_menu().getMenuMgr().
(incoming_x, incoming_y) = incomingMenuItem.get_abs_position()
(incoming_x, incoming_y) = self.glossMgr.get_selector_bar().get_true_abs_position(incomingMenuItem) #incomingMenuItem.get_abs_position()
#print self.itemGroup.get_abs_position()
#print "Starting group position: " + self.itemGroup.get_abs_position()
if incoming_y > bar_y:
#Then the incoming item is below the selector bar
gap = (incoming_y - bar_y - (self.item_gap/2)) * -1
height_diff = int(self.glossMgr.get_selector_bar().get_height() - self.glossMgr.get_selector_bar().get_height())
print "height diff: " + str(height_diff)
gap = (incoming_y - bar_y) * -1 #- (self.item_gap/2)) * -1
#gap = -65
self.displayMin = self.displayMin+1
self.displayMax = self.displayMax+1
else:
#Then the incoming item is above the selector bar
gap = bar_y - incoming_y + (self.item_gap/2)
gap = bar_y - incoming_y# + (self.item_gap/2)
#gap = 65
self.displayMin = self.displayMin-1
self.displayMax = self.displayMax-1
#print "Gap: " + str(gap)
new_y = (group_y+gap)
new_y = (group_y + gap)
knots = (\
(group_x, group_y),\
(group_x, new_y )\
@ -320,21 +321,21 @@ class ListItem (clutter.Label):
self.onStage = True
#self.itemTexturesGroup.show_all()
if level==1:
zoomTo = self.zoomLevel * self.menu.zoomStep1
zoomTo = self.menu.zoomStep1
opacityTo = self.menu.opacityStep1
if self.onStage:
self.menu.remove(self.itemTexturesGroup)
self.onStage = False
#self.itemTexturesGroup.hide_all()
if level==2:
zoomTo = self.zoomLevel * self.menu.zoomStep2
zoomTo = self.menu.zoomStep2
opacityTo = self.menu.opacityStep2
if self.onStage:
self.menu.remove(self.itemTexturesGroup)
self.onStage = False
#self.itemTexturesGroup.hide_all()
if zoomTo == self.currentZoom:
if (zoomTo == self.currentZoom) and (opacityTo == self.currentOpacity):
return None
alpha = clutter.Alpha(timeline, clutter.ramp_inc_func)
@ -342,9 +343,13 @@ class ListItem (clutter.Label):
self.behaviour2 = clutter.BehaviourOpacity(alpha, self.currentOpacity, opacityTo)
self.behaviour1.apply(self)
self.behaviour2.apply(self)
#timeline.connect('completed', self.scale_end_event, zoomTo, opacityTo)
self.currentZoom = zoomTo
self.currentOpacity = opacityTo
def scale_end_event(self, data, zoomTo, opacityTo):
pass
def get_zoom_level(self):
return self.zoomLevel

View File

@ -52,24 +52,24 @@ class VideoController:
#Now we can start the video
self.video_texture.set_playing(True)
#self.bin.set_state(gst.STATE_PAUSED)
#self.bin.set_state(gst.STATE_PLAYING)
self.bin.set_state(gst.STATE_PLAYING)
self.isPlaying = True
decodebin = self.bin.get_by_name("decodebin0")
#decodebin = self.bin.get_by_name("decodebin0")
#for element in decodebin.elements():
# print "GST Element 1: " + str(element.get_name())
#queue = decodebin.get_by_name("queue0")
#print queue.get_name()
#ypefind = decodebin.get_by_name("typefind")
decodebin.connect("pad-added", self.on_pad_added)
#decodebin.connect("pad-added", self.on_pad_added)
#vid = demuxer.get_by_name("video_00")
self.queue1 = gst.element_factory_make("queue", "queue1")
self.queue1.set_property("max-size-time", 50000)
self.queue1.set_property("max-size-buffers", 0)
#self.queue1 = gst.element_factory_make("queue", "queue1")
#self.queue1.set_property("max-size-time", 50000)
#self.queue1.set_property("max-size-buffers", 0)
#self.queue2 = gst.element_factory_make("queue", "queue2")
self.bin.add(self.queue1)
#self.bin.add(self.queue1)
#self.bin.add(self.queue2)
#decodebin.link(self.queue1)
#self.queue1.link(decodebin)

View File

@ -174,22 +174,9 @@ class MythBackendConnection(threading.Thread):
max_request_size = 270000
request_size_step = 16384
#Need to create a bit of a buffer so playback will begin
"""
x=0
while x<80:
transfer_cmd = "QUERY_FILETRANSFER "+ str(socket_id) + "[]:[]REQUEST_BLOCK[]:[]"+str(request_size)
self.send_cmd(cmd_sock, transfer_cmd)
num_bytes = int(self.receive_reply(cmd_sock))
data = data_sock.recv(num_bytes)
self.buffer_file.write(data)
x=x+1
self.buffer_file.flush()
"""
#self.videoPlayer.begin_playback(buffer_file_name)
reader_fd = os.dup(data_sock.fileno())
self.videoPlayer.begin_playback(reader_fd)
#Data is sent through a pipe to GStreamer
(pipe_rfd, pipe_wfd) = os.pipe()
self.videoPlayer.begin_playback(pipe_rfd)
print "BEGINNING PLAYBACK!"
self.Playing = True
@ -197,12 +184,11 @@ class MythBackendConnection(threading.Thread):
transfer_cmd = "QUERY_FILETRANSFER "+ str(socket_id) + "[]:[]REQUEST_BLOCK[]:[]"+str(request_size)
self.send_cmd(cmd_sock, transfer_cmd)
num_bytes = int(self.receive_reply(cmd_sock))
data_sock.recv(num_bytes)
#self.buffer_file.write(data)
#self.buffer_file.flush()
data = data_sock.recv(num_bytes)
os.write(pipe_wfd, data)
#This tries to optimise the request size
#print "Received: " + str(num_bytes)
if (num_bytes == request_size) and (request_size < max_request_size):
request_size = request_size + request_size_step
if request_size > max_request_size:
@ -212,7 +198,8 @@ class MythBackendConnection(threading.Thread):
print "Ending playback"
#self.buffer_file.close()
os.close(pipe_wfd)
os.close(pipe_rfd)
def message_socket_mgr(self, msg_socket):
#Do the protocol version check

View File

@ -180,7 +180,7 @@ class Module():
return
#Create a backdrop for the player. In this case we just use the same background as the menus
self.backdrop = glossMgr.get_themeMgr().get_texture("background", None) #clutter.CloneTexture(glossMgr.get_skinMgr().get_Background())
self.backdrop = glossMgr.get_themeMgr().get_texture("background", None, None) #clutter.CloneTexture(glossMgr.get_skinMgr().get_Background())
self.backdrop.set_size(self.stage.get_width(), self.stage.get_height())
self.backdrop.set_opacity(0)
self.backdrop.show()

View File

@ -129,6 +129,14 @@ class ThemeMgr:
#This is the generic function for setting up an actor.
#It sets up all the 'common' properties:
#Currently: size, position, opacity
def get_value(self, type, name, property):
element = self.search_docs(type, name).childNodes
#Quick check to make sure we found something
if element is None:
return None
return self.find_child_value(element, property)
def setup_actor(self, actor, element, parent):
#Set the size
#First setup the parent
@ -148,14 +156,15 @@ class ThemeMgr:
width = (float(width[:-1]) / 100.0) * parent.get_width()
#print "width: " + str(width)
width = int(width)
width = int(width)
height = self.find_child_value(element, "dimensions.height")
if (not height == "default") and (not height is None):
if height[-1] == "%":
height = (float(height[:-1]) / 100.0) * parent.get_height()
height = int(height)
height = int(height)
actor.set_size(width, height)
if (not width is None) and (not width == "default"): actor.set_width(width)
if (not height is None) and (not height == "default"): actor.set_height(height)
#Set the position of the actor
(x,y) = (0,0)
@ -284,4 +293,7 @@ class ThemeMgr:
menu.zoomStep2 = float(self.find_child_value(element, "scale_step2"))
menu.opacityStep0 = int(self.find_child_value(element, "opacity_step0"))
menu.opacityStep1 = int(self.find_child_value(element, "opacity_step1"))
menu.opacityStep2 = int(self.find_child_value(element, "opacity_step2"))
menu.opacityStep2 = int(self.find_child_value(element, "opacity_step2"))
#Finally set general actor properties (position etc)
self.setup_actor(menu.getItemGroup(), element, self.stage)

View File

@ -8,7 +8,16 @@
<size id="800x600">30</size>
</font>
<item_gap>10</item_gap>
<dimensions type="relativeToStage">
<width>40%</width>
<height>40%</height>
</dimensions>
<position type="relativeToStage">
<x>60%</x>
<y>30%</y>
</position>
<item_gap>0</item_gap>
<num_visible_elements>6</num_visible_elements>
<!-- These are the opacity and scale values for the 3 possible steps in the menu
@ -17,19 +26,10 @@
<opacity_step1>135</opacity_step1>
<opacity_step2>50</opacity_step2>
<scale_step0>1</scale_step0>
<scale_step1>0.85</scale_step1>
<scale_step2>0.75</scale_step2>
<scale_step1>0.5</scale_step1>
<scale_step2>0.4</scale_step2>
</menu>
<font id="main">
<face>Tahoma</face>
<size id="default">40</size>
<size id="1024x768">40</size>
<size id="800x600">30</size>
</font>
<texture id="background">
<image>background.png</image>
@ -46,11 +46,11 @@
<texture id="selector_bar">
<image>active_bar.png</image>
<dimensions type="relativeToStage">
<width>40</width>
<width>40%</width>
<height>default</height>
</dimensions>
<position type="relativeToParent">
<x>50</x>
<x>-50</x>
<y>0</y>
</position>
</texture>