Commit 1bf81bcd authored by Edward Hervey's avatar Edward Hervey

* pitivi/bin.py:

Fix up encoding for 0.10.
* pitivi/ui/infolayer.py:
More sensible info in InfoLayer
* pitivi/ui/complextimeline.py:
* pitivi/ui/layerwidgets.py:
* pitivi/ui/mainwindow.py:
* pitivi/ui/ruler.py:
* pitivi/ui/timeline.py:
Display current position in Ruler.
Beautified Ruler.
* pitivi/ui/viewer.py:
Temporary hack to distribute current timeline position.
Re-activate rendering


git-svn-id: svn+ssh://svn.gnome.org/svn/pitivi/trunk@697 d3729300-e425-0410-8a4c-d956edccc248
parent 665cbfc9
2006-02-22 Edward Hervey <edward@fluendo.com>
* pitivi/bin.py:
Fix up encoding for 0.10.
* pitivi/ui/infolayer.py:
More sensible info in InfoLayer
* pitivi/ui/complextimeline.py:
* pitivi/ui/layerwidgets.py:
* pitivi/ui/mainwindow.py:
* pitivi/ui/ruler.py:
* pitivi/ui/timeline.py:
Display current position in Ruler.
Beautified Ruler.
* pitivi/ui/viewer.py:
Temporary hack to distribute current timeline position.
Re-activate rendering
2006-02-21 Edward Hervey <edward@fluendo.com>
* pitivi/ui/complexsource.py:
......
......@@ -215,17 +215,23 @@ class SmartTimelineBin(SmartBin):
def record(self, uri, settings=None):
""" render the timeline to the given uri """
self.encthread = self._make_encthread(settings)
self.set_state(gst.STATE_PAUSED)
self.encthread.filesink.set_uri(uri)
self.add(self.encthread)
self.set_state(gst.STATE_PAUSED)
self.encthread.filesink.set_uri(uri)
# temporarily remove the audiosinkthread
self.tmpasink = self.asinkthread
self.remove_audio_sink_thread()
# set sync=false on the videosink
self.get_real_video_sink().set_property("sync", False)
self.debug("linking vtee to ecnthread:vsink")
self.vtee.get_pad("src%d").link(self.encthread.get_pad("vsink"))
self.debug("linking atee to encthread:asink")
self.atee.get_pad("src%d").link(self.encthread.get_pad("asink"))
self.set_state(gst.STATE_PAUSED)
self.debug("About to seek to beginning for encoding")
if not self.seek(1.0, gst.FORMAT_TIME,
gst.SEEK_FLAG_FLUSH,
gst.SEEK_TYPE_CUR, 0,
......@@ -236,6 +242,7 @@ class SmartTimelineBin(SmartBin):
def stop_recording(self):
""" stop the recording, removing the encoding thread """
self.set_state(gst.STATE_PAUSED)
if self.encthread:
apad = self.encthread.get_pad("vsink")
apad.unlink(apad.get_peer())
......@@ -249,6 +256,14 @@ class SmartTimelineBin(SmartBin):
self.set_audio_sink_thread(self.tmpasink)
self.tmpasink = None
self.get_real_video_sink().set_property("sync", True)
def get_real_video_sink(self):
""" returns the real video sink element or None """
if not self.vsinkthread:
return None
return self.vsinkthread.videosink.realsink
def _make_encthread(self, settings=None):
# TODO : verify if encoders take video/x-raw-yuv and audio/x-raw-int
if not settings:
......
......@@ -158,3 +158,9 @@ class ComplexTimelineWidget(gtk.VBox, ZoomableWidgetInterface):
self.topLayer.zoomChanged()
self.compositionLayers.zoomChanged()
## timeline position callback
def timelinePositionChanged(self, value, frame):
# for the time being we only inform the ruler
self.topLayer.timelinePositionChanged(value, frame)
......@@ -22,6 +22,8 @@
import gtk
import gst
import pitivi.timeline
from viewer import time_to_string
class InfoLayer(gtk.Expander):
......@@ -31,23 +33,48 @@ class InfoLayer(gtk.Expander):
}
def __init__(self, layerInfo):
gtk.Expander.__init__(self, "Track")
if layerInfo.composition.media_type == pitivi.timeline.MEDIA_TYPE_AUDIO:
name = "Audio Track"
elif layerInfo.composition.media_type == pitivi.timeline.MEDIA_TYPE_VIDEO:
name = "Video Track"
gtk.Expander.__init__(self, name)
self.layerInfo = layerInfo
self.set_border_width(5)
self.set_expanded(self.layerInfo.expanded)
self.add(gtk.Label("Track Info"))
self.label = gtk.Label(self.get_duration_string())
self.add(self.label)
self.layerInfo.composition.connect('start-duration-changed',
self.compositionStartDurationChangedCb)
# TODO :
# . react on 'expand' virtual method
# . put content
## signal from composition
def compositionStartDurationChangedCb(self, composition, start, duration):
self.label.set_text(self.get_duration_string())
## Gtk.Expander override
def do_activate(self):
gst.debug("do activate")
self.layerInfo.expanded = not self.get_expanded()
gtk.Expander.do_activate(self)
## Gtk.Widget override
def do_size_request(self, requisition):
# setting the requested height of the whole layer should be done here.
gtk.Expander.do_size_request(self, requisition)
requisition.height = max(requisition.height, self.getNeededHeight())
gst.debug("%r expanded:%d returning %s" % (self, self.layerInfo.expanded, list(requisition)))
## utils
def get_duration_string(self):
if self.layerInfo.composition.duration > 0:
return time_to_string(self.layerInfo.composition.duration)
return "Empty"
......@@ -85,6 +85,9 @@ class TopLayer(TimelineLayer, ZoomableWidgetInterface):
self.rightWidget.get_duration = self.get_duration
self.rightWidget.get_start_time = self.get_start_time
def timelinePositionChanged(self, value, frame):
self.rightWidget.timelinePositionChanged(value, frame)
class CompositionLayer(TimelineLayer, ZoomableWidgetInterface):
def __init__(self, leftSizeGroup, hadj, layerInfo):
......
......@@ -110,6 +110,9 @@ class PitiviMainWindow(gtk.Window):
viewerframe = gtk.Frame()
viewerframe.add(self.viewer)
# connect viewer's timeline position callback to the timeline widget
self.viewer.addTimelinePositionCallback(self.timeline.timelinePositionChanged)
hpaned.pack1(self.sourcefactories, resize=True, shrink=False)
hpaned.pack2(viewerframe, resize=False, shrink=False)
......@@ -146,6 +149,9 @@ class PitiviMainWindow(gtk.Window):
abt.set_license("GNU Lesser Public License\nSee http://www.gnu.org/copyleft/lesser.html for more details")
abt.show()
## PiTiVi main object callbacks
def _new_project_cb(self, pitivi, project):
print "Starting up a new project", project
......
......@@ -38,6 +38,8 @@ class ScaleRuler(gtk.Layout, ZoomableWidgetInterface):
gtk.Layout.__init__(self)
self.set_hadjustment(hadj)
self.pixmap = None
# position is in nanoseconds
self.position = 0
## ZoomableWidgetInterface methods are handled by the container (LayerStack)
## Except for ZoomChanged
......@@ -49,6 +51,17 @@ class ScaleRuler(gtk.Layout, ZoomableWidgetInterface):
def get_pixel_width(self):
return ZoomableWidgetInterface.get_pixel_width(self) + 2 * self.border
## timeline position changed callback
def timelinePositionChanged(self, value, frame):
previous = self.position
self.position = value
self.queue_draw_area(max(self.ns_to_pixel(min(value, previous)) - 5, 0),
0,
self.ns_to_pixel(max(value, previous)) + 5,
self.get_allocation().height)
## gtk.Widget overrides
def do_size_allocate(self, allocation):
......@@ -72,6 +85,9 @@ class ScaleRuler(gtk.Layout, ZoomableWidgetInterface):
self.bin_window.draw_drawable(self.style.fg_gc[gtk.STATE_NORMAL],
self.pixmap,
x, y, x, y, width, height)
# draw the position
context = self.bin_window.cairo_create()
self.draw_position(context, self.get_allocation())
return False
def doPixmap(self):
......@@ -96,12 +112,19 @@ class ScaleRuler(gtk.Layout, ZoomableWidgetInterface):
def draw_background(self, context, allocation):
context.save()
context.set_source_rgb(0.8, 0.8, 0.8)
context.set_source_rgb(0.5, 0.5, 0.5)
context.rectangle(0, 0,
allocation.width, allocation.height)
context.fill()
context.stroke
context.stroke()
if self.get_duration() > 0:
context.set_source_rgb(0.8, 0.8, 0.8)
context.rectangle(0, 0,
self.get_pixel_width(), allocation.height)
context.fill()
context.stroke
context.restore()
......@@ -116,11 +139,28 @@ class ScaleRuler(gtk.Layout, ZoomableWidgetInterface):
context.move_to(i, 0)
if (i - self.border) % 100:
# second
context.line_to(i, allocation.height / 4)
elif (i - self.border) % 600:
# 10 seconds
context.line_to(i, allocation.height / 2)
else:
# minute
context.line_to(i, allocation.height)
context.stroke()
context.restore()
def draw_position(self, context, allocation):
if self.get_duration() <= 0:
return
# a simple RED line will do for now
xpos = self.ns_to_pixel(self.position) + self.border
context.save()
context.set_source_rgb(1.0, 0, 0)
context.move_to(xpos, 0)
context.line_to(xpos, allocation.height)
context.stroke()
context.restore()
......@@ -94,7 +94,8 @@ class TimelineWidget(gtk.VBox):
gst.debug("state:%s" % event.state)
self.hscroll.emit("scroll-event", event)
def timelinePositionChanged(self, value, frame):
self.complexview.timelinePositionChanged(value, frame)
class SimpleTimelineContentWidget(gtk.HBox):
""" Widget for Simple Timeline content display """
......
......@@ -60,6 +60,7 @@ class PitiviViewer(gtk.VBox):
# Only set the check time timeout in certain cases...
self.checktimeoutid = 0
self.positionChangedCallbacks = []
self.pitivi.connect("new-project", self._new_project_cb)
self.pitivi.playground.connect("current-state", self._current_state_cb)
self.pitivi.playground.connect("bin-added", self._bin_added_cb)
......@@ -179,6 +180,7 @@ class PitiviViewer(gtk.VBox):
vqueue = gst.element_factory_make('queue')
vsinkthread.add(self.videosink, vqueue)
vqueue.link(self.videosink)
vsinkthread.videosink = self.videosink
vsinkthread.add_pad(gst.GhostPad("sink", vqueue.get_pad('sink')))
if self.videosink.realsink:
......@@ -195,6 +197,7 @@ class PitiviViewer(gtk.VBox):
aqueue = gst.element_factory_make('queue')
asinkthread.add(self.audiosink, aqueue)
aqueue.link(self.audiosink)
asinkthread.audiosink = self.audiosink
asinkthread.add_pad(gst.GhostPad("sink", aqueue.get_pad('sink')))
# setting sinkthreads on playground
......@@ -212,6 +215,8 @@ class PitiviViewer(gtk.VBox):
drawingarea.do_expose_event("hello")
self.pitivi.playground.play()
## gtk.HScale callbacks for self.slider
def _slider_button_press_cb(self, slider, event):
gst.info("button pressed")
self.moving_slider = True
......@@ -261,6 +266,10 @@ class PitiviViewer(gtk.VBox):
seekvalue = min(self.current_frame + 1, self.pitivi.playground.current.length)
self.pitivi.playground.seek_in_current(seekvalue, gst.FORMAT_DEFAULT)
## timeout functions for checking current time
## TODO : check_time timeout should in fact be in the playground to be more generic
def _check_time(self):
# check time callback
gst.log("checking time")
......@@ -279,12 +288,6 @@ class PitiviViewer(gtk.VBox):
self.pitivi.playground.current.warning("couldn't get position")
cur = 0
## gst.info("about to conver %s to GST_FORMAT_DEFAULT" % cur)
## try:
## format, currentframe = self.videosink.query_convert(gst.FORMAT_TIME, cur, gst.FORMAT_DEFAULT)
## except:
## gst.info("convert query failed")
# if the current_time or the length has changed, update time
if not float(self.pitivi.playground.current.length) == self.posadjust.upper or not cur == self.current_time or not currentframe == self.current_frame:
self.posadjust.upper = float(self.pitivi.playground.current.length)
......@@ -298,8 +301,20 @@ class PitiviViewer(gtk.VBox):
self.timelabel.set_text(time_to_string(value) + " / " + time_to_string(self.pitivi.playground.current.length))
if not self.moving_slider:
self.posadjust.set_value(float(value))
if isinstance(self.pitivi.playground.current, SmartTimelineBin):
self.__triggerTimelinePositionCallbacks(value, frame)
return False
def __triggerTimelinePositionCallbacks(self, value, frame = -1):
for callback in self.positionChangedCallbacks:
callback(value, frame)
def addTimelinePositionCallback(self, function):
self.positionChangedCallbacks.append(function)
## gtk.ComboBox callbacks for sources
def _combobox_changed_cb(self, cbox):
# selected another source
idx = cbox.get_active()
......@@ -308,45 +323,8 @@ class PitiviViewer(gtk.VBox):
if not self.pitivi.playground.current == smartbin:
self.pitivi.playground.switch_to_pipeline(smartbin)
def _get_smartbin_index(self, smartbin):
# find the index of a smartbin
# return -1 if it's not in there
for pos in range(len(self.sourcelist)):
if self.sourcelist[pos][1] == smartbin:
return pos
return -1
def _bin_added_cb(self, playground, smartbin):
# a smartbin was added
self.sourcelist.append([smartbin.displayname, smartbin])
self.sourcecombobox.set_sensitive(True)
def _bin_removed_cb(self, playground, smartbin):
# a smartbin was removed
idx = self._get_smartbin_index(smartbin)
if idx < 0:
return
del self.sourcelist[idx]
if len(self.sourcelist) == 0:
self.sourcecombobox.set_sensitive(False)
def _current_playground_changed(self, playground, smartbin):
if smartbin.width and smartbin.height:
self.aframe.set_property("ratio", float(smartbin.width) / float(smartbin.height))
else:
self.aframe.set_property("ratio", 4.0/3.0)
if not smartbin == playground.default:
if isinstance(smartbin, SmartTimelineBin):
gst.info("switching to Timeline, setting duration to %s" % (gst.TIME_ARGS(smartbin.project.timeline.videocomp.duration)))
self.posadjust.upper = float(smartbin.project.timeline.videocomp.duration)
smartbin.project.timeline.videocomp.connect("start-duration-changed",
self._timeline_duration_changed)
self.record_button.set_sensitive(True)
else:
self.posadjust.upper = float(smartbin.factory.length)
self.record_button.set_sensitive(False)
self._new_time(0)
self.sourcecombobox.set_active(self._get_smartbin_index(smartbin))
## active Timeline calllbacks
def _timeline_duration_changed(self, composition, start, duration):
self.posadjust.upper = float(duration)
......@@ -379,6 +357,9 @@ class PitiviViewer(gtk.VBox):
def _add_timeline_to_playground(self):
self.pitivi.playground.add_pipeline(self.pitivi.current.get_bin())
## Control gtk.Button callbacks
def record_cb(self, button):
win = EncodingDialog(self.pitivi.current)
win.show()
......@@ -389,7 +370,6 @@ class PitiviViewer(gtk.VBox):
def back_cb(self, button):
pass
def _play_button_cb(self, button, isplaying):
if isplaying:
self.pitivi.playground.play()
......@@ -402,6 +382,49 @@ class PitiviViewer(gtk.VBox):
def forward_cb(self, button):
pass
## Playground callbacks
def _current_playground_changed(self, playground, smartbin):
if smartbin.width and smartbin.height:
self.aframe.set_property("ratio", float(smartbin.width) / float(smartbin.height))
else:
self.aframe.set_property("ratio", 4.0/3.0)
if not smartbin == playground.default:
if isinstance(smartbin, SmartTimelineBin):
gst.info("switching to Timeline, setting duration to %s" % (gst.TIME_ARGS(smartbin.project.timeline.videocomp.duration)))
self.posadjust.upper = float(smartbin.project.timeline.videocomp.duration)
smartbin.project.timeline.videocomp.connect("start-duration-changed",
self._timeline_duration_changed)
self.record_button.set_sensitive(True)
else:
self.posadjust.upper = float(smartbin.factory.length)
self.record_button.set_sensitive(False)
self._new_time(0)
self.sourcecombobox.set_active(self._get_smartbin_index(smartbin))
def _bin_added_cb(self, playground, smartbin):
# a smartbin was added
self.sourcelist.append([smartbin.displayname, smartbin])
self.sourcecombobox.set_sensitive(True)
def _get_smartbin_index(self, smartbin):
# find the index of a smartbin
# return -1 if it's not in there
for pos in range(len(self.sourcelist)):
if self.sourcelist[pos][1] == smartbin:
return pos
return -1
def _bin_removed_cb(self, playground, smartbin):
# a smartbin was removed
idx = self._get_smartbin_index(smartbin)
if idx < 0:
return
del self.sourcelist[idx]
if len(self.sourcelist) == 0:
self.sourcecombobox.set_sensitive(False)
def _current_state_cb(self, playground, state):
gst.info("current state changed : %s" % state)
if state == int(gst.STATE_PLAYING):
......@@ -479,7 +502,6 @@ class EncodingDialog(GladeWindow):
self.timeoutid = None
self.rendering = False
self.settings = project.settings
self.widgets["recordbutton"].set_sensitive(False)
def filebutton_clicked(self, button):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment