def dump_dot_file(self, respond, basename='pipeline'): # GST_DEBUG_DUMP_DOT_DIR=/tmp/ directory = os.environ.get('GST_DEBUG_DUMP_DOT_DIR', None) if directory: dotfile = os.path.join(directory, '%s.dot' %basename) pngfile = os.path.join(directory, '%s.png' %basename) if os.path.isfile(dotfile): logging.getLogger('pipeline').debug('Removing existing dotfile %s' %dotfile) os.remove(dotfile) if os.path.isfile(dotfile): logging.getLogger('pipeline').debug('Removing existing pngfile %s' %pngfile) os.remove(pngfile) logging.getLogger('pipeline').debug('Dumping graph to %s' %dotfile) gst.DEBUG_BIN_TO_DOT_FILE(self.pipe, gst.DEBUG_GRAPH_SHOW_ALL, basename) dot = '/usr/bin/dot' os.system(dot + " -Tpng -o " + pngfile + " " + dotfile) logging.getLogger('pipeline').debug('Reading image file') with open(pngfile, 'r') as content_file: content = content_file.read() logging.getLogger('pipeline').debug('Inserting image file to database') image_id = self.db.images.insert({ "format": "jpg", "template": "default", "tags": ["delete"], "created_at": datetime.datetime.utcnow(), "data": Binary(content) }) respond({"temp_dotfile": dotfile, "temp_pngfile": pngfile, "temp_dbpath": "/image.jpg?id="+unicode(image_id)}) else: logging.getLogger('pipeline').debug("You need to define the GST_DEBUG_DUMP_DOT_DIR env var to dump a .dot graph of the running pipeline") respond(None)
def on_playbin_state_changed(self, old_state, new_state, pending_state): gst_logger.debug('Got state-changed message: old=%s new=%s pending=%s', old_state.value_name, new_state.value_name, pending_state.value_name) if new_state == gst.STATE_READY and pending_state == gst.STATE_NULL: # XXX: We're not called on the last state change when going down to # NULL, so we rewrite the second to last call to get the expected # behavior. new_state = gst.STATE_NULL pending_state = gst.STATE_VOID_PENDING if pending_state != gst.STATE_VOID_PENDING: return # Ignore intermediate state changes if new_state == gst.STATE_READY: return # Ignore READY state as it's GStreamer specific new_state = _GST_STATE_MAPPING[new_state] old_state, self._audio.state = self._audio.state, new_state target_state = _GST_STATE_MAPPING[self._audio._target_state] if target_state == new_state: target_state = None logger.debug( 'Audio event: state_changed(old_state=%s, new_state=%s, ' 'target_state=%s)', old_state, new_state, target_state) AudioListener.send('state_changed', old_state=old_state, new_state=new_state, target_state=target_state) if new_state == PlaybackState.STOPPED: logger.debug('Audio event: stream_changed(uri=None)') AudioListener.send('stream_changed', uri=None) if 'GST_DEBUG_DUMP_DOT_DIR' in os.environ: gst.DEBUG_BIN_TO_DOT_FILE(self._audio._playbin, gst.DEBUG_GRAPH_SHOW_ALL, 'mopidy')
def on_message(self, bus, message): mtype = message.type # print mtype if mtype == gst.MESSAGE_ERROR: err, debug = message.parse_error() print err print debug gst.DEBUG_BIN_TO_DOT_FILE (self.pipeline, gst.DEBUG_GRAPH_SHOW_ALL, \ 'transmageddon.dot') self.emit('got-error', err.message) elif mtype == gst.MESSAGE_ASYNC_DONE: self.emit('ready-for-querying') elif mtype == gst.MESSAGE_EOS: if (self.multipass != False): if (self.passcounter == 0): #removing multipass cache file when done if os.access(self.cachefile, os.F_OK): os.remove(self.cachefile) self.emit('got-eos') self.pipeline.set_state(gst.STATE_NULL) elif mtype == gst.MESSAGE_APPLICATION: self.pipeline.set_state(gst.STATE_NULL) self.pipeline.remove(self.uridecoder) return True
def int_handler(self, sig, frame): try: gst.DEBUG_BIN_TO_DOT_FILE(self.pipeline, 0, "pipelinedump") except: pass sys.exit(2)