~ubuntu-branches/ubuntu/precise/gst0.10-python/precise

« back to all changes in this revision

Viewing changes to gst/__init__.py

  • Committer: Bazaar Package Importer
  • Author(s): Loic Minier
  • Date: 2006-06-25 19:37:45 UTC
  • Revision ID: james.westby@ubuntu.com-20060625193745-9yeg0wq56r24n57x
Tags: upstream-0.10.4
ImportĀ upstreamĀ versionĀ 0.10.4

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# -*- Mode: Python -*-
 
2
# vi:si:et:sw=4:sts=4:ts=4
 
3
#
 
4
# gst-python
 
5
# Copyright (C) 2002 David I. Lehn
 
6
#
 
7
# This library is free software; you can redistribute it and/or
 
8
# modify it under the terms of the GNU Library General Public
 
9
# License as published by the Free Software Foundation; either
 
10
# version 2 of the License, or (at your option) any later version.
 
11
#
 
12
# This library is distributed in the hope that it will be useful,
 
13
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
15
# Library General Public License for more details.
 
16
#
 
17
# You should have received a copy of the GNU Library General Public
 
18
# License along with this library; if not, write to the
 
19
# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 
20
# Boston, MA 02111-1307, USA.
 
21
 
22
# Author: David I. Lehn <dlehn@users.sourceforge.net>
 
23
 
 
24
__ltihooks_used__ = False
 
25
try:
 
26
    import ltihooks
 
27
    __ltihooks_used__ = True
 
28
except:
 
29
   pass
 
30
 
 
31
import sys
 
32
 
 
33
# we always require 2.0 of pygtk; so if pygtk is not imported anywhere
 
34
# yet, we import pygtk here and .require
 
35
if 'gobject' not in sys.modules:
 
36
    import pygtk
 
37
    pygtk.require('2.0')
 
38
 
 
39
class Value:
 
40
   def __init__(self, type):
 
41
      assert type in ('fourcc', 'intrange', 'doublerange', 'fractionrange', 'fraction')
 
42
      self.type = type
 
43
 
 
44
class Fourcc(Value):
 
45
   def __init__(self, string):
 
46
      Value.__init__(self, 'fourcc')
 
47
      self.fourcc = string
 
48
   def __repr__(self):
 
49
      return '<gst.Fourcc %s>' % self.fourcc
 
50
 
 
51
class IntRange(Value):
 
52
   def __init__(self, low, high):
 
53
      Value.__init__(self, 'intrange')
 
54
      self.low = low
 
55
      self.high = high
 
56
   def __repr__(self):
 
57
      return '<gst.IntRange [%d, %d]>' % (self.low, self.high)
 
58
 
 
59
class DoubleRange(Value):
 
60
   def __init__(self, low, high):
 
61
      Value.__init__(self, 'doublerange')
 
62
      self.low = low
 
63
      self.high = high
 
64
   def __repr__(self):
 
65
      return '<gst.DoubleRange [%f, %f]>' % (self.low, self.high)
 
66
 
 
67
class FractionRange(Value):
 
68
   def __init__(self, low, high):
 
69
      Value.__init__(self, 'fractionrange')
 
70
      self.low = low
 
71
      self.high = high
 
72
   def __repr__(self):
 
73
      return '<gst.FractionRange [%d/%d, %d/%d]>' % (self.low.num,
 
74
                                                     self.low.denom,
 
75
                                                     self.high.num,
 
76
                                                     self.high.denom)
 
77
 
 
78
class Fraction(Value):
 
79
   def __init__(self, num, denom):
 
80
      Value.__init__(self, 'fraction')
 
81
      self.num = num
 
82
      self.denom = denom
 
83
   def __repr__(self):
 
84
      return '<gst.Fraction %d/%d>' % (self.num, self.denom)
 
85
 
 
86
import DLFCN, sys
 
87
dlsave = sys.getdlopenflags()
 
88
sys.setdlopenflags(DLFCN.RTLD_LAZY | DLFCN.RTLD_GLOBAL)
 
89
 
 
90
from _gst import *
 
91
import interfaces
 
92
 
 
93
version = get_gst_version
 
94
 
 
95
sys.setdlopenflags(dlsave)
 
96
del DLFCN, sys
 
97
 
 
98
# this restores previously installed importhooks, so we don't interfere
 
99
# with other people's module importers
 
100
# it also clears out the module completely as if it were never loaded,
 
101
# so that if anyone else imports ltihooks the hooks get installed
 
102
if __ltihooks_used__:
 
103
    ltihooks.uninstall()
 
104
    __ltihooks_used__ = False
 
105
    del ltihooks
 
106
    import sys
 
107
    del sys.modules['ltihooks']
 
108