def setcaps(self, this, caps): gst.gst_caps_get_structure.restype = ctypes.c_void_p structure = gst.gst_caps_get_structure(caps, 0) width = ctypes.c_int() gst.gst_structure_get_int(structure, 'width', ctypes.byref(width)) height = ctypes.c_int() gst.gst_structure_get_int(structure, 'height', ctypes.byref(height)) self.element._set_frame_format(width.value, height.value) return True
def _new_decoded_pad(self, decodebin, pad, last, data): '''Called by decodebin element when a source pad is created.''' caps = gst.gst_pad_get_caps(pad) struct = gst.gst_caps_get_structure(caps, 0) gst.gst_structure_get_name.restype = ctypes.c_char_p name = gst.gst_structure_get_name(struct) if name.startswith('audio/x-raw'): channels = ctypes.c_int() gst.gst_structure_get_int( struct, 'channels', ctypes.byref(channels)) depth = sample_rate = 0 # TODO self._new_audio_pad(pad, channels.value, depth, sample_rate) elif name.startswith('video/x-raw'): self._new_video_pad(pad)
def setcaps(self, this, caps): gst.gst_caps_get_structure.restype = ctypes.c_void_p structure = gst.gst_caps_get_structure(caps, 0) rate = ctypes.c_int() gst.gst_structure_get_int(structure, 'rate', ctypes.byref(rate)) self.rate = rate.value channels = ctypes.c_int() gst.gst_structure_get_int(structure, 'channels', ctypes.byref(channels)) depth = ctypes.c_int() gst.gst_structure_get_int(structure, 'depth', ctypes.byref(depth)) self.format = openal.get_format(channels.value, depth.value) self.element.channels = channels.value self.element.rate = rate.value self.bytes_per_second = \ float(channels.value * depth.value / 8 * rate.value) return True