Advertisement
Guest User

Untitled

a guest
Jun 19th, 2013
42
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 5.22 KB | None | 0 0
  1. @@ -21,9 +21,11 @@
  2.  from twisted.internet import defer
  3.  # moving this down causes havoc when running this file directly for some reason
  4.  from flumotion.common import errors, log
  5. -
  6. -import gobject
  7. -import gst
  8. +import gi
  9. +gi.require_version('Gst', '1.0')
  10. +from gi.repository import GObject, Gst
  11. +GObject.threads_init()
  12. +Gst.init(None)
  13.  
  14.  __version__ = "$Rev$"
  15.  
  16. @@ -47,13 +49,13 @@ def verbose_deep_notify_cb(object, orig, pspec, component):
  17.      A default deep-notify signal handler for pipelines.
  18.      """
  19.      value = orig.get_property(pspec.name)
  20. -    if pspec.value_type == gobject.TYPE_BOOLEAN:
  21. +    if pspec.value_type == GObject.TYPE_BOOLEAN:
  22.          if value:
  23.              value = 'TRUE'
  24.          else:
  25.              value = 'FALSE'
  26.          output = value
  27. -    elif pspec.value_type == gst.Caps.__gtype__:
  28. +    elif pspec.value_type == Gst.Caps.__gtype__:
  29.          output = caps_repr(value)
  30.      else:
  31.          output = value
  32. @@ -87,8 +89,8 @@ def element_factory_has_property(element_factory, property_nam
  33.      @rtype: boolean
  34.      """
  35.      # FIXME: find a better way than instantiating one
  36. -    e = gst.element_factory_make(element_factory)
  37. -    for pspec in gobject.list_properties(e):
  38. +    e = Gst.ElementFactory.make(element_factory)
  39. +    for pspec in GObject.list_properties(e):
  40.          if pspec.name == property_name:
  41.              return True
  42.      return False
  43. @@ -102,7 +104,7 @@ def element_factory_has_property_value(element_factory, prop
  44.      @rtype: boolean
  45.      """
  46.      # FIXME: find a better way than instantiating one
  47. -    e = gst.element_factory_make(element_factory)
  48. +    e = Gst.ElementFactory.make(element_factory)
  49.      try:
  50.          e.set_property(property_name, value)
  51.      except TypeError:
  52. @@ -117,8 +119,8 @@ def element_factory_exists(name):
  53.  
  54.      @rtype: boolean
  55.      """
  56. -    registry = gst.registry_get_default()
  57. -    factory = registry.find_feature(name, gst.TYPE_ELEMENT_FACTORY)
  58. +    registry = Gst.registry_get()
  59. +    factory = registry.find_feature(name, Gst.TYPE_ELEMENT_FACTORY)
  60.  
  61.      if factory:
  62.          return True
  63. @@ -133,7 +135,7 @@ def get_plugin_version(plugin_name):
  64.      @rtype: tuple of (major, minor, micro, nano), or None if it could not be
  65.              found or determined
  66.      """
  67. -    plugin = gst.registry_get_default().find_plugin(plugin_name)
  68. +    plugin = Gst.registry_get().find_plugin(plugin_name)
  69.  
  70.      if not plugin:
  71.          return None
  72. @@ -147,25 +149,25 @@ def get_plugin_version(plugin_name):
  73.  
  74.  
  75.  def get_state_change(old, new):
  76. -    table = {(gst.STATE_NULL, gst.STATE_READY):
  77. -             gst.STATE_CHANGE_NULL_TO_READY,
  78. -             (gst.STATE_READY, gst.STATE_PAUSED):
  79. -             gst.STATE_CHANGE_READY_TO_PAUSED,
  80. -             (gst.STATE_PAUSED, gst.STATE_PLAYING):
  81. -             gst.STATE_CHANGE_PAUSED_TO_PLAYING,
  82. -             (gst.STATE_PLAYING, gst.STATE_PAUSED):
  83. -             gst.STATE_CHANGE_PLAYING_TO_PAUSED,
  84. -             (gst.STATE_PAUSED, gst.STATE_READY):
  85. -             gst.STATE_CHANGE_PAUSED_TO_READY,
  86. -             (gst.STATE_READY, gst.STATE_NULL):
  87. -             gst.STATE_CHANGE_READY_TO_NULL}
  88. +    table = {(Gst.STATE.NULL, Gst.STATE.READY):
  89. +             Gst.STATE.CHANGE_NULL_TO_READY,
  90. +             (Gst.STATE.READY, Gst.STATE.PAUSED):
  91. +             Gst.STATE.CHANGE_READY_TO_PAUSED,
  92. +             (Gst.STATE.PAUSED, Gst.STATE.PLAYING):
  93. +             Gst.STATE.CHANGE_PAUSED_TO_PLAYING,
  94. +             (Gst.STATE.PLAYING, Gst.STATE.PAUSED):
  95. +             Gst.STATE.CHANGE_PLAYING_TO_PAUSED,
  96. +             (Gst.STATE.PAUSED, Gst.STATE.READY):
  97. +             Gst.STATE.CHANGE_PAUSED_TO_READY,
  98. +             (Gst.STATE.READY, Gst.STATE.NULL):
  99. +             Gst.STATE.CHANGE_READY_TO_NULL}
  100.      return table.get((old, new), 0)
  101.  
  102.  
  103.  def flumotion_reset_event():
  104.      ''' Helper method to create a 'flumotion-reset' event '''
  105. -    return gst.event_new_custom(gst.EVENT_CUSTOM_DOWNSTREAM,
  106. -                                gst.Structure('flumotion-reset'))
  107. +    return Gst.event_new_custom(Gst.EVENT_CUSTOM_DOWNSTREAM,
  108. +                                Gst.Structure('flumotion-reset'))
  109.  
  110.  
  111.  def event_is_flumotion_reset(event):
  112. @@ -203,13 +205,13 @@ class StateChangeMonitor(dict, log.Loggable):
  113.      def have_error(self, curstate, message):
  114.          # if we have a state change defer that has not yet
  115.          # fired, we should errback it
  116. -        changes = [gst.STATE_CHANGE_NULL_TO_READY,
  117. -                   gst.STATE_CHANGE_READY_TO_PAUSED,
  118. -                   gst.STATE_CHANGE_PAUSED_TO_PLAYING]
  119. +        changes = [Gst.STATE.CHANGE_NULL_TO_READY,
  120. +                   Gst.STATE.CHANGE_READY_TO_PAUSED,
  121. +                   Gst.STATE.CHANGE_PAUSED_TO_PLAYING]
  122.  
  123. -        extras = ((gst.STATE_PAUSED, gst.STATE_CHANGE_PLAYING_TO_PAUSED),
  124. -                  (gst.STATE_READY, gst.STATE_CHANGE_PAUSED_TO_READY),
  125. -                  (gst.STATE_NULL, gst.STATE_CHANGE_READY_TO_NULL))
  126. +        extras = ((Gst.STATE.PAUSED, Gst.STATE.CHANGE_PLAYING_TO_PAUSED),
  127. +                  (Gst.STATE.READY, Gst.STATE.CHANGE_PAUSED_TO_READY),
  128. +                  (Gst.STATE.NULL, Gst.STATE.CHANGE_READY_TO_NULL))
  129.          for state, change in extras:
  130.              if curstate <= state:
  131.                  changes.append(change)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement