示例#1
0
    def scale_button_release_cb(self, widget, event):
        # see seek.c:seek_cb
        real = self.seek_to
        gst.debug("value changed, perform seek to %r" % real)
        self.player.seek(real)
        # allow for a preroll
        # self.player.get_state(timeout=50*gst.MSECOND) # 50 ms

        # see seek.cstop_seek
        widget.disconnect(self.changed_id)
        self.changed_id = -1

        self.btn_live.set_sensitive(True)
        self.button.set_sensitive(True)
        if self.seek_timeout_id != -1:
            gobject.source_remove(self.seek_timeout_id)
            self.seek_timeout_id = -1
        else:
            gst.debug("released slider, setting back to playing")
            if self.was_playing:
                self.player.real_play()

        if self.update_id != -1:
            self.error("Had a previous update timeout id")
        else:
            self.update_id = gobject.timeout_add(self.UPDATE_INTERVAL, self.update_scale_cb)
示例#2
0
    def do_checksum_buffer(self, buf, checksum):
        self._discFrameCounter += 1

        # on first track ...
        if self._trackNumber == 1:
            # ... skip first 4 CD frames
            if self._discFrameCounter <= 4:
                gst.debug('skipping frame %d' % self._discFrameCounter)
                return checksum
            # ... on 5th frame, only use last value
            elif self._discFrameCounter == 5:
                values = struct.unpack("<I", buf[-4:])
                checksum += common.SAMPLES_PER_FRAME * 5 * values[0]
                checksum &= 0xFFFFFFFF
                return checksum

        # on last track, skip last 5 CD frames
        if self._trackNumber == self._trackCount:
            discFrameLength = self._sampleLength / common.SAMPLES_PER_FRAME
            if self._discFrameCounter > discFrameLength - 5:
                self.debug('skipping frame %d', self._discFrameCounter)
                return checksum

        values = struct.unpack("<%dI" % (len(buf) / 4), buf)
        for i, value in enumerate(values):
            # self._bytes is updated after do_checksum_buffer
            checksum += (self._bytes / 4 + i + 1) * value
            checksum &= 0xFFFFFFFF
            # offset = self._bytes / 4 + i + 1
            # if offset % common.SAMPLES_PER_FRAME == 0:
            #   print 'frame %d, ends before %d, last value %08x, CRC %08x' % (
            #     offset / common.SAMPLES_PER_FRAME, offset, value, sum)

        return checksum
示例#3
0
    def _setup_pipeline(self, fpath):
        fpathnz = fpath.replace(' ', '_')
        gst.debug('_setup_pipeline: %r' % (fpath,))

        self.ppl = gst.Pipeline('D-%s' % fpathnz)

        src = gst.element_make_from_uri(gst.URI_SRC, fpath, 'src-%s' % fpathnz)
        if not src:
            gst.warning('No element to access: %r' % fpath)
            self._finish(AnalysisError('No element to access the URI.'))
            return False

        dbin = gst.element_factory_make('decodebin2', 'dbin')
        self._connect(dbin, 'new-decoded-pad', self._cb_new_decoded_pad)
        self._connect(dbin, 'no-more-pads', self._cb_no_more_pads)
        self._connect(dbin, 'unknown-type', self._cb_unknown_type)

        tfind = dbin.get_by_name('typefind')
        self._connect(tfind, 'have-type', self._cb_have_type)
        self._connect(tfind.get_pad('src'),
                      'notify::caps', self._cb_notify_caps_tfind)

        self.ppl.add(src, dbin)
        src.link(dbin)

        gst.debug('pipeline created')

        self.bus = self.ppl.get_bus()
        self._connect(self.bus, 'message', self._cb_bus_message)

        self.bus.add_signal_watch()

        return True
示例#4
0
    def queue_next(self,step=1):
        """
        Advances 1 position in queue.
        case player state:
          - playing: the new track will start playing
          - paused : the current track will be preserved. new track will be played
          only if user inputs 'next' or ['stop','play'].
          - stopped: the new track will not be played until client sends 'play'

        Return values:
          - If successful [200,positions_moved]
          - else: [error_code]
        """
        ans = [400]
        try:
            gst.debug('Will next_prev(%d)' % step)
            ok,moved = self.next_prev(step)
            gst.debug('next_prev(%d) returned (%f,%d)' % (step,ok,moved))
            if ok:
                ans = [200]
                ans.append(moved)
        except Exception as e:
            print e
            gst.error('Problem near queue_next()')
        return ans
示例#5
0
    def testPendingLink(self):
        a = Action()
        p = Pipeline()
        src = common.FakeGnlFactory()
        src.addOutputStream(VideoStream(gst.Caps("video/x-raw-yuv"),
                                        pad_name="src"))
        sink = common.FakeSinkFactory()
        sink.addInputStream(MultimediaStream(gst.Caps("any"),
                                             pad_name="sink"))

        # set the link, it will be activated once the pad is added
        a.setLink(src, sink)
        # Let's see if the link is present
        self.assertEquals(a._links, [(src, sink, None, None)])

        p.setAction(a)

        gst.debug("about to activate action")
        a.activate()
        # only the producer and the consumer are created, the other elements are
        # created dinamically
        self.assertEquals(len(list(p._pipeline.elements())), 2)

        p.setState(STATE_PLAYING)
        time.sleep(1)
        # and make sure that all other elements were created (4)
        # FIXME  if it's failing here, run the test a few times trying to raise
        # the time.sleep() above, it may just be racy...
        self.assertEquals(len(list(p._pipeline.elements())), 4)

        a.deactivate()
        p.setState(STATE_NULL)
        self.assertEquals(len(list(p._pipeline.elements())), 0)
        p.release()
示例#6
0
    def do_checksum_buffer(self, buf, checksum):
        self._discFrameCounter += 1

        # on first track ...
        if self._trackNumber == 1:
            # ... skip first 4 CD frames
            if self._discFrameCounter <= 4:
                gst.debug('skipping frame %d' % self._discFrameCounter)
                return checksum
            # ... on 5th frame, only use last value
            elif self._discFrameCounter == 5:
                values = struct.unpack("<I", buf[-4:])
                checksum += common.SAMPLES_PER_FRAME * 5 * values[0]
                checksum &= 0xFFFFFFFF
                return checksum

        # on last track, skip last 5 CD frames
        if self._trackNumber == self._trackCount:
            discFrameLength = self._sampleLength / common.SAMPLES_PER_FRAME
            if self._discFrameCounter > discFrameLength - 5:
                self.debug('skipping frame %d', self._discFrameCounter)
                return checksum

        values = struct.unpack("<%dI" % (len(buf) / 4), buf)
        for i, value in enumerate(values):
            # self._bytes is updated after do_checksum_buffer
            checksum += (self._bytes / 4 + i + 1) * value
            checksum &= 0xFFFFFFFF
            # offset = self._bytes / 4 + i + 1
            # if offset % common.SAMPLES_PER_FRAME == 0:
            #   print 'frame %d, ends before %d, last value %08x, CRC %08x' % (
            #     offset / common.SAMPLES_PER_FRAME, offset, value, sum)

        return checksum
示例#7
0
 def scale_value_changed_cb(self, scale):
     # see seek.c:seek_cb
     real = long(scale.get_value() * self.p_duration / 100) # in ns
     gst.debug('value changed, perform seek to %r' % real)
     self.player.seek(real)
     # allow for a preroll
     self.player.get_state(timeout=50*gst.MSECOND) # 50 ms
示例#8
0
    def _setupPlayer(self):
        gst.debug("Creating initial SmartCaptureBin")
        # figure out adev
        probe = self.pitivi.deviceprobe
        if probe is not None and len(probe.getAudioSourceDevices()):
            adev = probe.getAudioSourceDevices()[0]
        else:
            adev = None
        self._changeSelectedAudio(adev)

        if len(probe.getVideoSourceDevices()):
            vdev = probe.getVideoSourceDevices()[0]
        else:
            vdev = None
        self._changeSelectedVideo(vdev)

        if probe is not None:
            probe.connect("device-added", self._deviceAddedCb)
            probe.connect("device-removed", self._deviceRemovedCb)

        if hasattr(self, "player"):
            self.player.set_state(gst.STATE_NULL)
        self.player = SmartCaptureBin(audiodevice=adev,
                                      videodevice=vdev)
        self.setSinks()
        # FIXME : check for state change failures
        self.player.set_state(gst.STATE_PLAYING)
示例#9
0
    def status(self):
        """
        Get player playing/!playing

        If metadata is available, then the answer will include it.

        Return value:
          - If successful: [200,True/False,metadata]
          - else: [err_code]
        """
        ans = [200]
        try:
            gst.debug(self.queue.__str__())
            playing = self.is_playing()
            current = self.player.get_current()
            tags    = self.queue_item_by_uri(current)
            if not tags:
                # Failed to find tags or search is still
                # in progress
                tags = {}
            ans.append([playing,current,tags])
        except Exception as e:
            print e
            gst.error('Problem near status()')
            ans = [400]
        return ans
示例#10
0
 def scale_value_changed_cb(self, scale):
     # see seek.c:seek_cb
     real = long(scale.get_value() * self.p_duration / 100)  # in ns
     gst.debug('value changed, perform seek to %r' % real)
     self.player.seek(real)
     # allow for a preroll
     self.player.get_state(timeout=50 * gst.MSECOND)  # 50 ms
示例#11
0
    def _new_gnl_source(self, location, start):
        """
        Creates a new GnlSource containing an AudioSource with the following
        properties correctly set:
        _ volume level
        _ priority
        _ duration
        The start position MUST be given
        """
        if not self._levels[location]:
            return None
        self.debug("Creating new GnlSource at %s for %s" % (gst.TIME_ARGS(start), location))
        idx = self._files.index(location) + self._loopsdone * len(self._files)
        rms, mixin, mixout, duration = self._levels[location]
        gnls = gst.element_factory_make("gnlsource", "source-%d-%s" % (idx, location))
        src = sources.AudioSource(location)
        gnls.add(src)

        # set volume
        level = 1.0
        if rms > self._target_rms:
            level = self._target_rms / rms
            gst.debug('setting volume of %f' % level)
        else:
            gst.debug('not going to go above 1.0 level')
        src.set_volume(level)

        # set proper position/duration/priority in composition
        gnls.props.priority = (2 * self._loopsdone) + 1 + (idx % 2)
        gnls.props.start = long(start)
        gnls.props.duration = long(duration)
        gnls.props.media_duration = long(duration)
        gnls.props.media_start = long(0)

        return gnls
示例#12
0
	def scale_button_release_cb(self, widget, event):
		# see seek.c:seek_cb
		real = self.seek_to
		gst.debug('value changed, perform seek to %r' % real)
		self.player.seek(real)
		# allow for a preroll
		#self.player.get_state(timeout=50*gst.MSECOND) # 50 ms

		# see seek.cstop_seek
		widget.disconnect(self.changed_id)
		self.changed_id = -1

		self.btn_live.set_sensitive(True)
		self.button.set_sensitive(True)
		if self.seek_timeout_id != -1:
			gobject.source_remove(self.seek_timeout_id)
			self.seek_timeout_id = -1
		else:
			gst.debug('released slider, setting back to playing')
			if self.was_playing:
				self.player.real_play()

		if self.update_id != -1:
			self.error('Had a previous update timeout id')
		else:
			self.update_id = gobject.timeout_add(self.UPDATE_INTERVAL,
				self.update_scale_cb)
示例#13
0
文件: leveller.py 项目: thomasvs/dad
    def clean(self):
        """
        Clean up the leveller.
        After calling this, the object cannot be used anymore.
        """
        # clean ourselves up completely
        self.stop()

        self.remove(self._source)
        self.remove(self._level)
        self.remove(self._fakesink)
        gst.debug("Emptied myself")
        utils.gc_collect('Leveller.clean() cleaned up source')
        self.debug("source refcount: %d" % self._source.__grefcount__)

        self._source = None
        self._fakesink = None
        self._level = None

        self.rmsdBs = None
        self.peakdBs = None
        self.decaydBs = None

        utils.gc_collect('Leveller.clean() done')
        self.debug("clean done, refcount now %d" % self.__grefcount__)
示例#14
0
 def _cb_bus_message(self, bus, message):
     mtype = message.type
     if mtype == gst.MESSAGE_EOS:
         # forcing finish now...
         gst.debug('EOS')
         reactor.callLater(0.0, self._finish)
     elif mtype == gst.MESSAGE_ERROR:
         error, desc = message.parse_error()
         if self.error_details:
             reactor.callLater(0.0, self._finish,
                               AnalysisError('%s (%s)' % (error.message,
                                                          desc)))
         else:
             reactor.callLater(0.0, self._finish,
                               AnalysisError('%s' % (error.message,)))
     elif mtype == gst.MESSAGE_TAG:
         self._process_tags(message)
     ## elif mtype == gst.MESSAGE_STATE_CHANGED:
     ##     pass
     ## elif mtype == gst.MESSAGE_WARNING:
     ##     pass
     ## elif mtype == gst.MESSAGE_ELEMENT:
     ##     pass
     else:
         gst.log('bus message: %s (%s)' % (mtype, message.src))
示例#15
0
 def is_in_state(self, state):
     gst.debug("checking if player is in state %r" % state)
     cur, pen, final = self.get_state(timeout=0)
     gst.debug("checked if player is in state %r" % state)
     if pen == gst.STATE_VOID_PENDING and cure == state:
         return True
     return False
示例#16
0
    def getDynamicLinks(self, producer, stream):
        links = Action.getDynamicLinks(self, producer, stream)
        consumer = common.FakeSinkFactory()

        links.append((producer, consumer, stream, None))
        gst.debug("Returning link")
        return links
示例#17
0
 def gctrack(self):
     # store all gst objects in the gc in a tracking dict
     # call before doing any allocation in your test, from setUp
     gst.debug('tracking gc GstObjects for types %r' % self._types)
     self.gccollect()
     self._tracked = {}
     for c in self._types:
         self._tracked[c] = [o for o in gc.get_objects() if isinstance(o, c)]
示例#18
0
 def setUp(self):
     TestCase.setUp(self)
     stream = AudioStream(gst.Caps("audio/x-raw-int"))
     self.factory = StubFactory()
     gst.debug("%r" % self.factory.duration)
     self.factory.addOutputStream(stream)
     self.track_object = SourceTrackObject(self.factory, stream)
     self.monitor = TrackSignalMonitor(self.track_object)
示例#19
0
    def createPipeline(self):
        if self._encodeVideo == False and self._encodeAudio == False:
            warning("NO audio and NO video ??")
            return None

        if (self._encodeVideo and self._encodeAudio) and not self._muxerFact:
            warning("NO muxer but we have two tracks ??")
            return None

        p = gst.Pipeline()

        # muxer and filesink
        if self._muxerFact:
            self._muxer = gst.element_factory_make(self._muxerFact, "muxer")
        else:
            self._muxer = gst.element_factory_make("identity", "muxer")
        filesink = gst.element_factory_make("filesink")
        filesink.props.location = self._outPath
        p.add(self._muxer, filesink)
        self._muxer.link(filesink)

        if self._encodeAudio:
            self._audioSource = make_audio_test_source(duration=self._mediaDuration)
            enc = gst.element_factory_make(self._audioFact)
            self._audioEncoder = gst.element_factory_make("audioresample")
            aconv = gst.element_factory_make("audioconvert")
            vq = gst.element_factory_make("queue", "audioqueue")
            p.add(self._audioSource, self._audioEncoder, aconv, enc, vq)
            gst.element_link_many(self._audioEncoder, aconv, enc, vq)
            cptpad = self._muxer.get_compatible_pad(vq.get_pad("src"),
                                                    enc.get_pad("src").get_caps())
            if cptpad == None:
                self.validateStep("muxer-can-use-encoders", False)
                return None
            gst.debug("Using pad %r for audio encoder" % cptpad)
            vq.get_pad("src").link(cptpad)
            self._audioSource.connect("pad-added",
                                      self._audioSourcePadAdded)

        if self._encodeVideo:
            self._videoSource = make_video_test_source(duration=self._mediaDuration)
            enc = gst.element_factory_make(self._videoFact)
            self._videoEncoder = gst.element_factory_make("ffmpegcolorspace")
            vq = gst.element_factory_make("queue", "videoqueue")
            p.add(self._videoSource, self._videoEncoder, enc, vq)
            gst.element_link_many(self._videoEncoder, enc, vq)
            cptpad = self._muxer.get_compatible_pad(vq.get_pad("src"),
                                                    enc.get_pad("src").get_caps())
            if cptpad == None:
                self.validateStep("muxer-can-use-encoders", False)
                return None
            gst.debug("Using pad %r for video encoder" % cptpad)
            vq.get_pad("src").link(cptpad)
            self._videoSource.connect("pad-added",
                                      self._videoSourcePadAdded)

        self.validateStep("muxer-can-use-encoders")
        return p
示例#20
0
 def setUp(self):
     TestCase.setUp(self)
     gst.debug("start")
     self.pipeline = Pipeline()
     self.monitor = SignalMonitor(self.pipeline, 'action-added',
                                  'action-removed', 'factory-added',
                                  'factory-removed', 'state-changed')
     self.assertEquals(self.monitor.action_added_count, 0)
     self.assertEquals(self.monitor.action_added_collect, [])
示例#21
0
文件: leveller.py 项目: thomasvs/dad
    def _source_done_cb(self, source, reason):
        gst.debug("done, reason %s" % reason)
        # we ignore eos as a reason here because we wait for pipeline EOS
        # in do_handle_message
        if reason == sources.EOS:
            return

        # any other reason gets passed through
        self.emit('done', reason)
示例#22
0
 def _changeSelectedCombo(self, combo, device):
     gst.debug("device %r" % device)
     model = combo.get_model()
     idx = 0
     for name, dev in model:
         if dev == device:
             break
         idx += 1
     combo.set_active(idx)
示例#23
0
 def stop(self):
     """
     Stop the leveller, freeing all resources.
     Call after the leveller emitted 'done' to clean up.
     """
     gst.debug("Setting to NULL")
     self.set_state(gst.STATE_NULL)
     gst.debug("Set to NULL")
     utils.gc_collect('Leveller.stop()')
示例#24
0
 def setUp(self):
     TestCase.setUp(self)
     gst.debug("start")
     self.pipeline = Pipeline()
     self.monitor = SignalMonitor(self.pipeline, 'action-added',
                                  'action-removed', 'factory-added',
                                  'factory-removed', 'state-changed')
     self.assertEquals(self.monitor.action_added_count, 0)
     self.assertEquals(self.monitor.action_added_collect, [])
示例#25
0
文件: leveller.py 项目: thomasvs/dad
 def stop(self):
     """
     Stop the leveller.
     Call this after the leveller emitted 'done'.
     Calls clean.
     """
     gst.debug("Setting to NULL")
     self.set_state(gst.STATE_NULL)
     self.debug("Set to NULL, refcount now %d" % self.__grefcount__)
     utils.gc_collect('Leveller.stop()')
示例#26
0
 def _check_prerolled(self):
     gst.debug("_check_prerolled: index: scan %d, play %d" % (
         self._scani, self._playi))
     if not self._prerolled and self._scani > self._playi + 1:
         self._prerolled = True
         # add initial sources here
         self._append_file(self._files[0])
         self._append_file(self._files[1])
         self.debug("now prerolled and ready to play")
         self.emit('prerolled')
示例#27
0
 def _check_prerolled(self):
     gst.debug("_check_prerolled: index: scan %d, play %d" %
               (self._scani, self._playi))
     if not self._prerolled and self._scani > self._playi + 1:
         self._prerolled = True
         # add initial sources here
         self._append_file(self._files[0])
         self._append_file(self._files[1])
         self.debug("now prerolled and ready to play")
         self.emit('prerolled')
示例#28
0
 def gccollect(self):
     # run the garbage collector
     ret = 0
     gst.debug('garbage collecting')
     while True:
         c = gc.collect()
         ret += c
         if c == 0: break
     gst.debug('done garbage collecting, %d objects' % ret)
     return ret
示例#29
0
 def gctrack(self):
     # store all gst objects in the gc in a tracking dict
     # call before doing any allocation in your test, from setUp
     gst.debug('tracking gc GstObjects for types %r' % self._types)
     self.gccollect()
     self._tracked = {}
     for c in self._types:
         self._tracked[c] = [
             o for o in gc.get_objects() if isinstance(o, c)
         ]
示例#30
0
 def gccollect(self):
     # run the garbage collector
     ret = 0
     gst.debug('garbage collecting')
     while True:
         c = gc.collect()
         ret += c
         if c == 0: break
     gst.debug('done garbage collecting, %d objects' % ret)
     return ret
示例#31
0
    def _new_decoded_pad_cb(self, dbin, pad, is_last):
        gst.debug("new decoded pad: pad %r [%s]" % (pad, pad.get_caps().to_string()))
        if not "audio" in pad.get_caps().to_string() or self._srcpad:
            return

        gst.debug("linking pad %r to audioconvert" % pad)
        pad.link(self.audioconvert.get_pad("sink"))

        self._srcpad = gst.GhostPad("src", self.volume.get_pad("src"))
        self._srcpad.set_active(True)
        self.add_pad(self._srcpad)
示例#32
0
 def _vdevComboChangedCb(self, widget):
     row = widget.get_model()[widget.get_active()]
     if len(row) < 2:
         return
     dev = row[1]
     gst.debug("device %r" % dev)
     if dev == self._videodev:
         return
     self._changeSelectedVideo(dev)
     if not hasattr(self, "player"):
         return
     CallbackThread(self._resetPlayer).start()
示例#33
0
    def gcverify(self):
        # verify no new gst objects got added to the gc
        # call after doing all cleanup in your test, from tearDown
        gst.debug('verifying gc GstObjects for types %r' % self._types)
        new = []
        for c in self._types:
            objs = [o for o in gc.get_objects() if isinstance(o, c)]
            new.extend([o for o in objs if o not in self._tracked[c]])

        self.failIf(new, new)
        #self.failIf(new, ["%r:%d" % (type(o), id(o)) for o in new])
        del self._tracked
    def setSinks(self, uri):
        gst.debug("SmartStreamBin player created")
        self.player = SmartStreamBin(uri)
        sink = SinkBin()
        sink.connectSink(self.player, self.player.is_video, self.player.is_audio)
        self.player.set_state(gst.STATE_PLAYING)


        bus = self.player.get_bus()
        bus.add_signal_watch()
        bus.enable_sync_message_emission()
        bus.connect('sync-message::element', self.on_sync_message)
示例#35
0
    def gcverify(self):
        # verify no new gst objects got added to the gc
        # call after doing all cleanup in your test, from tearDown
        gst.debug('verifying gc GstObjects for types %r' % self._types)
        new = []
        for c in self._types:
            objs = [o for o in gc.get_objects() if isinstance(o, c)]
            new.extend([o for o in objs if o not in self._tracked[c]])

        self.failIf(new, new)
        #self.failIf(new, ["%r:%d" % (type(o), id(o)) for o in new])
        del self._tracked
示例#36
0
 def setUp(self):
     """
     Override me by chaining up to me at the start of your setUp.
     """
     # Using private variables is BAD ! this variable changed name in
     # python 2.5
     try:
         methodName = self.__testMethodName
     except:
         methodName = self._testMethodName
     gst.debug('%s.%s' % (self.__class__.__name__, methodName))
     self.gctrack()
示例#37
0
 def _resetPlayer(self):
     ## call me in another thread !
     gst.debug("Setting previous to NULL")
     self.player.set_state(gst.STATE_NULL)
     gst.debug("Creating new SmartCaptureBin(%r,%r)" % (self._audiodev, self._videodev))
     self.player = SmartCaptureBin(audiodevice = self._audiodev,
                                   videodevice = self._videodev)
     gst.debug("Calling setSinks()")
     self.setSinks()
     gst.debug("Finally setting to PLAYING...")
     res = self.player.set_state(gst.STATE_PLAYING)
     gst.debug("... which returned %r" % res)
示例#38
0
 def setUp(self):
     """
     Override me by chaining up to me at the start of your setUp.
     """
     # Using private variables is BAD ! this variable changed name in
     # python 2.5
     try:
         methodName = self.__testMethodName
     except:
         methodName = self._testMethodName
     gst.debug('%s.%s' % (self.__class__.__name__, methodName))
     self.gctrack()
示例#39
0
    def setSinks(self, uri):
        gst.debug("SmartStreamBin player created")
        self.player = SmartStreamBin(uri)
        sink = SinkBin()
        sink.connectSink(self.player, self.player.is_video, self.player.is_audio)
        self.player.set_state(gst.STATE_PLAYING)


        bus = self.player.get_bus()
        bus.add_signal_watch()
        bus.enable_sync_message_emission()
        bus.connect('sync-message::element', self.on_sync_message)
示例#40
0
 def stop(self):
     """
     Stops playback.
     Wrapper for player.stop()
     """
     ans = [200]
     try:
         gst.debug('Will stop player')
         self.player.stop()
     except:
         ans = [400]
     return ans
示例#41
0
 def tearDown(self):
     """
     Override me by chaining up to me at the end of your tearDown.
     """
     # Using private variables is BAD ! this variable changed name in
     # python 2.5
     try:
         methodName = self.__testMethodName
     except:
         methodName = self._testMethodName
     gst.debug('%s.%s' % (self.__class__.__name__, methodName))
     self.gccollect()
     self.gcverify()
示例#42
0
 def seek(self, location):
     """
     @param location: time to seek to, in nanoseconds
     """
     gst.debug("seeking to %r" % location)
     event = gst.event_new_seek(
         1.0, gst.FORMAT_TIME, gst.SEEK_FLAG_FLUSH | gst.SEEK_FLAG_ACCURATE,
         gst.SEEK_TYPE_SET, location, gst.SEEK_TYPE_NONE, 0)
     res = self.player.send_event(event)
     if res:
         gst.info("setting new stream time to 0")
         self.player.set_new_stream_time(0L)
     else:
         gst.error("seek to %r failed" % location)
示例#43
0
    def scale_button_press_cb(self, widget, event):
        # see seek.c:start_seek
        gst.debug('starting seek')
        self.player.pause()

        # don't timeout-update position during seek
        if self.update_id != -1:
            gobject.source_remove(self.update_id)
            self.update_id = -1

        # make sure we get changed notifies
        if self.changed_id == -1:
            self.changed_id = self.hscale.connect('value-changed',
                self.scale_value_changed_cb)
    def do_recording(self, w):
        if self.record_btn.get_label() == "Start Recording":
            gst.debug("recording started")
            self.filepath = 'file://' + tempfile.mktemp(
                suffix=".ogg", prefix="pitivi-webcam-capture-")
            self.player.record(self.filepath, ExportSettings())
            self.record_btn.set_label("Stop Recording")
            self.player.set_state(gst.STATE_PLAYING)

        else:
            gst.debug("recording stopped")
            self.player.stopRecording()
            # FIXME : use the generic way for adding a file
            self.sourcefactories.addUris([self.filepath])
            self.player.set_state(gst.STATE_PLAYING)
            self.record_btn.set_label("Start Recording")
示例#45
0
 def _deviceRemovedCb(self, probe, device):
     gst.debug("device %r went away" % device)
     if self._audiodev == device:
         devs = self.pitivi.deviceprobe.getAudioSourceDevices()
         if len(devs):
             self._changeSelectedAudio(devs[0])
         else:
             self._audiodev = None
     elif self._videodev == device:
         devs = self.pitivi.deviceprobe.getVideoSourceDevices()
         if len(devs):
             self._changeSelectedVideo(devs[0])
         else:
             self._videodev = None
     self._updateAudioCombo()
     self._updateVideoCombo()
示例#46
0
    def scale_button_release_cb(self, widget, event):
        # see seek.cstop_seek
        widget.disconnect(self.changed_id)
        self.changed_id = -1

        if self.seek_timeout_id != -1:
            gobject.source_remove(self.seek_timeout_id)
            self.seek_timeout_id = -1
        else:
            gst.debug('released slider, setting back to playing')
            self.player.play()

        if self.update_id != -1:
            self.error('Had a previous update timeout id')
        else:
            self.update_id = gobject.timeout_add(self.UPDATE_INTERVAL,
                self.update_scale_cb)
示例#47
0
def debug(*listToPrint):
    """
	Global debug function to redirect all the debugging output from the other
	methods.
	
	Parameters:
		*listToPrint -- list of elements to append to the debugging output.
	"""
    #HACK: we can't import gst at the top of Globals.py because
    #if we do, gstreamer will get to the sys.args and print it's own
    #message instead of ours. This will be fixed once we can use
    #GOption when we depend on pygobject 2.12.
    import gst

    message = " ".join([str(x) for x in listToPrint])

    if DEBUG_STDOUT:
        print(message)
    if DEBUG_GST:
        gst.debug(message)
def output_plugin(plugin, indent=0):
    print "PLUGIN", plugin.get_name()
    version = plugin.get_version()
    
    elements = {}
    gst.debug('getting features for plugin %s' % plugin.get_name())
    registry = gst.registry_get_default()
    features = registry.get_feature_list_by_plugin(plugin.get_name())
    gst.debug('plugin %s has %d features' % (plugin.get_name(), len(features)))
    for feature in features:
        if isinstance(feature, gst.ElementFactory):
            elements[feature.get_name()] = feature
    #gst.debug("got features")
        
    elementsoutput = []
    keys = elements.keys()
    keys.sort()
    for name in keys:
        feature = elements[name]
        elementsoutput.append(output_element_factory(feature, indent + 2))

    filename = plugin.get_filename()
    basename = filename
    if basename:
        basename = os.path.basename(basename)
    d = {
        'name':        xmlencode(plugin.get_name()),
        'description': xmlencode(plugin.get_description()),
        'filename':    filename,
        'basename':    basename,
        'version':     version,
        'license':     xmlencode(plugin.get_license()),
        'source':      xmlencode(plugin.get_source()),
        'package':     xmlencode(plugin.get_package()),
        'origin':      xmlencode(plugin.get_origin()),
        'elements': "\n".join(elementsoutput),
    }
    block = PLUGIN_TEMPLATE % d
    
    offset = get_offset(indent)
    return offset + ("\n" + offset).join(block.split("\n"))
示例#49
0
    def live_pipeline(self, w=None):

        if self.player:
            self.player.set_state(gst.STATE_NULL)

        uri = self.uri.get_text()

        if uri != None :

            if gst.uri_is_valid (uri) is False:
                self.status.set_label("Invalid URI. Please verify.")
                gst.debug("Invalid URI")
                return
            if gst.uri_protocol_is_supported(gst.URI_SRC,
                                             uri.split('://')[0]):
                self.setSinks(uri)
                self.player.set_state(gst.STATE_PLAYING)
                self.status.push(self.status_id, "")
            else:
                self.status.set_label("Unsupported Protocol. Please verify the URI.")
                gst.debug("Unsupported Protocol")
示例#50
0
    def capture_pipeline(self, w=None):

        uri = self.uri.get_text()
        if self.capture_btn.get_label() == "Capture":
            if self.player is False and gst.uri_protocol_is_supported(gst.URI_SRC, uri.split('://')[0]) is False :
                self.status.set_label("Unsupported Protocol. Please verify the URI.")
                return
            elif self.player is False:
                self.player.set_state(gst.STATE_NULL)
                self.setSinks(uri)


            gst.debug("recording started")
            self.filepath = 'file://'+tempfile.mktemp()+'.ogg'
            self.player.record(self.filepath, ExportSettings())
            self.capture_btn.set_label("Stop")


        else:
            gst.debug("recording stopped")
            self.player.stopRecording()
            self.sourcefactories.sourcelist.addUris([self.filepath])
            self.capture_btn.set_label("Capture")
示例#51
0
    def _new_gnl_source(self, location, start):
        """
        Creates a new GnlSource containing an AudioSource with the following
        properties correctly set:
        _ volume level
        _ priority
        _ duration
        The start position MUST be given
        """
        if not self._levels[location]:
            return None
        self.debug("Creating new GnlSource at %s for %s" %
                   (gst.TIME_ARGS(start), location))
        idx = self._files.index(location) + self._loopsdone * len(self._files)
        rms, mixin, mixout, duration = self._levels[location]
        gnls = gst.element_factory_make("gnlsource",
                                        "source-%d-%s" % (idx, location))
        src = sources.AudioSource(location)
        gnls.add(src)

        # set volume
        level = 1.0
        if rms > self._target_rms:
            level = self._target_rms / rms
            gst.debug('setting volume of %f' % level)
        else:
            gst.debug('not going to go above 1.0 level')
        src.set_volume(level)

        # set proper position/duration/priority in composition
        gnls.props.priority = (2 * self._loopsdone) + 1 + (idx % 2)
        gnls.props.start = long(start)
        gnls.props.duration = long(duration)
        gnls.props.media_duration = long(duration)
        gnls.props.media_start = long(0)

        return gnls
def main():
    if len(sys.argv) == 1:
        sys.stderr.write("Please specify a source module to inspect")
        sys.exit(1)
    source = sys.argv[1]

    if len(sys.argv) > 2:
        os.chdir(sys.argv[2])

    registry = gst.registry_get_default()
    all = registry.get_plugin_list()
    for plugin in all:
        gst.debug("inspecting plugin %s from source %s" % (
            plugin.get_name(), plugin.get_source()))
        # this skips gstcoreelements, with bin and pipeline
        if plugin.get_filename() is None:
            continue
        if plugin.get_source() != source:
            continue

        filename = "plugin-%s.xml" % plugin.get_name()
        handle = open(filename, "w")
        handle.write(output_plugin(plugin))
        handle.close()