def remoteSetUp(self): debug("%s", self.uuid) gst.log("%s" % self.uuid) # local variables # create the pipeline try: self.pipeline = self.createPipeline() except: exception("Error while creating pipeline") self.pipeline = None finally: self.validateStep("valid-pipeline", not self.pipeline == None) if self.pipeline == None: self.remoteStop() return factory = self.pipeline.get_factory() if factory is None: facname = "(no factory)" else: facname = factory.get_name() self._elements = [(self.pipeline.get_name(),facname, "")] #name,factoryname,parentname self._watchContainer(self.pipeline) # connect to bus self.bus = self.pipeline.get_bus() self.bus.add_signal_watch() self.bus.connect("message", self._busMessageHandlerCb) PythonDBusTest.remoteSetUp(self)
def remoteTearDown(self): if not PythonDBusTest.remoteTearDown(self): return False gst.log("Tearing Down") # unref pipeline and so forth if self._waitcb: gobject.source_remove(self._waitcb) self._waitcb = None if self.pipeline: self.pipeline.set_state(gst.STATE_NULL) self.validateStep("no-errors-seen", self._errors == []) if not self._errors == []: self.extraInfo("errors", self._errors) if not self._tags == {}: debug("Got tags %r", self._tags) for key, val in self._tags.iteritems(): if isinstance(val, int): # make sure that only values < 2**31 (MAX_INT32) are ints # TODO : this is gonna screw up MASSIVELY with values > 2**63 if val >= 2**31: self._tags[key] = long(val) # FIXME : if the value is a list, the dbus python bindings screw up # # For the time being we remove the values of type list, but this is REALLY # bad. listval = [x for x in self._tags.keys() if type(self._tags[x]) == list] if listval: warning("Removing this from the taglist since they're list:%r", listval) for val in listval: del self._tags[val] self.extraInfo("tags", dbus.Dictionary(self._tags, signature="sv")) if not self._elements == []: self.extraInfo("elements-used", self._elements) return True
def _level_cb(self, element, time, channel, rmsdB, peakdB, decaydB): # rms is being signalled in dB # FIXME: maybe level should have a way of signalling actual values # signals are received in order, so I should get each channel one # by one if time > self._lasttime and self._lasttime > 0: # we have a new time point, so calculate stuff for the old block meansquaresum = 0.0 for i in self._rmsdB.keys(): meansquaresum += math.pow(10, self._rmsdB[i] / 10.0) # average over channels meansquaresum /= len(self._rmsdB.keys()) try: rmsdBstr = str(10 * math.log10(meansquaresum)) except OverflowError: rmsdBstr = "(-inf)" gst.log("meansquaresum %f (%s dB)" % (meansquaresum, rmsdBstr)) # update values self._peaksdB.append((self._lasttime, peakdB)) self._meansquaresums.append((self._lasttime, meansquaresum)) self._rmsdB = {} self._peakdB = 0.0 # store the current values for later processing gst.log("time %s, channel %d, rmsdB %f" % (gst.TIME_ARGS(time), channel, rmsdB)) self._lasttime = time self._rmsdB[channel] = rmsdB if peakdB > self._peakdB: self._peakdB = peakdB
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))
def _new_buffer_cb(self, sink): buf = sink.emit('pull-buffer') gst.log('received new buffer at offset %r with length %r' % (buf.offset, buf.size)) if self._first is None: self._first = buf.offset self.debug('first sample is sample offset %r', self._first) self._last = buf assert len(buf) % 4 == 0, "buffer is not a multiple of 4 bytes" # FIXME: gst-python 0.10.14.1 doesn't have adapter_peek/_take wrapped # see http://bugzilla.gnome.org/show_bug.cgi?id=576505 self._adapter.push(buf) while self._adapter.available() >= common.BYTES_PER_FRAME: # FIXME: in 0.10.14.1, take_buffer leaks a ref buf = self._adapter.take_buffer(common.BYTES_PER_FRAME) self._checksum = self.do_checksum_buffer(buf, self._checksum) self._bytes += len(buf) # update progress sample = self._first + self._bytes / 4 samplesDone = sample - self._sampleStart progress = float(samplesDone) / float((self._sampleLength)) # marshal to the main thread self.schedule(0, self.setProgress, progress)
def _new_buffer_cb(self, sink): buf = sink.emit('pull-buffer') gst.log('received new buffer at offset %r with length %r' % ( buf.offset, buf.size)) if self._first is None: self._first = buf.offset self.debug('first sample is sample offset %r', self._first) self._last = buf assert len(buf) % 4 == 0, "buffer is not a multiple of 4 bytes" # FIXME: gst-python 0.10.14.1 doesn't have adapter_peek/_take wrapped # see http://bugzilla.gnome.org/show_bug.cgi?id=576505 self._adapter.push(buf) while self._adapter.available() >= common.BYTES_PER_FRAME: # FIXME: in 0.10.14.1, take_buffer leaks a ref buf = self._adapter.take_buffer(common.BYTES_PER_FRAME) self._checksum = self.do_checksum_buffer(buf, self._checksum) self._bytes += len(buf) # update progress sample = self._first + self._bytes / 4 samplesDone = sample - self._sampleStart progress = float(samplesDone) / float((self._sampleLength)) # marshall to the main thread self.schedule(0, self.setProgress, progress)
def chainfunc(self, pad, buffer): gst.log("Passing buffer with ts %d" % (buffer.timestamp)) fft = numpy.frombuffer(buffer, numpy.complex128) fft = fft * self.transmission b = gst.Buffer(fft) b.set_caps(self.srcpad.get_caps()) b.timestamp = buffer.timestamp return self.srcpad.push(b)
def _noMorePadsCb(self, dbin): debug("no more pads") gst.log("no more pads") if len([stream for stream in self._streams if not stream.raw]): debug("we have non-raw streams, stopping") # FIXME : add post-checking self._analyzeDecodebin() self._validateStreams() gobject.idle_add(self.stop)
def playEpisode (self, view, episode): gst.info('Playing episode ' + episode.title) mrl = episode.getUri(self.getConnectionSpeed()) if mrl: gst.log('Playing uri ' + mrl) self.totem.action_set_mrl_and_play(mrl, None) #self.totem.action_remote(totem.REMOTE_COMMAND_ENQUEUE, mrl) #self.totem.action_remote(totem.REMOTE_COMMAND_PLAY, mrl) else: gst.error('No uri for episode ' + episode.title)
def chainfunc(self, pad, buffer): gst.log("Passing buffer with ts %d" % (buffer.timestamp)) fft = numpy.frombuffer(buffer, numpy.complex128) l = 2 * len(fft) - 2 data = numpy.fft.irfft(fft, l) b = gst.Buffer(data) b.set_caps(self.srcpad.get_caps()) b.timestamp = buffer.timestamp return self.srcpad.push(b)
def getConnectionSpeed(self): speed_map = [ 14400, 19200, 28800, 33600, 34400, 56000, 112000, 256000, 384000, 512000, 1536000, 10752000 ] speed_enum = self.gconf_client.get_int("/apps/totem/connection_speed") if speed_enum >= 0 and speed_enum < len(speed_map): speed_kbps = speed_map[speed_enum] / 1000 else: speed_kbps = 0 gst.log('Configured connection speed #%d: %d kbit/s' % (speed_enum, speed_kbps)) return speed_kbps
def remoteTest(self): # kickstart pipeline to initial state PythonDBusTest.remoteTest(self) debug("Setting pipeline to initial state %r", self.__pipeline_initial_state__) gst.log("Setting pipeline to initial state %r" % self.__pipeline_initial_state__) res = self.pipeline.set_state(self.__pipeline_initial_state__) debug("set_state returned %r", res) gst.log("set_state() returned %r" % res) self.validateStep("pipeline-change-state", not res == gst.STATE_CHANGE_FAILURE) if res == gst.STATE_CHANGE_FAILURE: warning("Setting pipeline to initial state failed, stopping test") gst.warning("State change failed, stopping") self.stop()
def make_property_widget(unused_element, prop, value=None): """ Creates a Widget for the given element property """ # FIXME : implement the case for flags type_name = gobject.type_name(prop.value_type.fundamental) if value == None: value = prop.default_value if (type_name == 'gchararray'): widget = gtk.Entry() widget.set_text(str(value)) elif (type_name in ['guint64', 'gint64', 'guint', 'gint', 'gfloat', 'gulong']): widget = gtk.SpinButton() if type_name == 'gint': widget.set_range(-(2**31), 2**31 - 1) elif type_name == 'guint': widget.set_range(0, 2**32 - 1) elif type_name == 'gint64': widget.set_range(-(2**63), 2**63 - 1) elif type_name in ['gulong', 'guint64']: widget.set_range(0, 2**64 - 1) elif type_name == 'gfloat': widget.set_range(0.0, 2**64 - 1) widget.set_digits(5) widget.set_value(float(value)) elif (type_name == 'gboolean'): widget = gtk.CheckButton() if value: widget.set_active(True) elif (type_name == 'GEnum'): model = gtk.ListStore(gobject.TYPE_STRING, prop.value_type) widget = gtk.ComboBox(model) cell = gtk.CellRendererText() widget.pack_start(cell, True) widget.add_attribute(cell, 'text', 0) idx = 0 for key, val in prop.enum_class.__enum_values__.iteritems(): gst.log("adding %s / %s" % (val.value_name, val)) model.append([val.value_name, val]) if val == value: selected = idx idx = idx + 1 widget.set_active(selected) else: widget = gtk.Label(type_name) widget.set_alignment(1.0, 0.5) if not prop.flags & gobject.PARAM_WRITABLE: widget.set_sensitive(False) return widget
def _finish(self, error=None): if self.done: return self.done = True gst.debug('finishing...') if self.bus: self.bus.remove_signal_watch() self.bus = None if self.toid: self.toid.cancel() self.toid = None for obj, sid in self.sids: obj.disconnect(sid) self.sids = [] if self.ppl: self.ppl.set_state(gst.STATE_NULL) if not error: # check if there's anything in the info, if so then add tags, # otherwise set result to the error if self.info.streams: self._set_tags() else: error = NotMediaFileError('No known media found.') d = self.d info = self.info self.ppl = None self.fakesink = None self.info = None self.streams = {} self.pending = [] self.all_pads = False self.fpath = None self.d = None # fire callback/errback with the 'result' if error: gst.debug('RESULT (err): %r (%r)' % (error, info)) reactor.callLater(0.0, d.errback, error) else: gst.log('RESULT (ok): %r' % info) reactor.callLater(0.0, d.callback, info)
def activate (self, totem_object): self.gconf_client = gconf.client_get_default () self.totem = totem_object self.view = ContentView() self.view.connect('play-episode', self.playEpisode) vbox = gtk.VBox() scrollwin = gtk.ScrolledWindow() scrollwin.add(self.view) scrollwin.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC) scrollwin.set_shadow_type(gtk.SHADOW_ETCHED_IN) vbox.pack_start(scrollwin, True, True) vbox.show_all () totem_object.add_sidebar_page ("bbc", _("BBC"), vbox) # connect to 'map' only after adding the sidebar page self.view.connect('map', self.mapped) gst.log('activated')
def do_set_caps(self, incaps, outcaps): # Enforce that the input rate has to be an integer multiple of the output rate rate_in = incaps[0]["rate"] rate_out = outcaps[0]["rate"] unit_size = self.do_get_unit_size(incaps) if not unit_size: return False if rate_out % rate_in: gst.log( "output rate is not an integer multiple of input rate. input rate = %d output rate = %d" % (rate_out, rate_in)) return False self.rate_in = rate_in self.rate_out = rate_out self.unit_size = unit_size return True
def do_transform_size(self, direction, caps, size, othercaps): self.cadence = self.rate_in / self.rate_out unit_size = self.do_get_unit_size(caps) if not unit_size: return False # Convert byte count to samples if size % unit_size: gst.log("buffer size %d is not a multiple of %d" % (size, unit_size)) return False size /= unit_size if direction == gst.PAD_SRC: # Compute samples required on the sink pad to # produce requested sample count on source pad # # size = # of samples requested on source pad # # cadence = # of input samples per output sample # # remainder = how many extra samples of input are # present on the sink pad othersize = size * self.cadence + self.remainder # FIXME: I think this is right, but I'm not sure... othersize *= unit_size return int(othersize) elif direction == gst.PAD_SINK: # Compute samples to be produced on source pad # from sample count available on sink pad # # size = # of samples available on sink pad # # cadence = # of input samples per output sample # # remainder = how many extra input samples have been # stored because the most recent input buffer # ended before a complete cycle if size >= self.cadence - self.remainder: othersize = (size + self.remainder) / self.cadence else: othersize = 0 othersize *= unit_size return int(othersize) else: raise ValueError(direction)
def get_genre(self, short_ref): # check if genre already exists if short_ref in self.genres: return self.genres[short_ref] # if not, create genre (and any parents which don't exist yet) lastslash_pos = short_ref.rfind('/') if lastslash_pos > 0: parent_ref = short_ref[0:lastslash_pos] gst.log('genre: ' + short_ref + ', parent_genre: ' + parent_ref) parent = self.get_genre(parent_ref) else: parent = None genre = Genre(short_ref, parent) self.genres[short_ref] = genre return genre
def run(leveller): gst.debug('leveller refcount on creation: %d' % leveller.__grefcount__) bus = leveller.get_bus() bus.add_signal_watch() done = False success = False gst.debug('leveller refcount before start: %d' % leveller.__grefcount__) utils.gc_collect('before start') leveller.start() gst.debug('leveller refcount after start: %d' % leveller.__grefcount__) utils.gc_collect('after start') while not done: # this call blocks until there is a message message = bus.poll(gst.MESSAGE_ANY, gst.SECOND) if message: gst.log("got message from poll: %s/%r" % (message.type, message)) else: gst.log("got NOTHING from poll") if message: if message.type == gst.MESSAGE_EOS: done = True success = True elif message.type == gst.MESSAGE_ERROR: done = True # message, if set, holds a ref to leveller, so we delete it here # to assure cleanup of leveller when we del it m = repr(message) del message utils.gc_collect('deleted message %s' % m) bus.remove_signal_watch() del bus utils.gc_collect('deleted bus') leveller.stop() return success
def __init__(self, pitivi): gst.log("Creating new WebcamManager Dialog") self.pitivi = pitivi GladeWindow.__init__(self) # Create gtk widget using glade model self.draw_window = self.widgets["draw_window"] self.draw_window.unset_flags(gtk.DOUBLE_BUFFERED) self.draw_window.unset_flags(gtk.SENSITIVE) self.record_btn = self.widgets["record_btn"] self.close_btn = self.widgets["close_btn"] self.close_btn.connect("clicked", self.close) self.record_btn.connect("clicked", self.threaded_recording) self.window.connect("destroy", self.close) self.record_btn = self.record_btn.get_children()[0] self.record_btn = self.record_btn.get_children()[0].get_children()[1] self.record_btn.set_label("Start Recording") self.sourcefactories = SourceList() self._audiodev = None self._videodev = None self._vdevcombo = self.widgets["videodev_combo"] self._vdevcombo.set_active(0) self._vdevcombo.set_model(gtk.ListStore(str, object)) self._vdevcombo.set_attributes(self._vdevcombo.child.get_cell_renderers()[0], text=0) self._adevcombo = self.widgets["audiodev_combo"] self._adevcombo.set_active(0) self._adevcombo.set_model(gtk.ListStore(str, object)) self._adevcombo.set_attributes(self._adevcombo.child.get_cell_renderers()[0], text=0) self._updateVideoCombo() self._updateAudioCombo() self.filepath = None self.sink = SinkBin() CallbackThread(self._setupPlayer).start()
def chainfunc(self, pad, buffer): # fixme: need to reset adapter when starting - see gstspectrum.c self.adapter.push(buffer) end_time = buffer.timestamp + buffer.duration gst.log("Got buffer with ts %d and length %d" % (buffer.timestamp, len(buffer))) l = 4096 bytes_num = l * 8 while self.adapter.available() >= bytes_num: time_till_end = int(self.adapter.available() / 8.0 / 44100 * gst.SECOND) data = numpy.frombuffer(self.adapter.peek(bytes_num)) fft = numpy.fft.rfft(data) # length of this array is l/2 + 1 b = gst.Buffer(fft) b.timestamp = end_time - time_till_end b.set_caps(self.srcpad.get_caps()) self.srcpad.push(b) self.adapter.flush(bytes_num) return gst.FLOW_OK
def OnCheckEncoders(self): """ List the available encoders installed on the computer. This code is not currently used, but is still here as it may be useful in the future. """ gstfeatures = gst.registry_get_default().get_feature_list(gst.ElementFactory) encoders = [] for feature in gstfeatures: if "Codec/Encoder/Audio" in feature.get_klass(): encoders.append(feature) gst.log(str(encoders)) # these encoders are not actually hooked up yet - we will most likely # need to use enc.get_short_name() to return the element to include in # the pipeline for enc in encoders: self.mixdownFormat.append_text(enc.get_longname())
def __init__(self, short_ref, parent_genre): self.short_ref = short_ref if short_ref in shortref_to_label_map: self.label = shortref_to_label_map[short_ref] else: self.label = _("Unknown: ") + short_ref if short_ref in shortref_to_sortrank_map: self.sort_rank = shortref_to_sortrank_map[short_ref] else: self.sort_rank = 99999 self.parent = parent_genre self.children = [] self.brands = [] if parent_genre is not None: parent_genre.add_child(self) gst.log('created genre ' + short_ref + ' = ' + self.label)
def __init__(self, instance): gst.log("Creating new ScreencastManager Dialog") self.app = instance # Create gtk widget using glade model glade_dir = os.path.dirname(os.path.abspath(__file__)) pool_ui = gtk.glade.XML( os.path.join(glade_dir, "screencast_manager.glade")) self.window = pool_ui.get_widget("screencast_window") self.close_btn = pool_ui.get_widget("btn_close") self.ok_btn = pool_ui.get_widget("btn_ok") self.screencast_btn = pool_ui.get_widget("btn_screencast") self.istanbul_btn = pool_ui.get_widget("btn_istanbul") self.close_btn.connect("clicked", self.close) self.ok_btn.connect("clicked", self.ok) self.istanbul_btn.connect("clicked", self.start_istanbul) self.screencast_btn.set_active(self.app.screencast) self.dbus_connect()
def do_set_caps(self, incaps, outcaps): # Enforce that the input rate has to be an integer multiple of the output rate rate_in = incaps[0]["rate"] rate_out = outcaps[0]["rate"] unit_size = self.do_get_unit_size(incaps) if not unit_size: return False if rate_in % rate_out: gst.log( "input rate is not an integer multiple of output rate. input rate = %d output rate = %d" % (rate_out, rate_in)) return False self.rate_in = rate_in self.rate_out = rate_out self.unit_size = unit_size if not incaps[0]["signed"]: self.data_type = numpy.uint32 elif incaps[0]["signed"]: self.data_type = numpy.int32 else: return False return True
def chainfunc(self, pad, buffer): # fixme: need to reset adapter when starting - see gstspectrum.c self.adapter.push(buffer) end_time = buffer.timestamp + buffer.duration gst.log("Got buffer with ts %d and length %d" % (buffer.timestamp, len(buffer))) l = 4096 bytes_num = l * 8 while self.adapter.available() >= bytes_num: time_till_end = int(self.adapter.available() / 8. / 44100 * gst.SECOND) data = numpy.frombuffer(self.adapter.peek(bytes_num)) fft = numpy.fft.rfft(data) # length of this array is l/2 + 1 b = gst.Buffer(fft) b.timestamp = end_time - time_till_end b.set_caps(self.srcpad.get_caps()) self.srcpad.push(b) self.adapter.flush(bytes_num) return gst.FLOW_OK
def do_transform_size(self, direction, caps, size, othercaps): self.cadence = self.rate_out / self.rate_in unit_size = self.do_get_unit_size(caps) if not unit_size: return False # Convert byte count to samples if size % unit_size: gst.log("buffer size %d is not a multiple of %d" % (size, unit_size)) return False size /= unit_size if direction == gst.PAD_SRC: # Compute samples required on the sink pad to # produce requested sample count on source pad # # size = # of samples requested on source pad # # cadence = # of output samples per input sample if size >= self.cadence: othersize = size / self.cadence else: othersize = 0 othersize *= unit_size return int(othersize) elif direction == gst.PAD_SINK: # Compute samples to be produced on source pad # from sample count available on sink pad # # size = # of samples available on sink pad # # cadence = # of output samples per input sample othersize = size * self.cadence othersize *= unit_size return int(othersize) else: raise ValueError(direction)
def __init__(self, instance): gst.log("Creating new ScreencastManager Dialog") self.app = instance # Create gtk widget using glade model if 'pitivi.exe' in __file__.lower(): glade_dir = LIBDIR + '\\pitivi.exe' else: glade_dir = os.path.dirname(os.path.abspath(__file__)) pool_ui = gtk.glade.XML(os.path.join(glade_dir, "screencast_manager.glade")) self.window = pool_ui.get_widget("screencast_window") self.close_btn = pool_ui.get_widget("btn_close") self.ok_btn = pool_ui.get_widget("btn_ok") self.screencast_btn = pool_ui.get_widget("btn_screencast") self.istanbul_btn = pool_ui.get_widget("btn_istanbul") self.close_btn.connect("clicked",self.close) self.ok_btn.connect("clicked",self.ok) self.istanbul_btn.connect("clicked",self.start_istanbul) self.screencast_btn.set_active(self.app.screencast) self.dbus_connect()
def _busMessageHandlerCb(self, bus, message): debug("%s from %r message:%r", self.uuid, message.src, message) gst.log("%s from %r message:%r" % (self.uuid, message.src, message)) # let's pass it on to subclass to see if they want us to ignore that message if self.handleBusMessage(message) == False: debug("ignoring message") return # handle common types if message.type == gst.MESSAGE_ERROR: gerror, dbg = message.parse_error() self._errors.append((gerror.code, gerror.domain, gerror.message, dbg)) debug("Got an error on the bus, stopping") self.stop() elif message.type == gst.MESSAGE_TAG: self._gotTags(message.parse_tag()) elif message.src == self.pipeline: if message.type == gst.MESSAGE_EOS: # it's not 100% sure we want to stop here, because of the # race between the final state-change message and the eos message # arriving on the bus. debug("Saw EOS, stopping") # we give an extra 3s for the stat change to complete all the same if self._reachedInitialState: self.stop() else: gst.debug("Saw EOS but not yet in initial state, allowing an extra 3s to see it") self._waitcb = gobject.timeout_add(3000, self._waitingForStateChange) elif message.type == gst.MESSAGE_STATE_CHANGED: prev, cur, pending = message.parse_state_changed() if cur == self.__pipeline_initial_state__ and pending == gst.STATE_VOID_PENDING: gst.log("Reached initial state") self.validateStep("reached-initial-state") self._reachedInitialState = True if self.pipelineReachedInitialState(): debug("Stopping test because we reached initial state") gst.log("Stopping test because we reached initial state") self.stop() self.elementMessageHandlerCb(bus, message)
def chainfunc(self, pad, buffer): gst.log("Passing buffer with ts %d" % (buffer.timestamp)) return self.srcpad.push(buffer)
def add_brand(self, brand): if brand not in self.brands: self.brands.append(brand) gst.log(self.short_ref + ': adding show ' + brand.title)
def stop(self): gst.log("Stopping...") PythonDBusTest.stop(self)
l = leveller.Leveller(path) except KeyError: print '%s does not exist' % path continue bus = l.get_bus() bus.add_signal_watch() done = False success = False l.start() while not done: # this call blocks until there is a message message = bus.poll(gst.MESSAGE_ANY, gst.SECOND) if message: gst.log("got message from poll: %s/%r" % ( message.type, message)) else: gst.log("got NOTHING from poll") if message: if message.type == gst.MESSAGE_EOS: done = True success = True elif message.type == gst.MESSAGE_ERROR: sys.stderr.write('Error analyzing file:\n') error, debug = message.parse_error() sys.stderr.write('%s.\n' % error) done = True # message, if set, holds a ref to leveller, so we delete it here # to assure cleanup of leveller when we del it del message
def mapped (self, contentview): gst.log('mapped') if not self.loaded_content: self.view.load() self.loaded_content = True
def _eos_cb(self, source): gst.debug("eos, start calcing") # get the highest peak RMS for this track highestdB = self._peaksdB[0][1] for (time, peakdB) in self._peaksdB: if peakdB > highestdB: highestdB = peakdB gst.debug("highest peak(dB): %f" % highestdB) # get the length (self.length, peakdB) = self._peaksdB[-1] # find the mix in point for (time, peakdB) in self._peaksdB: gst.log("time %s, peakdB %f" % (gst.TIME_ARGS(time), peakdB)) if peakdB > self._thresholddB + highestdB: gst.debug("found mix-in point of %f dB at %s" % ( peakdB, gst.TIME_ARGS(time))) self.mixin = time break # reverse and find out point self._peaksdB.reverse() found = None for (time, peakdB) in self._peaksdB: if found: self.mixout = time gst.debug("found mix-out point of %f dB right before %s" % ( found, gst.TIME_ARGS(time))) break if peakdB > self._thresholddB + highestdB: found = peakdB # now calculate RMS between these two points weightedsquaresums = 0.0 lasttime = self.mixin for (time, meansquaresum) in self._meansquaresums: if time <= self.mixin: continue delta = time - lasttime weightedsquaresums += meansquaresum * delta gst.log("added MSS %f over time %s at time %s, now %f" % ( meansquaresum, gst.TIME_ARGS(delta), gst.TIME_ARGS(time), weightedsquaresums)) lasttime = time if time > self.mixout: break # calculate try: ms = weightedsquaresums / (self.mixout - self.mixin) except ZeroDivisionError: # this is possible when, for example, the whole sound file is # empty gst.warning('ZeroDivisionError on %s, mixin %s, mixout %s' % ( self._filename, gst.TIME_ARGS(self.mixin), gst.TIME_ARGS(self.mixout))) self.emit('done', WRONG_TYPE) return self.rms = math.sqrt(ms) self.rmsdB = 10 * math.log10(ms) self.emit('done', EOS)
def _newDecodedPadCb(self, dbin, pad, is_last): debug("pad:%r , caps:%s, is_last:%r", pad, pad.get_caps().to_string(), is_last) gst.log("pad:%r , caps:%s, is_last:%r" % (pad, pad.get_caps().to_string(), is_last)) stream = Stream(pad, caps=pad.get_caps()) self._connectFakesink(pad, self.pipeline) self._streams.append(stream)
def chainfunc(self, pad, buffer): gst.log ("Passing buffer with ts %d" % (buffer.timestamp)) return self.srcpad.push (buffer)