pitivi r1236 - in branches/SOC_2008_SLAKSHMAN: . pitivi pitivi/ui
- From: slynux svn gnome org
- To: svn-commits-list gnome org
- Subject: pitivi r1236 - in branches/SOC_2008_SLAKSHMAN: . pitivi pitivi/ui
- Date: Sun, 24 Aug 2008 06:22:43 +0000 (UTC)
Author: slynux
Date: Sun Aug 24 06:22:43 2008
New Revision: 1236
URL: http://svn.gnome.org/viewvc/pitivi?rev=1236&view=rev
Log:
Fixed Network streaming, Added T\timeoverlay: Tested all features
Modified:
branches/SOC_2008_SLAKSHMAN/ChangeLog
branches/SOC_2008_SLAKSHMAN/pitivi/bin.py
branches/SOC_2008_SLAKSHMAN/pitivi/ui/net_capture.glade
branches/SOC_2008_SLAKSHMAN/pitivi/ui/netstream_managerdialog.py
branches/SOC_2008_SLAKSHMAN/pitivi/ui/sourcefactories.py
branches/SOC_2008_SLAKSHMAN/pitivi/ui/webcam_managerdialog.py
Modified: branches/SOC_2008_SLAKSHMAN/pitivi/bin.py
==============================================================================
--- branches/SOC_2008_SLAKSHMAN/pitivi/bin.py (original)
+++ branches/SOC_2008_SLAKSHMAN/pitivi/bin.py Sun Aug 24 06:22:43 2008
@@ -27,7 +27,12 @@
import gst
from elements.smartscale import SmartVideoScale
from objectfactory import FileSourceFactory
+from signalgroup import SignalGroup
from ui import plumber
+import instance
+from sourcelist import SourceList
+from threads import CallbackThread
+import time
class SmartBin(gst.Pipeline):
"""
@@ -520,11 +525,19 @@
self.vsinkthread = gst.Bin('vsinkthread')
vqueue = gst.element_factory_make('queue')
+ timeoverlay = gst.element_factory_make('timeoverlay')
cspace = gst.element_factory_make('ffmpegcolorspace')
vscale = gst.element_factory_make('videoscale')
vscale.props.method = 1
- self.vsinkthread.add(self.videosink, vqueue, vscale, cspace)
- vqueue.link(self.videosink)
+ self.vsinkthread.add(self.videosink,timeoverlay, vqueue, vscale, cspace)
+ vqueue.link(timeoverlay)
+ timeoverlay.link(self.videosink)
+ timeoverlay.set_property("halign","right")
+ timeoverlay.set_property("valign","bottom")
+ timeoverlay.set_property("deltax",65)
+ timeoverlay.set_property("deltay",20)
+
+
cspace.link(vscale)
vscale.link(vqueue)
self.vsinkthread.videosink = self.videosink
@@ -541,10 +554,13 @@
self.asinkthread.audiosink = self.audiosink
self.asinkthread.add_pad(gst.GhostPad("sink", aconv.get_pad('sink')))
- def connectSink(self,player):
- player.setVideoSinkThread(self.vsinkthread)
- player.setAudioSinkThread(self.asinkthread)
-
+ def connectSink(self,player,is_video,is_audio):
+ if is_video is True :
+ player.setVideoSinkThread(self.vsinkthread)
+ if is_audio is True :
+ player.setAudioSinkThread(self.asinkthread)
+
+
gst.debug("success connecting sources to SinkBin")
@@ -583,20 +599,129 @@
self.debug("finished connecting sources")
-
-class SmartStreamBin(SmartFileBin):
+class SmartCaptureBin(SmartBin):
"""
- SmartStreamBin with network stream from URI can be used as source.
+ SmartBin derivative for capturing streams.
"""
- def __init__(self, url):
- gst.log("Creating new smartstreambin")
+ def __init__(self):
+ gst.log("Creating new smartcapturebin")
+ self.videosrc = gst.element_factory_make("v4l2src", "webcam-vsrc")
+ self.audiosrc = gst.element_factory_make("alsasrc", "webcam-asrc")
+
+ SmartBin.__init__(self, "smartcapturebin", has_video=True, has_audio=True,
+ width=640, height=480)
+
+ def _addSource(self):
+ self.q1 = gst.element_factory_make("queue", "webcam-firstvqueue")
+ self.q1.props.max_size_time = 10 * gst.SECOND
+ self.q2 = gst.element_factory_make("queue", "webcam-firstaqueue")
+ self.q2.props.max_size_time = 30 * gst.SECOND
+ self.q2.props.max_size_buffers = 0
+ self.q2.props.max_size_bytes = 0
+ self.add(self.videosrc,self.audiosrc,self.q1,self.q2)
+
+ def _connectSource(self):
+ self.debug("connecting sources")
+ #vcaps = gst.caps_from_string("video/x-raw-yuv,width=320,height=240,framerate=25.0")
+ gst.element_link_many(self.videosrc,self.q1,self.vtee)
+ gst.element_link_many(self.audiosrc,self.q2,self.atee)
+
+ #self.videosrc.get_pad("src").link(self.vtee.get_pad("sink"))
+ #self.audiosrc.get_pad("src").link(self.atee.get_pad("sink"))
+
+ self.debug("finished connecting sources")
+
+class Discover:
+ """
+ A Pipeline which return audio/video info about the uri stream
+ """
+
+ def __init__(self,uri):
+
+ self.is_audio = False
+ self.is_video = True
+
+ try:
+
+ self.pipeline = gst.parse_launch(" %s ! decodebin name=dbin ! fakesink" % uri)
+ except:
+ gst.log("Error occured with Disover, StreamBin Detector")
+ return
+
+ self.dbin = self.pipeline.get_by_name("dbin")
+ self.no = 0
+ self.dbin.connect("new-decoded-pad", self._new_decoded_pad_cb)
+
+ self.pipeline.set_state(gst.STATE_PLAYING)
- self.factory = FileSourceFactory(url)
- self.source = self.factory.makeBin()
+ time.sleep(0.1)
+
+
+ def info(self):
+ CallbackThread(self.kill).start()
+ return (self.is_video,self.is_audio)
+
+ def _new_decoded_pad_cb(self, dbin, pad, is_last):
+
+ # Does the file contain got audio or video ?
+ if "audio" in pad.get_caps().to_string():
+ self.is_audio = True
+
+ elif "video" in pad.get_caps().to_string():
+ self.is_video = True
+ def kill(self):
+ time.sleep(1)
+ del self
+
+
+class SmartStreamBin(SmartBin):
+ """
+ SmartBin derivative for capturing streams.
+ """
+
+ def __init__(self,uri):
+ gst.log("Creating new smartcapturebin")
+
+
+ (self.is_video,self.is_audio) = (True,True)
+
+
+ self.urisrc = gst.element_make_from_uri(gst.URI_SRC,uri)
+ self.decodebin = gst.element_factory_make("decodebin","decode-smartbin")
+ self.videoq = gst.element_factory_make("queue","video-queue")
+ self.audioq = gst.element_factory_make("queue","audio-queue")
+
+ SmartBin.__init__(self, "smartcapturebin", has_video=self.is_video, has_audio=self.is_audio,
+
+ width=640, height=480)
+
+
+ def _addSource(self):
+ self.add(self.urisrc,self.decodebin,self.videoq,self.audioq)
+
+ def _connectSource(self):
+ self.debug("connecting sources")
+ gst.element_link_many(self.urisrc,self.decodebin)
+ if self.is_video :
+ gst.element_link_many(self.videoq,self.vtee)
+ if self.is_audio:
+ gst.element_link_many(self.audioq,self.atee)
+
+
+ self.decodebin.connect("new-decoded-pad",self.on_new_decoded_pad)
+
+ self.debug("finished connecting sources")
+ # DecodeBin callback
+ def on_new_decoded_pad(self, element, pad, last):
+ caps = pad.get_caps()
+ name = caps[0].get_name()
+ if name.startswith("video"):
+ pad.link(self.videoq.get_pad('sink'))
- SmartBin.__init__(self, "smartdefaultbin", has_video=True, has_audio=True)
+ elif name.startswith("audio"):
+ pad.link(self.audioq.get_pad('sink'))
Modified: branches/SOC_2008_SLAKSHMAN/pitivi/ui/net_capture.glade
==============================================================================
--- branches/SOC_2008_SLAKSHMAN/pitivi/ui/net_capture.glade (original)
+++ branches/SOC_2008_SLAKSHMAN/pitivi/ui/net_capture.glade Sun Aug 24 06:22:43 2008
@@ -34,6 +34,7 @@
<child>
<widget class="GtkButton" id="close_btn">
<property name="visible">True</property>
+ <property name="tooltip" translatable="yes">Close</property>
<property name="can_default">True</property>
<property name="can_focus">True</property>
<property name="label">gtk-close</property>
@@ -143,8 +144,8 @@
<child>
<widget class="GtkDrawingArea" id="screen">
- <property name="width_request">300</property>
- <property name="height_request">300</property>
+ <property name="width_request">446</property>
+ <property name="height_request">349</property>
<property name="visible">True</property>
</widget>
</child>
@@ -272,7 +273,7 @@
<widget class="GtkRadioButton" id="protocol">
<property name="visible">True</property>
<property name="can_focus">True</property>
- <property name="label" translatable="yes">http / https / ftp / mms</property>
+ <property name="label" translatable="yes">http / https</property>
<property name="use_underline">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
@@ -763,6 +764,7 @@
<property name="width_request">84</property>
<property name="height_request">39</property>
<property name="visible">True</property>
+ <property name="tooltip" translatable="yes">Preview Stream from URI</property>
<property name="can_focus">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
@@ -870,6 +872,7 @@
<property name="width_request">118</property>
<property name="height_request">39</property>
<property name="visible">True</property>
+ <property name="tooltip" translatable="yes">Capture Stream from URI</property>
<property name="can_focus">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
@@ -998,7 +1001,56 @@
</child>
<child>
- <placeholder/>
+ <widget class="GtkHBox" id="hbox9">
+ <property name="visible">True</property>
+ <property name="homogeneous">False</property>
+ <property name="spacing">0</property>
+
+ <child>
+ <widget class="GtkLabel" id="label20">
+ <property name="width_request">316</property>
+ <property name="height_request">19</property>
+ <property name="visible">True</property>
+ <property name="label" translatable="yes"></property>
+ <property name="use_underline">False</property>
+ <property name="use_markup">False</property>
+ <property name="justify">GTK_JUSTIFY_LEFT</property>
+ <property name="wrap">False</property>
+ <property name="selectable">False</property>
+ <property name="xalign">0.5</property>
+ <property name="yalign">0.5</property>
+ <property name="xpad">0</property>
+ <property name="ypad">0</property>
+ <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
+ <property name="width_chars">-1</property>
+ <property name="single_line_mode">False</property>
+ <property name="angle">0</property>
+ </widget>
+ <packing>
+ <property name="padding">2</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkStatusbar" id="status">
+ <property name="width_request">397</property>
+ <property name="visible">True</property>
+ <property name="has_resize_grip">True</property>
+ </widget>
+ <packing>
+ <property name="padding">2</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="padding">2</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
</child>
</widget>
</child>
Modified: branches/SOC_2008_SLAKSHMAN/pitivi/ui/netstream_managerdialog.py
==============================================================================
--- branches/SOC_2008_SLAKSHMAN/pitivi/ui/netstream_managerdialog.py (original)
+++ branches/SOC_2008_SLAKSHMAN/pitivi/ui/netstream_managerdialog.py Sun Aug 24 06:22:43 2008
@@ -32,6 +32,8 @@
from gettext import gettext as _
from pitivi import instance
from sourcefactories import SourceFactoriesWidget
+from pitivi.sourcelist import SourceList
+from pitivi.objectfactory import FileSourceFactory
from pitivi.bin import SmartStreamBin, SinkBin
from pitivi.settings import ExportSettings
@@ -53,7 +55,8 @@
self.port = self.objectpool_ui.get_widget("port")
self.address = self.objectpool_ui.get_widget("address")
self.uri = self.objectpool_ui.get_widget("url")
-
+ self.status = self.objectpool_ui.get_widget("status")
+ self.status_id = self.status.get_context_id("status")
self.http_radiobtn = self.objectpool_ui.get_widget("protocol")
self.udp_radiobtn = self.objectpool_ui.get_widget("udp")
@@ -84,12 +87,14 @@
# For Setting up audio,video sinks
- def setSinks(self,uri=None):
-
+ def setSinks(self,uri):
gst.debug("SmartStreamBin player created")
- self.player = SmartStreamBin(uri)
+ self.player=SmartStreamBin(uri)
sink = SinkBin()
- sink.connectSink(self.player)
+ sink.connectSink(self.player,self.player.is_video,self.player.is_audio)
+ self.player.set_state(gst.STATE_PLAYING)
+
+
bus = self.player.get_bus()
bus.add_signal_watch()
bus.enable_sync_message_emission()
@@ -99,36 +104,54 @@
# Create live display pipeline
def live_pipeline(self,w=None):
-
+
if self.player:
self.player.set_state(gst.STATE_NULL)
- if self.uri.get_text() != None :
- self.setSinks(self.uri.get_text())
- self.player.set_state(gst.STATE_PLAYING)
+ uri = self.uri.get_text()
+
+ if uri != None :
+
+ if gst.uri_is_valid (uri) is False:
+ self.status.push(self.status_id,"Invalid URI. Please verify.")
+ gst.debug("Invalid URI")
+ return
+ if gst.uri_protocol_is_supported(gst.URI_SRC,uri.split('://')[0]):
+ self.setSinks(uri)
+ self.player.set_state(gst.STATE_PLAYING)
+ self.status.push(self.status_id,"")
+ else:
+ self.status.push(self.status_id,"Unsupported Protocol. Please verify the URI.")
+ gst.debug("Unsupported Protocol")
# Stream capture pipeline
def capture_pipeline(self,w=None):
+ uri = self.uri.get_text()
if self.capture_btn.get_label() == "Capture":
- self.player.set_state(gst.STATE_NULL)
- self.setSinks(self.uri.get_text())
+
+ if self.player is False and gst.uri_protocol_is_supported(gst.URI_SRC,uri.split('://')[0]) is False :
+ self.status.push(self.status_id,"Unsupported Protocol. Please verify the URI.")
+ return
+ elif self.player is False:
+ self.player.set_state(gst.STATE_NULL)
+ self.setSinks(uri)
+
gst.debug("recording started")
self.filepath = 'file://'+tempfile.mktemp()+'.ogg'
self.player.record(self.filepath,ExportSettings())
self.capture_btn.set_label("Stop")
self.player.set_state(gst.STATE_PLAYING)
-
-
else:
gst.debug("recording stopped")
self.player.stopRecording()
self.sourcefactories.sourcelist.addFiles([self.filepath])
self.capture_btn.set_label("Capture")
+
def on_message(self,bus,message):
t = message.type
@@ -171,4 +194,3 @@
if self.capture_pipe:
self.capture_pipe.set_state(gst.STATE_NULL)
-
Modified: branches/SOC_2008_SLAKSHMAN/pitivi/ui/sourcefactories.py
==============================================================================
--- branches/SOC_2008_SLAKSHMAN/pitivi/ui/sourcefactories.py (original)
+++ branches/SOC_2008_SLAKSHMAN/pitivi/ui/sourcefactories.py Sun Aug 24 06:22:43 2008
@@ -412,6 +412,7 @@
self.addFolders(filenames)
else:
self.addFiles(filenames)
+ print filenames
else:
dialogbox.destroy()
self._importDialog = None
Modified: branches/SOC_2008_SLAKSHMAN/pitivi/ui/webcam_managerdialog.py
==============================================================================
--- branches/SOC_2008_SLAKSHMAN/pitivi/ui/webcam_managerdialog.py (original)
+++ branches/SOC_2008_SLAKSHMAN/pitivi/ui/webcam_managerdialog.py Sun Aug 24 06:22:43 2008
@@ -68,7 +68,7 @@
# Perform record in a seperate thread
def threaded_recording(self,w):
- print "test"
+
CallbackThread(self.do_recording,w).start()
@@ -95,7 +95,7 @@
# For Setting up audio,video sinks
def setSinks(self):
sink = SinkBin()
- sink.connectSink(self.player)
+ sink.connectSink(self.player,True,True)
bus = self.player.get_bus()
bus.add_signal_watch()
bus.enable_sync_message_emission()
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]