~timo-jyrinki/ubuntu/trusty/pitivi/backport_utopic_fixes

« back to all changes in this revision

Viewing changes to pitivi/factories/file.py

  • Committer: Package Import Robot
  • Author(s): Sebastian Dröge
  • Date: 2014-04-05 15:28:16 UTC
  • mfrom: (6.1.13 sid)
  • Revision ID: package-import@ubuntu.com-20140405152816-6lijoax4cngiz5j5
Tags: 0.93-3
* debian/control:
  + Depend on python-gi (>= 3.10), older versions do not work
    with pitivi (Closes: #732813).
  + Add missing dependency on gir1.2-clutter-gst-2.0 (Closes: #743692).
  + Add suggests on gir1.2-notify-0.7 and gir1.2-gnomedesktop-3.0.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# PiTiVi , Non-linear video editor
2
 
#
3
 
#       :base.py
4
 
#
5
 
# Copyright (c) 2005-2008, Edward Hervey <bilboed@bilboed.com>
6
 
#               2008,2009 Alessandro Decina <alessandro.decina@collabora.co.uk>
7
 
#
8
 
# This program is free software; you can redistribute it and/or
9
 
# modify it under the terms of the GNU Lesser General Public
10
 
# License as published by the Free Software Foundation; either
11
 
# version 2.1 of the License, or (at your option) any later version.
12
 
#
13
 
# This program is distributed in the hope that it will be useful,
14
 
# but WITHOUT ANY WARRANTY; without even the implied warranty of
15
 
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16
 
# Lesser General Public License for more details.
17
 
#
18
 
# You should have received a copy of the GNU Lesser General Public
19
 
# License along with this program; if not, write to the
20
 
# Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
21
 
# Boston, MA 02110-1301, USA.
22
 
 
23
 
import gst
24
 
import os
25
 
 
26
 
from pitivi.factories.base import RandomAccessSourceFactory, \
27
 
        SinkFactory
28
 
from pitivi.stream import MultimediaStream, AudioStream, VideoStream
29
 
 
30
 
 
31
 
class FileSourceFactory(RandomAccessSourceFactory):
32
 
    """
33
 
    Factory for local files.
34
 
 
35
 
    @see: L{RandomAccessSourceFactory}.
36
 
    """
37
 
 
38
 
    def __init__(self, uri, name=''):
39
 
        name = name or os.path.basename(uri)
40
 
        RandomAccessSourceFactory.__init__(self, uri, name)
41
 
        # FIXME: backward compatibility
42
 
        self.filename = uri
43
 
 
44
 
 
45
 
class PictureFileSourceFactory(FileSourceFactory):
46
 
    """
47
 
    Factory for image sources.
48
 
 
49
 
    @see: L{FileSourceFactory}, L{RandomAccessSourceFactory}.
50
 
    """
51
 
 
52
 
    duration = 3600 * gst.SECOND
53
 
    default_duration = 5 * gst.SECOND
54
 
 
55
 
    def _makeDefaultBin(self):
56
 
        return self._makeStreamBin(self.output_streams[0])
57
 
 
58
 
    def _makeStreamBin(self, output_stream, child_bin=None):
59
 
        self.debug("making picture bin for %s", self.name)
60
 
        freeze = gst.element_factory_make("imagefreeze")
61
 
 
62
 
        self.debug("Chaining up with %r", freeze)
63
 
 
64
 
        ret = FileSourceFactory._makeStreamBin(self, output_stream,
65
 
            freeze)
66
 
        self.debug("Returning %r", ret)
67
 
 
68
 
        return ret
69
 
 
70
 
 
71
 
class URISinkFactory(SinkFactory):
72
 
    """ A simple sink factory """
73
 
 
74
 
    def __init__(self, uri, *args, **kwargs):
75
 
        self.uri = uri
76
 
        SinkFactory.__init__(self, *args, **kwargs)
77
 
        self.addInputStream(MultimediaStream(caps=gst.caps_new_any()))
78
 
 
79
 
    def _makeBin(self, input_stream=None):
80
 
        sink_element = gst.element_make_from_uri(gst.URI_SINK, self.uri)
81
 
        sink_element.set_property("async", False)
82
 
        return sink_element