tkinter - Gstreamer python get bus message reconnection -
i have tkinter application gstreamer pipelines display different streams , i'd detect when 1 of pipelines loses connection. tried bus messages seems me doesn't post message @ all. created widget manage gstreamer logic , code widget following.
from tkinter.ttk import widget import gi # needed set_window_handle(): gi.require_version('gstvideo', '1.0') gi.require_version('gst', '1.0') gi.repository import gst, gstvideo class gstwidget(widget): def __init__(self, gst_launch_string, x, y, width, height, master=none, **kw): super(gstwidget, self).__init__(master, 'frame', **kw) self.place(x=x, y=y, width=width, height=height) self.frame_id = self.winfo_id() self.player = gst.parse_launch(gst_launch_string) self.player.set_state(gst.state.playing) self.bus = self.player.get_bus() self.bus.add_signal_watch() self.bus.connect('message::error', self.on_error) self.bus.connect('message::state-changed', self.on_status_changed) self.bus.connect('message::eos', self.on_eos) self.bus.connect('message::info', self.on_info) self.bus.enable_sync_message_emission() self.bus.connect('sync-message::element', self.set_frame_handle) def on_status_changed(self, bus, message): print('status_changed message -> {}'.format(message)) def on_eos(self, bus, message): print('eos message -> {}'.format(message)) def on_info(self, bus, message): print('info message -> {}'.format(message)) def on_error(self, bus, message): print('error message -> {}'.format(message.parse_error())) def play(self): print('current state of pipeline {}'.format(self.player.current_state)) print('setting pipeline state playing') self.player.set_state(gst.state.playing) def close(self): self.player.set_state(gst.state.null) def is_playing(self): print('\t\t{}'.format(self.player.current_state)) return self.player.current_state not gst.state.playing def set_frame_handle(self, bus, message): if message.get_structure().get_name() == 'prepare-window-handle': frame = message.src frame.set_property('force-aspect-ratio', true) frame.set_window_handle(self.frame_id)
can point me i'm wrong? i've put breakpoints events , it's not printing events i'd watch. , can point me if there's way retry connect pipeline on lost connection?
i figured out. "problem" tkinter mainloop. since gstreamer depends heavily on glib , tkinter doesn't use glib mainloop had create 1 suggested @jldupont @ tkinter integration glib mainloop
Comments
Post a Comment