Image Serving Event
Dende
benjamin.slater at gmail.com
Wed Nov 13 20:46:51 UTC 2019
Hi,
I'm pretty new to Gstreamer development. I am working on an image
processing tester. The gstreamer app posts jpeg's in an h264 stream to the
unit being tested via rtp (see how the unit being tested processes a
standardized set of jpeg images coming in a h264 stream). In order for this
to work I need to know when the images are first being served to the unit.
I have all the jpeg streaming protocol working and I can push new images, I
can't figure out how to trigger an event to tell me when the image is going
through the sink for the first time.
Code is in Python. I will include some relevant snippets.
Thanks!
class SenderImages:
def __init__(self):
# Control if it is allowed push buffer in queue using "need-data"
and "enough-data" signals
self.is_push_buffer_allowed = None
self._mainloop = GObject.MainLoop()
auto_video_sink_pipeline = "appsrc name=source !
image/jpeg,framerate=(fraction)" + str(framerate) + "/1 ! jpegdec !
videoconvert ! videoscale ! capsfilter caps=video/x-raw,width=" + image_w +
",height=" + image_h + " ! x264enc ! rtph264pay ! multiudpsink clients=" +
Image_Stream_URIs
self._pipeline = Gst.parse_launch(auto_video_sink_pipeline)
self._src = self._pipeline.get_by_name('source')
self._src.connect('need-data', self.start_feed)
self._src.connect('enough-data', self.stop_feed)
self._src.set_property('format', 'time')
self._src.set_property('do-timestamp', True)
def start_feed(self, src, length):
# print('======================> need data length: %s' % length)
self.is_push_buffer_allowed = True
def stop_feed(self, src):
# print('======================> enough_data')
self.is_push_buffer_allowed = False
def play(self):
self._pipeline.set_state(Gst.State.PLAYING)
def stop(self):
self._pipeline.set_state(Gst.State.NULL)
def run(self):
""" Run - blocking. """
self._mainloop.run()
# def push(self):
def push(self, filename):
""" Push a buffer into the source. """
import os
if self.is_push_buffer_allowed:
handle = open(filename, "rb");
data = handle.read()
handle.close()
# Allocate GstBuffer
buf = Gst.Buffer.new_allocate(None, len(data), None)
buf.fill(0, data)
# Add buffer metadata
write_meta(buf, filename)
# Create GstSample
sample = Gst.Sample.new(buf,
Gst.caps_from_string("image/jpeg,framerate=(fraction)" + str(framerate) +
"/1"),
None, None)
# Push Sample on appsrc
gst_flow_return = self._src.emit('push-sample', sample)
if gst_flow_return != Gst.FlowReturn.OK:
print('We got some error, stop sending data')
else:
print('It is enough data for buffer....')
--
Sent from: http://gstreamer-devel.966125.n4.nabble.com/
More information about the gstreamer-devel
mailing list