def get_pads_for_stream(element, stream): """ Fetches the pads of the given element which are compatible with the given stream. @param element: The element to search on. @type element: C{gst.Element} @param stream: The stream to match against. @type stream: L{MultimediaStream} @return: The compatible pads @rtype: List of C{gst.Pad} """ log.debug("stream", "element:%r, stream:%r" % (element, stream)) while True: try: ls = [x for x in element.pads() if pad_compatible_stream(x, stream)] break except TypeError: continue # FIXME : I'm not 100% certain that checking against the stream pad_name # is a good idea .... # only filter the list if there's more than one choice if stream and len(ls) > 1 and stream.pad_name: return [x for x in ls if x.get_name() == stream.pad_name] return ls
def get_pads_for_stream(element, stream): """ Fetches the pads of the given element which are compatible with the given stream. @param element: The element to search on. @type element: C{gst.Element} @param stream: The stream to match against. @type stream: L{MultimediaStream} @return: The compatible pads @rtype: List of C{gst.Pad} """ log.debug("stream", "element:%r, stream:%r" % (element, stream)) while True: try: ls = [ x for x in element.pads() if pad_compatible_stream(x, stream) ] break except: continue # FIXME : I'm not 100% certain that checking against the stream pad_name # is a good idea .... # only filter the list if there's more than one choice if stream and len(ls) > 1 and stream.pad_name: return [x for x in ls if x.get_name() == stream.pad_name] return ls
def get_type_from_decoder(decoder): log.debug("stream", "%r" % decoder) klass = decoder.get_factory().get_klass() parts = klass.split('/', 2) if len(parts) != 3: return None return parts[2].lower()
def show_user_manual(): time_now = int(time.time()) for uri in (APPMANUALURL_OFFLINE, APPMANUALURL_ONLINE): try: gtk.show_uri(None, uri, time_now) return except Exception, e: log.debug("utils", "Failed loading URI %s: %s", uri, e) continue
def get_stream_for_pad(pad): log.debug("stream", "pad:%r") caps = pad.props.caps if caps is None: caps = pad.get_caps() pad_id = get_pad_id(pad) stream = get_stream_for_caps(caps, pad) stream.pad_id = pad_id return stream
def get_stream_for_pad(pad, store_pad=False): log.debug("stream", "pad:%r") caps = pad.props.caps if caps is None: caps = pad.get_caps() pad_id = get_pad_id(pad) stream = get_stream_for_caps(caps, pad) stream.pad_id = pad_id if store_pad: stream.pad = pad return stream
def pad_compatible_stream(pad, stream): """ Checks whether the given pad is compatible with the given stream. @param pad: The pad @type pad: C{gst.Pad} @param stream: The stream to match against. @type stream: L{MultimediaStream} @return: Whether the pad is compatible with the given stream @rtype: C{bool} """ log.debug("stream", "pad:%r, stream:%r" % (pad, stream)) if stream == None: # yes, None is the magical stream that takes everything return True # compatible caps if stream.caps: return not stream.caps.intersect(pad.get_caps()).is_empty() raise Exception("Can't figure out compatibility since the stream doesn't have any caps")
def _buildFactories(self): # build the cache log.debug("utils", "Getting factories list") factories = self._registry.get_feature_list(gst.ElementFactory) if self._factoryFilter is not None: log.debug("utils", "filtering") factories = filter(self._factoryFilter, factories) log.debug("utils", "Sorting by rank") factories.sort(key=lambda factory: factory.get_rank(), reverse=True) self._factories = factories log.debug("utils", "Cached factories is now %r", self._factories)
def get_controllable_properties(element): """ Returns a list of controllable properties for the given element (and child if it's a container). The list is made of tuples containing: * The GstObject * The GParamspec """ log.debug("utils", "element %r, %d", element, isinstance(element, gst.Bin)) res = [] if isinstance(element, gst.Bin): for child in element.elements(): res.extend(get_controllable_properties(child)) else: for prop in gobject.list_properties(element): if prop.flags & gst.PARAM_CONTROLLABLE: log.debug("utils", "adding property %r", prop) res.append((element, prop)) return res
def pad_compatible_stream(pad, stream): """ Checks whether the given pad is compatible with the given stream. @param pad: The pad @type pad: C{gst.Pad} @param stream: The stream to match against. @type stream: L{MultimediaStream} @return: Whether the pad is compatible with the given stream @rtype: C{bool} """ log.debug("stream", "pad:%r, stream:%r" % (pad, stream)) if stream == None: # yes, None is the magical stream that takes everything return True # compatible caps if stream.caps: return not stream.caps.intersect(pad.get_caps()).is_empty() raise Exception( "Can't figure out compatibility since the stream doesn't have any caps" )
def get_stream_for_caps(caps, pad=None): """ Returns the appropriate MediaStream corresponding to the given caps. """ log.debug("stream", "caps:%s, pad:%r" % (caps.to_string(), pad)) # FIXME : we should have an 'unknown' data stream class ret = None if pad is not None: pad_name = pad.get_name() stream_type = get_pad_type(pad) else: pad_name = None stream_type = caps[0].get_name().split('/', 1)[0] log.debug("stream", "stream_type:%s" % stream_type) if stream_type in ('video', 'image'): ret = VideoStream(caps, pad_name, stream_type == 'image') elif stream_type == 'audio': ret = AudioStream(caps, pad_name) elif stream_type == 'text': ret = TextStream(caps, pad_name) return ret
def get_stream_for_caps(caps, pad=None): """ Returns the appropriate MediaStream corresponding to the given caps. """ log.debug("stream", "caps:%s, pad:%r" % (caps.to_string(), pad)) # FIXME : we should have an 'unknown' data stream class ret = None if pad is not None: pad_name = pad.get_name() stream_type = get_pad_type(pad) else: pad_name = None stream_type = caps[0].get_name().split('/', 1)[0] log.debug("stream", "stream_type:%s" % stream_type) if stream_type in ('video', 'image'): ret = VideoStream(caps, pad_name, stream_type == 'image') elif stream_type == 'audio': ret = AudioStream(caps, pad_name) elif stream_type in ('text', 'subpicture'): ret = TextStream(caps, pad_name) return ret
def data_probe(pad, data, section=""): """Callback to use for gst.Pad.add_*_probe. The extra argument will be used to prefix the debug messages """ if section == "": section = "%s:%s" % (pad.get_parent().get_name(), pad.get_name()) if isinstance(data, gst.Buffer): log.debug( "probe", "%s BUFFER timestamp:%s , duration:%s , size:%d , offset:%d , offset_end:%d", section, gst.TIME_ARGS(data.timestamp), gst.TIME_ARGS(data.duration), data.size, data.offset, data.offset_end) if data.flags & gst.BUFFER_FLAG_DELTA_UNIT: log.debug("probe", "%s DELTA_UNIT", section) if data.flags & gst.BUFFER_FLAG_DISCONT: log.debug("probe", "%s DISCONT", section) if data.flags & gst.BUFFER_FLAG_GAP: log.debug("probe", "%s GAP", section) log.debug("probe", "%s flags:%r", section, data.flags) else: log.debug("probe", "%s EVENT %s", section, data.type) if data.type == gst.EVENT_NEWSEGMENT: upd, rat, fmt, start, stop, pos = data.parse_new_segment() log.debug( "probe", "%s Update:%r rate:%f fmt:%s, start:%s, stop:%s, pos:%s", section, upd, rat, fmt, gst.TIME_ARGS(start), gst.TIME_ARGS(stop), gst.TIME_ARGS(pos)) return True
def data_probe(pad, data, section=""): """Callback to use for gst.Pad.add_*_probe. The extra argument will be used to prefix the debug messages """ if section == "": section = "%s:%s" % (pad.get_parent().get_name(), pad.get_name()) if isinstance(data, gst.Buffer): log.debug("probe","%s BUFFER timestamp:%s , duration:%s , size:%d , offset:%d , offset_end:%d", section, gst.TIME_ARGS(data.timestamp), gst.TIME_ARGS(data.duration), data.size, data.offset, data.offset_end) if data.flags & gst.BUFFER_FLAG_DELTA_UNIT: log.debug("probe","%s DELTA_UNIT", section) if data.flags & gst.BUFFER_FLAG_DISCONT: log.debug("probe","%s DISCONT", section) if data.flags & gst.BUFFER_FLAG_GAP: log.debug("probe","%s GAP", section) log.debug("probe","%s flags:%r", section, data.flags) else: log.debug("probe","%s EVENT %s", section, data.type) if data.type == gst.EVENT_NEWSEGMENT: upd, rat, fmt, start, stop, pos = data.parse_new_segment() log.debug("probe","%s Update:%r rate:%f fmt:%s, start:%s, stop:%s, pos:%s", section, upd, rat, fmt, gst.TIME_ARGS(start), gst.TIME_ARGS(stop), gst.TIME_ARGS(pos)) return True