Exemple #1
0
    def test(self, method):
        print '%s:' % (method,),
        self.method = method
        
	print self.pipeline.get_state()
        self.pipeline.set_state(gst.STATE_PLAYING)
	print self.pipeline.get_state()

        if method == 'py':
            self.start = time.time()
            while self.pipeline.iterate():
                pass
        elif method == 'c':
            self.start = time.time()
            gobject.idle_add(self.pipeline.iterate)
            gst.main()
        #elif method == 'gst':
        #    self.start = time.time()
        #    gtk.idle_add(self.idle, self.pipeline)
        #    gtk.main()

        self.pipeline.set_state(gst.STATE_NULL)
Exemple #2
0
def main(args):
    if len(args) != 2:
        print 'Usage: %s file' % args[0]
        return -1

    filename = args[1]

    play = gst.play.Play()
    play.connect('stream-length', stream_length_cb)
    play.connect('have-video-size', have_video_size_cb)
    play.connect('found-tag', found_tag_cb)
    play.connect('eos', lambda p: gst.main_quit())

    # Setup source and sinks
    play.set_data_src(gst.element_factory_make('filesrc'))
    play.set_audio_sink(gst.element_factory_make('osssink'))
    play.set_video_sink(gst.element_factory_make('fakesink'))

    # Point location to our filename
    play.set_location(filename)

    # Start playing the stream
    play.set_state(gst.STATE_PLAYING)
    gst.main()
Exemple #3
0
def main(args):
    if len(args) != 2:
        print 'Usage: %s file' % args[0]
        return -1

    filename = args[1]
    
    play = gst.play.Play()
    play.connect('stream-length', stream_length_cb)
    play.connect('have-video-size', have_video_size_cb)
    play.connect('found-tag', found_tag_cb)
    play.connect('eos', lambda p: gst.main_quit())

    # Setup source and sinks
    play.set_data_src(gst.element_factory_make('filesrc'))
    play.set_audio_sink(gst.element_factory_make('osssink'))
    play.set_video_sink(gst.element_factory_make('fakesink'))

    # Point location to our filename
    play.set_location(filename)

    # Start playing the stream
    play.set_state(gst.STATE_PLAYING)
    gst.main()
	sink.set_property ("location", filename)
	
	return extractAudioTrack (device, track_number, sink, extra)
	
################################################################################
if __name__ == '__main__':
	import sys
	class L (operations.OperationListener):
		def on_metadata (self, event, metadata):
			print metadata
			
		def on_finished (self, event):
			if event.id == operations.ABORTED:
				print "Aborted!"
				
			if event.id == operations.ERROR:
				print "Error:", event.error
			gst.main_quit()
	
	l = L()
	f = fileToWav (sys.argv[1], sys.argv[2])
	#f = fileAudioMetadata (sys.argv[1])
	#f = extractAudioTrackFile ("/dev/cdrom", int(sys.argv[1]) + 1, sys.argv[2])
	f.listeners.append (l)
	f.start()
	l.finished = False
	gst.main()
#	while not l.finished:
#		pass
	
# We don't export the gvfs function if there is no gnome.vfs avail
try:
	import gnome.vfs
	def gvfs_to_wav (src_uri, sink_uri):
		"Converts a given source URI to a wav located in sink URI."
		src = gst.element_factory_make ("gnomevfssrc")
		src.set_property ("location", src_uri)
		handle = gnome.vfs.Handle (sink_uri)
		sink = gst.element_factory_make ("gnomevfssink")
		sink.set_property ("handle", handle)
		return source_to_wav (src, sink)
except:
	pass

################################################################################
if __name__ == '__main__':
	import sys
	class L (operations.OperationListener):
		def on_finished (self, event):
			gst.main_quit()
	
	l = L()
	f = file_to_wav (sys.argv[1], sys.argv[2])
	f.listeners.append (l)
	f.start()
	l.finished = False
	gst.main()
#	while not l.finished:
#		pass