<html><head></head><body><div style="color:#000; background-color:#fff; font-family:lucida console, sans-serif;font-size:13px"><div id="yui_3_16_0_ym19_1_1505922022782_18830">I call the GObject and Gst init() methods in main.</div><div id="yui_3_16_0_ym19_1_1505922022782_18833"><br></div><div id="yui_3_16_0_ym19_1_1505922022782_18831">Something else I noticed is that you put your pipeline in PLAYING state before conencting.</div><div id="yui_3_16_0_ym19_1_1505922022782_21140">Not sure it explains your problem but you might miss some messages.</div><div id="yui_3_16_0_ym19_1_1505922022782_21146"><br></div><div>Do you receive the sync-message:element ?<br></div><div id="yui_3_16_0_ym19_1_1505922022782_18832"><span></span></div> <div class="qtdSeparateBR"><br><br></div><div class="yahoo_quoted" style="display: block;"> <div style="font-family: lucida console, sans-serif; font-size: 13px;"> <div style="font-family: HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif; font-size: 16px;"> <div dir="ltr"><font face="Arial" size="2"> Le Mercredi 20 septembre 2017 16h11, WisdomPill <anas.el.amraoui@live.com> a écrit :<br></font></div> <br><br> <div class="y_msg_container"><div dir="ltr">I do have those two lines but in a class that inherits from Tkinter window...<br clear="none">The code is the following<br clear="none"><br clear="none">import json<br clear="none">from configparser import ConfigParser<br clear="none">from threading import Timer<br clear="none">from time import time, sleep<br clear="none">from tkinter import Tk<br clear="none"><br clear="none">import gi<br clear="none"><br clear="none">from lib.descriptors import ConfigurationDescriptor, StreamDescriptor<br clear="none">from lib.widgets import SensorStreamWidget<br clear="none"><br clear="none">gi.require_version('Gst', '1.0')<br clear="none">from gi.repository import Gst, GObject<br clear="none"><br clear="none"><br clear="none">class VisualizerApp(Tk):<br clear="none"> def __init__(self):<br clear="none"> super(VisualizerApp, self).__init__()<br clear="none"><br clear="none"> self.config(cursor='none', background='black')<br clear="none"> self.attributes("-fullscreen", True)<br clear="none"> # Update the app to apply the geometry<br clear="none"> self.update()<br clear="none"><br clear="none"> self.config_filename = 'conf/config.ini'<br clear="none"> self.conf = self.init_configuration()<br clear="none"><br clear="none"> self.streams = list()<br clear="none"><br clear="none"> self.calculate_streams_rectangles()<br clear="none"><br clear="none"> Gst.init(None)<br clear="none"> GObject.threads_init()<br clear="none"><br clear="none"> self.streaming_widgets = self.init_streaming_widgets()<br clear="none"><br clear="none"> def init_configuration(self):<br clear="none"> conf = self.parse_configuration()<br clear="none"><br clear="none"> row_height = int(conf['grid']['row_height'])<br clear="none"> streams_filename = conf['grid']['streams_filename']<br clear="none"><br clear="none"> streams_json = json.load(open(streams_filename))<br clear="none"><br clear="none"> d = {<br clear="none"> 'row_height': row_height,<br clear="none"> 'streams': streams_json['streams']<br clear="none"> }<br clear="none"><br clear="none"> return ConfigurationDescriptor(d)<br clear="none"><br clear="none"> def calculate_streams_rectangles(self):<br clear="none"> x = 0<br clear="none"> y = 0<br clear="none"><br clear="none"> for stream_dict in self.conf.streams:<br clear="none"> initial_resolution = stream_dict['resolution']<br clear="none"> initial_width = int(initial_resolution['width'])<br clear="none"> initial_height = int(initial_resolution['height'])<br clear="none"><br clear="none"> final_height = self.conf.row_height<br clear="none"> final_width = initial_width * self.conf.row_height /<br clear="none">initial_height<br clear="none"><br clear="none"> if x + final_width >= self.winfo_width():<br clear="none"> x = 0<br clear="none"> y += self.conf.row_height<br clear="none"><br clear="none"> d = {<br clear="none"> 'x': x,<br clear="none"> 'y': y,<br clear="none"> 'width': final_width,<br clear="none"> 'height': final_height<br clear="none"> }<br clear="none"><br clear="none"> stream_dict.update(d)<br clear="none"><br clear="none"> # TODO remove this is only for debug purposes<br clear="none"> print(json.dumps(d, indent=4))<br clear="none"><br clear="none"> self.streams.append(StreamDescriptor(stream_dict))<br clear="none"><br clear="none"> x += final_width<br clear="none"><br clear="none"> def parse_configuration(self):<br clear="none"> conf = ConfigParser()<br clear="none"> conf.read(self.config_filename)<br clear="none"><br clear="none"> return conf<br clear="none"><br clear="none"> def init_streaming_widgets(self):<br clear="none"> streaming_widgets = list()<br clear="none"> for stream in self.streams:<br clear="none"> streaming_widget = SensorStreamWidget(stream, self)<br clear="none"> streaming_widgets.append(streaming_widget)<br clear="none"><br clear="none"> return streaming_widgets<br clear="none"><br clear="none">then I have a widgets.py file with the following <br clear="none"><br clear="none">from tkinter.ttk import Widget<br clear="none"><br clear="none">import gi<br clear="none"><br clear="none"># Needed for set_window_handle():<br clear="none">gi.require_version('GstVideo', '1.0')<br clear="none">gi.require_version('Gst', '1.0')<br clear="none">from gi.repository import Gst, GObject, GstVideo<br clear="none"><br clear="none"><br clear="none">class GstWidget(Widget):<br clear="none"> def __init__(self, gst_launch_string, x, y, width, height, master=None,<br clear="none">**kw):<br clear="none"> super(GstWidget, self).__init__(master, 'frame', **kw)<br clear="none"><br clear="none"> self.place(x=x, y=y, width=width, height=height)<br clear="none"><br clear="none"> self.frame_id = self.winfo_id()<br clear="none"><br clear="none"> self.player = Gst.parse_launch(gst_launch_string)<br clear="none"> self.player.set_state(Gst.State.PLAYING)<br clear="none"><br clear="none"> self.bus = self.player.get_bus()<br clear="none"> self.bus.add_signal_watch()<br clear="none"> self.bus.connect('message::error', self.on_error)<br clear="none"> self.bus.connect('message::state-changed', self.on_status_changed)<br clear="none"> self.bus.connect('message::eos', self.on_eos)<br clear="none"> self.bus.connect('message::info', self.on_info)<br clear="none"> self.bus.enable_sync_message_emission()<br clear="none"> self.bus.connect('sync-message::element', self.set_frame_handle)<br clear="none"><br clear="none"> def on_status_changed(self, bus, message):<br clear="none"> print('status_changed message -> {}'.format(message))<br clear="none"><br clear="none"> def on_eos(self, bus, message):<br clear="none"> print('eos message -> {}'.format(message))<br clear="none"><br clear="none"> def on_info(self, bus, message):<br clear="none"> print('info message -> {}'.format(message))<br clear="none"><br clear="none"> def on_error(self, bus, message):<br clear="none"> print('error message -> {}'.format(message.parse_error()))<br clear="none"><br clear="none"> def play(self):<br clear="none"> print('Current state of my pipeline is<br clear="none">{}'.format(self.player.current_state))<br clear="none"> print('setting pipeline state to playing')<br clear="none"> self.player.set_state(Gst.State.PLAYING)<br clear="none"><br clear="none"> def close(self):<br clear="none"> self.player.set_state(Gst.State.NULL)<br clear="none"><br clear="none"> def is_playing(self):<br clear="none"> print('\t\t{}'.format(self.player.current_state))<br clear="none"> return self.player.current_state is not Gst.State.PLAYING<br clear="none"><br clear="none"> def set_frame_handle(self, bus, message):<br clear="none"> if message.get_structure().get_name() == 'prepare-window-handle':<br clear="none"> frame = message.src<br clear="none"> frame.set_property('force-aspect-ratio', True)<br clear="none"> frame.set_window_handle(self.frame_id)<br clear="none"><br clear="none"><br clear="none">class SensorStreamWidget(GstWidget):<br clear="none"> def __init__(self, stream, master=None, **kw):<br clear="none"> gstreamer_launch_string = 'tcpclientsrc host={} port={} ! gdpdepay !<br clear="none">' \<br clear="none"> 'rtph264depay ! avdec_h264 ! videoconvert<br clear="none">! ' \<br clear="none"> 'autovideosink<br clear="none">sync=false'.format(stream.host, stream.port)<br clear="none"><br clear="none"> x = stream.x<br clear="none"> y = stream.y<br clear="none"> width = stream.width<br clear="none"> height = stream.height<br clear="none"> self.stream_descriptor = stream<br clear="none"><br clear="none"> super(SensorStreamWidget, self).__init__(gstreamer_launch_string, x,<br clear="none">y, width, height, master, **kw)<br clear="none"><br clear="none">then I start my app from a file called main.py<br clear="none"><br clear="none">from lib.app import VisualizerApp<br clear="none"><br clear="none">if __name__ == '__main__':<br clear="none"> window = VisualizerApp()<br clear="none"> window.mainloop()<br clear="none"><br clear="none"><br clear="none">I tried moving the two lines to the init method of the GstWidget but without<br clear="none">success.<div class="yqt4294351500" id="yqtfd27989"><br clear="none"><br clear="none"><br clear="none"><br clear="none">--<br clear="none">Sent from: <a shape="rect" href="http://gstreamer-devel.966125.n4.nabble.com/" target="_blank">http://gstreamer-devel.966125.n4.nabble.com/</a><br clear="none">_______________________________________________<br clear="none">gstreamer-devel mailing list<br clear="none"><a shape="rect" ymailto="mailto:gstreamer-devel@lists.freedesktop.org" href="mailto:gstreamer-devel@lists.freedesktop.org">gstreamer-devel@lists.freedesktop.org</a><br clear="none"><a shape="rect" href="https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel" target="_blank">https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel</a><br clear="none"></div></div><br><br></div> </div> </div> </div></div></body></html>