Ejemplo n.º 1
0
    def openfile(self, filename, aModel):
        self.images = list()
        self.errors = list()
        self.fileName = filename
        self.codec = ""
        if (self.player != None):
            self.player.set_state(gst.STATE_NULL)

        self.__isEndOfStream = False
        self.player = gst.element_factory_make("playbin", "player")
        videoBin = gst.Bin("video")
        videoFilter = gst.element_factory_make("capsfilter", "videofilter")
        videoBin.add(videoFilter)
        videoFilter.set_property("caps",
                                 gst.Caps("video/x-raw-rgb, depth=24, bpp=24"))
        ghostPad = gst.GhostPad("sink", videoFilter.get_pad("sink"))
        videoBin.add_pad(ghostPad)
        videoSink = gst.element_factory_make("fakesink", "videosink")
        videoBin.add(videoSink)
        pad = videoSink.get_pad("sink")
        pad.add_buffer_probe(self.__onBufferProbe)
        gst.element_link_many(videoFilter, videoSink)
        self.player.set_property("video-sink", videoBin)

        self.bus = self.player.get_bus()
        self.bus.add_signal_watch()
        self.watchID = self.bus.connect("message", self.__onMessage)
        self.player.set_property("uri", "file://" + filename)
        self.player.set_state(gst.STATE_PAUSED)
        self.model = aModel
Ejemplo n.º 2
0
def init():
    global __player
    global __bus

    if __player:
        dispose()
        __player = None

    __player = Gst.ElementFactory.make("playbin", "player")
    __scaletempo = Gst.ElementFactory.make("scaletempo", "scaletempo")
    __scaletempo.sync_state_with_parent()

    __audiobin = Gst.Bin("audioline")
    __audiobin.add(__scaletempo)

    __audiosink = Gst.ElementFactory.make("autoaudiosink", "audiosink")
    __audiobin.add(__audiosink)

    __scaletempo.link(__audiosink)
    __pad = __scaletempo.get_static_pad("sink")
    __audiobin.add_pad(Gst.GhostPad("sink", __pad))

    __player.set_property("audio-sink", __audiobin)

    __bus = __player.get_bus()
    __bus.add_signal_watch()
    __bus.connect("message", __on_gst_message)

    cozy.filesystem_monitor.FilesystemMonitor().add_listener(
        __on_storage_changed)
Ejemplo n.º 3
0
 def __init__(self, name, elements ):
     super(EasyBin,self).__init__( name )
     for element in elements:
         self.add(element)
     for element,next in zip(elements,elements[1:]):
         element.link( next )
     for pad in elements[0].sinkpads:
         self.add_pad(
             Gst.GhostPad( pad.name, pad ),
         )
     for pad in elements[-1].srcpads:
         self.add_pad(
             Gst.GhostPad( pad.name, pad )
         )
     for element in elements:
         element.sync_state_with_parent( )
Ejemplo n.º 4
0
 def __init__(self, build_callback, **named ):
     super(RetryBin,self).__init__()
     self.build_callback = build_callback
     self.selector = utils.create_element(
         'input-selector',
         'selector',
     )
     self.add( self.selector )
     self.src_pad = Gst.GhostPad( 'src', self.selector.get_static_pad( 'src' ))
     self.add_pad( self.src_pad )
     if 'default_build' in named:
         default_build = named['default_build']
     else:
         def default_build(*args,**named):
             # This isn't very useful, as it doesn't properly use the 
             # real source's format to control the test source
             return utils.create_element('videotestsrc', pattern=2)
     self.default_src,self.default_sink = self.rebuild_source( default_build, False )
     element,sink = self.rebuild_source(self.build_callback)
     self.selector.set_property('active-pad',sink)
Ejemplo n.º 5
0
    def __init__(self):
        GstBase.PushSrc.__init__(self)
        self.src = SvgOverlaySource()
        self.queue = Gst.ElementFactory.make('queue')
        self.upload = Gst.ElementFactory.make('glupload')
        self.convert = Gst.ElementFactory.make('glcolorconvert')
        self.filter = Gst.ElementFactory.make('capsfilter')

        self.add(self.src)
        self.add(self.queue)
        self.add(self.upload)
        self.add(self.convert)
        self.add(self.filter)

        self.src.link_pads('src', self.queue, 'sink')
        self.queue.link_pads('src', self.upload, 'sink')
        self.upload.link_pads('src', self.convert, 'sink')
        self.convert.link_pads('src', self.filter, 'sink')
        pad = Gst.GhostPad('src', self.filter.get_static_pad('src'))
        self.add_pad(pad)
        self.filter.set_property(
            'caps',
            Gst.Caps.from_string('video/x-raw(memory:GLMemory),format=RGBA'))
Ejemplo n.º 6
0
    def __init__(self):
        Gst.Bin.__init__(self)
        self.shader = None
        self.vao = 0
        self.positions_buffer = 0
        self.texcoords_buffer = 0
        self.vbo_indices = 0
        self.u_transformation = 0
        self.glcontext = None
        self.glimagesink = Gst.ElementFactory.make('glimagesink')
        self.add(self.glimagesink)
        self.add_pad(
            Gst.GhostPad('sink', self.glimagesink.get_static_pad('sink')))
        self.glimagesink.connect('client-draw', self.on_draw)
        self.glimagesink.connect('client-reshape', self.on_reshape)
        self.glimagesink.get_static_pad('sink').add_probe(
            Gst.PadProbeType.EVENT_UPSTREAM, self.on_glimagesink_event)
        self.get_static_pad('sink').add_probe(
            Gst.PadProbeType.QUERY_DOWNSTREAM, self.on_downstream_query)
        self.render_thread = None
        self.cond = threading.Condition()
        self.rendering = False
        self.svg = None
        self.buffers = [None] * NUM_BUFFERS
        self.index = 0
        self.matrix = IDENTITY_MATRIX

        self.print_fps = int(os.environ.get('PRINT_FPS', '0'))
        self.incoming_frames = 0
        self.incoming_overlays = 0
        self.rendered_overlays = 0
        self.draws = 0
        self.fps_start = 0
        if self.print_fps:
            self.glimagesink.get_static_pad('sink').add_probe(
                Gst.PadProbeType.BUFFER, self.on_incoming_frame)
Ejemplo n.º 7
0
            auto_jump()


__player = Gst.ElementFactory.make("playbin", "player")
__scaletempo = Gst.ElementFactory.make("scaletempo", "scaletempo")
__scaletempo.sync_state_with_parent()

__audiobin = Gst.Bin("audioline")
__audiobin.add(__scaletempo)

__audiosink = Gst.ElementFactory.make("autoaudiosink", "audiosink")
__audiobin.add(__audiosink)

__scaletempo.link(__audiosink)
__pad = __scaletempo.get_static_pad("sink")
__audiobin.add_pad(Gst.GhostPad("sink", __pad))

__player.set_property("audio-sink", __audiobin)

__bus = __player.get_bus()
__bus.add_signal_watch()
__bus.connect("message", __on_gst_message)
__current_track = None
__listeners = []
__wait_to_seek = False


def get_gst_bus():
    """
    Get the global gst bus.
    :return: gst bus