<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<div class="moz-cite-prefix">You cannot expect any messages on the
bus after you have set the pipeline to NULL. Your EOS message
will be dropped on the floor and
`self._pipeline.send_event(Gst.Event.new_eos())` would very likely
return FALSE indicating a failure to send the message.<br>
<br>
Cheers<br>
-Matt<br>
<br>
On 4/11/19 7:46 pm, Ravi Modha wrote:<br>
</div>
<blockquote type="cite"
cite="mid:CAC0Vn7sWeOQYp9NhOY5p_Y_FkprHa_epv1ZkPB9qX9mYMsgn5w@mail.gmail.com">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<div dir="ltr">
<div>
<p dir="auto">I am new to GStreamer and I have created a small
example where I am recording the webcam and used app sink to
get the sample but when I try to stop the pipeline by
setting its state to null and sending EOS event, my bus
callback function never gets called for the EOS. And because
of this memory leak is happening.</p>
<p dir="auto">Guys, Please help me</p>
<p dir="auto"><br>
</p>
<p dir="auto">import gi import time import threading</p>
<p dir="auto">gi.require_version('Gst', '1.0')
gi.require_version('Gtk', '3.0')
gi.require_version('GstApp', '1.0')</p>
<p dir="auto">from gi.repository import GObject, Gst, Gtk,
GstApp import signal</p>
<p dir="auto">Gst.init(None)</p>
<p dir="auto">class Main: </p>
<p dir="auto">shutdown = False</p>
<pre style="white-space:pre-wrap" lang="plaintext"><font face="arial, sans-serif"><span id="gmail-m_-3436724900575022937gmail-LC1" lang="plaintext">def __init__(self):</span>
<span id="gmail-m_-3436724900575022937gmail-LC2" lang="plaintext"> signal.signal(signal.SIGINT, self.keyboardInterruptHandler)</span>
<span id="gmail-m_-3436724900575022937gmail-LC3" lang="plaintext"></span>
<span id="gmail-m_-3436724900575022937gmail-LC4" lang="plaintext"> self._pipeline = Gst.parse_launch("avfvideosrc </span>
<span id="gmail-m_-3436724900575022937gmail-LC5" lang="plaintext"> name=avfvideosrc ! x264enc name=x264enc ! appsink </span>
<span id="gmail-m_-3436724900575022937gmail-LC6" lang="plaintext"> name=appsink max-buffers=1 drop=false sync=false emit- </span>
<span id="gmail-m_-3436724900575022937gmail-LC7" lang="plaintext"> signals=true wait-on-eos=false")</span>
<span id="gmail-m_-3436724900575022937gmail-LC8" lang="plaintext"> bus = self._pipeline.get_bus()</span>
<span id="gmail-m_-3436724900575022937gmail-LC9" lang="plaintext"> bus.add_signal_watch()</span>
<span id="gmail-m_-3436724900575022937gmail-LC10" lang="plaintext"> bus.connect("message::eos", self._on_eos_from_sink_pipeline)</span>
<span id="gmail-m_-3436724900575022937gmail-LC11" lang="plaintext"> bus.connect("message", self.on_status_changed)</span>
<span id="gmail-m_-3436724900575022937gmail-LC12" lang="plaintext"> appsink = self._pipeline.get_by_name('appsink')</span>
<span id="gmail-m_-3436724900575022937gmail-LC13" lang="plaintext"> appsink.connect('new-sample', self.on_new_sample)</span>
<span id="gmail-m_-3436724900575022937gmail-LC14" lang="plaintext"> appsink.connect('eos', self.eos)</span>
<span id="gmail-m_-3436724900575022937gmail-LC15" lang="plaintext"></span>
<span id="gmail-m_-3436724900575022937gmail-LC16" lang="plaintext"> #bus.connect('message', self.on_status_changed)</span>
<span id="gmail-m_-3436724900575022937gmail-LC17" lang="plaintext"> self._pipeline.set_state(Gst.State.PLAYING)</span>
<span id="gmail-m_-3436724900575022937gmail-LC18" lang="plaintext"></span>
<span id="gmail-m_-3436724900575022937gmail-LC19" lang="plaintext">def on_new_sample(self, appsink):</span>
<span id="gmail-m_-3436724900575022937gmail-LC20" lang="plaintext"> return Gst.FlowReturn.OK</span>
<span id="gmail-m_-3436724900575022937gmail-LC21" lang="plaintext"></span>
<span id="gmail-m_-3436724900575022937gmail-LC22" lang="plaintext">def _on_eos_from_sink_pipeline(self, _bus, _message):</span>
<span id="gmail-m_-3436724900575022937gmail-LC23" lang="plaintext"> print("Got EOS from sink pipeline")</span>
<span id="gmail-m_-3436724900575022937gmail-LC24" lang="plaintext"> exit()</span>
<span id="gmail-m_-3436724900575022937gmail-LC25" lang="plaintext"></span>
<span id="gmail-m_-3436724900575022937gmail-LC26" lang="plaintext">def eos(self, sink):</span>
<span id="gmail-m_-3436724900575022937gmail-LC27" lang="plaintext"> print("SINK EOS")</span>
<span id="gmail-m_-3436724900575022937gmail-LC28" lang="plaintext"> return True</span>
<span id="gmail-m_-3436724900575022937gmail-LC29" lang="plaintext"></span>
<span id="gmail-m_-3436724900575022937gmail-LC30" lang="plaintext">def on_status_changed(self, bus, message):</span>
<span id="gmail-m_-3436724900575022937gmail-LC31" lang="plaintext"> print('Status: ', message.type)</span>
<span id="gmail-m_-3436724900575022937gmail-LC32" lang="plaintext"> print('Object: ', message.src)</span>
<span id="gmail-m_-3436724900575022937gmail-LC33" lang="plaintext"> print('Parsed Message: ', message.parse_state_changed())</span>
<span id="gmail-m_-3436724900575022937gmail-LC34" lang="plaintext"></span>
<span id="gmail-m_-3436724900575022937gmail-LC35" lang="plaintext">def keyboardInterruptHandler(self,signal, frame):</span>
<span id="gmail-m_-3436724900575022937gmail-LC36" lang="plaintext"> print("KeyboardInterrupt (ID: {}) has been caught. Cleaning </span>
<span id="gmail-m_-3436724900575022937gmail-LC37" lang="plaintext"> up...".format(signal))</span>
<span id="gmail-m_-3436724900575022937gmail-LC38" lang="plaintext"> self.shutdown = True</span>
<span id="gmail-m_-3436724900575022937gmail-LC39" lang="plaintext"> self.stopFetching()</span>
<span id="gmail-m_-3436724900575022937gmail-LC40" lang="plaintext"></span>
<span id="gmail-m_-3436724900575022937gmail-LC41" lang="plaintext">def stopFetching(self):</span>
<span id="gmail-m_-3436724900575022937gmail-LC42" lang="plaintext"> print("AT THE START OF STOP FETCHING") </span>
<span id="gmail-m_-3436724900575022937gmail-LC43" lang="plaintext"> self._pipeline.set_state(Gst.State.NULL)</span>
<span id="gmail-m_-3436724900575022937gmail-LC44" lang="plaintext"> self._pipeline.send_event(Gst.Event.new_eos())</span>
<span id="gmail-m_-3436724900575022937gmail-LC45" lang="plaintext"> print("AT THE END OF STOP FETCHING")</span>
</font></pre>
<pre style="white-space:pre-wrap" lang="plaintext"><font face="arial, sans-serif">start = Main()
Gtk.main()`</font></pre>
<font color="#888888">--<br>
<div dir="ltr">
<div dir="ltr">
<div style="font-size:12.8px">
<div><font face="arial, helvetica, sans-serif"
color="#0b5394"><font size="2"><b>Thanks &
Regards</b></font><font
style="font-weight:bold" size="1">,</font></font></div>
</div>
</div>
</div>
</font></div>
-- <br>
<div dir="ltr" class="gmail_signature"
data-smartmail="gmail_signature">
<div dir="ltr">
<div style="color:rgb(136,136,136);font-size:12.8px">
<div><font face="arial, helvetica, sans-serif"
color="#0b5394"><font size="2"><b>Thanks & Regards</b></font><font
style="font-weight:bold" size="1">,</font></font></div>
<div><font face="arial, helvetica, sans-serif"><font
style="font-weight:bold" size="1" color="#0b5394"><br>
</font></font></div>
</div>
<div><font face="arial, helvetica, sans-serif"
color="#0b5394"><b>Ravi Modha</b></font></div>
<div style="color:rgb(136,136,136)"><font color="#0b5394"><font
face="arial, helvetica, sans-serif"><b
style="font-size:x-small"><font color="#0b5394"><a
href="mailto:ravi.modha@tudip.com"
style="color:rgb(17,85,204)" target="_blank"
moz-do-not-send="true">ravi.modha@tudip.com</a></font> | </b><b><span
style="font-size:xx-small">Skype:</span><font
size="1"> </font></b></font></font><b
style="color:rgb(11,83,148);font-family:arial,helvetica,sans-serif;font-size:x-small"><font
color="#0b5394"><a href="mailto:ravi.modha@tudip.com"
style="color:rgb(17,85,204)" target="_blank"
moz-do-not-send="true">ravi.modha@tudip.com</a></font></b></div>
<div style="color:rgb(136,136,136)"><font color="#0b5394"><font
face="arial, helvetica, sans-serif"><b><font size="1"><br>
</font></b></font></font></div>
<div style="color:rgb(136,136,136);font-size:12.8px"><a
href="https://tudip.com/"
style="color:rgb(17,85,204);font-size:12.8px"
target="_blank" moz-do-not-send="true"><img
src="https://drive.google.com/a/tudip.com/uc?id=1zJSxP1wMlTI9XJDYbJGWCkGHmI5b-YcL&export=download"
moz-do-not-send="true"></a><span
style="font-size:12.8px"> </span><a
href="https://in.linkedin.com/company/tudip-technologies-pvt-ltd-"
style="color:rgb(17,85,204);font-size:12.8px"
target="_blank" moz-do-not-send="true"><img
src="https://drive.google.com/a/tudip.com/uc?id=1bePNWXohkGCJvWAIXBS28IrhzeOdr-EM&export=download"
moz-do-not-send="true"></a><a
href="https://clutch.co/profile/tudip-technologies"
style="color:rgb(17,85,204);font-size:12.8px"
target="_blank" moz-do-not-send="true"><img
src="https://drive.google.com/a/tudip.com/uc?id=1x29SoNoRpMwAqn0F88BtoDNmYWzp47_D&export=download"
moz-do-not-send="true"></a><a
href="https://www.goodfirms.co/companies/view/4439/tudip-technologies-pvt-ltd"
style="color:rgb(17,85,204);font-size:12.8px"
target="_blank" moz-do-not-send="true"><img
src="https://drive.google.com/a/tudip.com/uc?id=1jd6xtL-FoNWGuQH6U78g02hyYKh4-0Wa&export=download"
moz-do-not-send="true"></a><span
style="font-size:12.8px"> </span><a
href="https://www.facebook.com/TudipTechnologies"
style="color:rgb(17,85,204);font-size:12.8px"
target="_blank" moz-do-not-send="true"><img
src="https://drive.google.com/a/tudip.com/uc?id=1X-lj_gJC1T7qEB1uYIw2GivNd8F_Eb0C&export=download"
moz-do-not-send="true"></a><span
style="font-size:12.8px"> </span><a
href="https://twitter.com/TudipTech"
style="color:rgb(17,85,204);font-size:12.8px"
target="_blank" moz-do-not-send="true"><img
src="https://drive.google.com/a/tudip.com/uc?id=1YGDJSRzIZOvM0VZXzhokH-uGcw9umlH0&export=download"
moz-do-not-send="true"></a><span
style="font-size:12.8px"> </span><a
href="https://www.youtube.com/channel/UCoNPz2mbzNF_AZhLQEzuWCg"
style="color:rgb(17,85,204);font-size:12.8px"
target="_blank" moz-do-not-send="true"><img
src="https://drive.google.com/a/tudip.com/uc?id=12WOVgEFKgxD86LKWFaZN7rJF9VxKV3zH&export=download"
moz-do-not-send="true"></a></div>
<div style="color:rgb(136,136,136);font-size:12.8px"><font
style="color:rgb(11,83,148);font-weight:bold" size="1"><font
style="color:rgb(17,85,204)"><a
href="https://tudip.com/"
style="color:rgb(17,85,204)" target="_blank"
moz-do-not-send="true">www.tudip.com</a></font> </font><font
style="color:rgb(11,83,148);font-weight:bold" size="1">|</font><font
style="color:rgb(11,83,148);font-weight:bold" size="1"> <font
color="#0b5394"><a
href="https://tudip.com/tudip-technologies-in-news/"
style="color:rgb(17,85,204)" target="_blank"
moz-do-not-send="true"><font color="#0b5394">Tudip
in News</font></a> </font></font><br>
</div>
<div style="color:rgb(136,136,136);font-size:12.8px"><span
style="font-weight:bold;font-family:arial;font-size:x-small"><a
href="callto:+91%2020%204674%200881"
style="color:rgb(17,85,204)" target="_blank"
moz-do-not-send="true"><font color="#0b5394">+91 20
4674 0881</font></a><font color="#0b5394"> | </font><a
href="callto:+1%20408%20216%208162"
style="color:rgb(17,85,204)" target="_blank"
moz-do-not-send="true"><font color="#0b5394">+1 408
216 8162</font></a></span></div>
</div>
</div>
</div>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<pre class="moz-quote-pre" wrap="">_______________________________________________
gstreamer-devel mailing list
<a class="moz-txt-link-abbreviated" href="mailto:gstreamer-devel@lists.freedesktop.org">gstreamer-devel@lists.freedesktop.org</a>
<a class="moz-txt-link-freetext" href="https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel">https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel</a></pre>
</blockquote>
<p><br>
</p>
</body>
</html>